FEALPy Documentation
repository·main·Indexed 19 days ago
https://github.com/weihuayi/fealpyA 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.
What's inside FEALPy
- Detri2 is a program developed by Hang Si. This repository aims to provide a Python API for the Detri2 program, allowing users to interface with its capabilities through Python.
Overview of Learning-automated FEM Electrical Impedance Tomography (LaFEM-EIT)
mainLaFEM-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.Overview of AFAP: Advanced Fracture Analysis Platform
mainAFAP (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.Overview of WHYSC
mainWHYSC (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.What is FEALPy?
mainFEALPy 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.Use Computational Conformal Geometry algorithms
mainTheapp/ccgmodule 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.Mesh entity and dimension naming conventions
mainFEALPy 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 indexf: Face indexe: Edge indexv: Vertex count indexi, j, k, d: Degrees of freedom (dof) or basis function indicesq: Quadrature point or barycentric coordinate indexm, n: Spatial or topological dimension indices
Calculate the convergence order of numerical methods
mainIn 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.
Define History Data in Abaqus .inp files
mainHistory 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:
linearnonlinearstaticdynamic
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.
Understanding Monte Carlo Integration and Importance Sampling
mainMonte 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.
Understand Mesh data structures and members
mainA Mesh object in FEALPy contains geometric and topological information.
Basic Member Data
node: Anumpyarray with shape(NN, GD), whereNNis the number of nodes andGDis the geometry dimension.ds: The topology data structure containing:NN: Number of nodesNC: Number of cellsedge: Anumpyarray with shape(NE, 2)face: Anumpyarray with shape(NF, NFV)cell: Anumpyarray 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.
Monte Carlo for Optimization via Simulated Annealing
mainOptimization 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.