DeepCFD
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.
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
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
hf download OneScience-Group/DeepCFD --local-dir ./DeepCFD
cd DeepCFD
Set Up the Runtime Environment
DCU Environment
# 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
# 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:
hf download --repo-type dataset OneScience-Group/deepcfd --local-dir ./data
The project dataset can also be downloaded from Zenodo.
The dataset contains two files:
dataX.pkl: Geometric input data for 981 channel-flow samplesdataY.pkl: Ground-truth CFD solutions for the corresponding samples, computed with thesimpleFOAMsolver
Training
Single GPU:
- Training parameters are read from the
root.datapipe,root.model, androot.trainingsections ofconfig/config.yaml. The default configuration is intended for a minimal smoke test. - For full training, set
root.datapipe.source.data_dirto the actual DeepCFD dataset directory and increase the model size, batch size, and number of epochs as needed.
python scripts/train.py
Multiple GPUs:
torchrun --standalone --nproc_per_node=<num_GPUs> scripts/train.py
By default, training saves the best checkpoint to:
./weight/best_model.pt
Model Weights
This repository will provide pretrained DeepCFD weights in the weights/ directory. The weights will be uploaded soon.
Inference
python scripts/inference.py
Evaluation and Visualization
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
- This repository retains source attribution and has been adapted for automated execution through OneScience and ModelScope.
中文说明
模型概览
DeepCFD 是德国航空航天中心开发的一种基于 U-Net 的代理模型(surrogate model),用于二维稳态层流。它利用几何信息快速预测速度场和压力场,加速对通道流动、障碍物绕流和气动设计的评估。
论文 DeepCFD:使用深度卷积神经网络高效近似 稳态层流。
模型描述
DeepCFD 采用 U-Net 深度卷积架构,输入为有符号距离场(SDF)和流动区域掩码,可快速预测二维非均匀稳态层流的速度场与压力场。
使用场景
| 使用场景 | 说明 |
|---|---|
| 稳态层流预测 | 近似二维非均匀稳态层流的速度场和压力场 |
| 通道流动模拟 | 预测通道内随机形状障碍物周围的流动分布 |
| 计算流体力学(CFD)代理建模 | 替代 OpenFOAM 等常规计算流体力学流程,提高推理(inference)效率 |
| 气动与流体外形优化 | 在低速层流设计中评估大量候选几何形状 |
使用方法
1. OneCode
在 OneCode 在线环境中体验智能一键 AI for Science(AI4S)编程。
2. 手动设置
硬件要求
- 建议使用 GPU 或 DCU。
- 可使用 CPU 检查导入和验证小规模流程,完整训练和推理的速度会较慢。
- DCU 用户须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 为目标集群推荐的版本。
下载模型包
hf download OneScience-Group/DeepCFD --local-dir ./DeepCFD
cd DeepCFD
配置运行环境
DCU 环境
# 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 环境
# 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
训练数据
OneScience 社区提供用于训练的 deepcfd 数据集。使用以下命令下载,并确认 conf/config.yaml 中的数据路径配置正确。
hf download --repo-type dataset OneScience-Group/deepcfd --local-dir ./data
项目数据集也可以从 Zenodo 下载。
数据集包含两个文件
dataX.pkl,981 个通道流动样本的几何输入数据dataY.pkl,使用simpleFOAM求解器计算的对应样本的计算流体力学真值解
训练
单 GPU
- 训练参数从
root.datapipe、root.model和root.training各节读取,配置文件为config/config.yaml。默认配置用于最小冒烟测试。 - 要运行完整训练,请将
root.datapipe.source.data_dir设为实际 DeepCFD 数据集目录,并按需增大模型规模、批大小和训练轮数。
python scripts/train.py
多 GPU
torchrun --standalone --nproc_per_node=<num_GPUs> scripts/train.py
默认情况下,训练将最佳模型权重(检查点)(checkpoint)保存至以下位置。
./weight/best_model.pt
模型权重
本仓库将在 weights/ 目录中提供预训练的 DeepCFD 权重。权重文件将于近期上传。
推理
python scripts/inference.py
评估与可视化
python scripts/result.py
OneScience 官方资源
| 平台 | OneScience 仓库 | Skills 仓库 |
|---|---|---|
| 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 |
引用与许可证
- DeepCFD 原始论文 DeepCFD:使用深度卷积神经网络高效近似稳态层流
- 本仓库保留来源署名,并已适配 OneScience 和 ModelScope 上的自动化运行。
- Downloads last month
- 16