This example demonstrates physics informing of a data-driven model using numerical derivatives (PINO).
To examine the properties of PINOs with 3 coupled nonlinear equations, we
examined the ability of the networks to reproduce the nonlinear shallow water
equations. These equations are applicable in several physical scenarios
including tsunami modeling. We assumed that the total fluid column height
where the gravitational coefficient
We will demonstrate the use of data loss and physics constraints,
specifically the equation residual loss, to create accurate predictions.
The physicsnemo.sym module (install with pip install "nvidia-physicsnemo[sym]")
has utilities tailored for physics-informed machine learning, and we leverage them
here to add physics to an existing data-driven model with ease while keeping a
fully explicit training loop.
If you previously used the (now archived)
physicsnemo-sym repository,
where the Solver / Domain / Constraint abstractions handled the
training loop and physics losses implicitly, see the
PhysicsNeMo v2.0 Migration Guide
for how the equivalent pieces look in this newer, explicit style.
The training and validation datasets for this example can be found on the PINO Applications Github page.
To demonstrate the usefulness of the Physics loss, we will deliberately choose a smaller dataset size of 45 samples. In such regiemes, the effect of physics loss is more evident, as it regularizes the model in the absence of large data.
In this example, we will use a Fourier Neural Operator (FNO). and then compute the derivatives in a PINO style, using Numerical differentiation with Fourier derivatives. With this example, we intend to demonstrate how to implement multiple equations into the loss function.
In this example, we will also use the PDE class from
physicsnemo.sym to symbolically define the PDEs.
This is a convenient and natural way to define PDEs and allows
us to print the equations to check for correctness. This also abstracts out the
complexity of converting the equation into a pytorch representation. physicsnemo.sym also
provides several complex, well-tested PDEs like 3D Navier-Stokes, Linear elasticity,
Electromagnetics, etc. pre-defined which can be used directly in physics-informing
applications. We will also give you the option to choose between the
derivative functions from physicsnemo.sym or from the original paper.
Install the requirements using:
pip install -r requirements.txt
pip install "nvidia-physicsnemo[sym]"The downloading and pre-processing of the data can also be done by running the below set of commands:
python download_data.pyTo get started with the example, simply run,
python train_swe_nl_pino.py