FEALPy Documentation

repository·main·Indexed 19 days ago

https://github.com/weihuayi/fealpy

A Python library for Finite Element Analysis (FEA) that integrates traditional Computer-Aided Engineering (CAX) fundamentals with AI. It includes specialized modules such as AFAP for material fracture and failure simulation, LaFEM-EIT for Electrical Impedance Tomography, and Computational Conformal Geometry algorithms. The library supports multiple computational backends including Numpy, JAX, PyTorch, and TensorFlow, and is complemented by WHYSC, a C++ scientific computing package.

Tokens
31.5K
Snippets
82
Records
124
Agent score
64%

What's inside FEALPy

  1. Overview of Learning-automated FEM Electrical Impedance Tomography (LaFEM-EIT)

    main
    LaFEM-EIT is a module within FEALPy designed for Learning-automated Finite Element Method (FEM) Electrical Impedance Tomography. It combines FEM-based electrical impedance modeling with automated learning techniques.
  2. Overview of AFAP: Advanced Fracture Analysis Platform

    main
    AFAP (Advanced Fracture Analysis Platform) is an open-source Python-based software package designed for simulating material fracture and failure. It provides a flexible computational framework that allows users to switch between different backends to optimize performance and leverage different mathematical or AI capabilities.
  3. Overview of WHYSC

    main
    WHYSC (WeiHuaYi's Scientific Computing Package) is a C++ scientific computing package designed to complement the FEALPy Python finite element package. It is built with a focus on extensibility, modularity, and layered architecture, utilizing object-oriented programming and templates while prioritizing standard C++ libraries to avoid over-engineering.
  4. What is FEALPy?

    main
    FEALPy is an open-source Python package designed for the numerical solution of Partial Differential Equations (PDEs). It serves as a foundational algorithm library for industrial simulation (Computer-Aided Engineering, CAE), aiming to provide a controllable and transparent alternative to proprietary commercial software. The library focuses on implementing mathematical algorithms, such as the Finite Element Method (FEM), to solve complex physical and engineering problems.
  5. Use Computational Conformal Geometry algorithms

    main
    The app/ccg module implements algorithms from Professor Xianfeng Gu's Computational Conformal Geometry course. These algorithms are built upon the mesh data structures provided by the core FEALPy library.
  6. Mesh entity and dimension naming conventions

    main

    FEALPy uses a specific set of shorthand notations for indexing and dimensions in Finite Element Analysis. Understanding these is critical for reading mesh-related code and mathematical implementations:

    • c: Cell index
    • f: Face index
    • e: Edge index
    • v: Vertex count index
    • i, j, k, d: Degrees of freedom (dof) or basis function indices
    • q: Quadrature point or barycentric coordinate index
    • m, n: Spatial or topological dimension indices
  7. Calculate the convergence order of numerical methods

    main

    In FEALPy, the convergence order (accuracy) of a numerical method describes how the error between the numerical solution $u_h$ and the exact solution $u$ decreases as the mesh size $\Delta x$ or time step $\Delta t$ decreases.

    To estimate the spatial convergence order $p$ using different mesh sizes (e.g., $\Delta x$ and $\frac{1}{2}\Delta x$), you can use the ratio of the errors $R$ obtained at those sizes:

    $$p = \log_2\left(\frac{R(\Delta x)}{R(\frac{1}{2} \Delta x)}\right)$$

    Important Note for Spatial Convergence: When testing for spatial convergence order, the time step $\Delta t$ must be kept sufficiently small. If the time step is too large, the temporal error will dominate and interfere with the measurement of the spatial convergence order.

  8. Define History Data in Abaqus .inp files

    main

    History data defines how the model reacts to external loads or non-steady initial conditions. Analysis is organized into steps.

    Required History Data

    You must specify the response type:

    • linear
    • nonlinear
    • static
    • dynamic

    Optional History Data

    • Loading: Application of external forces/pressures.
    • Boundary conditions: Time-varying constraints.
    • Output control: Requesting specific field outputs during the step.
    • Contact: Contact mechanics definitions within the step.
    • Auxiliary controls: Additional analysis controls.
  9. Understanding Monte Carlo Integration and Importance Sampling

    main

    Monte Carlo methods are used to estimate integrals $I = \int_D g(x)\mathrm{d}x$ by drawing $m$ independent and identically distributed (i.i.d.) samples $\mathbf{x}^{(1)}, \dots, \mathbf{x}^{(m)}$ from a region $D$ and calculating the average:

    $$\hat{I}m = \frac{1}{m}\sum{j=1}^m g(\mathbf{x}^{(j)})$$

    According to the Law of Large Numbers, $\hat{I}_m$ converges to $I$ as $m \to \infty$. The error rate is $O(m^{-1/2})$, which is independent of the dimension of $\mathbf{x}$.

    Importance Sampling

    To overcome high variance in large regions or difficulties in generating uniform samples, importance sampling is used. Instead of uniform sampling, samples are drawn from a non-uniform distribution $\pi(\mathbf{x})$ that places more probability mass on important parts of the state space $D$. The estimate becomes:

    $$\hat{\hat{I}} = \frac{1}{m}\sum_{j=1}^m\frac{g(\mathbf{x}^{(j)})}{\pi(\mathbf{x}^{(j)})}$$

    Ideally, choosing $\pi(\mathbf{x}) \propto g(\mathbf{x})$ minimizes variance, though in practice, finding an optimal $\pi$ is a central challenge.

  10. Understand Mesh data structures and members

    main

    A Mesh object in FEALPy contains geometric and topological information.

    Basic Member Data

    • node: A numpy array with shape (NN, GD), where NN is the number of nodes and GD is the geometry dimension.
    • ds: The topology data structure containing:
      • NN: Number of nodes
      • NC: Number of cells
      • edge: A numpy array with shape (NE, 2)
      • face: A numpy array with shape (NF, NFV)
      • cell: A numpy array with shape (NC, NCV)
    • nodedata, celldata, edgedata, facedata: Dictionaries for storing additional data on entities.

    Common Mesh Methods

    • geo_dimension(): Returns the geometry dimension.
    • top_dimension(): Returns the topological dimension.
    • number_of_nodes(), number_of_cells(), number_of_edges(), number_of_faces(): Returns counts for each entity type.
    • entity(etype): Accesses entities of a specific type.
    • entity_measure(etype): Returns the measure (e.g., area, volume) of entities.
    • entity_barycenter(etype): Returns the barycenter of entities.
    • integrator(index): Retrieves the quadrature formula for the specific mesh type.
    • bc_to_points(bc): Transforms quadrature points from barycentric coordinates to physical cell points.
  11. Monte Carlo for Optimization via Simulated Annealing

    main

    Optimization problems can be reframed as Monte Carlo sampling problems. To find the minimum of a target function $h(\mathbf{x})$ in a complex configuration space, one can define a family of probability distributions:

    $$\pi_T(\mathbf{x}) \propto e^{-h(\mathbf{x})/T}, \quad T > 0$$

    As the temperature $T$ decreases, the probability mass concentrates around the minimum of $h(\mathbf{x})$. This principle forms the basis of the Simulated Annealing algorithm and tempering techniques used to improve Monte Carlo efficiency.