DeepCFD / README.md
OneScience's picture
Upload folder using huggingface_hub
8880eca verified
|
Raw
History Blame Contribute Delete
5.08 kB
---
license: apache-2.0
language:
- en
tags:
- OneScience
- fluid dynamics
- steady-state laminar flow prediction
- CFD surrogate modeling
frameworks: PyTorch
---
<p align="center">
<strong>
<span style="font-size: 30px;">DeepCFD</span>
</strong>
</p>
# Model Overview
DeepCFD is a U-Net-based surrogate model developed by the German Aerospace Center for two-dimensional steady-state laminar flows. It uses geometric information to rapidly predict velocity and pressure fields, accelerating the evaluation of channel flows, flows around obstacles, and aerodynamic designs.
Paper: [DeepCFD: Efficient Steady-State Laminar Flow
Approximation with Deep Convolutional Neural Networks](https://arxiv.org/abs/2004.08826).
# Model Description
DeepCFD uses a U-Net deep convolutional architecture that takes a signed distance field (SDF) and flow-region mask as inputs to rapidly predict velocity and pressure fields for two-dimensional, nonuniform, steady-state laminar flows.
## Use Cases
| Use Case | Description |
| ---------- | ---------------------------------- |
| Steady-state laminar flow prediction | Approximate velocity and pressure fields in two-dimensional, nonuniform, steady-state laminar flows |
| Channel-flow simulation | Predict flow distributions around randomly shaped obstacles in a channel |
| CFD surrogate modeling | Replace conventional CFD workflows such as OpenFOAM to improve inference efficiency |
| Aerodynamic and fluid-shape optimization | Evaluate large numbers of candidate geometries for low-speed laminar-flow design |
# Usage
## 1. OneCode
Use the online OneCode environment for an intelligent, one-click AI for Science (AI4S) programming experience:
[Launch OneCode for one-click AI4S programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
## 2. Manual Setup
**Hardware Requirements**
- A GPU or DCU is recommended.
- A CPU can be used for import checks and small-scale pipeline validation, but full training and inference will be slow.
- DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version for the target cluster, is recommended.
### Download the Model Package
```bash
modelscope download --model OneScience/DeepCFD --local_dir ./DeepCFD
cd DeepCFD
```
### Set Up the Runtime Environment
**DCU Environment**
```bash
# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```
**GPU Environment**
```bash
# Activate Conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```
### Training Data
The OneScience community provides the `deepcfd` dataset for training. Download it with the command below and verify that the data path in `conf/config.yaml` is configured correctly:
```bash
modelscope download --dataset OneScience/deepcfd --local_dir ./data
```
The project dataset can also be [downloaded from Zenodo](https://zenodo.org/record/3666056/files/DeepCFD.zip?download=1).
The dataset contains two files:
- `dataX.pkl`: Geometric input data for 981 channel-flow samples
- `dataY.pkl`: Ground-truth CFD solutions for the corresponding samples, computed with the `simpleFOAM` solver
### Training
Single GPU:
- Training parameters are read from the `root.datapipe`, `root.model`, and `root.training` sections of `config/config.yaml`. The default configuration is intended for a minimal smoke test.
- For full training, set `root.datapipe.source.data_dir` to the actual DeepCFD dataset directory and increase the model size, batch size, and number of epochs as needed.
```bash
python scripts/train.py
```
Multiple GPUs:
```bash
torchrun --standalone --nproc_per_node=<num_GPUs> scripts/train.py
```
By default, training saves the best checkpoint to:
```text
./weight/best_model.pt
```
### Model Weights
This repository will provide pretrained DeepCFD weights in the `weights/` directory. The weights will be uploaded soon.
### Inference
```bash
python scripts/inference.py
```
### Evaluation and Visualization
```bash
python scripts/result.py
```
# Official OneScience Resources
| Platform | OneScience Repository | Skills Repository |
| --- | --- | --- |
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
# Citations and License
- Original DeepCFD paper: [DeepCFD: Efficient Steady-State Laminar Flow Approximation with Deep Convolutional Neural Networks](https://arxiv.org/abs/2004.08826)
- This repository retains source attribution and has been adapted for automated execution through OneScience and ModelScope.