This project implements a Variational Physics-Informed Neural Network (VPINN) to solve a 2D linear elasticity problem. The specific case is a square plate under uniaxial tension, modeled using plane stress assumptions.
The methodology is inspired by the hp-VPINNs paper by Kharazmi et al., which leverages the calculus of variations to formulate the loss function. The network is trained to minimize the residual of the weak form of the governing PDE.
- Reference: Kharazmi, E., Zhang, Z., & Karniadakis, G. E. (2021). hp-VPINNs: Variational Physics-Informed Neural Networks With Domain Decomposition.
-
Domain: A unit square plate,
$\Omega = [0,1] \times [0,1]$ . -
Boundary Conditions (BCs):
-
Left Edge (
$x=0$ ): Fixed horizontally,$u=0$ . -
Bottom Edge (
$y=0$ ): Fixed vertically,$v=0$ . -
Right Edge (
$x=1$ ): Prescribed horizontal displacement,$u=0.1$ . -
Top Edge (
$y=1$ ): Free (Neumann BC).
-
Left Edge (
The system is governed by the equilibrium equation (assuming no body forces):
Instead of minimizing the strong form residual (
where
-
Test Functions: The test functions
$\mathbf{v}_n$ are constructed from Legendre polynomials of the form
, which are well-suited for variational methods.
- Numerical Integration: The integral in the weak form is approximated numerically using Gauss-Legendre quadrature.
- Coordinate Transformation: The network operates on the physical domain
[0,1]x[0,1]
, but the Legendre polynomials and quadrature rules are defined on the reference domain[-1,1]x[-1,1]
. A linear mapping is used, and the change of variables is handled by applying a Jacobian correction to the integration weights and spatial derivatives.
The Dirichlet boundary conditions are enforced analytically using an Augmented Deep Formulation (ADF). The predicted displacement
-
$N(\mathbf{x}; \theta)$ : The raw output from the neural network. -
$\mathbf{g}(\mathbf{x})$ : An extension function that satisfies the non-homogeneous BCs. For this problem,$g_u = 0.1 \cdot x^\delta$ . -
$\mathbf{\Phi}(\mathbf{x})$ : A distance function that is zero on the Dirichlet boundaries, ensuring the network's output does not alter the imposed conditions. Here,$\Phi_u = x^\alpha (1-x)^\gamma$ and$\Phi_v = y^\beta$ .
This structure guarantees that the BCs are met exactly, regardless of the network's weights.
-
Loss Function: The total loss combines the variational loss with an explicit (though architecturally redundant) boundary loss term to guide training:
$L_{total} = L_{variational} + w \cdot L_{boundary}$ . -
Optimization: A two-stage optimization process is used for robust convergence:
- Adam: For rapid, broad exploration of the loss landscape.
- L-BFGS: For fine-tuning and achieving high-precision results near the minimum.
main.py
: Main script to run the training, evaluation, and plotting.vpinn.py
: Core VPINN class, handling the variational loss, boundary conditions, and optimizers.models.py
: Defines theElasticityNet
neural network architecture with the ADF for BC enforcement.config.py
: Contains all hyperparameters, material properties, and training settings.FE/
: Helper module for generating basis functions and quadrature rules.
- Install dependencies:
pip install torch matplotlib scipy numpy
- Run the simulation:
python main.py
- Check the outputs:
deformation_plots.png
: Visualization of undeformed vs. deformed mesh and displacement components.stress_strain_plots.png
: Contour plots of all stress and strain components.strain_comparison.png
&stress_comparison.png
: Comparison of VPINN results against the analytical solution.vpinn_results.npz
&vpinn_results.txt
: Saved numerical data for all fields at grid points.