File size: 5,081 Bytes
8880eca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
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.