Softcase's picture
Create README.md
454777b verified
|
Raw History Blame Contribute Delete
6.55 kB
# Model Card: PINN for 2D Unsteady Navier–Stokes (Taylor-Green Vortex)
## Model Details
- **Model type:** Physics-Informed Neural Network (PINN); fully-connected MLP surrogate for a PDE solution field
- **Architecture:** MLP, 6 hidden layers × 64 neurons, Tanh activation, Xavier-normal weight init, zero bias init
- Input: `(x, y, t)` — 3 features
- Output: `(u, v, p)` — 2D velocity components and pressure
- Parameters: reported at build time in the notebook (`n_params`) — record the printed value when re-running
- **Framework:** PyTorch (run recorded on PyTorch 2.10.0+cu128, CUDA, Tesla T4 GPU)
- **Developed by:** Modelling and Simulation Laboratory study group, Telkom University
- **License / status:** Coursework / research exercise notebook — no formal license specified
## Intended Use
- **Primary use:** Educational and research demonstration of PINNs for solving the 2D incompressible unsteady Navier–Stokes equations, using the Taylor-Green Vortex (TGV) as a test case with a known closed-form solution.
- **Intended users:** Students/researchers exploring PINN methodology; not intended as a production CFD solver.
- **Out-of-scope use:** Real-world flow prediction, engineering design decisions, or any Reynolds number / geometry outside the trained regime (e.g., turbulent, high-Re, or non-periodic domains). The model is a proof-of-concept validated against a single analytical benchmark and should not be used as a general-purpose Navier–Stokes solver.
## Physics / Problem Formulation
- **Governing equations:** 2D incompressible Navier–Stokes (non-dimensional), momentum-x, momentum-y, and continuity (mass conservation)
- **Test case:** Taylor-Green Vortex — one of the few 2D Navier–Stokes configurations with an exact analytical solution, used here as ground truth
- **Reynolds number:** Re = 100 (laminar regime)
- **Spatial domain:** (x, y) ∈ [0, 2π] × [0, 2π], periodic boundary conditions
- **Temporal domain:** t ∈ [0, 1]
## Training Data
No observational/measured data is used — this is a data-free PINN. Training relies entirely on:
- **Collocation points (PDE residual):** N_f = 10,000 points sampled uniformly at random over the (x, y, t) domain; re-sampled every 1,000 epochs
- **Initial-condition points:** N_0 = 2,000 points at t = 0, labeled using the analytical solution
- **Boundary points:** N_b = 1,000 point-pairs per direction, used to enforce periodic BCs (matching u, v, p at x=0/x=2π and y=0/y=2π)
## Training Procedure
- **Loss composition:** `L = λ_pde·L_pde + λ_ic·L_ic + λ_bc·L_bc`
- L_pde: mean-squared PDE residual (momentum-x, momentum-y, continuity)
- L_ic: mean-squared error vs. analytical u, v at t=0
- L_bc: mean-squared mismatch between paired periodic boundary points (u, v, p)
- Weights: λ_pde = 1.0, λ_ic = 10.0 (upweighted as the more fundamental constraint), λ_bc = 1.0
- **Optimizer:** Adam, initial learning rate 1e-3
- **LR schedule:** StepLR, step size 5,000 epochs, gamma 0.5
- **Epochs:** 20,000
- **Second-order fine-tuning (e.g., L-BFGS):** not used in this run (listed as future work)
- **Derivatives:** computed via PyTorch autograd (`create_graph=True`) for PDE residuals up to second order
- **Reproducibility:** `torch.manual_seed(42)`, `np.random.seed(42)`
- **Compute / wall-clock:** ~919.5 seconds (~15.3 minutes) on a Tesla T4 GPU for 20,000 epochs
- **Training loss at final logged step (epoch 19,500):** total ≈ 4.68e-04 (PDE ≈ 9.78e-05, IC ≈ 2.28e-05, BC ≈ 1.42e-04); loss decreased from ≈9.05 at epoch 0, with some noisy spikes around epochs 3,500–10,000 before settling
## Evaluation
Evaluated against the exact analytical TGV solution on a 100×100 grid at five time points, using L2 (RMS) absolute and relative error.
| t | L2 error u | Rel. error u | L2 error v | Rel. error v | Rel. error p (raw) | Rel. error p (gauge-corrected) |
|---|---|---|---|---|---|---|
| 0.00 | 4.43e-03 | 0.89% | 4.17e-03 | 0.83% | 93.21% | 1.73% |
| 0.25 | 4.42e-03 | 0.89% | 4.63e-03 | 0.93% | 93.50% | 1.35% |
| 0.50 | 4.62e-03 | 0.93% | 4.83e-03 | 0.98% | 93.74% | 1.43% |
| 0.75 | 4.96e-03 | 1.01% | 4.71e-03 | 0.96% | 93.93% | 1.83% |
| 1.00 | 5.52e-03 | 1.13% | 4.35e-03 | 0.89% | 94.08% | 2.44% |
- **Velocity fields (u, v):** relative L2 error stays under ~1.2% across the full time horizon — accurate and stable over time.
- **Pressure field (p):** raw relative error is large (~93–94%) because pressure in incompressible Navier–Stokes is only defined up to an additive constant (no boundary condition pins its absolute level), and the PINN's output isn't zero-mean by construction. After removing the mean from both predicted and true pressure fields ("pressure gauge" correction), relative error drops to 1.3–2.4%, confirming the *shape* of the pressure field is learned correctly — only the arbitrary constant offset differs.
- **Vorticity:** reconstructed via autograd from the velocity output (ω = ∂v/∂x − ∂u/∂y) and compared qualitatively/visually to the analytical vorticity field at t = 0.5; consistent with the analytical field in the notebook's plots.
## Limitations
- **Pressure ambiguity:** raw pressure error is uninformative without gauge correction; any downstream use of `p` must account for the unknown additive constant.
- **Single benchmark, single Re:** only validated at Re = 100 on a periodic, doubly-periodic square domain — no evidence of generalization to other Reynolds numbers, geometries, or boundary conditions.
- **Training cost:** ~15 minutes per run on a T4 GPU for a very simple, well-posed 2D case with a known closed-form solution; substantially slower than classical CFD solvers (FDM/FEM) for equivalent accuracy.
- **Convergence stability:** training loss showed non-monotonic spikes (e.g., epochs ~3,500, ~4,500, ~10,000) requiring loss monitoring; not guaranteed to converge smoothly with different seeds/hyperparameters.
- **Sensitivity:** accuracy noted as sensitive to the loss weighting (λ_pde, λ_ic, λ_bc); no ablation over these weights is included.
- **No data-driven validation:** all "ground truth" comes from the same analytical formula used to construct the loss (IC) and evaluation — this checks self-consistency of the solver, not agreement with real/experimental flow data.
## Environmental / Compute Impact
- Single Tesla T4 GPU, ~15.3 minutes training time for the reported run — compute footprint is minor at this scale, but note this is per-run and does not include experimentation/tuning overhead.