Skip to content

Commit

Permalink
Merge branch 'develop' into fix_doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
HydrogenSulfate authored Mar 25, 2024
2 parents 0e6dcba + a9dd9f8 commit 70c44a0
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/zh/examples/chip_heat.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $$
$$

<figure markdown>
![domain_chip.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/domain_chip.pdf){ loading=lazy style="height:80%;width:80%" align="center" }
![domain_chip.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/domain_chip.PNG){ loading=lazy style="height:80%;width:80%" align="center" }
<figcaption> 内部具有随机热源分布的 2D 芯片模拟区域,边界上可以为任意的边界条件。</figcaption>
</figure>

Expand Down Expand Up @@ -94,7 +94,7 @@ PI-DeepONet模型,将 DeepONet 和 PINN 方法相结合,是一种结合了
对于芯片热仿真问题,PI-DeepONet 模型可以表示为如图所示的模型结构:

<figure markdown>
![pi_deeponet.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/pi_deeponet.pdf){ loading=lazy style="height:80%;width:80%" align="center" }
![pi_deeponet.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/pi_deeponet.PNG){ loading=lazy style="height:80%;width:80%" align="center" }
</figure>

如图所示,我们一共使用了 3 个分支网络和一个主干网络,分支网络分别输入边界类型指标、随机热源分布 $S(x, y)$ 和边界函数 $Q(x, y)$,主干网络输入二维坐标点坐标信息。每个分支网和主干网均输出 $q$ 维特征向量,通过 Hadamard(逐元素)乘积组合所有这些输出特征,然后将所得向量相加为预测温度场的标量输出。
Expand Down
76 changes: 76 additions & 0 deletions ppsci/geometry/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ def from_pymesh(cls, mesh: "pymesh.Mesh") -> "Mesh":
Returns:
Mesh: Instantiated ppsci.geometry.Mesh object.
Examples:
>>> import ppsci
>>> import pymesh
>>> import numpy as np
>>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
>>> mesh = ppsci.geometry.Mesh.from_pymesh(box)
>>> print(mesh.vertices)
[[0. 0. 0.]
[1. 0. 0.]
[1. 1. 0.]
[0. 1. 0.]
[0. 0. 1.]
[1. 0. 1.]
[1. 1. 1.]
[0. 1. 1.]]
"""
# check if pymesh is installed when using Mesh Class
if not checker.dynamic_import_to_globals(["pymesh"]):
Expand Down Expand Up @@ -182,6 +198,40 @@ def translate(self, translation: np.ndarray, relative: bool = True) -> "Mesh":
Returns:
Mesh: Translated Mesh object.
Examples:
>>> import ppsci
>>> import pymesh
>>> import numpy as np
>>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
>>> mesh = ppsci.geometry.Mesh(box)
>>> print(mesh.vertices)
[[0. 0. 0.]
[1. 0. 0.]
[1. 1. 0.]
[0. 1. 0.]
[0. 0. 1.]
[1. 0. 1.]
[1. 1. 1.]
[0. 1. 1.]]
>>> print(mesh.translate((-0.5, 0, 0.5), False).vertices) # the center is moved to the translation vector.
[[-1. -0.5 0. ]
[ 0. -0.5 0. ]
[ 0. 0.5 0. ]
[-1. 0.5 0. ]
[-1. -0.5 1. ]
[ 0. -0.5 1. ]
[ 0. 0.5 1. ]
[-1. 0.5 1. ]]
>>> print(mesh.translate((-0.5, 0, 0.5), True).vertices) # the translation vector is directly added to the geometry coordinates
[[-0.5 0. 0.5]
[ 0.5 0. 0.5]
[ 0.5 1. 0.5]
[-0.5 1. 0.5]
[-0.5 0. 1.5]
[ 0.5 0. 1.5]
[ 0.5 1. 1.5]
[-0.5 1. 1.5]]
"""
vertices = np.array(self.vertices, dtype=paddle.get_default_dtype())
faces = np.array(self.faces)
Expand Down Expand Up @@ -221,6 +271,32 @@ def scale(
Returns:
Mesh: Scaled Mesh object.
Examples:
>>> import ppsci
>>> import pymesh
>>> import numpy as np
>>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
>>> mesh = ppsci.geometry.Mesh(box)
>>> print(mesh.vertices)
[[0. 0. 0.]
[1. 0. 0.]
[1. 1. 0.]
[0. 1. 0.]
[0. 0. 1.]
[1. 0. 1.]
[1. 1. 1.]
[0. 1. 1.]]
>>> mesh = mesh.scale(2, (0.25, 0.5, 0.75))
>>> print(mesh.vertices)
[[-0.25 -0.5 -0.75]
[ 1.75 -0.5 -0.75]
[ 1.75 1.5 -0.75]
[-0.25 1.5 -0.75]
[-0.25 -0.5 1.25]
[ 1.75 -0.5 1.25]
[ 1.75 1.5 1.25]
[-0.25 1.5 1.25]]
"""
vertices = np.array(self.vertices, dtype=paddle.get_default_dtype())
faces = np.array(self.faces, dtype=paddle.get_default_dtype())
Expand Down

0 comments on commit 70c44a0

Please sign in to comment.