Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ Alternatively, if you want to skip pysdf installation, you can run the following
docker build -t modulus-sym:deploy -f Dockerfile --target no-pysdf .
```


### Windows Container
For building windows just use
```
docker build -t modulus - < Windows.Dockerfile
```

### Additional notes

New modification suppose to work with pip to (you'll just need to install two additional libralies)
```
pip install trimesh
pip install mesh_to_sdf
```
Tesselation will work because insted of using pysdf I used mesh_to_sdf (I have not yet implemented sdf derivatives yet, so some function will not work on windows (It's only a few functions for visualisation difference with real data (as far as I know)))
Copy link

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


## Contributing

For guidance on making a contribution to Modulus, see the [contributing guidelines](https://github.com/NVIDIA/modulus-sym/blob/main/CONTRIBUTING.md).
Expand Down
11 changes: 11 additions & 0 deletions Windows.Dockerfile
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
165 changes: 165 additions & 0 deletions modulus/sym/eq/pdes/navier_stokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'''
Copy link

Choose a reason for hiding this comment

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

Should be custom and equations


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)
Copy link

Choose a reason for hiding this comment

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

If this incompressible, then surely rho must be a constant? Therefore raising an exception would make more sense

Copy link
Author

Choose a reason for hiding this comment

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

You probably correct, I will fix it

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):
"""
Expand Down Expand Up @@ -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'''
Copy link

Choose a reason for hiding this comment

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

Typo as above

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)
)
Loading