OneScience-Group/MeshGraphNet
022
1---2frameworks:3- ""4language:5- en6license: apache-2.07tags:8- OneScience9- fluid dynamics10- external flow prediction11- unstructured-mesh simulation12 13---14<p align="center">15 <strong>16 <span style="font-size: 30px;">MeshGraphNet</span>17 </strong>18</p>19 20# Model Overview21 22MeshGraphNets is a graph neural network developed by DeepMind for mesh-based physical simulation. It rapidly predicts the dynamics of complex physical systems, including fluids, structures, and cloth.23 24Paper: Learning Mesh-Based Simulation with Graph Networks25https://arxiv.org/abs/2010.0340926 27# Model Description28MeshGraphNets uses an encoder–processor–decoder graph-network architecture trained on trajectories from fluid, structural, and cloth simulations to perform long-horizon dynamical simulation of complex physical systems.29 30## Use Cases31 32| Use Case | Description |33|---|---|34| External flow prediction | Predict velocity, pressure, and other flow variables at mesh nodes |35| Structural deformation simulation | Predict the displacement, stress, and deformation of loaded structures |36| Cloth dynamics | Simulate the motion of deformable objects such as flexible membranes and cloth |37| ModelScope/OneCode execution | Download the standalone model package, install its dependencies, and run the provided scripts |38 39 40# Usage41 42## 1. OneCode43 44Use the online OneCode environment for an intelligent, one-click AI for Science (AI4S) programming experience:45 46[Launch OneCode for one-click AI4S programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)47 48## 2. Manual Setup49 50**Hardware Requirements**51 52- A GPU or DCU is recommended.53- DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version for the target cluster, is recommended.54 55 56### Download the Model Package57 58```bash59hf download OneScience-Group/MeshGraphNet --local-dir ./MeshGraphNet 60cd MeshGraphNet 61```62 63### Set Up the Runtime Environment64 65 66**DCU Environment**67 68```bash69# Activate DTK and Conda first70conda create -n onescience311 python=3.11 -y71conda activate onescience31172# Installation with uv is also supported73pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai74```75 76**GPU Environment**77```bash78# Activate Conda first79conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=1280conda activate onescience31181# Installation with uv is also supported82pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai83```84 85### Training Data86 87The OneScience community provides the `cylinder_flow` dataset for training. Download it with the command below and verify that the data path in `config/config.yaml` is configured correctly:88 89```bash90hf download --repo-type dataset OneScience-Group/cylinder_flow --local-dir ./data91```92 93### Training94 95Single GPU:96 97```bash98python scripts/train.py99```100 101Multiple GPUs:102 103```bash104torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py105```106 107Training saves `.pth` files under `weight/checkpoints`.108 109### Model Weights110This repository will provide weights trained on the `cylinder_flow` dataset in the `weights/` directory. The weights will be uploaded soon.111 112### Inference113 114```bash115python scripts/inference.py116```117 118Inference results are saved to `result/output/`.119 120### Evaluation and Visualization121 122```bash123python scripts/result.py124```125 126 127# Official OneScience Resources128 129| Platform | OneScience Repository | Skills Repository |130| --- | --- | --- |131| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |132| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |133 134# Citations and License135- Original MeshGraphNet paper: [Learning Mesh-Based Simulation with Graph Networks](https://arxiv.org/abs/2010.03409).136- This repository retains source attribution and has been adapted for automated execution through OneScience and ModelScope.137 