GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - heyacode/Membrane-Deflection-Linear-Elasticity---FEniCSx-and-DeepXDE-Comparison: Comparison of FEniCSx finite elements and DeepXDE physics-informed neural networks for tumor-induced elastic membrane deformation.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
Comparison.ipynb
Comparison.ipynb
 
 
DeepXDE.ipynb
DeepXDE.ipynb
 
 
FEniCSx.ipynb
FEniCSx.ipynb
 
 
README.md
README.md
 
 

Repository files navigation

Membrane Deflection: Finite Elements vs Physics-Informed Neural Networks

This project models the deformation of a two-dimensional elastic membrane subjected to a localized, Gaussian pressure representing tumor growth. It compares a conventional finite-element solution produced with FEniCSx against a physics-informed neural-network (PINN) approximation trained with DeepXDE and PyTorch.

The comparison treats the FEniCSx solution as the numerical reference and evaluates how well the PINN reproduces the displacement field.

Problem formulation

The computational domain is the unit square (\Omega = [0,1] \times [0,1]). The unknown displacement field is

$$ \mathbf{u}(x,y) = (u_x, u_y). $$

The membrane is modeled as an isotropic, linear-elastic material with:

Parameter Value Meaning
Young's modulus (E) 1.0 Material stiffness
Poisson's ratio (\nu) 0.3 Lateral strain response
First Lamé parameter (\lambda) 0.5769 Elastic parameter
Shear modulus (\mu) 0.3846 Elastic parameter
Load amplitude (A) 1.0 Peak tumor pressure
Load radius (r) 0.15 Gaussian spread
Load center (0.5, 0.5) Center of the membrane

The Lamé parameters are calculated as

$$ \mu = \frac{E}{2(1+\nu)}, \qquad \lambda = \frac{E\nu}{(1+\nu)(1-2\nu)}. $$

The vertical body force is a Gaussian distribution:

$$ p(x,y) = A\exp\left(-\frac{(x-x_c)^2+(y-y_c)^2}{r^2}\right), \qquad \mathbf{f} = (0,p). $$

All outer edges are clamped, so (\mathbf{u}=\mathbf{0}) on (\partial\Omega).

Methods

FEniCSx: finite element method (FEM)

FEniCSx.ipynb solves the linear-elasticity weak form using:

  • a 40 × 40 unit-square mesh of triangular elements (3,200 cells);
  • first-order Lagrange vector elements for ((u_x,u_y));
  • the small-strain tensor (\varepsilon(\mathbf{u})=\operatorname{sym}(\nabla\mathbf{u}));
  • isotropic Hookean stress (\sigma(\mathbf{u})=\lambda\operatorname{tr}(\varepsilon)I+2\mu\varepsilon);
  • zero Dirichlet displacement on every boundary; and
  • a PETSc LU direct solve of the resulting linear system.

It exports nodal coordinates, displacement components, and displacement magnitude to fenicsx_solution.csv.

DeepXDE: physics-informed neural network (PINN)

DeepXDE.ipynb approximates the same PDE without a finite-element mesh. Its main configuration is:

  • DeepXDE with the PyTorch backend;
  • a fully connected network with architecture 2 → 50 → 50 → 50 → 2;
  • tanh activations and Glorot-normal initialization;
  • 3,000 interior collocation points, 400 boundary points, and 1,000 test points;
  • an Adam optimizer with learning rate 1e-3, trained for 5,000 iterations; and
  • a loss combining PDE residual and Dirichlet-boundary-condition terms.

The model predicts (u_x) and (u_y); the reported total displacement is (|\mathbf{u}|=\sqrt{u_x^2+u_y^2}). Predictions on an 80 × 80 grid are exported to deepxde_solution.csv.

Comparison and validation

Comparison.ipynb evaluates the PINN against the FEM reference:

  1. FEniCSx displacement components are linearly interpolated onto the DeepXDE evaluation points with SciPy griddata.
  2. Pointwise vector-displacement error is computed as $$ e=\sqrt{(u_x^{FEM}-u_x^{PINN})^2+(u_y^{FEM}-u_y^{PINN})^2}. $$
  3. MAE, RMSE, maximum error, spatial error maps, displacement-field plots, and a centerline comparison at (y=0.5) are produced.

The recorded comparison reports MAE = 0.002238, RMSE = 0.002495, and maximum error = 0.005896. The PINN reproduces the overall deformation pattern but underestimates the central peak displacement relative to FEM.

Repository contents

File Purpose
FEniCSx.ipynb FEM formulation, solution, visualisation, and CSV export
DeepXDE.ipynb PINN formulation, training, prediction, visualisation, and CSV export
Comparison.ipynb FEM–PINN interpolation, metrics, plots, and interpretation
report.pdf Project report

Requirements

The notebooks use Python and the following packages:

numpy
pandas
matplotlib
scipy
torch
deepxde
mpi4py
petsc4py
fenics-dolfinx
ufl

FEniCSx is usually installed through Conda, Docker, or another platform-specific distribution; consult the official FEniCSx installation guidance for your platform. The DeepXDE notebook sets DDE_BACKEND=pytorch before importing DeepXDE.

Run order

  1. Run FEniCSx.ipynb to generate fenicsx_solution.csv.
  2. Run DeepXDE.ipynb to generate deepxde_solution.csv.
  3. Run Comparison.ipynb to calculate and save comparison_metrics.csv.

The notebooks are intended to be run from the repository root so the generated CSV files are available to the comparison notebook.

Key takeaway

For this linear-elasticity case, FEM provides the more accurate and stable reference solution. The PINN offers a mesh-free, AI-based approximation that captures the global displacement field well, while remaining sensitive to architecture, sampling, optimizer settings, and training convergence near the peak-load region.

About

Comparison of FEniCSx finite elements and DeepXDE physics-informed neural networks for tumor-induced elastic membrane deformation.

Topics

biomechanicscomputational-mechanicsdeepxdefenicsxfinite-element-methodlinear-elasticitypdephysics-informed-neural-networkspinnpythonpytorchscientific-machine-learningtumor-modeling

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.