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

Add disc init to NS #374

Closed
wants to merge 57 commits into from
Closed
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
bb4f783
add discontinuity initialization
anderson2981 Feb 25, 2021
3e56e02
fixed up linting
anderson2981 Feb 25, 2021
9334c6a
Merge branch 'master' into disc_init
MTCam Feb 25, 2021
b749507
Update mirgecom/initializers.py
anderson2981 Feb 25, 2021
d5f6922
Update mirgecom/initializers.py
anderson2981 Feb 25, 2021
db97930
Merge branch 'master' into disc_init
anderson2981 Feb 25, 2021
4307941
Update mirgecom/initializers.py
anderson2981 Feb 25, 2021
d70df8e
added convective velocity to discontinutiy initializer
anderson2981 Mar 24, 2021
d5b2372
Merge branch 'main' into disc_init
anderson2981 Mar 25, 2021
36d51ce
Merge branch 'main' into disc_init
anderson2981 Apr 5, 2021
6ca4a65
Merge branch 'main' into disc_init
anderson2981 Apr 7, 2021
b821410
Merge branch 'main' into disc_init
MTCam Apr 8, 2021
dc5697a
Silence flake8.
MTCam Apr 8, 2021
05db922
updated for multi-species
anderson2981 Apr 8, 2021
65699d7
Silence flake8.
MTCam Apr 8, 2021
842ee72
Silence pydocstyle
MTCam Apr 8, 2021
0054a27
oopsie do
anderson2981 Apr 8, 2021
0b9131e
geez
anderson2981 Apr 8, 2021
950df19
Update mirgecom/initializers.py
anderson2981 Apr 8, 2021
23d6ed7
Update mirgecom/initializers.py
anderson2981 Apr 8, 2021
ec2600f
Update mirgecom/initializers.py
anderson2981 Apr 8, 2021
80784b7
Update mirgecom/initializers.py
anderson2981 Apr 8, 2021
6554078
Update mirgecom/initializers.py
anderson2981 Apr 8, 2021
19e082a
removed superfluous intermediate variables
anderson2981 Apr 8, 2021
b0dbcd2
clarified time dependence
anderson2981 Apr 8, 2021
ad58629
new name! PlanarDiscontinuity
anderson2981 Apr 8, 2021
ebc3f2e
linting
anderson2981 Apr 8, 2021
044ed42
changed API to be more descriptive
anderson2981 Apr 9, 2021
cbe1976
added variable time support for the position of the interface, removi…
anderson2981 Apr 9, 2021
ab8c1c8
Merge branch 'main' into disc_init
inducer Apr 10, 2021
a42efea
Merge branch 'main' into disc_init
MTCam Apr 16, 2021
4600a27
Merge branch 'main' into disc_init
anderson2981 Apr 21, 2021
80b22b5
Merge branch 'main' into disc_init
anderson2981 May 19, 2021
e04b336
Merge branch 'navier-stokes' into mrgns
MTCam May 21, 2021
58a1a89
Correct the interface used by the RHS operators to pull boundary data…
MTCam May 21, 2021
59c8290
Merge main docs
MTCam May 23, 2021
51ae536
Merge branch 'navier-stokes' into mrgns
MTCam May 23, 2021
b5d8fb0
Merge branch 'navier-stokes' into mrgns-to-disc-to-nw
MTCam Jun 1, 2021
a8d114a
Merge branch 'navier-stokes' into mrgns
MTCam Jun 7, 2021
30825be
Merge branch 'navier-stokes' into mrgns
MTCam Jun 9, 2021
abddd75
Merge branch 'ns-to-cv-actx' into mrgactx
MTCam Jun 9, 2021
e1f788a
Merge branch 'main' into mrgmain
MTCam Jun 11, 2021
2bce12c
Adjust to main merge
MTCam Jun 11, 2021
c057a5c
Merge from NS
MTCam Jun 12, 2021
2fbfb18
Merge branch 'main' into add-disc-init-to-ns-actx
MTCam Jun 23, 2021
2b0af0f
Merge branch 'navier-stokes' into add-disc-init-to-ns-actx
MTCam Jun 23, 2021
997d766
Merge main
MTCam Jul 10, 2021
51ee8a5
Update from upstream
MTCam Aug 21, 2021
2404fd1
Merge branch 'navier-stokes' into add-disc-init-to-ns-actx
MTCam Aug 21, 2021
339dce6
Merge branch 'navier-stokes' into add-disc-init-to-ns-actx
MTCam Aug 22, 2021
6c473dd
Merge branch 'navier-stokes' into add-disc-init-to-ns-actx
MTCam Aug 23, 2021
149f889
Merge branch 'navier-stokes' into add-disc-init-to-ns-actx
MTCam Aug 23, 2021
327ed53
Sharpen doc with correct indentation, specific mixture interface usage.
MTCam Aug 23, 2021
d665142
Merge branch 'navier-stokes' into add-disc-init-to-ns-actx
MTCam Aug 24, 2021
64dc675
Merge branch 'navier-stokes' into add-disc-init-to-ns-actx
MTCam Aug 25, 2021
58a9108
Update initializers.py
anderson2981 Nov 19, 2021
87a0826
Merge branch 'navier-stokes' into add-disc-init-to-ns-actx
MTCam Dec 14, 2021
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
138 changes: 138 additions & 0 deletions mirgecom/initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
.. autoclass:: AcousticPulse
.. automethod: make_pulse
.. autoclass:: MixtureInitializer
.. autoclass:: PlanarDiscontinuity
.. autoclass:: PlanarPoiseuille
"""

Expand Down Expand Up @@ -42,6 +43,7 @@
from pytools.obj_array import make_obj_array
from meshmode.dof_array import thaw
from mirgecom.eos import IdealSingleGas
from numbers import Number
from mirgecom.fluid import make_conserved


Expand Down Expand Up @@ -853,6 +855,142 @@ def __call__(self, x_vec, eos, **kwargs):
momentum=mom, species_mass=specmass)


class PlanarDiscontinuity:
r"""Solution initializer for flow with a discontinuity.

This initializer creates a physics-consistent flow solution
given an initial thermal state (pressure, temperature) and an EOS.

The solution varies across a planar interface defined by a tanh function
located at disc_location for pressure, temperature, velocity, and mass fraction

.. automethod:: __init__
.. automethod:: __call__
"""

def __init__(
self, *, dim=3, normal_dir=0, disc_location=0, nspecies=0,
temperature_left, temperature_right,
pressure_left, pressure_right,
velocity_left=None, velocity_right=None,
species_mass_left=None, species_mass_right=None,
convective_velocity=None, sigma=0.5
):
r"""Initialize mixture parameters.

Parameters
----------
dim: int
specifies the number of dimensions for the solution
normal_dir: int
specifies the direction (plane) the discontinuity is applied in
disc_location: float or Callable
fixed location of discontinuity or optionally a function that
returns the time-dependent location.
nspecies: int
specifies the number of mixture species
pressure_left: float
pressure to the left of the discontinuity
temperature_left: float
temperature to the left of the discontinuity
velocity_left: numpy.ndarray
velocity (vector) to the left of the discontinuity
species_mass_left: numpy.ndarray
species mass fractions to the left of the discontinuity
pressure_right: float
pressure to the right of the discontinuity
temperature_right: float
temperaure to the right of the discontinuity
velocity_right: numpy.ndarray
velocity (vector) to the right of the discontinuity
species_mass_right: numpy.ndarray
species mass fractions to the right of the discontinuity
sigma: float
sharpness parameter
"""
if velocity_left is None:
velocity_left = np.zeros(shape=(dim,))
if velocity_right is None:
velocity_right = np.zeros(shape=(dim,))

if species_mass_left is None:
species_mass_left = np.zeros(shape=(nspecies,))
if species_mass_right is None:
species_mass_right = np.zeros(shape=(nspecies,))

self._nspecies = nspecies
self._dim = dim
self._disc_location = disc_location
self._sigma = sigma
self._ul = velocity_left
self._ur = velocity_right
self._uc = convective_velocity
self._pl = pressure_left
self._pr = pressure_right
self._tl = temperature_left
self._tr = temperature_right
self._yl = species_mass_left
self._yr = species_mass_right
self._xdir = normal_dir
if self._xdir >= self._dim:
self._xdir = self._dim - 1

def __call__(self, x_vec, eos, *, time=0.0, **kwargs):
"""Create the mixture state at locations *x_vec*.

Parameters
----------
x_vec: numpy.ndarray
Coordinates at which solution is desired
eos:
Mixture-compatible equation-of-state object must provide
these functions:
`eos.get_density`
`eos.get_internal_energy`
time: float
Time at which solution is desired. The location is (optionally)
dependent on time
"""
if x_vec.shape != (self._dim,):
raise ValueError(f"Position vector has unexpected dimensionality,"
f" expected {self._dim}.")

x = x_vec[self._xdir]
actx = x.array_context
if isinstance(self._disc_location, Number):
x0 = self._disc_location
else:
x0 = self._disc_location(time)

xtanh = 1.0/self._sigma*(x0 - x)
weight = 0.5*(1.0 - actx.np.tanh(xtanh))
pressure = self._pl + (self._pr - self._pl)*weight
temperature = self._tl + (self._tr - self._tl)*weight
velocity = self._ul + (self._ur - self._ul)*weight
y = self._yl + (self._yr - self._yl)*weight

if self._nspecies:
mass = eos.get_density(pressure, temperature,
species_mass_fractions=y)
else:
mass = pressure/temperature/eos.gas_const()

specmass = mass * y
mom = mass * velocity
if self._nspecies:
internal_energy = \
eos.get_internal_energy(temperature,
species_mass_fractions=y)
else:
internal_energy = pressure/mass/(eos.gamma() - 1)

kinetic_energy = 0.5 * np.dot(velocity, velocity)
energy = mass * (internal_energy + kinetic_energy)

return make_conserved(dim=self._dim, mass=mass, energy=energy,
momentum=mom, species_mass=specmass)


class PlanarPoiseuille:
r"""Initializer for the planar Poiseuille case.

Expand Down