NVIDIA Modulus Core (Latest Release)
Core (Latest Release)

AeroGraphNet for external aerodynamic evaluation

This example demonstrates how to train the AeroGraphNet model for external aerodynamic analysis of both simplified (Ahmed body-type) and more realistic (DrivAerNet dataset) car geometries. AeroGraphNet is based on the MeshGraphNet architecture. It achieves good accuracy on predicting the pressure and wall shear stresses on the surface mesh of the respective geometries, as well as the drag coefficient.

  1. Problem overview

  2. Datasets

    1. Ahmed Body

    2. DrivAerNet

  3. Model

  4. Training

    1. Ahmed Body

    2. DrivAerNet

  5. Inference

To goal is to develop an AI surrogate model that can use simulation data to learn the external aerodynamic flow over parameterized car body shape. The trained model can be used to predict the change in drag coefficient,and surface pressure and wall shear stresses due to changes in the car geometry. This is a stepping stone to applying similar approaches to other application areas such as aerodynamic analysis of aircraft wings, more complex real car geometries, and so on.

AeroGraphNet currently supports two datasets: Ahmed Body and DrivAerNet.

Ahmed Body

Industry-standard Ahmed-body geometries are characterized by six design parameters: length, width, height, ground clearance, slant angle, and fillet radius. Refer to the [2, 3] for details on Ahmed body geometry. In addition to these design parameters, we include the inlet velocity to address a wide variation in Reynolds number. We identify the design points using the Latin hypercube sampling scheme for space filling design of experiments and generate around 500 design points.

The aerodynamic simulations were performed using the GPU-accelerated OpenFOAM solver for steady-state analysis, applying the SST K-omega turbulence model. These simulations consist of 7.2 million mesh points on average, but we use the surface mesh as the input to training which is roughly around 70k mesh nodes.

To request access to the full dataset, please reach out to the NVIDIA Modulus team.

DrivAerNet

DrivAerNet [5] is a larger dataset which contains around 4000 high-quality car meshes, coefficients and flow information. The dataset can be downloaded by following the instructions on the DrivAerNet GitHub Please see the corresponding paper for more details.

The AeroGraphNet model is based on the MeshGraphNet [1] architecture which is instrumental for learning from mesh-based data using GNNs. Depending on the dataset, the model takes different inputs:

Ahmed Body dataset

  • Ahmed body surface mesh

  • Reynolds number

  • Geometry parameters (optional, including length, width, height, ground clearance, slant angle, and fillet radius)

  • surface normals (optional)

Output of the model are:

  • Surface pressure

  • Wall shear stresses

  • Drag coefficient - optional, computed using pressure and shear stress outputs.

ahmed_body_results.png

Fig. 3 Comparison between the AeroGraphNet prediction and the ground truth for surface pressure, wall shear stresses, and the drag coefficient for one of the samples from the test dataset.

The input to the model is in form of a .vtp file and is then converted to bi-directional DGL graphs in the dataloader. The final results are also written in the form of .vtp files in the inference code. A hidden dimensionality of 256 is used in the encoder, processor, and decoder. The encoder and decoder consist of two hidden layers, and the processor includes 15 message passing layers. Batch size per GPU is set to 1. Summation aggregation is used in the processor for message aggregation. A learning rate of 0.0001 is used, decaying exponentially with a rate of 0.99985. Training is performed on 8 NVIDIA A100 GPUs, leveraging data parallelism. Total training time is 4 hours, and training is performed for 500 epochs.

DrivAerNet dataset

  • Surface mesh

Output of the model are:

  • Surface pressure

  • Wall shear stresses

  • Drag coefficient - optional, can be learned by the model along with other outputs.

The input to the model is the original DrivAerNet dataset. It is recommended to enable dataset caching (on by default) to speed up the subsequent data loading and training.

drivaernet_results.png

Fig. 4 Comparison between the AeroGraphNet prediction and the ground truth for surface pressure, wall shear stresses, and absolute error for one of the samples from the test dataset.

The example uses Hydra for experiment configuration. Hydra provides a convenient way to change almost any experiment parameter, such as dataset configuration, model and optimizer settings and so on.

This example also requires the pyvista and vtk libraries. Install with

Copy
Copied!
            

pip install pyvista vtk

Ahmed Body training

The Ahmed Body dataset for this example is not publicly available. To get access, please reach out to the NVIDIA Modulus team.

To train the model, run

Copy
Copied!
            

python train.py +experiment=ahmed/mgn data.data_dir=/data/ahmed_body/

Make sure to set data.data_dir to a proper location.

The following example demonstrates how to change some of the parameters:

Copy
Copied!
            

python train.py \ +experiment=ahmed/mgn \ data.data_dir=/data/ahmed_body/ \ model.processor_size=10 \ optimizer.lr=0.0003 \ loggers.wandb.mode=online

This will change the number of model message passing layers to 10, set learning rate to 0.0003 and enable Weights & Biases logger.

Data parallelism is also supported with multi-GPU runs. To launch a multi-GPU training, run

Copy
Copied!
            

mpirun -np <num_GPUs> python train.py +experiment=ahmed/mgn data.data_dir=/data/ahmed_body/

If running in a docker container, you may need to include the --allow-run-as-root in the multi-GPU run command.

Progress and loss logs can be monitored using Weights & Biases. To activate that, add loggers.wandb.mode=online to the train script command line. This requires to have an active Weights & Biases account. You also need to provide your API key. There are multiple ways for providing the API key but you can simply export it as an environment variable

Copy
Copied!
            

export WANDB_API_KEY=<your_api_key>

The URL to the dashboard will be displayed in the terminal after the run is launched.

DrivAer training

To train the MeshGraphNet model, run

Copy
Copied!
            

python train.py +experiment=drivaernet/mgn data.data_dir=/data/DrivAerNet/

Make sure to set data.data_dir to a proper location.

Another option is to train an extended version of MGN, called AeroGraphNet. This model predicts a drag coefficient directly, along with pressure and WSS. To use AGN instead of MGN, use drivaernet/agn experiment

Copy
Copied!
            

python train.py +experiment=drivaernet/agn data.data_dir=/data/DrivAerNet/

Once the model is trained, run

Copy
Copied!
            

python inference.py +experiment=drivaernet/mgn \ data.data_dir=/data/DrivAerNet/ \ data.test.num_samples=2 \ resume_dir=./outputs/

Update experiment and data directory as needed. resume_dir directory should point to the output directory of the training which contains model checkpoints. This example will run inference for only 2 samples, this is just to demonstrate how various options can be set from the command line.

The inference script will save the predictions for the test dataset in .vtp format in the output directory. Use ParaView or VTK.js to open and explore the results.

Previous Unified Recipe for Training Global Weather Forecasting Models
Next MeshGraphNet for transient vortex shedding
© Copyright 2023, NVIDIA Modulus Team. Last updated on Jul 25, 2024.