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.
The computational domain is the unit square (\Omega = [0,1] \times [0,1]). The unknown displacement field is
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
The vertical body force is a Gaussian distribution:
All outer edges are clamped, so (\mathbf{u}=\mathbf{0}) on (\partial\Omega).
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.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; tanhactivations 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.ipynb evaluates the PINN against the FEM reference:
- FEniCSx displacement components are linearly interpolated onto the DeepXDE evaluation points with SciPy
griddata. - Pointwise vector-displacement error is computed as $$ e=\sqrt{(u_x^{FEM}-u_x^{PINN})^2+(u_y^{FEM}-u_y^{PINN})^2}. $$
- 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.
| 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 |
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
FEniCSx.ipynbto generatefenicsx_solution.csv. - Run
DeepXDE.ipynbto generatedeepxde_solution.csv. - Run
Comparison.ipynbto calculate and savecomparison_metrics.csv.
The notebooks are intended to be run from the repository root so the generated CSV files are available to the comparison notebook.
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.