Skip to content

Commit

Permalink
fixed unstart 3D init
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson2981 committed Aug 15, 2024
1 parent 93f6419 commit 5884e69
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
16 changes: 6 additions & 10 deletions y3prediction/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2683,6 +2683,7 @@ def inlet_ramp_pressure(t):
dim=dim,
nspecies=nspecies,
disc_sigma=500.,
disc_loc=shock_loc_x,
pressure_bulk=pres_bkrnd,
temperature_bulk=temp_bkrnd,
velocity_bulk=vel_outflow,
Expand Down Expand Up @@ -5032,15 +5033,13 @@ def inflow_ramp_pressure(t):
mach=inlet_mach,
p_fun=inflow_ramp_pressure)
else:
smooth_r0 = fluid_nodes
smooth_r0[1] = actx.np.zeros_like(fluid_nodes[0])
smooth_r0[2] = actx.np.zeros_like(fluid_nodes[0])
r0 = np.zeros(shape=(dim,))
inflow_state = IsentropicInflow(
dim=dim,
temp_wall=temp_wall,
temp_sigma=temp_sigma,
vel_sigma=vel_sigma,
smooth_r0=smooth_r0,
smooth_r0=r0,
smooth_r1=0.013,
normal_dir=normal_dir,
gamma=gamma,
Expand Down Expand Up @@ -5415,15 +5414,13 @@ def _sponge_sigma(sponge_field, x_vec):
thickness=outlet_sponge_thickness,
amplitude=sponge_amp,
direction=1)
#sponge_init_top = InitSponge(x0=top_sponge_x0,
#thickness=top_sponge_thickness,
#amplitude=sponge_amp,
#direction=1)

def _sponge_sigma(sponge_field, x_vec):
sponge_field = sponge_init_outlet(sponge_field=sponge_field, x_vec=x_vec)
sponge_field = sponge_init_inlet(sponge_field=sponge_field, x_vec=x_vec)
sponge_field = sponge_init_top(sponge_field=sponge_field, x_vec=x_vec)
if dim == 2:
sponge_field = sponge_init_top(
sponge_field=sponge_field, x_vec=x_vec)
return sponge_field

sponge_sigma = actx.np.zeros_like(restart_cv.mass)
Expand Down Expand Up @@ -5948,7 +5945,6 @@ def my_write_viz(step, t, t_wall, viz_state, viz_dv,
if viz_level > 2:

if use_species_limiter:
print(f"{theta_rho.shape=}")
viz_ext = [("theta_rho", theta_rho),
("theta_Y", theta_Y),
("theta_pressure", theta_pres)]
Expand Down
13 changes: 6 additions & 7 deletions y3prediction/unstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InitUnstartRamp:
.. automethod:: add_injection
"""

def __init__(self, *, dim=2, nspecies=0, disc_sigma,
def __init__(self, *, dim=2, nspecies=0, disc_sigma, disc_loc,
pressure_bulk, temperature_bulk, velocity_bulk,
mass_frac_bulk,
pressure_inlet, temperature_inlet, velocity_inlet,
Expand All @@ -44,6 +44,7 @@ def __init__(self, *, dim=2, nspecies=0, disc_sigma,
self._dim = dim
self._nspecies = nspecies
self._disc_sigma = disc_sigma
self._disc_loc = disc_loc
self._temp_wall = temp_wall
self._temp_sigma = temp_sigma
self._vel_sigma = vel_sigma
Expand Down Expand Up @@ -135,7 +136,7 @@ def inlet_smoothing_func(self, x_vec, sigma):
else:
r1 = 0.013
radius = actx.np.sqrt((x_vec[1])**2 + (x_vec[2])**2)
smth_radial = smooth_step(actx, -sigma*(radius - r1))
smth_radial = smooth_step(actx, sigma*actx.np.abs(radius - r1))
return smth_radial

def outlet_smoothing_func(self, x_vec, sigma):
Expand All @@ -150,7 +151,7 @@ def outlet_smoothing_func(self, x_vec, sigma):
else:
r1 = 0.2
radius = actx.np.sqrt((x_vec[1])**2 + (x_vec[2])**2)
smth_radial = smooth_step(actx, -sigma*(radius - r1))
smth_radial = smooth_step(actx, sigma*actx.np.abs(radius - r1))
return smth_radial

def add_inlet(self, cv, pressure, temperature, x_vec, eos, *, time=0.0):
Expand Down Expand Up @@ -183,11 +184,9 @@ def add_inlet(self, cv, pressure, temperature, x_vec, eos, *, time=0.0):

# initial discontinuity location
if self._dim == 2:
y0 = -0.325
dist = y0 - x_vec[1]
dist = self._disc_loc - x_vec[1]
else:
x0 = -0.325
dist = x0 - x_vec[0]
dist = self._disc_loc - x_vec[0]

# now solve for T, P, velocity
xtanh = self._disc_sigma*dist
Expand Down
3 changes: 2 additions & 1 deletion y3prediction/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ def __init__(self, *, dim, T0, P0, mass_frac, mach, gamma,
self._x0 = smooth_x0
self._y0 = smooth_y0
self._z0 = smooth_z0
self._r0 = smooth_r0
self._x1 = smooth_x1
self._y1 = smooth_y1
self._z1 = smooth_z1
Expand All @@ -517,6 +516,8 @@ def __init__(self, *, dim, T0, P0, mass_frac, mach, gamma,
if smooth_r0 is None:
self._r0 = np.zeros(shape=(dim,))
self._r0[0] = 1
else:
self._r0 = smooth_r0

if normal_dir is None:
self._normal_dir = np.zeros(shape=(dim,))
Expand Down

0 comments on commit 5884e69

Please sign in to comment.