Skip to content

Commit 3ef8011

Browse files
Merge branch 'develop' into clean_code
2 parents 3b091b9 + f17d1b3 commit 3ef8011

39 files changed

+1042
-145
lines changed

docs/zh/cooperation.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
# 共创计划
22

3-
PaddleScience 作为一个开源项目,欢迎来各行各业的伙伴携手共建基于飞桨的 AI for Science 领域顶尖开源项目, 打造活跃的前瞻性的 AI for Science 开源社区,建立产学研闭环,推动科研创新与产业赋能。点击了解 [飞桨AI for Science共创计划](https://www.paddlepaddle.org.cn/science)
3+
PaddleScience 作为一个开源项目,欢迎来各行各业的伙伴携手共建基于飞桨的 AI for Science 领域顶尖开源项目,打造活跃的前瞻性的 AI for Science 开源社区,建立产学研闭环,推动科研创新与产业赋能。点击了解 [飞桨 AI for Science 共创计划](https://www.paddlepaddle.org.cn/science)
4+
5+
## 项目精选
6+
7+
- 使用嵌套傅立叶神经算子进行实时高分辨二氧化碳地质封存预测: <https://aistudio.baidu.com/projectdetail/7390303>
8+
- 多源异构数据与机理融合的极端天气预报算法研究: <https://aistudio.baidu.com/projectdetail/7586532>
9+
- 基于强化学习的复杂系统控制 —— 以疾病传播: <https://aistudio.baidu.com/projectdetail/7520457>
10+
- 基于 Transformer 架构的流体流动降阶模拟: <https://aistudio.baidu.com/projectdetail/7509905>
11+
- 基于 Transformer 的神经算子预测模型: <https://aistudio.baidu.com/projectdetail/7309026>
12+
- 基于 PINN 方法求解可压缩流体欧拉方程组的正问题: <https://aistudio.baidu.com/projectdetail/7502148>
13+
- 基于连续演化数据预测双曲方程简断解: <https://aistudio.baidu.com/projectdetail/7620492>
14+
- 拉格朗日粒子流体 Benchmark 开源数据集: <https://aistudio.baidu.com/projectdetail/7507477>
15+
- 基于 PINN 方法求解可压缩流体欧拉方程组的正问题: <https://aistudio.baidu.com/projectdetail/7593837>
16+
- 数据驱动 AI 模型的 PDE 方程可解释性评估: <https://aistudio.baidu.com/projectdetail/7463477>
17+
- 数据驱动 AI 模型的 PDE 方程可解释性评估: <https://aistudio.baidu.com/projectdetail/7512749>

docs/zh/examples/bubble.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@
2020
python bubble.py mode=eval EVAL.pretrained_model_path=https://paddle-org.bj.bcebos.com/paddlescience/models/bubble/bubble_pretrained.pdparams
2121
```
2222

23+
=== "模型导出命令"
24+
25+
``` sh
26+
python bubble.py mode=export
27+
```
28+
29+
=== "模型推理命令"
30+
31+
``` sh
32+
# linux
33+
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/BubbleNet/bubble.mat
34+
# windows
35+
# curl https://paddle-org.bj.bcebos.com/paddlescience/datasets/BubbleNet/bubble.mat --output bubble.mat
36+
python bubble.py mode=infer
37+
```
38+
2339
| 预训练模型 | 指标 |
2440
|:--| :--|
2541
| [bubble_pretrained.pdparams](https://paddle-org.bj.bcebos.com/paddlescience/models/bubble/bubble_pretrained.pdparams) | loss(bubble_mse): 0.00558<br>MSE.u(bubble_mse): 0.00090<br>MSE.v(bubble_mse): 0.00322<br>MSE.p(bubble_mse): 0.00066<br>MSE.phil(bubble_mse): 0.00079 |

docs/zh/examples/control_arm.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,42 @@
4646
python inverse_parameter.py mode=eval EVAL.pretrained_model_path=https://paddle-org.bj.bcebos.com/paddlescience/models/control_arm/inverse_x_axis_pretrained.pdparams
4747
```
4848

49+
=== "模型导出命令"
50+
51+
=== "正问题:受力分析求解"
52+
53+
``` sh
54+
python forward_analysis.py mode=export
55+
```
56+
57+
=== "逆问题:参数逆推求解"
58+
59+
``` sh
60+
python inverse_parameter.py mode=export
61+
```
62+
63+
=== "模型推理命令"
64+
65+
=== "正问题:受力分析求解"
66+
67+
``` sh
68+
# linux
69+
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/control_arm/control_arm.stl -P ./datasets/
70+
# windows
71+
# curl https://paddle-org.bj.bcebos.com/paddlescience/datasets/control_arm/control_arm.stl --output ./datasets/control_arm.stl
72+
python forward_analysis.py mode=infer
73+
```
74+
75+
=== "逆问题:参数逆推求解"
76+
77+
``` sh
78+
# linux
79+
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/control_arm/control_arm.stl -P ./datasets/
80+
# windows
81+
# curl https://paddle-org.bj.bcebos.com/paddlescience/datasets/control_arm/control_arm.stl --output ./datasets/control_arm.stl
82+
python inverse_parameter.py mode=infer
83+
```
84+
4985
| 预训练模型 | 指标 |
5086
|:--| :--|
5187
| [inverse_x_axis_pretrained.pdparams](https://paddle-org.bj.bcebos.com/paddlescience/models/control_arm/inverse_x_axis_pretrained.pdparams) | loss(geo_eval): 0.02505<br>L2Rel.lambda_(geo_eval): 0.06025<br>L2Rel.mu(geo_eval): 0.07949 |

docs/zh/examples/earthformer.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
开始训练、评估前,请先下载
44

5-
[ICAR-ENSO数据集](https://nbviewer.org/github/MIT-AI-Accelerator/eie-sevir/blob/master/examples/SEVIR_Tutorial.ipynb#download)
5+
[ICAR-ENSO数据集](https://tianchi.aliyun.com/dataset/98942)
66

7-
[SEVIR数据集](https://tianchi.aliyun.com/dataset/98942)
7+
[SEVIR数据集](https://nbviewer.org/github/MIT-AI-Accelerator/eie-sevir/blob/master/examples/SEVIR_Tutorial.ipynb#download
8+
)
89

910
=== "模型训练命令"
1011

@@ -77,14 +78,14 @@ EarthFormer 原代码中训练了 ICAR-ENSO 数据集中海面温度 (sst) 和 S
7778

7879
<figure markdown>
7980
![earthformer-pretraining](https://paddle-org.bj.bcebos.com/paddlescience/docs/earthformer/earthformer-pretrain.png){ loading=lazy style="margin:0 auto;height:70%;width:70%"}
80-
<figcaption>earthformer模型预训练</figcaption>
81+
<figcaption>earthformer 模型预训练</figcaption>
8182
</figure>
8283

8384
在推理阶段,给定长度序列为 $T$ 的数据,得到长度序列为 $K$ 的预测结果。
8485

8586
<figure markdown>
8687
![earthformer-pretraining](https://paddle-org.bj.bcebos.com/paddlescience/docs/earthformer/earthformer-infer.png){ loading=lazy style="margin:0 auto;height:60%;width:60%"}
87-
<figcaption>earthformer模型推理</figcaption>
88+
<figcaption>earthformer 模型推理</figcaption>
8889
</figure>
8990

9091
## 3. 海面温度模型实现
@@ -95,7 +96,7 @@ EarthFormer 原代码中训练了 ICAR-ENSO 数据集中海面温度 (sst) 和 S
9596

9697
数据集采用了 [EarthFormer](https://github.com/amazon-science/earth-forecasting-transformer/tree/main) 处理好的 ICAR-ENSO 数据集。
9798

98-
本数据集由气候与应用前沿研究院 ICAR 提供。数据包括 CMIP5/6 模式的历史模拟数据和美国 SODA 模式重建的近100多年历史观测同化数据。每个样本包含以下气象及时空变量:海表温度异常 (SST) ,热含量异常 (T300),纬向风异常 (Ua),经向风异常 (Va),数据维度为 (year,month,lat,lon)。训练数据提供对应月份的 Nino3.4 index 标签数据。测试用的初始场数据为国际多个海洋资料同化结果提供的随机抽取的 n 段 12 个时间序列,数据格式采用NPY格式保存
99+
本数据集由气候与应用前沿研究院 ICAR 提供。数据包括 CMIP5/6 模式的历史模拟数据和美国 SODA 模式重建的近100多年历史观测同化数据。每个样本包含以下气象及时空变量:海表温度异常 (SST) ,热含量异常 (T300),纬向风异常 (Ua),经向风异常 (Va),数据维度为 (year,month,lat,lon)。训练数据提供对应月份的 Nino3.4 index 标签数据。测试用的初始场数据为国际多个海洋资料同化结果提供的随机抽取的 n 段 12 个时间序列,数据格式采用 NPY 格式保存
99100

100101
**训练数据:**
101102

@@ -141,9 +142,9 @@ examples/earthformer/earthformer_enso_train.py:58:64
141142

142143
`SupervisedConstraint` 的第一个参数是数据的加载方式,这里使用上文中定义的 `train_dataloader_cfg`
143144

144-
第二个参数是损失函数的定义,这里使用自定义的损失函数 `mse_loss`
145+
第二个参数是损失函数的定义,这里使用自定义的损失函数 `mse_loss`
145146

146-
第三个参数是约束条件的名字,方便后续对其索引。此处命名为 "Sup"
147+
第三个参数是约束条件的名字,方便后续对其索引。此处命名为 `Sup`
147148

148149
#### 3.2.2 模型构建
149150

@@ -167,7 +168,7 @@ examples/earthformer/conf/earthformer_enso_pretrain.yaml:46:105
167168

168169
#### 3.2.3 学习率与优化器构建
169170

170-
本案例中使用的学习率方法为 `Cosine`,学习率大小设置为 2e-4。优化器使用 `AdamW`,并将参数进行分组,使用不同的
171+
本案例中使用的学习率方法为 `Cosine`,学习率大小设置为 `2e-4`。优化器使用 `AdamW`,并将参数进行分组,使用不同的
171172
`weight_decay`,用 PaddleScience 代码表示如下:
172173

173174
``` py linenums="101" title="examples/earthformer/earthformer_enso_train.py"
@@ -186,7 +187,7 @@ examples/earthformer/earthformer_enso_train.py:68:95
186187
--8<--
187188
```
188189

189-
`SupervisedValidator` 评估器与 `SupervisedConstraint` 比较相似,不同的是评估器需要设置评价指标 `metric`,在这里使用了自定义的评价指标分别是 `MAE``MSE``RMSE``corr_nino3.4_epoch``corr_nino3.4_weighted_epoch`
190+
`SupervisedValidator` 评估器与 `SupervisedConstraint` 比较相似,不同的是评估器需要设置评价指标 `metric`,在这里使用了自定义的评价指标分别是 `MAE``MSE``RMSE``corr_nino3.4_epoch` `corr_nino3.4_weighted_epoch`
190191

191192
#### 3.2.5 模型训练与评估
192193

@@ -314,9 +315,9 @@ examples/earthformer/earthformer_sevir_train.py:61:67
314315

315316
`SupervisedConstraint` 的第一个参数是数据的加载方式,这里使用上文中定义的 `train_dataloader_cfg`
316317

317-
第二个参数是损失函数的定义,这里使用自定义的损失函数 `mse_loss`
318+
第二个参数是损失函数的定义,这里使用自定义的损失函数 `mse_loss`
318319

319-
第三个参数是约束条件的名字,方便后续对其索引。此处命名为 "Sup"
320+
第三个参数是约束条件的名字,方便后续对其索引。此处命名为 `Sup`
320321

321322
### 4.2.2 模型构建
322323

@@ -340,7 +341,7 @@ examples/earthformer/conf/earthformer_sevir_pretrain.yaml:58:117
340341

341342
#### 4.2.3 学习率与优化器构建
342343

343-
本案例中使用的学习率方法为 `Cosine`,学习率大小设置为 1e-3。优化器使用 `AdamW`,并将参数进行分组,使用不同的 `weight_decay`,用 PaddleScience 代码表示如下:
344+
本案例中使用的学习率方法为 `Cosine`,学习率大小设置为 `1e-3`。优化器使用 `AdamW`,并将参数进行分组,使用不同的 `weight_decay`,用 PaddleScience 代码表示如下:
344345

345346
``` py linenums="121" title="examples/earthformer/earthformer_sevir_train.py"
346347
--8<--
@@ -445,6 +446,9 @@ examples/earthformer/earthformer_sevir_train.py:279:285
445446
创建预测器:
446447

447448
``` py linenums="293" title="examples/earthformer/earthformer_sevir_train.py"
449+
--8<--
450+
examples/earthformer/earthformer_sevir_train.py:293:294
451+
--8<--
448452
```
449453

450454
准备预测数据并进行对应模式的数据预处理:
@@ -483,7 +487,7 @@ examples/earthformer/earthformer_sevir_train.py
483487

484488
<figure markdown>
485489
![SEVIR-predict](https://paddle-org.bj.bcebos.com/paddlescience/docs/earthformer/sevir-predict.png){ loading=lazy style="margin:0 auto;height:100%;width:100%"}
486-
<figcaption>SEVIR中vil的预测结果("prediction")与真值结果("target")</figcaption>
490+
<figcaption>SEVIR 中 vil 的预测结果("prediction")与真值结果("target")</figcaption>
487491
</figure>
488492

489493
说明:

docs/zh/examples/heat_exchanger.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
python heat_exchanger.py mode=eval EVAL.pretrained_model_path=https://paddle-org.bj.bcebos.com/paddlescience/models/HEDeepONet/HEDeepONet_pretrained.pdparams
1313
```
1414

15+
=== "模型导出命令"
16+
17+
``` sh
18+
python heat_exchanger.py mode=export
19+
```
20+
21+
=== "模型推理命令"
22+
23+
``` sh
24+
python heat_exchanger.py mode=infer
25+
```
26+
1527
| 预训练模型 | 指标 |
1628
|:--| :--|
1729
| [heat_exchanger_pretrained.pdparams](https://paddle-org.bj.bcebos.com/paddlescience/models/HEDeepONet/HEDeepONet_pretrained.pdparams) | The L2 norm error between the actual heat exchanger efficiency and the predicted heat exchanger efficiency: 0.02087<br>MSE.heat_boundary(interior_mse): 0.52005<br>MSE.cold_boundary(interior_mse): 0.16590<br>MSE.wall(interior_mse): 0.01203 |

docs/zh/examples/phycrnet.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ $$u_t+u\cdot \nabla u -\nu u =0$$
5454
## 3. 问题求解
5555

5656
### 3.1 模型构建
57+
5758
在这一部分中,我们介绍 PhyCRNet 的架构,包括编码器-解码器模块、残差连接、自回归(AR)过程和基于过滤的微分。网络架构如图所示。编码器(黄色Encoder,包含3个卷积层),用于从输入状态变量 $u(t=i),i = 0,1,2,..,T-1$ 学习低维潜在特征,其中 $T$ 表示总时间步。我们应用 ReLU 作为卷积层的激活函数。然后,我们将ConvLSTM层的输出(Encoder得到的低分辨率),潜在特征的时间传播器(绿色部分),其中,输出的LSTM的记忆单元 $C_i$ 和LSTM的隐藏变量单元 $h_i$ 会作为下一个时间步的输入。这样做的好处是对低维变量的基本动态进行建模,能够准确地捕获时间依赖性,同时有助于减轻记忆负担。 使用 LSTM 的另一个优势来自输出状态的双曲正切函数,它可以保持平滑的梯度曲线,并将值控制在 -1 和 1 之间。在建立低分辨率LSTM卷积循环方案后,我们基于上采样操作Decoder(蓝色部分)直接将低分辨率潜在空间重建为高分辨率量。特别注明,应用了子像素卷积层(即像素shuffle),因为与反卷积相比,它具有更好的效率和重建精度,且伪像更少。 最后,我们添加另一个卷积层,用于将有界潜变量空间输出,缩放回原始的物理空间。该Decoder后面没有激活函数。 此外,值得一提的是,鉴于输入变量数量有限及其对超分辨率的缺陷,我们在 PhyCRNet 中没有考虑 batch normalization。 作为替代,我们使用 batch normalization 来训练网络,以实现训练加速和更好的收敛性。受到动力学中,Forward Eular Scheme 的启发,我们在输入状态变量 $u_i$ 和输出变量 $u_{i+1}$ 之间附加全局残差连接。具体网络结构如下图所示:
5859

5960
![image](https://paddle-org.bj.bcebos.com/paddlescience/docs/phycrnet/PhyCRnet.png)
@@ -94,6 +95,7 @@ examples/phycrnet/conf/burgers_equations.yaml:34:42
9495

9596
### 3.2 数据载入
9697
我们使用RK4或者谱方法生成的数据(初值为使用正态分布生成),需要从.mat文件中将其读入,:
98+
9799
``` py linenums="54"
98100
--8<--
99101
examples/phycrnet/main.py:54:72
@@ -139,17 +141,21 @@ $$
139141
$$
140142

141143
这一步需要通过设置外界函数来进行,因此在训练过程中,我们使用`function.transform_out`来进行训练
144+
142145
``` py linenums="47"
143146
--8<--
144147
examples/phycrnet/main.py:47:51
145148
--8<--
146149
```
150+
147151
而在评估过程中,我们使用`function.tranform_output_val`来进行评估,并生成累计均方根误差。
152+
148153
``` py linenums="142"
149154
--8<--
150155
examples/phycrnet/main.py:142:142
151156
--8<--
152157
```
158+
153159
完成上述设置之后,只需要将上述实例化的对象按顺序传递给 `ppsci.solver.Solver`
154160

155161
``` py linenums="117"

docs/zh/examples/shock_wave.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@
2828
python shock_wave.py -cn=shock_wave_Ma0.728 mode=eval EVAL.pretrained_model_path=https://paddle-org.bj.bcebos.com/paddlescience/models/shockwave/shock_wave_Ma0728_pretrained.pdparams
2929
```
3030

31+
=== "模型导出命令"
32+
33+
=== "Ma=2.0"
34+
35+
``` sh
36+
python shock_wave.py mode=export
37+
```
38+
=== "Ma=0.728"
39+
40+
``` sh
41+
python shock_wave.py -cn=shock_wave_Ma0.728 mode=export
42+
```
43+
44+
=== "模型推理命令"
45+
46+
=== "Ma=2.0"
47+
48+
``` sh
49+
python shock_wave.py mode=infer
50+
```
51+
=== "Ma=0.728"
52+
53+
``` sh
54+
python shock_wave.py -cn=shock_wave_Ma0.728 mode=infer
55+
```
56+
3157
## 1. 背景简介
3258

3359
激波是自然界以及工程应用中经常发现的现象。它们不仅广泛地存在于航空航天领域的可压缩流动中,而且也表现在理论与应用物理以及工程应用等其它领域。在超声速与高超声速流动中,激波的出现对流体流动的整体特征会产生重要影响。激波捕捉问题已在CFD领域发展了数十年,以弱解的数学理论为基础的激波捕捉方法以其简单易实现的特点发展迅速,并在复杂超声速、高超声速流动数值模拟中得到了广泛应用。

0 commit comments

Comments
 (0)