Skip to content

Commit

Permalink
add units for PINN forward examples
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Dec 17, 2024
1 parent f837ccc commit a006228
Show file tree
Hide file tree
Showing 17 changed files with 1,917 additions and 256 deletions.
54 changes: 0 additions & 54 deletions docs/examples-pinn-forward/Beltrami_flow.ipynb

This file was deleted.

44 changes: 0 additions & 44 deletions docs/examples-pinn-forward/Euler_beam.ipynb

This file was deleted.

44 changes: 0 additions & 44 deletions docs/examples-pinn-forward/Helmholtz_Dirichlet_2d.ipynb

This file was deleted.

7 changes: 7 additions & 0 deletions docs/examples-pinn-forward/Klein_Gordon.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
"\n",
"The reference solution is $y(x, t) = x\\cos(t)$."
]
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": ""
}
],
"metadata": {
Expand Down
7 changes: 7 additions & 0 deletions docs/examples-pinn-forward/Kovasznay_flow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
"\n",
"The reference solution is $u = 1 - e^{\\lambda x} \\cos(2\\pi y), v = \\frac{\\lambda}{2\\pi}e^{\\lambda x} \\sin(2\\pi x)$, $p =\\frac{1}{2}(1 - e^{2\\lambda x})$, where $\\lambda = \\frac{1}{2\\nu}-\\sqrt{\\frac{1}{4\\nu^2}+4\\pi^2}$."
]
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": ""
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples-pinn-forward/Kovasznay_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pinnx


Re = 20
nu = 1 / Re
l = 1 / (2 * nu) - u.math.sqrt(1 / (4 * nu ** 2) + 4 * u.math.pi ** 2)
Expand Down Expand Up @@ -33,7 +34,6 @@ def pde(x, y):
continuity = u_vel_x + v_vel_y

return momentum_x, momentum_y, continuity
# return {'momentum_u': momentum_x, 'momentum_v': momentum_y, 'continuity': continuity}


def bc_func(x):
Expand Down
44 changes: 0 additions & 44 deletions docs/examples-pinn-forward/diffusion_1d.ipynb

This file was deleted.

6 changes: 1 addition & 5 deletions docs/examples-pinn-forward/elasticity_plate.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def fx(x):
-lmbd * (
4 * u.math.pi ** 2 * u.math.cos(2 * u.math.pi * x['x']) * u.math.sin(u.math.pi * x['y'])
- Q * x['y'] ** 3 * u.math.pi * u.math.cos(u.math.pi * x['x'])
)
-
) -
mu * (
u.math.pi ** 2 * u.math.cos(2 * u.math.pi * x['x']) * u.math.sin(u.math.pi * x['y'])
- Q * x['y'] ** 3 * u.math.pi * u.math.cos(u.math.pi * x['x'])
Expand All @@ -112,7 +111,6 @@ def fy(x):
)



def pde(x, y):
jacobian = net.jacobian(x)

Expand All @@ -127,7 +125,6 @@ def pde(x, y):
Sxx_x = jacobian["s"]["x"]
Syy_y = jacobian["c"]["y"]
Sxy_x = jacobian["e"]["x"]
# Sxy_x = jacobian(f, x, i=4, j=0)
Sxy_y = jacobian['e']['y']

momentum_x = Sxx_x + Sxy_y - fx(x)
Expand Down Expand Up @@ -179,4 +176,3 @@ def pde(x, y):
trainer = pinnx.Trainer(data)
trainer.compile(bst.optim.Adam(0.001), metrics=["l2 relative error"]).train(iterations=1000)
trainer.saveplot(issave=True, isplot=True)

4 changes: 4 additions & 0 deletions docs/unit-examples-forward.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ PINN Forward Examples
.. toctree::
:maxdepth: 1

unit-examples-forward/Beltrami_flow.ipynb
unit-examples-forward/diffusion_1d.ipynb
unit-examples-forward/Euler_beam.ipynb
unit-examples-forward/Helmholtz_Dirichlet_2d.ipynb
unit-examples-forward/burgers.ipynb
unit-examples-forward/Burgers_RAR.ipynb
unit-examples-forward/heat.ipynb
Expand Down
Loading

0 comments on commit a006228

Please sign in to comment.