-
Notifications
You must be signed in to change notification settings - Fork 103
Added NS incompressible and Euler equation. Also fixed tessellation, so now will work on windows via docker or pip #30
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
1227ae8
e2cb843
ce8387e
1e76c30
74c77b8
2974b70
73606d4
0a62b89
fe306bb
167dbc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM nvcr.io/nvidia/modulus/modulus:23.05 | ||
|
||
RUN rm -rf \ | ||
/usr/lib/x86_64-linux-gnu/libcuda.so* \ | ||
/usr/lib/x86_64-linux-gnu/libnvcuvid.so* \ | ||
/usr/lib/x86_64-linux-gnu/libnvidia-*.so* \ | ||
/usr/lib/firmware \ | ||
/usr/local/cuda/compat/lib | ||
|
||
RUN pip install trimesh \ | ||
mesh_to_sdf |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,6 +339,90 @@ def __init__(self, T, dim=3, time=True): | |
normal_x * T.diff(x) + normal_y * T.diff(y) + normal_z * T.diff(z) | ||
) | ||
|
||
class NavierStokesIncompressible(PDE): | ||
'''Cystom implementation of incompressible NS eqyastyans''' | ||
|
||
|
||
name = "navier stokes incompressible" | ||
|
||
def __init__(self, nu, rho=1, dim=3, time=False): | ||
|
||
'''Parameters | ||
========== | ||
nu : float, Sympy Symbol/Expr, str | ||
The kinematic viscosity. If `nu` is a str then it is | ||
converted to Sympy Function of form `nu(x,y,z,t)`. | ||
If `nu` is a Sympy Symbol or Expression then this | ||
is substituted into the equation. This allows for | ||
variable viscosity. | ||
rho : float, Sympy Symbol/Expr, str | ||
The density of the fluid. If `rho` is a str then it is | ||
converted to Sympy Function of form 'rho(x,y,z,t)'. | ||
If 'rho' is a Sympy Symbol or Expression then this | ||
is substituted into the equation to allow for | ||
compressible Navier Stokes. Default is 1. | ||
dim : int | ||
Dimension of the Navier Stokes (2 or 3). Default is 3. | ||
time : bool | ||
If time-dependent equations or not. Default is False.''' | ||
|
||
self.dim = dim | ||
self.time = time | ||
|
||
# coordinates | ||
x, y, z = Symbol("x"), Symbol("y"), Symbol("z") | ||
|
||
# time | ||
t = Symbol("t") | ||
|
||
input_variables = {"x": x, "y": y, "z": z, "t": t} | ||
if self.dim == 2: | ||
input_variables.pop("z") | ||
if not self.time: | ||
input_variables.pop("t") | ||
|
||
|
||
# kinematic viscosity | ||
if isinstance(nu, str): | ||
nu = Function(nu)(*input_variables) | ||
elif isinstance(nu, (float, int)): | ||
nu = Number(nu) | ||
|
||
# density | ||
if isinstance(rho, str): | ||
rho = Function(rho)(*input_variables) | ||
|
||
elif isinstance(rho, (float, int)): | ||
rho = Number(rho) | ||
|
||
|
||
u = Function("u")(*input_variables) | ||
v = Function("v")(*input_variables) | ||
w = Function("w")(*input_variables) | ||
|
||
|
||
|
||
#pressure | ||
p = Function("p")(*input_variables) | ||
|
||
# set equations | ||
self.equations = {} | ||
self.equations["continuity"] = ( | ||
u.diff(x) + v.diff(y) + w.diff(z) | ||
) | ||
|
||
self.equations["momentum_x"] = ( | ||
u.diff(t) + u * u.diff(x) + v * u.diff(y) + w * u.diff(z) + 1 / rho * p.diff(x) | ||
- nu * (u.diff(x).diff(x) + u.diff(y).diff(y) + u.diff(z).diff(z)) | ||
) | ||
|
||
self.equations["momentum_y"] = ( | ||
v.diff(t) +u * v.diff(x) + v * v.diff(y) + w * v.diff(z) + 1 / rho * p.diff(y) | ||
- nu * (v.diff(x).diff(x) + v.diff(y).diff(y) + v.diff(z).diff(z)) | ||
) | ||
self.equations["momentum_z"] = ( | ||
w.diff(t) +u * w.diff(x) + v * w.diff(y) + w * w.diff(z) + 1 / rho * p.diff(z) | ||
- nu * (w.diff(x).diff(x) + w.diff(y).diff(y) + w.diff(z).diff(z)) | ||
) | ||
|
||
|
||
class Curl(PDE): | ||
""" | ||
|
@@ -507,3 +591,84 @@ def __init__(self, T="T", D="D", rho=1, vec=["u", "v", "w"]): | |
self.equations[str(T) + "_flux"] += ( | ||
Symbol(v) * n * rho * T - rho * D * n * g | ||
) | ||
|
||
|
||
class Euler(PDE): | ||
'''Cystom implementation of compressible Euler eqyastyans''' | ||
|
||
def __init__(self, rho=1, dim=3, ratio_heats=1.4, time=False): | ||
''' | ||
Parameters | ||
========== | ||
rho : float, Sympy Symbol/Expr, str | ||
The density of the fluid. If `rho` is a str then it is | ||
converted to Sympy Function of form 'rho(x,y,z,t)'. | ||
If 'rho' is a Sympy Symbol or Expression then this | ||
is substituted into the equation to allow for | ||
compressible Navier Stokes. Default is 1. | ||
dim : int | ||
Dimension of the Navier Stokes (2 or 3). Default is 3. | ||
time : bool | ||
If time-dependent equations or not. Default is False. | ||
ratio_heats : float | ||
Ratio of specific heats. Default is 1.4 (for air). | ||
''' | ||
self.dim = dim | ||
self.time = time | ||
|
||
# coordinates | ||
x, y, z = Symbol("x"), Symbol("y"), Symbol("z") | ||
|
||
# time | ||
t = Symbol("t") | ||
|
||
# make input variables | ||
input_variables = {"x": x, "y": y, "z": z, "t": t} | ||
if self.dim == 2: | ||
input_variables.pop("z") | ||
if not self.time: | ||
input_variables.pop("t") | ||
|
||
u = Function("u")(*input_variables) | ||
v = Function("v")(*input_variables) | ||
if self.dim == 3: | ||
w = Function("w")(*input_variables) | ||
else: | ||
w = Number(0) | ||
|
||
|
||
# pressure | ||
p = Function("p")(*input_variables) | ||
|
||
# density | ||
if isinstance(rho, str): | ||
rho = Function(rho)(*input_variables) | ||
elif isinstance(rho, (float, int)): | ||
rho = Number(rho) | ||
|
||
|
||
self.equations = {} | ||
|
||
e = p /(rho * (ratio_heats - 1)) | ||
# Energy | ||
E = rho * (e + (u **2 + v **2 + w **2) / 2) | ||
|
||
self.equations["continuity"] = ( | ||
rho.diff(t) + (rho * u).diff(x) + (rho * v).diff(y) + (rho * w).diff(z) | ||
) | ||
|
||
self.equations["momentum_x"] = ( | ||
(rho * u).diff(t) + (rho * u **2 + p).diff(x) + (rho * u * v).diff(y) + (rho * u * w).diff(z) | ||
|
||
) | ||
|
||
self.equations["momentum_y"] = ( | ||
(rho * v).diff(t) + (rho * u * v).diff(x) + (rho * v **2 + p).diff(y) + (rho * v * w).diff(z) | ||
) | ||
|
||
self.equations["momentum_z"] = ( | ||
(rho * w).diff(t) + (rho * u * w).diff(x) + (rho * v * w).diff(y) + (rho * w **2 + p).diff(z) | ||
) | ||
|
||
self.equations["energy"] = ( | ||
E.diff(t) + (u * (E + p)).diff(x) + (v * (E + p)).diff(y) + (w * (E + p)).diff(z) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typo, should be instead