A comparative study of Physics-Informed Neural Networks (PINN) and Variational Physics-Informed Neural Networks (VPINN) applied to elliptic PDEs with a nonlocal integral boundary condition — in 1D and 2D, covering both linear and nonlinear (temperature-dependent conductivity) regimes.
We consider steady-state heat conduction with two formulations, in 1D and 2D:
Linear:
Nonlinear (temperature-dependent conductivity):
Linear (Poisson):
Nonlinear:
All cases share a nonlocal integral boundary condition on the left edge and Dirichlet conditions elsewhere:
| Boundary | 1D | 2D |
|---|---|---|
| Left |
|
|
| Right | ||
| Bottom / Top | — |
This class of nonlocal conditions arises in models involving energy specification constraints, distributed sensors, and thermoelastic feedback systems.
1D:
2D:
The 2D solution is a separable extension of the 1D case. The source term
The PDE residual is enforced point-wise at interior collocation points. For nonlinear cases, the residual is computed via automatic differentiation on the flux
This flux-based AD approach avoids manually expanding the chain rule.
The weak form is obtained by integration by parts against test functions:
-
1D: Legendre test functions
$v_k(x) = P_k(2x-1) - 1$ with$v_k(1) = 0$ -
2D: Tensor product
$v_i(x) \cdot w_j(y)$ where$v_i$ are Legendre and$w_j(y) = \sin(j\pi y)$
The boundary flux appears naturally as a trainable Lagrange multiplier — scalar
- Reduces the required differentiation order from 2 to 1
- Naturally accommodates the global integral constraint
- Provides the boundary flux as a free output
| Metric | PINN | VPINN |
|---|---|---|
| L2 error | 8.74 × 10⁻⁶ | 3.49 × 10⁻⁶ |
| L∞ error | 1.84 × 10⁻⁵ | 6.58 × 10⁻⁶ |
| H1 error | 1.57 × 10⁻⁴ | 7.53 × 10⁻⁵ |
| Metric | PINN | VPINN |
|---|---|---|
| L2 error | 1.92 × 10⁻⁴ | 2.39 × 10⁻⁵ |
| L∞ error | 3.40 × 10⁻⁴ | 4.57 × 10⁻⁵ |
| Integral BC | 1.58 × 10⁻⁴ | 2.32 × 10⁻⁶ |
| Metric | PINN | VPINN |
|---|---|---|
| L2 error | 3.09 × 10⁻⁵ | 1.79 × 10⁻³ |
| Time (min) | 18 | 31 |
| — | −1.8680 (exact: −1.8684) |
VPINN improves to L2 = 1.92 × 10⁻⁴ with enriched test space (
| Metric | PINN | VPINN |
|---|---|---|
| L2 error | 7.14 × 10⁻⁵ | 5.16 × 10⁻⁴ |
| — | −4.1411 (exact: −4.1400) |
In 2D with sufficient test functions (
| PINN L2 | VPINN L2 (25×8) | Winner | |
|---|---|---|---|
| 0.5 | 1.54 × 10⁻⁴ | 1.23 × 10⁻⁴ | VPINN |
| 2.0 | 8.08 × 10⁻⁴ | 3.30 × 10⁻⁴ | VPINN ×2.4 |
| 3.0 | 6.50 × 10⁻⁴ | 2.22 × 10⁻³ | PINN ×3.4 |
| 5.0 | 7.13 × 10⁻⁴ | 1.71 × 10⁻² | PINN ×24 |
| Dimension | Regime | PINN L2 | VPINN L2 | Best default |
|---|---|---|---|---|
| 1D | Linear | 8.74 × 10⁻⁶ | 3.49 × 10⁻⁶ | VPINN |
| 1D | NL |
1.92 × 10⁻⁴ | 2.39 × 10⁻⁵ | VPINN |
| 2D | Linear | 3.09 × 10⁻⁵ | 1.79 × 10⁻³ | PINN |
| 2D | NL |
7.14 × 10⁻⁵ | 5.16 × 10⁻⁴ | PINN |
In 1D the VPINN dominates. In 2D the PINN leads with default settings, but the VPINN catches up with enriched test spaces and surpasses PINN for moderate nonlinearity.
.
├── README.md
├── LICENSE
├── linear/ # 1D linear (-u'' = f)
│ ├── requirements.txt
│ ├── src/
│ │ ├── exact_solution.py
│ │ ├── network.py
│ │ ├── utils.py
│ │ ├── pinn_solver.py
│ │ ├── vpinn_solver.py
│ │ └── run_all.py # 4 studies + 5 figures
│ └── figures/
├── nonlinear/ # 1D nonlinear (-[k(u)u']' = f)
│ ├── requirements.txt
│ ├── src/
│ │ ├── exact_solution.py
│ │ ├── network.py
│ │ ├── utils.py
│ │ ├── pinn_solver.py
│ │ ├── vpinn_solver.py
│ │ └── run_all.py # 5 studies + 5 figures
│ └── figures/
├── 2D_linear/ # 2D Poisson (-Δu = f)
│ ├── requirements.txt
│ ├── src/
│ │ ├── exact_solution.py
│ │ ├── network.py
│ │ ├── utils.py
│ │ ├── pinn_solver.py
│ │ ├── vpinn_solver.py
│ │ └── run_all.py # 4 studies + 5 figures
│ └── results/ # Figures + summary
├── 2D_nonlinear/ # 2D nonlinear (-div(k∇u) = f)
│ ├── requirements.txt
│ ├── src/
│ │ ├── exact_solution.py
│ │ ├── network.py
│ │ ├── utils.py
│ │ ├── pinn_solver.py
│ │ ├── vpinn_solver.py
│ │ ├── run_all.py # 5 studies + 5 figures
│ │ ├── study_ntest_beta_heatmap.py # N_test × β analysis
│ │ └── study_deep_analysis.py # Crossover + push N_test
│ └── results/ # 10 figures + summaries
- Python >= 3.10
- PyTorch >= 2.0
- NumPy >= 1.24
- SciPy >= 1.10 (for 2D FDM sparse solvers)
- Matplotlib >= 3.7
pip install torch numpy scipy matplotlib# 1D linear (~30 min)
cd linear/src && python run_all.py
# 1D nonlinear (~1h)
cd nonlinear/src && python run_all.py
# 2D linear (~2.5h, CPU)
cd 2D_linear/src && python run_all.py
# 2D nonlinear (~4.5h, CPU)
cd 2D_nonlinear/src && python run_all.py
# Deep analysis: crossover + N_test push (~3h)
cd 2D_nonlinear/src && python study_ntest_beta_heatmap.py
cd 2D_nonlinear/src && python study_deep_analysis.pyAll solvers accept a configuration dictionary :
from pinn_solver import train_pinn
results = train_pinn(config={
"n_hidden": 64,
"n_layers": 5,
"beta": 2.0, # nonlinearity strength (nonlinear cases)
"n_adam": 20_000,
"seed": 123,
})
print(f"L2 error: {results['errors']['L2']:.4e}")-
Raissi, M., Perdikaris, P. & Karniadakis, G.E. (2019). Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. J. Comput. Phys., 378, 686-707.
-
Kharazmi, E., Zhang, Z. & Karniadakis, G.E. (2021). hp-VPINNs: Variational physics-informed neural networks with domain decomposition. CMAME, 374, 113547.
-
Liu, Y. (1999). Numerical solution of the heat equation with nonlocal boundary conditions. J. Comput. Appl. Math., 110(1), 115-127.
-
Cannon, J.R. (1963). The solution of the heat equation subject to the specification of energy. Quart. Appl. Math., 21(2), 155-160.
If you use this code in your research or projects, please cite:
@software{auger2026pinn_integral_bc,
author = {Auger, Maxime},
title = {{PINN vs VPINN for Steady-State Heat Conduction with
Nonlocal Integral Boundary Condition (1D and 2D)}},
year = {2026},
url = {https://github.com/MaximeAuger/steady-state-heat-conduction},
institution = {FEMTO-ST Institute, Dept. of Applied Mechanics, SUPMICROTECH}
}This project is licensed under the MIT License — see LICENSE for details.
Author: Maxime Auger — FEMTO-ST Institute, Dept. of Applied Mechanics, ENSMM, Besancon, France.





