File size: 5,704 Bytes
338c3e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
147
148
149
150
151
152
153
154
155
156
157
158
159
---
language:
- en
tags:
- OneScience
- fluid dynamics
- large-scale fluid dynamics benchmark
frameworks: PyTorch
---

<p align="center">
  <strong>
    <span style="font-size: 30px;">CFDBench</span>
  </strong>
</p>

# Model Overview

CFDBench is a large-scale benchmark developed by researchers at Tsinghua University to evaluate machine-learning methods for computational fluid dynamics. It focuses on model generalization across different boundary conditions, fluid properties, and geometric configurations.

Paper: [CFDBench: A Large-Scale Benchmark for Machine Learning Methods in Fluid Dynamics](https://arxiv.org/abs/2310.05963)

# Model Description
CFDBench is built from several representative computational fluid dynamics datasets spanning diverse boundary conditions, fluid properties, and geometries. It evaluates both flow-field prediction performance and the generalization capabilities of machine-learning methods.


# Use Cases

| Use Case | Description |
| :---: | :---: |
| CFD surrogate benchmarking | Compare the flow-field prediction capabilities of neural operators and other deep-learning models using consistent data splits and metrics |
| Autoregressive flow evolution | Predict subsequent two-dimensional velocity fields step by step from the current grid-based field and assess error accumulation over multiple steps |
| Non-autoregressive field queries | Predict velocity directly at target locations from operating parameters and spatiotemporal coordinates, enabling evaluation over long time horizons |


## Supported Models

| Type | `root.model.name` | Training Entry Point |
| :--- | :--- | :--- |
| Non-autoregressive | `ffn` | `python scripts/train.py` |
| Non-autoregressive | `deeponet` | `python scripts/train.py` |
| Autoregressive | `auto_ffn` | `python scripts/train_auto.py` |
| Autoregressive | `auto_deeponet` | `python scripts/train_auto.py` |
| Autoregressive | `auto_edeeponet` | `python scripts/train_auto.py` |
| Autoregressive | `auto_deeponet_cnn` | `python scripts/train_auto.py` |
| Autoregressive | `resnet` | `python scripts/train_auto.py` |
| Autoregressive | `unet` | `python scripts/train_auto.py` |
| Autoregressive | `fno` | `python scripts/train_auto.py` |

# 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
```
modelscope download --model OneScience/CFDBench --local_dir ./CFDBench
cd CFDBench
```
### 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 `cfdbench` dataset for training. Download it with the command below and verify that the data path in `config/config.yaml` is configured correctly:

```bash
modelscope download --dataset OneScience/cfdbench --local_dir ./data
```

### Training
**Autoregressive Training**

The default configuration sets `root.model.name: fno`, so use the autoregressive training entry point:

```bash
python scripts/train_auto.py
```


To select another autoregressive model, edit `conf/config.yaml`:

```yaml
root:
  model:
    name: "auto_ffn"
```

**Non-autoregressive Training**
```bash
python scripts/train.py --model deeponet
```
### Model Weights
This repository will provide pretrained CFDBench model weights in the `weights/` directory. The weights will be uploaded soon.

### Inference and Visualization

The inference script automatically selects the task type from the current model name and reads the following path by default:

```text
./weight/<model.name>.pt
```

Default FNO inference and visualization:

```bash
python scripts/inference.py
python scripts/result.py
```

Non-autoregressive models can likewise be selected through a command-line argument:

```bash
python scripts/inference.py --model ffn
python scripts/result.py --model ffn
```
# 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 CFDBench paper: [CFDBench: A Large-Scale Benchmark for Machine Learning Methods in Fluid Dynamics](https://arxiv.org/abs/2310.05963)
- Original CFDBench code repository: https://github.com/luo-yining/CFDBench
- This repository retains source attribution and has been adapted for automated execution through OneScience and ModelScope. Before public redistribution, verify the applicable licensing requirements of the upstream project.