-
Notifications
You must be signed in to change notification settings - Fork 215
【Hackathon 8th No.13】Domino 论文复现 #1093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xiaoyewww
wants to merge
11
commits into
PaddlePaddle:develop
Choose a base branch
from
xiaoyewww:donimo
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1fb4980
feat(domino): support domino
xiaoyewww a313b5d
feat(domino): support domino for training and test
xiaoyewww 3eea7c0
feat(domino): support domino for training and test
xiaoyewww 5d0f63e
feat(domino): support domino for training and test
xiaoyewww baa40d3
feat(domino): remove something of torch
xiaoyewww f7918c7
feat(domino): move physicsnemo to arch
xiaoyewww 905be9a
feat(domino): refactor physicsnemo
xiaoyewww 7074ccf
feat(domino): refactor physicsnemo
xiaoyewww 5df9b6d
feat(domino): refactor physicsnemo
xiaoyewww 385a128
feat(domino): refactor physicsnemo
xiaoyewww 2b14a8a
feat(domino): complement reade
xiaoyewww File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# DoMINO | ||
|
||
=== "模型训练命令" | ||
|
||
``` sh | ||
cd examples/domino | ||
|
||
# 1. Download the DrivAer ML dataset using the provided download_aws_dataset.sh script or using the Hugging Face repo(https://huggingface.co/datasets/neashton/drivaerml). | ||
sh download_aws_dataset.sh | ||
|
||
# 2. Specify the configuration settings in `examples/domino/conf/config.yaml`. | ||
|
||
# 3. Run process_data.py. This will process VTP/VTU files and save them as npy for faster processing in DoMINO datapipe. Modify data_processor key in config file. Additionally, run cache_data.py to save outputs of DoMINO datapipe in the .npy files. The DoMINO datapipe is set up to calculate Signed Distance Field and Nearest Neighbor interpolations on-the-fly during training. Caching will save these as a preprocessing step and should be used in cases where the STL surface meshes are upwards of 30 million cells. The final processed dataset should be divided and saved into 2 directories, for training and validation. Specify these directories in conf/config.yaml. | ||
# specify mode using `process`, set path to data_processor.output_dir and data_processor.input_dir | ||
python3 domino.py | ||
|
||
# 4. run train, specify mode using `train`, set path to data.input_dir and data.input_dir_val | ||
python3 domino.py | ||
``` | ||
|
||
=== "模型评估命令" | ||
|
||
暂无 | ||
|
||
=== "模型导出命令" | ||
|
||
暂无 | ||
|
||
=== "模型推理命令" | ||
|
||
``` sh | ||
cd examples/domino | ||
# specify mode using `eval`, and set path to eval.test_path, eval.save_path and eval.checkpoint_name | ||
python3 domino.py | ||
``` | ||
|
||
## 1. 背景简介 | ||
|
||
在现代工程产品的设计与开发过程中,数值模拟(如计算流体动力学,CFD)扮演着至关重要的角色。它们能够提供对复杂物理现象的精确预测,从而指导产品性能优化和设计迭代。然而,传统的高保真数值模拟方法,特别是针对具有复杂几何形状(例如汽车、飞机等)和大规模计算域的场景,往往需要耗费巨大的计算资源和时间。动辄数小时甚至数天的模拟周期,严重制约了设计迭代的效率和并行探索多个设计方案的可能性。 | ||
|
||
为了突破这一瓶颈,近年来研究人员积极探索将机器学习(ML)模型作为传统数值模拟的快速替代(即代理模型)。这些ML模型通过从大量的模拟数据中学习物理系统的输入-输出映射关系,从而在显著减少计算时间的同时,仍能保持可接受的精度。早期的ML代理模型在处理较小规模或简化问题时表现出一定的潜力。然而,当面对大型工程模拟时,这些模型常常暴露出局限性,例如在准确性和可扩展性方面存在瓶颈。许多现有方法依赖于对模拟网格进行大幅度的降采样,这不仅可能导致预测精度的下降,还会损害模型在未见数据上的泛化能力,限制了它们在实际复杂工程问题中的应用。因此,开发一种既能处理大规模数据、又能保持高精度和良好泛化能力的机器学习代理模型,成为了当前研究的迫切需求。 | ||
|
||
## 2. 问题定义 | ||
|
||
### 2.1 数据集 | ||
|
||
DrivAerML数据集是一个专门为汽车空气动力学机器学习研究而设计的大规模、高保真计算流体动力学(CFD)数据集。它包含了数百个经过几何变形的DrivAer溜背式汽车变体的高保真CFD模拟结果。该数据集以其庞大的数据量、高分辨率的网格以及显著的几何变化而著称,这为训练和测试能够处理复杂几何和流场的机器学习模型提供了理想的基准。与早期的DrivAerNet相比,DrivAerML及其后续版本如DrivAerNet++包含了更多样的几何设计(例如,DrivAerNet++包含8000个汽车设计,涵盖了传统的内燃机汽车和电动汽车的各种底盘和车轮设计),以及更为丰富的CFD模拟数据,包括STL格式的参数化汽车几何体、表面压力场数据,以及全三维的压力、速度和湍流场以及壁面剪切应力等。这些数据集的发布旨在为数据驱动的空气动力学设计提供大规模、高保真的数据,支持机器学习模型在空气动力学评估、生成设计等方面的训练。 | ||
|
||
### 2.2 主要问题 | ||
|
||
尽管机器学习代理模型在工程模拟领域展现出广阔前景,但其在大规模工程模拟中的应用仍面临诸多挑战。具体而言,本文所要解决的问题主要集中在以下几个方面: | ||
|
||
- *可扩展性与计算效率*: 传统的ML模型在处理大规模计算域和高分辨率网格(通常包含数亿甚至数十亿个网格元素)时,面临巨大的内存和计算资源需求。它们难以有效地扩展到如此庞大的数据量,导致训练和推理时间过长,无法满足实时或准实时的工程应用需求。 | ||
|
||
- *几何表示与泛化能力*: 许多现有ML方法难以有效地表示复杂的三维几何形状。它们通常试图学习一个全局的几何表示来预测整个计算域的解场。然而,这种全局表示往往是高维且密集的,对于具有精细特征的复杂几何体,很难准确捕捉到解场与局部几何细节之间的复杂关系。此外,许多模型对输入数据的空间结构敏感,导致在不同网格类型或点云分布之间泛化能力较差。例如,在结构化网格上训练的模型可能无法很好地应用于非结构化网格或任意分布的点云数据。 | ||
|
||
- *精度与长程相互作用*: 尽管一些方法能够扩展到大型网格,但由于无法有效捕捉长程物理相互作用(例如,上游几何形状对下游流场的影响),它们的预测精度往往受到限制。这意味着模型可能无法准确预测远离输入几何体或在复杂流态(如尾流)中的物理量。 | ||
|
||
- *迭代特性与物理一致性*: 传统的模拟过程通常是迭代的,逐步收敛到稳态解。ML代理模型往往直接预测最终解,缺乏迭代特性,这可能导致其无法充分利用物理约束或通过迭代修正来提高解的物理一致性。 | ||
|
||
针对这些问题,本文的目标是开发一种新的ML模型架构,能够有效地处理大规模几何数据,准确捕捉局部和长程依赖关系,同时具有良好的泛化能力,并在计算效率上取得显著提升,从而成为高保真工程模拟的实用替代方案。 | ||
|
||
## 3. 模型原理 | ||
|
||
为了克服上述挑战,本文提出了DOMINO(Decomposable Multi-scale Iterative Neural Operator)模型。DOMINO的核心思想是结合了点云处理、多尺度学习和迭代优化,以高效地建模大规模工程模拟。 | ||
|
||
### 3.1 模型架构概述 | ||
|
||
DOMINO模型以三维几何体的表面点云(通常从表面网格转换而来)作为输入。它首先在几何体周围定义一个三维包围盒作为整个计算域。关键创新在于,DOMINO不试图一次性学习整个计算域的全局解,而是将问题分解为局部的、可并行处理的子问题,并通过多尺度和迭代的方式逐步细化解。 | ||
|
||
### 3.2 几何表示与特征提取 | ||
|
||
- *输入表示*: 原始的三维几何体通过其表面网格(例如,三角形网格)或点云进行表示。这些几何信息被转换为一个标准化的N维结构化表示,用于定义计算域内的分辨率。 | ||
|
||
- *全局几何编码网络*: 这是一个多尺度的点卷积网络,旨在从输入的表面几何体中提取丰富的几何特征。 | ||
|
||
- *多尺度点卷积*: 针对表面几何体,采用一系列具有不同半径参数(核大小)的点卷积核。这使得网络能够同时捕捉几何体的精细局部特征和长程的几何相互作用(例如,车身不同部位之间的相对位置关系)。 | ||
- *特征传播到计算域*: 提取到的表面几何特征需要传播到整个计算域。DOMINO提供了两种方法: | ||
1. *独立的点卷积*: 学习一组单独的多尺度点卷积核,将表面几何信息直接投影到计算域的规则网格或点云上。 | ||
2. *CNN块传播*: 使用包含卷积、池化和反池化层的U-Net风格的卷积神经网络(CNN)块,将表面包围盒网格上提取的特征有效、分层地传播到计算域包围盒网格上。这种方法能够更好地捕捉不同尺度下的空间上下文信息。 | ||
|
||
- *局部几何编码*: 尽管全局几何编码提供了丰富的上下文信息,但计算域中任何一点的解场主要受其局部物理环境的影响。因此,DOMINO设计了一种机制来从全局几何编码中提取特定点的局部几何编码。这通过在每个采样点周围定义一个子区域并对该子区域内的特征进行聚合来实现,确保模型能够关注与当前预测点最相关的几何特征。 | ||
|
||
### 3.3 迭代与多分辨率预测框架 | ||
|
||
DOMINO采用了一种多分辨率迭代方法来逐步精化预测结果,这模拟了传统数值模拟的迭代求解过程: | ||
|
||
- *计算模板*: 在计算域中随机或均匀采样一批离散点。对于每个采样点,在其周围采样一定数量(p个)的邻近点,形成一个“计算模板”(类似于有限差分或有限体积方法中的计算单元)。这些邻近点及其特征构成了当前点预测的局部上下文。 | ||
|
||
- *聚合网络*: 一个专门的聚合神经网络被设计用于处理每个采样点及其计算模板的输入特征。这个网络结合了局部几何编码、模板中点的坐标信息以及迭代过程中的当前预测值。它通过对这些局部信息的聚合和非线性变换,预测出当前采样点的新解值。 | ||
|
||
- *迭代细化*: DOMINO是一个迭代模型。在每次迭代中,模型会基于当前的解场和几何信息,利用聚合网络更新所有采样点的解。这种迭代过程允许模型逐步收敛到更准确的解,并可以模拟物理系统中的信息传播。 | ||
|
||
- *多分辨率*: DOMINO支持多分辨率处理。模型可以在不同分辨率的网格或点云上进行预测,通过迭代过程在粗粒度上捕捉大尺度特征,然后在细粒度上捕捉局部细节。 | ||
|
||
### 3.4 表面与体积变量预测 | ||
|
||
DOMINO能够同时预测表面变量(如压力系数$C_p$、壁面剪切应力$\tau_w$)和体积变量(如速度场$u$、压力$p$、湍流参数等)。由于表面变量和体积变量的物理特性和分布模式不同,DOMINO为表面预测和体积预测设计了独立的聚合神经网络。然而,共享的全局几何编码网络可以为两者提供统一的几何上下文信息,提高了模型的效率。 | ||
|
||
$$y_i=\Sigma_{j=0}^{j=n_y}f(\overrightarrow{x_i},\overrightarrow{x_j},d_{ij})$$ | ||
|
||
其中,$\overrightarrow{x_i},\overrightarrow{x_j}$分别表示不同的点云数据集,$d_{ij}$表示两者之间的距离,$n_y$表示独立的聚合神经网络。 | ||
|
||
### 3.5 损失函数与训练 | ||
|
||
模型通常通过最小化预测值与真实CFD模拟数据之间的L2范数误差进行训练。为了提高模型的泛化能力和鲁棒性,可能会结合其他损失项,例如物理约束损失或正则化项。 | ||
|
||
$$\epsilon=\frac{\sqrt(\Sigma(y_T^2))-y_2^P}{\sqrt(\Sigma(y_T^2))}$$ | ||
|
||
其中,$y_T^2$和$y_P^2$分别表示真实值与预测CFD模拟数据。 | ||
|
||
## 4. 完整代码 | ||
|
||
``` py linenums="1" title="examples/domino/domino.py" | ||
--8<-- | ||
examples/domino/domino.py | ||
--8<-- | ||
``` | ||
|
||
## 5. 结果展示 | ||
|
||
### 5.1 实验结果与性能评估 | ||
|
||
在DrivAerML数据集上的实验结果充分证明了DOMINO模型的有效性和优越性: | ||
|
||
- *准确捕获表面和体积流场*: DOMINO模型能够准确地预测汽车表面的压力分布和壁面剪切应力,这些是评估车辆空气动力学性能的关键指标。例如,在挡风玻璃、侧后视镜、车身底部等关键区域,模型的预测值与高保真CFD模拟结果高度吻合。对于体积流场,如速度、压力和湍流粘度,DOMINO也能在整个计算域内提供高精度的预测。 | ||
|
||
- *准确捕捉设计趋势与工程指标*: 除了流场的可视化对比,DOMINO还能准确预测关键工程指标,例如汽车的空气阻力(Drag Force)。模型不仅能给出准确的阻力值,还能捕获不同几何变体下的阻力设计趋势,这对于辅助工程师进行快速设计迭代至关重要。研究中提供了模拟值与DOMINO预测值之间的回归图,进一步证实了其预测精度。 | ||
|
||
- *出色的泛化能力*: 模型在训练集中未见过的几何变体上表现出强大的泛化能力,这表明DOMINO能够学习到通用的物理规律和几何-流场映射关系,而不仅仅是记忆训练数据。 | ||
|
||
- *网格独立性*: 这是DOMINO的一个显著优势。模型在均匀采样的点云上而非原始模拟网格上进行验证,证明了其预测能力不依赖于特定的网格结构。这意味着DOMINO可以应用于不同离散化方式或分辨率的数据,极大地增强了其在实际应用中的灵活性。 | ||
|
||
- *计算效率*: 尽管论文中没有直接给出具体的加速倍数,但作为基于深度学习的代理模型,DOMINO的目标就是在保持高精度的前提下,显著降低推理时间,从而实现近乎实时的空气动力学评估,这对于迭代设计和优化过程至关重要。通过利用局部信息和迭代细化,DOMINO避免了处理整个大规模网格的内存和计算瓶颈。 | ||
|
||
### 5.2 局限性与未来工作 | ||
|
||
尽管DOMINO取得了显著进展,但论文可能也指出了未来改进的方向。例如,对于一些稀疏且复杂的物理量(如湍流粘度),特别是在远离几何体的区域,预测精度仍有提升空间。未来工作可能包括探索更先进的神经网络架构、更有效的损失函数、或者结合更多物理约束来进一步提高模型在各种复杂流态下的预测精度和鲁棒性。 | ||
|
||
## 6. 参考资料 | ||
|
||
- [DoMINO: A Decomposable Multi-scale Iterative Neural Operator for Modeling Large Scale Engineering Simulations](https://arxiv.org/abs/2501.13350) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 - 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-FileCopyrightText: All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
project: # Project name | ||
name: AWS_Dataset | ||
|
||
mode: train # process, train, eval | ||
seed: 42 | ||
exp_tag: 1 # Experiment tag | ||
# Main output directory. | ||
output: outputs/${project.name}/${exp_tag} | ||
|
||
hydra: # Hydra config | ||
run: | ||
dir: ${output} | ||
output_subdir: hydra # Default is .hydra which causes files not being uploaded in W&B. | ||
|
||
data: # Input directory for training and validation data | ||
input_dir: outputs/volume_data/ | ||
input_dir_val: outputs/volume_data/ | ||
bounding_box: # Bounding box dimensions for computational domain | ||
min: [-3.5, -2.25 , -0.32] | ||
max: [8.5 , 2.25 , 3.00] | ||
bounding_box_surface: # Bounding box dimensions for car surface | ||
min: [-1.1, -1.2 , -0.32] | ||
max: [4.5 , 1.2 , 1.2] | ||
|
||
# The directory to search for checkpoints to continue training. | ||
resume_dir: ${output}/models | ||
|
||
variables: | ||
surface: | ||
solution: | ||
# The following is for AWS DrivAer dataset. | ||
pMeanTrim: scalar | ||
wallShearStressMeanTrim: vector | ||
volume: | ||
solution: | ||
# The following is for AWS DrivAer dataset. | ||
UMeanTrim: vector | ||
pMeanTrim: scalar | ||
nutMeanTrim: scalar | ||
|
||
model: | ||
model_type: combined # train which model? surface, volume, combined | ||
loss_function: "mse" # mse or rmse | ||
interp_res: [64, 32, 24] # resolution of latent space | ||
use_sdf_in_basis_func: true # SDF in basis function network | ||
positional_encoding: false # calculate positional encoding? | ||
volume_points_sample: 1024 # Number of points to sample in volume per epoch | ||
surface_points_sample: 1024 # Number of points to sample on surface per epoch | ||
geom_points_sample: 2_000 # Number of points to sample on STL per epoch | ||
surface_neighbors: true # Pre-compute surface neighborhood from input data | ||
num_surface_neighbors: 7 # How many neighbors? | ||
use_surface_normals: true # Use surface normals and surface areas for surface computation? | ||
use_only_normals: true # Use only surface normals and not surface area | ||
integral_loss_scaling_factor: 0 # Scale integral loss by this factor | ||
normalization: min_max_scaling # or mean_std_scaling | ||
encode_parameters: true # encode inlet velocity and air density in the model | ||
geometry_rep: # Hyperparameters for geometry representation network | ||
base_filters: 16 | ||
geo_conv: | ||
base_neurons: 32 # 256 or 64 | ||
base_neurons_out: 1 | ||
radius_short: 0.1 | ||
radius_long: 0.5 # 1.0, 1.5 | ||
hops: 1 | ||
geo_processor: | ||
base_filters: 8 | ||
geo_processor_sdf: | ||
base_filters: 8 | ||
nn_basis_functions: # Hyperparameters for basis function network | ||
base_layer: 512 | ||
aggregation_model: # Hyperparameters for aggregation network | ||
base_layer: 512 | ||
position_encoder: # Hyperparameters for position encoding network | ||
base_neurons: 512 | ||
geometry_local: # Hyperparameters for local geometry extraction | ||
neighbors_in_radius: 64 | ||
radius: 0.05 # 0.2 in expt 7 | ||
base_layer: 512 | ||
parameter_model: | ||
base_layer: 512 | ||
scaling_params: [30.0, 1.226] # [inlet_velocity, air_density] | ||
|
||
train: # Training configurable parameters | ||
epochs: 50 | ||
checkpoint_interval: 1 | ||
dataloader: | ||
batch_size: 1 | ||
sampler: | ||
shuffle: true | ||
drop_last: false | ||
checkpoint_dir: outputs/AWS_Dataset/3/models/ | ||
|
||
val: # Validation configurable parameters | ||
dataloader: | ||
batch_size: 1 | ||
sampler: | ||
shuffle: true | ||
drop_last: false | ||
|
||
eval: # Testing configurable parameters | ||
test_path: drivaer_data_full | ||
save_path: outputs/mesh_predictions_surf_final1/ | ||
checkpoint_name: outputs/AWS_Dataset/1/models/DoMINO.0.30.pdparams | ||
|
||
data_processor: # Data processor configurable parameters | ||
kind: drivaer_aws # must be either drivesim or drivaer_aws | ||
output_dir: data/volume_data/ | ||
input_dir: drivaer_aws/drivaer_data_full/ | ||
num_processors: 12 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy Right需要改为PaddlePaddle,并声明是对原始论文的复现
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.