Skip to content

Commit

Permalink
fix all wrong linenumbers in fence
Browse files Browse the repository at this point in the history
  • Loading branch information
HydrogenSulfate committed Jan 12, 2024
2 parents 37f6f2a + 0f178a5 commit 1781bcf
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.272'
rev: "v0.0.272"
hooks:
- id: ruff

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/api/utils/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
- debug
- warning
- error
- scaler
- scalar
show_root_heading: True
heading_level: 3
8 changes: 7 additions & 1 deletion docs/zh/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,19 @@ pip install -r docs/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
PaddleScience 文档基于 [Mkdocs-Material](https://squidfunk.github.io/mkdocs-material/)、[PyMdown](https://facelessuser.github.io/pymdown-extensions/extensions/arithmatex/) 等插件进行编写,其在 Markdown 语法基础上支持了多种扩展性功能,能极大地提升文档的美观程度和阅读体验。建议参考超链接内的文档内容,选择合适的功能辅助文档撰写。
### 3.3 预览文档
### 3.3 使用 markdownlint 格式化文档[可选]
如果您使用的开发环境为 VSCode,则推荐安装 [markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) 扩展。安装完毕后在编写完的文档内:点击右键-->格式化文档即可。
### 3.4 预览文档
`PaddleScience/` 目录下执行以下命令,等待构建完成后,点击显示的链接进入本地网页预览文档内容。
``` sh
mkdocs serve
```
``` log
# ====== 终端打印信息如下 ======
# INFO - Building documentation...
# INFO - Cleaning site directory
Expand Down
10 changes: 5 additions & 5 deletions docs/zh/examples/cfdgcn.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# only linux
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/CFDGCN/data.zip
unzip data.zip
wget https://paddle-org.bj.bcebos.com/paddlescience/datasets/CFDGCN/meshes.tar
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/CFDGCN/meshes.tar
tar -xvf meshes.tar
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/CFDGCN/SU2Bin.tgz
tar -zxvf SU2Bin.tgz
Expand Down Expand Up @@ -64,7 +64,7 @@
``` sh
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/CFDGCN/data.zip
unzip data.zip
wget https://paddle-org.bj.bcebos.com/paddlescience/datasets/CFDGCN/meshes.tar
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/CFDGCN/meshes.tar
tar -xvf meshes.tar
```

Expand Down Expand Up @@ -172,13 +172,13 @@ examples/cfdgcn/cfdgcn.py:39:48

完成上述设置之后,只需要将上述实例化的对象按顺序传递给 `ppsci.solver.Solver`,然后启动训练。

``` py linenums="120"
``` py linenums="125"
--8<--
examples/cfdgcn/cfdgcn.py:126:140
examples/cfdgcn/cfdgcn.py:125:140
--8<--
```

### 3.8 结果可视化
### 3.9 结果可视化

训练完毕之后程序会对测试集中的数据进行预测,并以图片的形式对结果进行可视化,如下所示。

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/examples/control_arm.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ examples/control_arm/conf/forward_analysis.yaml:61:63

训练过程会调用优化器来更新模型参数,此处选择较为常用的 `Adam` 优化器,并配合使用机器学习中常用的 ExponentialDecay 学习率调整策略。

``` py linenums="23"
``` py linenums="26"
--8<--
examples/control_arm/forward_analysis.py:26:30
--8<--
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/examples/deephpms.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ examples/deephpms/burgers.py:157:173

第二阶段训练、评估

``` py linenums="218"
``` py linenums="221"
--8<--
examples/deephpms/burgers.py:221:237
--8<--
Expand Down
44 changes: 21 additions & 23 deletions docs/zh/examples/labelfree_DNN_surrogate.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
=== "模型训练命令"

案例一:Pipe Flow

``` sh
python poiseuille_flow.py
```

案例二:Aneurysm Flow

``` sh
wget https://paddle-org.bj.bcebos.com/paddlescience/datasets/LabelFree-DNN-Surrogate/LabelFree-DNN-Surrogate_data.zip
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/LabelFree-DNN-Surrogate/LabelFree-DNN-Surrogate_data.zip
unzip LabelFree-DNN-Surrogate_data.zip

python aneurysm_flow.py
Expand All @@ -18,13 +20,15 @@
=== "模型评估命令"

案例一:Pipe Flow

``` sh
python poiseuille_flow.py mode=eval EVAL.pretrained_model_path=https://paddle-org.bj.bcebos.com/paddlescience/models/poiseuille_flow/poiseuille_flow_pretrained.pdparams
```

案例二:Aneurysm Flow

``` sh
wget https://paddle-org.bj.bcebos.com/paddlescience/datasets/LabelFree-DNN-Surrogate/LabelFree-DNN-Surrogate_data.zip
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/LabelFree-DNN-Surrogate/LabelFree-DNN-Surrogate_data.zip
unzip LabelFree-DNN-Surrogate_data.zip

python aneurysm_flow.py mode=eval EVAL.pretrained_model_path=https://paddle-org.bj.bcebos.com/paddlescience/models/LabelFree-DNN-Surrogate/aneurysm_flow.pdparams
Expand Down Expand Up @@ -114,15 +118,9 @@ $$

上式中 $f_1, f_2, f_3$ 即为 MLP 模型本身,$transform_{input}, transform_{output}$, 表示施加额外的结构化自定义层,用于施加约束和丰富输入,用 PaddleScience 代码表示如下:

``` py linenums="78"
--8<--
examples/pipe/poiseuille_flow.py:78:80
--8<--
```

``` py linenums="105"
``` py linenums="71"
--8<--
examples/pipe/poiseuille_flow.py:105:111
examples/pipe/poiseuille_flow.py:71:105
--8<--
```

Expand All @@ -134,9 +132,9 @@ examples/pipe/poiseuille_flow.py:105:111

由于本案例使用的是 Navier-Stokes 方程的2维稳态形式,因此可以直接使用 PaddleScience 内置的 `NavierStokes`

``` py linenums="117"
``` py linenums="110"
--8<--
examples/pipe/poiseuille_flow.py:117:121
examples/pipe/poiseuille_flow.py:110:115
--8<--
```

Expand All @@ -146,9 +144,9 @@ examples/pipe/poiseuille_flow.py:117:121

本文中本案例的计算域和参数自变量 $\nu$ 由`numpy`随机数生成的点云构成,因此可以直接使用 PaddleScience 内置的点云几何 `PointCloud` 组合成空间的 `Geometry` 计算域。

``` py linenums="52"
``` py linenums="45"
--8<--
examples/pipe/poiseuille_flow.py:52:75
examples/pipe/poiseuille_flow.py:45:69
--8<--
```

Expand Down Expand Up @@ -210,9 +208,9 @@ examples/pipe/poiseuille_flow.py:52:75

以作用在流体域内部点上的 `InteriorConstraint` 为例,代码如下:

``` py linenums="128"
``` py linenums="122"
--8<--
examples/pipe/poiseuille_flow.py:128:146
examples/pipe/poiseuille_flow.py:122:142
--8<--
```

Expand All @@ -236,19 +234,19 @@ examples/pipe/poiseuille_flow.py:52:75

训练过程会调用优化器来更新模型参数,此处选择较为常用的 `Adam` 优化器。

``` py linenums="127"
``` py linenums="107"
--8<--
examples/pipe/poiseuille_flow.py:114:114
examples/pipe/poiseuille_flow.py:107:108
--8<--
```

#### 2.2.7 模型训练、评估与可视化

完成上述设置之后,只需要将上述实例化的对象按顺序传递给 `ppsci.solver.Solver`,然后启动训练。

``` py linenums="152"
``` py linenums="144"
--8<--
examples/pipe/poiseuille_flow.py:152:164
examples/pipe/poiseuille_flow.py:144:156
--8<--
```

Expand All @@ -258,9 +256,9 @@ examples/pipe/poiseuille_flow.py:152:164

2. 当我们选取截断高斯分布的动力粘性系数 ${\nu}$ 采样(均值为 $\hat{\nu} = 10^{−3}$, 方差 $\sigma_{\nu}​=2.67 \times 10^{−4}$),中心处速度的概率密度函数和解析解对比

``` py linenums="166"
``` py linenums="159"
--8<--
examples/pipe/poiseuille_flow.py:166:274
examples/pipe/poiseuille_flow.py:159:261
--8<--
```

Expand Down Expand Up @@ -301,7 +299,7 @@ $$

本文主要研究了两种类型的典型血管流(具有标准化的血管几何形状),狭窄流和动脉瘤流。
狭窄血流是指流过血管的血流,其中血管壁变窄和再扩张。 血管的这种局部限制与许多心血管疾病有关,例如动脉硬化、中风和心脏病发作 。
动脉瘤内的血管血流,即由于血管壁薄弱导致的动脉扩张,称为动脉瘤血流。 动脉瘤破裂可能导致危及生命的情况,例如,由于脑动脉瘤破裂引起的蛛网膜下腔出血 (SAH,而血液动力学的研究可以提高诊断和对动脉瘤进展和破裂的基本了解 。
动脉瘤内的血管血流,即由于血管壁薄弱导致的动脉扩张,称为动脉瘤血流。 动脉瘤破裂可能导致危及生命的情况,例如,由于脑动脉瘤破裂引起的蛛网膜下腔出血 (SAH),而血液动力学的研究可以提高诊断和对动脉瘤进展和破裂的基本了解 。

虽然现实的血管几何形状通常是不规则和复杂的,包括曲率、分叉和连接点,但这里研究理想化的狭窄和动脉瘤模型以进行概念验证。 即,狭窄血管和动脉瘤血管都被理想化为具有不同横截面半径的轴对称管,其由以下函数参数化,

Expand Down
10 changes: 5 additions & 5 deletions docs/zh/examples/rossler.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ examples/rossler/conf/enn.yaml:22:34

本案例基于数据驱动的方法求解问题,因此需要使用 PaddleScience 内置的 `SupervisedConstraint` 构建监督约束。在定义约束之前,需要首先指定监督约束中用于数据加载的各个参数,代码如下:

``` py linenums="57" title="examples/rossler/train_enn.py"
``` py linenums="55" title="examples/rossler/train_enn.py"
--8<--
examples/rossler/train_enn.py:55:74
--8<--
Expand Down Expand Up @@ -129,9 +129,9 @@ examples/rossler/train_enn.py:76:86

用 PaddleScience 代码表示如下:

``` py linenums="89" title="examples/rossler/train_enn.py"
``` py linenums="92" title="examples/rossler/train_enn.py"
--8<--
examples/rossler/train_enn.py:93:99
examples/rossler/train_enn.py:92:99
--8<--
```

Expand Down Expand Up @@ -189,9 +189,9 @@ examples/rossler/conf/transformer.yaml:23:34

Transformer 模型同样基于数据驱动的方法求解问题,因此需要使用 PaddleScience 内置的 `SupervisedConstraint` 构建监督约束。在定义约束之前,需要首先指定监督约束中用于数据加载的各个参数,代码如下:

``` py linenums="67" title="examples/rossler/train_transformer.py"
``` py linenums="64" title="examples/rossler/train_transformer.py"
--8<--
examples/rossler/train_transformer.py:65:82
examples/rossler/train_transformer.py:64:82
--8<--
```

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/examples/topopt.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ examples/topopt/topoptmodel.py
| Poisson30 | 0.8617 | 0.9221 | 0.9488 | 0.9670 | 0.9662 | 0.9769 | 0.9773 | 0.9786 | 0.9803 | 0.9833 | 0.9850 | 0.9853 | 0.9855 | 0.9860 | 0.9875 | 0.9873 |
| Uniform | 0.8887 | 0.9367 | 0.9452 | 0.9468 | 0.9644 | 0.9655 | 0.9659 | 0.9695 | 0.9717 | 0.9787 | 0.9787 | 0.9816 | 0.9784 | 0.9835 | 0.9831 | 0.9845 |

## 参考文献
## 6. 参考文献

- [Sosnovik I, & Oseledets I. Neural networks for topology optimization](https://arxiv.org/pdf/1709.09578)

Expand Down
48 changes: 35 additions & 13 deletions docs/zh/install_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,47 @@

### 1.4 安装 PaddleScience

从 [1.4.1 git 源码安装](#141-git) 和 [1.4.2 pip 安装](#142-pip) 任选一种安装方式即可。
#### 1.4.1 安装基础功能

#### 1.4.1 git 源码安装[**推荐**]
从以下三种安装方式中**任选一种**

执行以下命令,从 github 上 clone PaddleScience 源代码,并以 editable 的方式安装 PaddleScience。
=== "git 源码安装[**推荐**]"

--8<--
./README.md:git_install
--8<--
执行以下命令,从 github 上 clone PaddleScience 源代码,并以 editable 的方式安装 PaddleScience。

--8<--
./README.md:git_install
--8<--

=== "pip 安装"

执行以下命令以 pip 的方式安装最新版本的 PaddleScience。

``` shell
pip install -U paddlesci
```

=== "设置 PYTHONPATH"

如果在您的环境中,上述两种方式都无法正常安装,则可以选择本方式,在终端内将环境变量 `PYTHONPATH` 临时设置为 `PaddleScience`**绝对路径**,如下所示。

=== "Linux"

``` sh
cd PaddleScience/
export PYTHONPATH=$PYTHONPATH:$PWD
```

#### 1.4.2 pip 安装
=== "Windows"

执行以下命令以 pip 的方式安装 PaddleScience。
``` sh
cd PaddleScience/
set PYTHONPATH=%cd%
```

``` sh
pip install paddlesci
```
上述方式的优点是步骤简单无需安装,缺点是当环境变量生效的终端被关闭后,需要重新执行上述命令设置 `PYTHONPATH` 才能再次使用 PaddleScience,较为繁琐。

#### 1.4.3 额外依赖安装[可选]
#### 1.4.2 安装额外功能[可选]

如需使用 `.obj`, `.ply`, `.off`, `.stl`, `.mesh`, `.node`, `.poly` and `.msh` 等复杂几何文件构建几何(计算域),以及使用加密采样等功能,则需按照下方给出的命令,安装 open3d、
pybind11、pysdf、PyMesh 四个依赖库。
Expand Down Expand Up @@ -145,7 +167,7 @@ pybind11、pysdf、PyMesh 四个依赖库。

如果出现 `PaddleScience is installed successfully.✨ 🍰 ✨`,则说明安装验证成功。

- [可选]如果已按照 [1.4.3 额外依赖安装](#143) 正确安装了 4 个额外依赖库,则可以执行以下代码,
- [可选]如果已按照 [1.4.2 安装额外依赖](#142) 正确安装了 4 个额外依赖库,则可以执行以下代码,
验证 PaddleScience 的 `ppsci.geometry.Mesh` 模块是否能正常运行。

``` sh
Expand Down
Loading

0 comments on commit 1781bcf

Please sign in to comment.