This example demonstrates how to set up a data-driven model for a 2D Darcy flow using the Transolver inside of PhysicsNeMo.
Training progress can be tracked through MLFlow. This example runs on a single GPU.
This example is based on a 2D Darcy flow problem, which is often used to model
flow diffusion through a porous medium. The equation describes the steady-state
pressure and velocity field (related by the constitutive relation, based on
Darcy's law) for some fluid of interest. As an applied example, one might
consider a geological example, where the fluid is oil which is both a) generated
by a source term
where
For the baseline case defined in train_transolver_darcy.py, the dataset is
generated on-the-fly at train time via the Darcy2D Datapipe described in
./physicsnemo/datapipes/benchmarks/darcy.py.
For the modified case with a fixed (i.e., precomputed) dataset defined in
train_transolver_darcy_fix.py, the dataset is pre-generated, and loaded via
the Darcy2D_fix Datapipe. In the fixed case, extra data is needed for training
and the data path should be added when Darcy_2D_fix dataset is constructed.
You can download the data
here.
The fix dataset training (which uses a fixed dataset) requires you to convert
data from matlab to numpy format, for faster startup of the training. Just
use the convert_mat_to_npz.py script to port your data.
Install the required dependencies by running below:
pip install -r requirements.txtTo train the model following PhysicsNeMo's settings, simply run:
python train_transolver_darcy.pyEach batch is a new data generated by equation, which is different from commonly-used settings.
To reproduce the results in the paper, run:
python train_transolver_darcy_fix.pyIn this case, the train set and test set are fixed after the construction of Dataset, corresponding to Transolver's setting.
To train Transolver on the same 2D Darcy flow problem with different physical
parameters or ML hyperparameters, modify the config.yaml file.
To train Transolver on your own physics problem, modify the dataloader in
train_transolver_darcy.py to use your own pre-computed data or on-the-fly
solver.
More components are added for convenience. Validators calculate the loss
between ground-truth and prediction, and visualize them in ./mlruns. Below is
a simple example of visualization.

