Modulus v4
Modulus v4
with Modulus
1
Agenda
• What is Modulus?
2
Saturating Performance in Traditional HPC
Simulations are getting larger and more complex
3
NVIDIA Modulus
4
What is Modulus?
Modulus is a PDE solver
• Like traditional solvers such as Finite Element, Finite Difference, Finite Volume, and Spectral solvers, Modulus can solve PDEs
A comparison between Modulus and commercial solver results for a bracket deflection example. Linear elasticity equations are solved here.
5
What is Modulus?
Modulus is a tool for efficient design optimization for multi-physics problems
• With Modulus, professionals in Manufacturing and Product Development can explore different configurations and scenarios of a model,
in near-real-time by changing its parameters, allowing them to gain deeper insights about the system or product, and to perform efficient
design optimization of their products.
Efficient design space exploration of the heatsink of a Field-Programmable Gate Array (FPGA) using Modulus.
6
What is Modulus?
Modulus is a solver for inverse problems
• Many applications in science and engineering involve inferring unknown system characteristics given measured data from sensors or
imaging.
• By combining data and physics, Modulus can effectively solve inverse problems.
A comparison between Modulus and OpenFOAM results for the flow velocity, pressure and passive scalar concentration fields. Modulus has inferred the velocity and
pressure fields using scattered data from passive scalar concentration.
7
What is Modulus?
Modulus is a tool for developing digital twins
• A digital twin is a virtual representation (a true-to-reality simulation of physics) of a real-world physical asset or system, which is
continuously updated via stream of data.
• Digital twin predicts the future state of the real-world system under varying conditions.
Virtual representation
8
What is Modulus?
Modulus is a tool for developing data-driven solutions to engineering problems
• Modulus contains a variety of APIs for developing data-driven machine learning solutions to challenging engineering systems, including:
• Data-driven modeling of physical systems
• Super resolution of low-fidelity results computed by traditional solvers
9
What is Modulus?
Putting it all together
10
Modulus Architecture
11
Modulus Training
12
Physics Informed Neural Networks (PINNs) in Modulus
A problem with NNs and the promise of PINNs
∑ ( )
2 2
𝐿𝑑𝑎𝑡𝑎 =
2
(𝑢𝑛𝑒𝑡 ( 𝑥 𝑖 ) −𝑢 𝑡𝑟𝑢𝑒 ( 𝑥𝑖 ) ) 𝛿 𝑢𝑛𝑒𝑡
𝑥 𝑖 ∈𝑑𝑎𝑡𝑎
𝐿𝑝h𝑦𝑠𝑖𝑐𝑠= ∑ 𝛿𝑥
2 ( 𝑥 𝑖 ) − 𝑓 ( 𝑥𝑖 ) 𝐿 𝑝h𝑦𝑠𝑖𝑐𝑠 = 𝐿 𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙 + 𝐿 𝐵𝐶
𝑥 𝑗 ∈𝑑𝑜𝑚𝑎𝑖𝑛
13
PINNs Theory: Neural Network Solver
Problem description
• Goal: Train a neural network to satisfy the boundary conditions and differential equations by constructing an appropriate loss function
• Consider an example problem:
• We construct a neural network which has a single value input and single value output .
• We assume the neural network is infinitely differentiable - Use activation functions that are infinitely differentiable
14
PINNs Theory: Neural Network Solver
Loss formulation
• Construct the loss function. We can compute the second order derivatives using Automatic differentiation
15
PINNs Theory: Neural Network Solver
Results
16
Modulus: Anatomy of a project
Overview
17
Modulus: Anatomy of a project
Load Hydra
defaults :
- modulus_default
- scheduler: tf_exponential_lr
- optimizer: adam
- loss: sum
- _self_
scheduler:
decay_rate: 0.95
decay_steps: 200
save_filetypes : "vtk,npz"
training:
rec_results_freq : 1000
rec_constraint_freq: 1000
max_steps : 5000
18
Modulus: Anatomy of a project
Create geometry, domain and nodes
@modulus.main(config_path="conf",
config_name="config")
def run(cfg: ModulusConfig) -> None:
# make geometry
x = Symbol("x")
geo = Line1D(0, 1)
nodes = (eq.make_nodes() +
[u_net.make_node(name="u_network")])
# make domain
domain = Domain()
19
Modulus: Anatomy of a project
Add constraints
# bcs
bc = PointwiseBoundaryConstraint(
nodes=nodes,
geometry=geo,
outvar={"u": 0},
batch_size=2,
)
domain.add_constraint(bc, "bc")
# interior
interior = PointwiseInteriorConstraint(
nodes=nodes,
geometry=geo,
outvar={"custom_pde": 0},
batch_size=100,
bounds={x: (0, 1)},
)
domain.add_constraint(interior, "interior")
20
Modulus: Anatomy of a project
Create utils to visualize the results and run the solver
# add inferencer
x_np = np.linspace(0, 1.0, 100).reshape(-1,1)
inference = PointwiseInferencer(
nodes=nodes,
invar={"x": x_np},
output_names=["u"],
)
domain.add_inferencer(inference, "inf_data")
# make solver
slv = Solver(cfg, domain)
# start solver
slv.solve()
if __name__ == "__main__":
run()
python <script_name>.py
mpirun –np <#GPU> <script_name>.py
21
Accessing the supplemental material
DLI Interface and JupyterLab
22
Solving Parameterized Problems
Problem definition
• Consider the parameterized version of the same problem as before. Suppose we want to determine how the solution changes as we move
the position on the boundary condition
• Parameterize the position by variable and the problem now becomes:
• This time, we construct a neural network which has and as input and single value output .
• The losses become
23
Solving Parameterized Problems
Results
24
Solving Inverse Problems
Problem definition
• For inverse problems, we start with a set of observations and then calculate the causal factors that produced them
• For example, suppose we are given the solution at 100 random points between 0 and 1 and we want to determine the that is causing it
• Train two networks and to approximate and
25
Solving Inverse Problems
Results
Comparison of 𝑢_𝑛𝑒𝑡 (𝑥) and train points from 𝑢_𝑡𝑟𝑢𝑒 Comparison of the true solution for and the inverted out
26
Solution to 1D diffusion
Problem description
• Composite bar with material of conductivity for and for . Points A and C are maintained at temperatures of and respectively
• Equations: Diffusion equation in
When
When
27
Solution to 1D diffusion
Code snippets – Custom symbolic PDE
29
Solution to 1D diffusion
Code snippets
Solver
Results generated from numpy output
30
Parameterized Solution to 1D diffusion
Problem description and code snippets
32
Solution to ODEs – Coupled Spring Mass System
Code snippets
• For the same system, assume we know the analytical solution which is given by:
• With the above data and the values for same as before, use the neural network to find the values of and
34
Inverse Problem – Coupled Spring Mass System
Code snippets
Additional network
to invert out the
unknowns
Results 35
Data-driven analysis – Surrogate Model for Darcy Flow
Problem description
• Use Fourier Neural Operator (FNO) and its variants to develop a surrogate model that learns a mapping between a permeability field and
pressure field, , for a distribution of permeability fields .
• The Darcy PDE is a second order, elliptical PDE with the following form:
• Where is the flow pressure, is the permeability field and is the forcing function.
• The Darcy flow can parameterize a variety of systems including flow through porous media, elastic materials and heat conduction.
• Here, we will define the domain as a 2D unit square with the boundary condition , .
• Both the permeability and flow fields are discretized into a 2D matrix .
36
Darcy Flow – Fourier Neural Operators (FNO)
Theory
• FNO can be used to parameterize solutions for a distribution of PDE solutions. The key feature of FNO is the spectral convolutions:
operations that place the integral kernel in Fourier space:
• is the transformation containing the learnable parameters . This operator is calculated over the entire structured Euclidean domain . Fast
Fourier Transform (FFT) is used to perform the Fourier transforms efficiently and the resulting transformation is a finite size matrix of
learnable weights.
• In spectral convolution, the Fourier coefficients are truncated to only the lower modes which allows explicit control over the
dimensionality of the spectral space and linear operator.
• The FNO model is a composition of a fully-connected “lifting” layer, spectral convolutions with point-wise linear skip connections and a
decoding point-wise fully-connected neural network at the end:
• Here, is the spectral convolution layer with the point-wise linear transform and activation function . is the point-wise lifting network
that projects the input into a higher dimensional latent space. Q is the point-wise fully-connected decoding network.
• Since all fully-connected components of FNO are point-wise operations, the model is invariant to the dimensionality of the input.
• Note
• The constraint will construct the data loader
automatically.
• Modulus constraints can instantly be scaled to
multi-node/multi-GPU training.
• Optimizations such as torch script/CUDA graphs
will be performed under-the-hood.
Supervised grid constraints
• Batch size is controlled in the Hydra configuration
file.
• These are the two core components of setting up
basic data-driven problem in Modulus.
Grid Validators
39
Darcy Flow – Fourier Neural Operators (FNO)
Results and discussion
40
Darcy Flow – Adaptive Fourier Neural Operators (AFNO)
Theory
• AFNO combines the Fourier Neural Operator (FNO) with the powerful Vision Transformer (ViT) model for image processing. The ViT
and related variants of transformer models have achieved SOTA performance in image processing tasks. The multi-head self-attention
(MHSA) mechanism of the ViT is key to its impressive performance.
• The first step in the architecture involves dividing the input image into a regular grid with equal sized patches of size . The parameter is
referred to as the patch size. For simplicity, we consider a single channel image. Each patch is embedded into a token of size d, the
embedding dimension. The patch embedding operation results in a token tensor of size . The patch size and embedding dimension are
user selected parameters. A smaller patch size allows the model to capture fine scale details better while increasing the computational cost
of training the model. A higher embedding dimension also increases the parameter count of the model. The token tensor is then processed
by multiple layers of the transformer architecture performing spatial and channel mixing. The AFNO architecture implements the
following operations in each layer.
• The token tensor is first transformed to the Fourier domain with
• Here, is the index the patch location and DFT denotes a 2D discrete Fourier transform.
41
Darcy Flow – Adaptive Fourier Neural Operators (AFNO)
Code Snippets
43
Darcy Flow – Physics Informed Neural Operators (PINO)
Theory
• PINO incorporates a PDE loss to the Fourier Neural Operator. This improves interpretability and reduces the amount of data required to
train a surrogate model, since the PDE loss constrains the solution space.
• In general, the PDE loss involves computing the PDE operator which in turn involves computing the partial derivatives of the Fourier
Neural Operator ansatz, which is nontrivial. The key set of innovations in the PINO are the various ways to compute the partial
derivatives of the operator ansatz. The PINO framework implements the differentiation in three different ways.
• Numerical differentiation using a finite difference Method (FDM).
• Numerical differentiation computed via spectral derivative.
• Hybrid differentiation based on a combination of first-order “exact” and second-order FDM derivatives.
44
Darcy Flow – Physics Informed Neural Operators (PINO)
Code snippets
• Setting up a PINO problem in Modulus requires setting up a custom PDE loss that can compute on grid data. Readers are referred to the
supplemental Jupyter notebooks for the code snippets for the Loss definition.
Additional nodes
for physics loss
45
Darcy Flow – Physics Informed Neural Operators (PINO)
Code snippets and results and discussion
Results. Left: Inputs to the model (Input permeability and its gradients), Right: Model
prediction and its comparison with true solution
• Modulus supports several neural operators (also includes the famous DeepONets) that can easily be used out of the box.
• Modulus uses Hydra configuration for easily adjusting hyperparameters and even changing model architectures with minimal changes to
Python code.
• Data-driven training can quickly be integrated into the Modulus framework.
• For more information on supported models and examples please see the Modulus documentation.
47
Modulus Features
Constructive Solid Geometry Module – Fully parameterizable with SymPy and allows Boolean ops
• Allows to create complex geometries using a variety of primitives (torus, cones, ellipse, etc.)
• Supports functions like translate, rotate, scale, repeat, etc.
Boolean (Union, Intersection and, Subtraction) of different Geometry parameterizable using SymPy 48
primitives within Modulus
Modulus Features
PySDF library: Tessellated Geometry Module, OptiX for sampling and SDF
49
Modulus Features and Advancements
Physics types and solution of differential equations
Physics types:
• Linear Elasticity (plane stress, plane strain and 3D)
• Fluid Mechanics
• Heat Transfer
• Coupled Fluid-Thermal
• Electromagnetics
• Wave propagation
• Examples of 2-eqn. turbulence (on fully developed channel case)
Linear Elasticity
Solution of differential equations:
Electromagnetics
• Ordinary Differential Equations
• Differential (strong) Form
Modulus t=600ms
• Integral (weak) form of the PDEs
Conjugate Heat Transfer
52
Modulus Features and Advancements
Other advanced training features
• APIs to automatically generate point clouds from Boolean compositions of geometry primitives or import point cloud for
complex geometry (e.g., STL files)
• Parameterized system representation that solves several configurations concurrently for analytical geometry
using Modulus CSG module
• Transfer learning for efficient surrogate-based parameterization of STL and constructive solid geometries
STL geometry and Transfer Learning Geometry parameterization using Modulus’ CSG module
53
Omniverse Extension for Modulus
54
Modulus Resources
55
Modulus Resources
• Papers:
• NVIDIA SimNet™: An AI-Accelerated Multi-Physics Simulation Framework
• Physics-Informed Machine Learning and Uncertainty Quantification for Mechanics of Heterogeneous Materials
• Physics Informed RNN-DCT Networks for Time-Dependent Partial Differential Equations
• Talks:
• A Novel Framework for Physics based Machine Learning in Science & Engineering Domains
• Accelerate HPC Simulations at Scale with Physics-informed Neural Networks and NVIDIA GPUs on AWS
• Toward Developing High Reynolds Number, Compressible, Reacting Flows in Modulus
• Physics-informed Neural Networks for Wave Propagation Using NVIDIA Modulus
• Uncertainty Quantification for Transport in Porous Media Using Parameterized Physics Informed Neural Networks
• Using Physics-Informed Neural Networks and Modulus to Accelerate Product Development
• Physics-Informed Neural Networks for Mechanics of Heterogenous Media
• Hybrid Physics-Informed Neural Networks for Digital Twin in Prognosis and Health Management
• Physics-Informed Neural Network for Flow and Transport in Porous Media
• AI-Accelerated Computational Science and Engineering Using Physics-Based Neural Networks
• Cumulative Damage Models, Hybrid-Physics-Informed Neural Networks, and Digital TwinsWWCumulative
Damage Models, Hybrid-Physics-Informed Neural Networks, and Digital Twins
• NVIDIA Modulus - Accelerating Scientific & Engineering Simulation workflows with AI
• Podcast:
• AI Physics Simulation Toolkit SimNet & PINNs
56
57