Skip to content
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

[Feature] Replace python funcion with sympy expression #507

Merged

Conversation

HydrogenSulfate
Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate commented Aug 26, 2023

PR types

Others

PR changes

Others

Describe

主要修改点:

  1. 基于 [Feature&Fix] Add sympy_to_func #505,将所有内置方程从 python function 替换为 smypy expression,并修改相关模块的代码,包括 Solverexpression
    • examples/aneurysm/aneurysm_flow.py
    • examples/aneurysm/aneurysm.py
    • examples/bracket/bracket.py
    • examples/cylinder/2d_unsteady/cylinder2d_unsteady_Re100.py
    • examples/darcy/darcy2d.py
    • examples/euler_beam/euler_beam.py
    • examples/fsi/viv.py
    • examples/laplace/laplace2d.py
    • examples/ldc/ldc2d_steady_Re10.py
    • examples/ldc/ldc2d_unsteady_Re10.py
    • examples/pipe/poiseuille_flow.py

其他:

  1. 修改 laplace2d 案例的输出目录,从二级目录改为一级目录
  2. 完善 Probability 文档
  3. 更改 aneurysm 案例中,normal_dot_velnormal_dot_vec
  4. 更改 bracket 案例中的 label 顺序,与对应公式在方程中的初始化顺序保持一致
  5. 删除所有关于 sp_parser 的相关无用代码
  6. 更改 initializer.py 内 liner_init 和 conv_init 的初始化方式为 kaiming 初始化

@paddle-bot
Copy link

paddle-bot bot commented Aug 26, 2023

Thanks for your contribution!

@HydrogenSulfate HydrogenSulfate changed the title [WIP][Feature] Replace python funcion with sympy expression [Feature] Replace python funcion with sympy expression Sep 10, 2023
ppsci/equation/pde/normal_dot_vec.py Show resolved Hide resolved
def __init__(self, nu: Union[float, Callable], rho: float, dim: int, time: bool):
def __init__(
self,
nu: Union[float, Callable],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后面代码中 nu 允许类型为 str, 类型提示需要修改下。其他变量也检查下有没有类似情况

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

invars = (t,) + invars
if dim == 3:
invars += (z,)

self.nu = nu
self.rho = rho
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两行代码中用的的 nu, rho 在后续代码中有修改,看是否需要把这两行放到修改后面

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@@ -33,15 +35,15 @@ class Poisson(base.PDE):
>>> pde = ppsci.equation.Poisson(2)
"""

def __init__(self, dim: int):
def __init__(self, dim: int, detach_keys: Optional[Tuple[str, ...]] = None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更新docstring

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@@ -61,214 +62,114 @@ def __init__(
rho: float = 1,
dim: int = 3,
time: bool = False,
detach_keys: Optional[Tuple[str, ...]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更新docstring

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

dim: int,
q: float,
D: float,
detach_keys: Optional[Tuple[str, ...]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更新docstring, 检查类型提示

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator

@zhiminzhang0830 zhiminzhang0830 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhiminzhang0830 zhiminzhang0830 merged commit 8b8eae6 into PaddlePaddle:develop Sep 13, 2023
4 checks passed
@HydrogenSulfate HydrogenSulfate deleted the cvt_pyfunc_to_sym branch September 13, 2023 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants