Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

domain.

add_validator(val, "test")

1.6.4 Solver and Training the Model


We can create a solver by using the domain we just created along with the other configurations
that define the optimizer choices, settings using Modulus’ Solver class. The solver can then be
executed using the solve method.
[ ]: # to make the logging work in the jupyter cells
# Need to execute this only once!
import logging
logging.getLogger().addHandler(logging.StreamHandler())

[ ]: import os
from modulus.sym.solver import Solver

# optional set appropriate GPU in case of multi-GPU machine


#os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
#os.environ["CUDA_VISIBLE_DEVICES"]="2"

# make solver
slv = Solver(cfg, domain)

# start solver
slv.solve()

1.6.5 Results and Post-processing


The checkpoint directory is saved based on the results recording frequency specified in the
rec_results_freq parameter of its derivatives. The network directory folder contains several
plots of different validation predictions. Several are shown below, and you can see that the model
is able to accurately predict the pressure field for permeability fields it had not seen previously.
These visualizations can also be viewed during the training using the Tensorboard.
FNO validation predictions. (Left to right) Input permeability, true pressure, predicted pressure,
error.

1.7 Part 2: Solution Using AFNO


Let’s see how to solve the problem using the AFNOs. The complete problem setup can be found
in the darcy_AFNO.py script, but here for the sake of understanding, we will build the constraints
and the case step by step. config_AFNO.yaml lists the configs required for the problem. Let’s
start by loading them. The process of setting the AFNO training is very similar from a case setup
standpoint hence we will only highlight the important differences wherever necessary.
The AFNO is based on the ViT transformer architecture and requires tokenization of the inputs.
Here each token is a patch of the image with a patch size defined in the configuration file through
the parameter patch_size. The embed_dim parameter defines the size of the latent embedded
features used inside the model for each patch.

You might also like