Physics-Informed Neural Networks (PINNs)#
PhysicsNeMo supports physics-informed training as a first-class workflow
through the upstreamed physicsnemo.sym namespace. PINN training is
expressed as a plain PyTorch training loop that uses
physicsnemo.sym.eq.phy_informer.PhysicsInformer to evaluate
PDE residuals on the model outputs and add them to the loss.
Building blocks#
A PhysicsNeMo PINN training script is composed of a small number of explicit pieces, all of which the user assembles directly:
Network — any
torch.nn.Module(typically aphysicsnemo.models.mlp.fully_connected.FullyConnected) that maps coordinates to the field variables of interest.PDE definition — a
physicsnemo.sym.eq.pde.PDEsubclass that declares the governing equations symbolically with SymPy. Equations are written once and reused across forward and inverse problems.PhysicsInformer — a
physicsnemo.sym.eq.phy_informer.PhysicsInformerinstance that, given a PDE and a chosengrad_method("autodiff","finite_difference","meshless_finite_difference","spectral", or"least_squares"), computes the spatial derivatives and evaluates the equation residuals on the network’s outputs.Loss and optimizer — a standard PyTorch loss that sums the data fitting terms (where applicable) and the physics residual terms, optimized with any
torch.optimoptimizer.Configuration — Hydra (
@hydra.main) for a smallconfig.yaml, with no PhysicsNeMo-specific configuration wrappers.
This mirrors the rest of the PhysicsNeMo training workflows:
the same physicsnemo.distributed for multi-GPU initialization,
physicsnemo.utils.logging for logs and checkpoints, and standard
torch.optim optimizers and schedulers. Physics-informing is just an
additional residual term in the loss.
Worked examples#
The two canonical PINN examples in the PhysicsNeMo repository are the recommended starting points and serve as the reference templates for new projects:
Lid-Driven Cavity (LDC) PINN — a forward, purely physics-driven PINN that solves 2D incompressible Navier–Stokes on the LDC geometry. Demonstrates the minimal end-to-end training script: network,
PDE,PhysicsInformer, training loop.Inverse PINN (heat-sink coefficient recovery) — an inverse PINN that recovers unknown PDE coefficients (kinematic viscosity and thermal diffusivity) from observed OpenFOAM data, using
PhysicsInformer.
Both examples are self-contained, runnable as python scripts, and are intended to be copied and adapted to new problems rather than extended through framework hooks.
Migrating from PhysicsNeMo-Sym#
If you previously used the standalone physicsnemo-sym repository
with the Solver / Domain / Constraint / Geometry
abstractions, the
PhysicsNeMo v2.0 Migration Guide
(PhysicsNeMo Sym → physicsnemo.sym section) describes the mapping
between the old abstractions and the explicit PyTorch loop expressed
above. The two examples linked in this section also include
side-by-side migration notes from their physicsnemo-sym predecessors.