Paper · 2021-10-29 · cs.LG, cs.CE, math.NA, physics.comp-ph, physics.flu-dyn
CAN-PINN: A Fast Physics-Informed Neural Network Based on Coupled-Automatic-Numerical Differentiation Method
PINNs whose PDE loss uses only automatic differentiation need dense collocation points. CAN-PINN couples AD slopes with numerical-differentiation stencils over neighbouring points (upwind for convection, central for pressure), so sparse samples still constrain the flow. Author-reported: it beats AD-only and stencil-only PINNs on several flow problems.
Physics-informed neural networkAutomatic differentiationFinite-difference methodphysics-informedpdenavier-stokesfluid-dynamicsnumerical-differentiation
arXivPDFCodeMarkdown11 min read
AI-compiled by claude-haiku-5-5 on 2026-11-01, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
A physics-informed neural network learns a flow field by penalising it when it breaks the governing equations at a set of sample points. The usual way to measure how much an equation is broken is automatic differentiation, which gives exact slopes at each point. When the points are few, the network can make those slopes match at every point and still be wrong between them, so the answer looks fine to the training loss but is far from the true flow.
This paper's idea is to also look at the neighbours of each point, as classic numerical methods do with finite differences. The slope is then estimated from nearby values, which ties neighbouring points together. The authors combine the two: the neighbour-based estimate and the exact slope at the point are mixed so the result is more accurate than the neighbour estimate alone. They test this on fluid flow problems, mainly the incompressible Navier-Stokes equations, and report that it keeps working with few sample points where the usual approach fails.
TL;DR
- Standard PINNs compute derivatives of the PDE residual with automatic differentiation (AD) at each collocation point and need many points.
- CAN-PINN adds derivative terms built from neighbouring network outputs (numerical differentiation, ND) and couples them to the AD slope at the point §2.3 eq. 6a.
- Two schemes are derived for the Navier-Stokes equations: can(uw2) for convection and can(cd) for pressure gradients §2.3.1 §2.3.2.
- Author-reported: lower error than AD-only and ND-only PINNs on several flow problems. With few CPUs its per-iteration cost is the highest of the three §3 fig. 11c.
- Only the lid-driven cavity forward problem has released code [Paper vs code].
Problem
AD-based PINN losses evaluate each PDE residual exactly at the collocation points, and nothing ties one point to the next. With sparse points the network can drive the residual to a very small value while its solution is far from the truth §1 §2.2 fig. 1. The authors report that such AD-only PINNs (a-PINNs) need dense sampling and long training, and that their training loss can be misleading §2.2 §3.1.1 §3.2.1.
Method
Overview. The PINN is a fully connected network û(x, t; w), trained by minimising a weighted sum of PDE, boundary and initial-condition losses §2.1 eq. 1a–c eq. 2a–e. The Navier-Stokes instantiation uses the velocity components u, v and pressure p as network outputs §3.3 eq. 27a–c.
Input features (all PINN variants). Inputs (x, t) are first mapped through a sinusoidal layer γ(v) = sin(2π(Wv + b)) §2.1 eq. 3. Weights W are sampled from a normal distribution N(0, σ²) with σ = 1, and b starts at zero [tab. 1, note 2]. Hidden layers use sine activations and He-uniform initialisation; the output layer is linear tab. 1, note 2.
Numerical-differentiation (n-PINN) baseline. The first derivative of u at a point is written as a difference between face values at x ± Δx/2 eq. 4. Three stencils are given eq. 5a–c:
- 1st-order upwind, n(uw1): face value û(x) eq. 5a;
- 2nd-order upwind, n(uw2): face value 3/2 û(x) − 1/2 û(x − Δx) eq. 5b;
- 2nd-order central, n(cd2): face value (û(x + Δx) + û(x − Δx)) / 2 eq. 5c.
Derivative terms are evaluated from the network at neighbouring points, so the network is called at x ± Δx and at x ± 2Δx §2.2 eq. 5b. The points are not required to form a mesh §2.2.
Coupling step (can-PINN). The face value is a linear combination of the network output and its AD derivative: u_e|can = a1 · û(x) + a2 · û_x(x) eq. 6a. Taylor expansions of û(x) and û_x(x) about the face eq. 6b, 6c give a1 = 1 and a2 = Δx/2 eq. 7a, 7b. Thus u_e|can(uw2) = û(x) + (Δx/2) û_x(x) eq. 8a, and u_w|can(uw2) = û(x − Δx) + (Δx/2) û_x(x − Δx) eq. 8b. The derivative is then (u_e − u_w)/Δx eq. 9 and, with the modified-equation expansion, carries a leading error term of order Δx² eq. 10 eq. 11. The authors state the theoretical accuracy order as two §2.3.1.
Central pressure gradient, can(cd). Central differencing of pressure alone lets velocity and pressure decouple on collocated grids §2.3.2. The face pressure is therefore corrected with the AD slope at the centre and at the neighbour eq. 12a, 12b:
# Face pressure, can(cd) [§2.3.2] [eq. 12a] [eq. 12b]
# Inputs: p and p_x (AD) at x, and at its east neighbour x + dx
# Output: p_e, the pressure at the east face
def face_pressure_east(p, p_x, p_east, p_x_east, dx):
# Average of the two nodal values [eq. 12a]
average = (p + p_east) / 2.0
# Correction with the difference of AD slopes, scaled by dx/8 [eq. 12a]
correction = (dx / 8.0) * (p_x_east - p_x)
return average - correctionThe gradient is then (p_e − p_w)/Δx eq. 13. The authors give the same form for the west face eq. 12b. Modified-equation analysis gives accuracy order two eq. 14a, 14b.
Convection and pressure used in the N-S experiments. Convection uses can(uw2) and pressure uses can(cd); the viscous terms use central second differences from neighbouring values §3.3 §2.3. The paper calls this can(uw2-conv, cd-p). It also trains a variant with plain central pressure differences, can(uw2-conv), to show the effect of the can pressure scheme §3.3.
Dispersion and dissipation. The authors compare the wavenumber error of can(uw2) and can(cd) with first- and second-order upwind schemes using a Fourier analysis §2.4 eq. 15a–20b fig. 3. Their reading: both can schemes have smaller dispersion error, can(uw2) has smaller dissipation, and can(cd) is non-dissipative §2.4 fig. 3.
Sampling and boundaries. Collocation points are sampled from the domain, for example on an equispaced grid, by Latin hypercube or by importance sampling §2.1. Boundary and initial conditions enter through the losses in eq. 2d and 2e §2.1.
Hyperparameters
Values for the lid-driven cavity (LDC), the case with released code, first. Other rows come from tab. 1 and the text.
| Name | Value | Where | Notes |
|---|---|---|---|
| Sinusoidal features | 64 features (layer width 64) | eq. 3 tab. 1 d01_can-pinn_lid_driven_cavity_re400.ipynb | Code: dense layer of width 2 × n_ffs with n_ffs = 32 d01_can-pinn_lid_driven_cavity_re400.ipynb, then sin(2π·) |
| Feature weights W init | N(0, σ²), σ = 1 | §2.1 tab. 1, note 2 | Code samples a truncated normal with stddev 1 d01_can-pinn_lid_driven_cavity_re400.ipynb |
| Feature bias b init | zero | tab. 1, note 2 | |
| Hidden activation | sine, linear output | tab. 1, note 2 | Code uses sin in all hidden layers and linear heads d01_can-pinn_lid_driven_cavity_re400.ipynb |
| Hidden init | He uniform | tab. 1, note 2 | |
| LDC architecture | (x, y)–64–20–20–20–[20–20–20–(û), 20–20–20–(v̂), 20–20–20–(p̂)] | tab. 1 | Code: 3 shared 20-wide layers, then 3 per output head; 6,172 parameters d01_can-pinn_lid_driven_cavity_re400.ipynb |
| Optimizer | Adam | §2.1 | Only the learning rate is passed to the optimizer d01_can-pinn_lid_driven_cavity_re400.ipynb |
| Initial learning rate | 1e-3 | tab. 1 d01_can-pinn_lid_driven_cavity_re400.ipynb | |
| LR schedule | Reduce on plateau down to min 5e-6 | tab. 1, note 4 | Paper gives no factor or patience. Code: monitor loss, factor 0.5, patience 50 epochs, min 5e-6 d01_can-pinn_lid_driven_cavity_re400.ipynb |
| Loss weight λ | 1 | tab. 1, note 3 d01_can-pinn_lid_driven_cavity_re400.ipynb | |
| Re | 400 | §3.3 | |
| LDC domain | x ∈ [0, 1], y ∈ [−1, 0] | §3.3 d01_can-pinn_lid_driven_cavity_re400.ipynb | |
| Lid velocity | u = 1 on the top wall, no slip elsewhere | §3.3 fig. 8 d01_can-pinn_lid_driven_cavity_re400.ipynb | |
| LDC collocation points | 2,601 equispaced (51 × 51), Δx = Δy = 0.02 | tab. 1 d01_can-pinn_lid_driven_cavity_re400.ipynb d01_can-pinn_lid_driven_cavity_re400.ipynb | |
| LDC mini-batch | 475 collocation + 0 IC + 25 boundary | tab. 1, note 3 d01_can-pinn_lid_driven_cavity_re400.ipynb | |
| LDC training length | 200,000 iterations | tab. 1 d01_can-pinn_lid_driven_cavity_re400.ipynb | Code runs 2,000 epochs × 100 batches; see Paper vs code |
| Ground truth (LDC) | in-house IDFC solver | §3.3 RE400_LDC_GROUND_TRUTH_51X51.csv | |
| Sampling study, LDC | 2,601 / 10,201 / 40,401 equispaced points, Δx = 0.02 / 0.01 / 0.005 | tab. 2 | Iterations 200k / 1M / 2M; mini-batch 500 / 500 / 1000 |
| Sampling study, uniform | random uniform points, Δx = 0.01 | tab. 2 | 2M iterations, mini-batch 1000 |
| Table 1 ODE | (x)–64–20–20–20–(û); 41 / 81 / 161 points; batch 6+0+2; 1e5 iterations; lr 5e-3 | tab. 1 §3.1 | Δx values in the table are partly unreadable in the source; 41 equispaced points on [0, 2π] give Δx = 2π/40 |
| Table 1 flow mixing | (x, y, t)–64–20–20–20–(û); Δx = Δy = 0.16; 65,025 points; batch 470+15+15; 1e5 iterations; lr 5e-3 | tab. 1 | |
| Table 1 backward step | (x, y)–64–20–20–20–[20–20–20 heads]; Δx = 0.05, Δy = 0.026; 16,000 points; batch 475+0+25; 5e5 iterations; lr 1e-3 | tab. 1 | |
| Table 1 channel | (x, y)–128–30–30–30–[30–30–30 heads]; Δx = Δy = 0.02; 3,437 points; batch 475+0+25; 5e5 iterations; lr 1e-3 | tab. 1 §3.5 | 674 boundary + 2,763 interior points §3.5 |
Results
Author-reported. Setups below are the paper's own; no independent reproduction is in the source.
| Setting | Metric | Baseline | This paper | Source |
|---|---|---|---|---|
| ODE du/dx = cos x, 41 points, 10 runs | MSE | a-PINN: large; n-PINNs and can-PINNs 1 to 3 orders better | can-PINNs statistically better than n-PINNs in all scenarios | §3.1.1 fig. 4 fig. 5 |
| Flow mixing, 65,025 points, 50 runs | u MSE | a-PINN: wide spread, some runs far from truth | can(uw2) and can(cd) clearly more accurate than n-PINN; can(uw2) lower variance than can(cd) | §3.2.1 fig. 6 fig. 7 |
| LDC Re = 400, 2,601 points, 50 runs | u & v MSE | a-PINN: above 1e-2 | can-PINN about 2 orders of magnitude lower than a-PINN; n-PINN about 1 order lower | §3.3.1 fig. 10a |
| LDC Re = 400, 10,201 / 40,401 points | u & v MSE | a-PINN: 40,401 points gives about 2e-4 | can-PINN below 1e-5 at 40,401 points | §3.3.2 fig. 11a |
| LDC, 2,601 points, uniform sampling, 2M iterations | u & v MSE | a-PINN better than with fixed points | can-PINN outperforms a-PINN and n-PINN in all sampling settings tested | §3.3.2 fig. 11b |
| LDC training time per iteration | ms per iteration | a-PINN, n-PINN, can-PINN | n-PINN fastest and can-PINN slowest with 4 CPUs per PINN; similar with over 20 CPUs | §3.3.2 fig. 11c |
| Inverse LDC, Re unknown, 10 observations | inferred Re and u&v MSE | a-PINN: largest spread | Re within about 10% at Re = 400 and within 20% at Re = 1000; u&v MSE below 5e-5 at Re = 400 and 5e-4 at Re = 1000 | §3.3.3 fig. 12 |
| Backward-facing step, Re = 200, 16,000 points, 25 runs | reattachment x1 (GT 2.608) | a-PINN 4.761; n-PINN 2.601 | can-PINN 2.604 | tab. 3 |
| Backward-facing step, Re = 200 | MSE | a-PINN | can-PINN about 5 orders lower than a-PINN and 1 order lower than n-PINN | §3.4.1 fig. 15 |
| Backward-facing step, Re = 400, 32,000 points, 2M iterations | MSE u, v, p | not reported | 8.4e-7, 6.3e-8, 3.9e-8 | §3.4.2 |
| Backward-facing step, Re = 400 | x1, x2, x3 (GT 4.276, 4.093, 5.122) | Literature values in tab. 3 | can-PINN 4.292, 4.120, 5.161 | tab. 3 |
| Inverse backward step, Re = 200, 400, 800, 30 observations | inferred 1/Re and u&v MSE | ground truth 1/Re | Re error below 2.5%; u&v MSE below 5e-6 | §3.4.3 fig. 18 |
| 2D complex channel, Re = 400, 25 runs | u&v MSE | a-PINN fails | can-PINN gives good solutions; n-PINN less accurate | §3.5.1 fig. 20 |
Paper vs code
The paper names no code link. The official repository was found as
chiuph/CAN-PINN: its description matches the paper's title and its owner
name matches the first author's handle. Its README gives A*STAR as copyright
holder and cites this paper. Checked at commit
a92594e623cfa7260efa88019a27c53a1cd664dd.
- Scope. The repository has three notebooks for forward LDC at Re = 400:
d01can-PINN,d02n-PINN andd03a-PINN. No code for the ODE, flow-mixing, backward-facing-step, channel or inverse experiments is in the repository d01_can-pinn_lid_driven_cavity_re400.ipynb d02_n-pinn_lid_driven_cavity_re400.ipynb d03_a-pinn_lid_driven_cavity_re400.ipynb. - Hyperparameters match Table 1 for LDC. Re = 400, 51 × 51 grid, batch 475 + 0 + 25, learning rate 1e-3, λ = 1, min learning rate 5e-6, 2,000 epochs × 100 batches d01_can-pinn_lid_driven_cavity_re400.ipynb d01_can-pinn_lid_driven_cavity_re400.ipynb d01_can-pinn_lid_driven_cavity_re400.ipynb. The same values appear in
d02andd03. - Update count. Table 1, note 4 says the PINN weights are updated every 100 iterations. The code calls one Adam step per mini-batch; the sampler reports 100 batches per epoch and training runs 2,000 epochs, so 200,000 steps d01_can-pinn_lid_driven_cavity_re400.ipynb d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Weight initialisation. The paper says N(0, σ²); the code uses a truncated normal with stddev σ = 1 d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Momentum residual. The paper writes the momentum equations in conservative form eq. 27b. The code's momentum residual adds a term −u · div, where div is the discrete divergence from face velocities, and the same term in v d01_can-pinn_lid_driven_cavity_re400.ipynb. The paper has no such term.
- Negative face velocity. The paper derives only the positive-flow branch of can(uw2) eq. 8a, 8b. The code uses a mirror-image formula when the face velocity is negative d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Upwind switch. The paper does not say which velocity selects the upwind side. The code uses the average of the two velocities at the face d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Loss form. The paper's loss is a weighted sum with λ_BC and λ_IC eq. 2a. The code adds the PDE loss divided by λ and the boundary loss with no separate weight d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Continuity and viscous terms. Central differences, as the paper states §3.3 d01_can-pinn_lid_driven_cavity_re400.ipynb. No discrepancy found.
- Pressure gradient. The can(cd) correction matches eq. 12a and 12b in form d01_can-pinn_lid_driven_cavity_re400.ipynb. No discrepancy found.
- Logged result. The saved output of the can-PINN run ends at training loss 8.11e-06 after 2,000 epochs d01_can-pinn_lid_driven_cavity_re400.ipynb. The notebook does not log the MSE against the ground truth.
- Dependencies. The README badges name Python 3.8 and TensorFlow 2.4 README.md. The notebooks use the
tf.compat.v1graph API d01_can-pinn_lid_driven_cavity_re400.ipynb. - Licence. No LICENSE file exists. The README states "All rights reserved" README.md. Cite the code by path and line only; do not copy snippets.
Pitfalls
- AD-only loss can mislead. With sparse points the PDE residual can be near zero while the solution is wrong. Do not judge convergence by training loss alone §1 fig. 1 §3.2.1 §3.3.1.
- Upwind branches. The positive-flow face formulas are in the paper eq. 8a, 8b. The negative branch and the choice of which velocity sets the side are not stated. Use the code's mirror formula and face-average rule, and say so in the implementation d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Boundary samples inside the batch. The sampler draws 475 points from all 2,601, including boundary points. The residual drops boundary points, so a batch yields fewer than 475 PDE residuals d01_can-pinn_lid_driven_cavity_re400.ipynb d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Corner double-count. Left and bottom boundary terms both include the bottom-left corner, so that corner counts twice in the boundary loss d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Pressure is unconstrained. The boundary loss enforces only u and v. The paper states no pressure condition, and the code adds none, so pressure is fixed only up to a constant §3.3 d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Cost. Each can-PINN residual evaluates the network at eight neighbours (x ± Δx, x ± 2Δx, and the same in y) and takes AD slopes at the neighbours. The authors report it as the slowest per iteration with few CPUs d01_can-pinn_lid_driven_cavity_re400.ipynb fig. 11c.
- Inverse-problem weights. The text states the data-loss to PDE-loss weight as 100 to 1. It gives no boundary-loss weight for that experiment §3.3.3.
- Learning-rate schedule. Factor and patience are not stated in the paper. The code uses factor 0.5 and patience 50 epochs, which is 5,000 steps d01_can-pinn_lid_driven_cavity_re400.ipynb.
- Sampling density. At 2,601 points a-PINN fails while can-PINN works. At 40,401 points a-PINN reaches about 2e-4 and can-PINN below 1e-5. Larger sets need more iterations and larger batches, so the cost rises with the point count §3.3.2 tab. 2.
- Code is forward only. The notebooks are not a reproduction of the inverse or multi-problem results.
Lineage
- Builds on: finite-difference and multi-moment schemes the paper cites §2.3 §2.3.1; physics-informed neural networks [2]; sinusoidal features [37].
- Compared against: AD-based PINNs (a-PINN) and numerical-differentiation PINNs (n-PINN) with 1st-order upwind, 2nd-order upwind and central stencils §2.2 eq. 5a–c.
- Superseded by: not stated in this card's sources.
Source and license
Adapted from “CAN-PINN: A Fast Physics-Informed Neural Network Based on Coupled-Automatic-Numerical Differentiation Method” by Pao-Hsiung Chiu, Jian Cheng Wong, Chinchun Ooi, My Ha Dao, Yew-Soon Ong (arXiv:2110.15832), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/chiuph/CAN-PINN at commit a92594e623cf (none (no LICENSE file in the repository)). Any quoted code is shown under that license.