Skip to content

Commit 2baab77

Browse files
committed
updated test initial condition files to work with latest UserDataInit structure
1 parent 45f93b0 commit 2baab77

File tree

5 files changed

+39
-278
lines changed

5 files changed

+39
-278
lines changed

src/pybella/tests/test_internal_long_wave.py

Lines changed: 13 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,47 @@
11
import numpy as np
22

3-
from ..flow_solver.utils import options as opts, boundary as bdry, variable as var
3+
from ..utils import options as opts
4+
5+
from ..flow_solver.utils import boundary as bdry, variable as var
46
from ..flow_solver.physics import hydrostatics
57

68
from ..utils.data_structures import DiagnosticState
79

810

911
class UserData(object):
10-
NSPEC = 1
11-
BUOY = 0
12-
13-
grav = 9.81
14-
omega = 7.292 * 1e-5 # [s^{-1}]
15-
16-
R_gas = 287.4
17-
R_vap = 461.0
18-
Q_vap = 2.53e06
19-
gamma = 1.4
20-
21-
h_ref = 10000.0
22-
t_ref = 100.0
23-
T_ref = 300.00
24-
p_ref = 1e5
25-
u_ref = h_ref / t_ref
26-
rho_ref = p_ref / (R_gas * T_ref)
27-
28-
Nsq_ref = 1.0e-4
29-
3012
# planetary -> 160.0; long-wave -> 20.0; standard -> 1.0;
3113
scale_factor = 20.0
3214

33-
i_gravity = np.zeros((3))
34-
i_coriolis = np.zeros((3))
35-
36-
tout = np.zeros((2))
37-
3815
def __init__(self):
3916
self.scale_factor = self.scale_factor
4017

41-
self.h_ref = self.h_ref
42-
self.t_ref = self.t_ref
43-
self.T_ref = self.T_ref
44-
self.p_ref = self.p_ref
45-
self.rho_ref = self.rho_ref
46-
self.u_ref = self.u_ref
47-
self.Nsq_ref = self.Nsq_ref
48-
self.g_ref = self.grav
49-
self.gamm = self.gamma
50-
self.Rg_over_Rv = self.R_gas / self.R_vap
51-
self.Q = self.Q_vap / (self.R_gas * self.T_ref)
52-
53-
self.nspec = self.NSPEC
54-
55-
self.is_nonhydrostatic = 1
56-
self.is_compressible = 1
57-
self.is_ArakawaKonor = 0
58-
59-
self.compressibility = 0.0
60-
self.acoustic_timestep = 0
61-
self.Msq = self.u_ref * self.u_ref / (self.R_gas * self.T_ref)
18+
self.h_ref = 10000.0 # [m]
19+
self.t_ref = 100.0 # [s]
20+
self.T_ref = 300.00 # [K]
21+
self.p_ref = 1e5 # [Pa]
22+
self.omega = 7.292 * 1e-5 # [s^{-1}]
23+
self.grav = 9.81 # [m/s^2]
24+
self.R_gas = 287.4 # [J kg^{-1} K^{-1}]
25+
self.u_ref = self.h_ref / self.t_ref # [m/s]
26+
self.Nsq_ref = 1.0e-4 # [s^{-2}]
27+
self.Msq = self.u_ref * self.u_ref / (self.R_gas * self.T_ref) # Mach number squared
6228

6329
self.gravity_strength = np.zeros((3))
64-
self.coriolis_strength = np.zeros((3))
6530

6631
self.gravity_strength[1] = self.grav * self.h_ref / (self.R_gas * self.T_ref)
67-
self.coriolis_strength[0] = self.omega * self.t_ref
68-
# self.coriolis_strength[2] = self.omega * self.t_ref
69-
# self.coriolis_strength[1] = self.omega * self.t_ref
7032

7133
gravity_mask = (self.gravity_strength > np.finfo(np.float64).eps) | (np.arange(3) == 1)
7234
self.i_gravity = gravity_mask.astype(int)
7335
if np.any(gravity_mask):
7436
self.gravity_direction = np.where(gravity_mask)[0][-1] # Use last matching index
7537

76-
coriolis_mask = self.coriolis_strength > np.finfo(np.float64).eps
77-
self.i_coriolis = coriolis_mask.astype(int)
78-
7938
self.xmin = -15.0 * self.scale_factor
8039
self.xmax = 15.0 * self.scale_factor
8140
self.ymin = 0.0
8241
self.ymax = 1.0
8342
self.zmin = -1.0
8443
self.zmax = 1.0
8544

86-
self.u_wind_speed = 0.0 * 20.0 / self.u_ref
87-
self.v_wind_speed = 0.0
88-
self.w_wind_speed = 0.0
8945

9046
self.bdry_type = np.empty((3), dtype=object)
9147
self.bdry_type[0] = opts.BdryType.PERIODIC
@@ -110,36 +66,15 @@ def __init__(self):
11066
self.dtfixed = 1.0
11167

11268
self.inx = 301 + 1
113-
# self.inx = 1205+1
11469
self.iny = 10 + 1
115-
# self.iny = 40+1
11670
self.inz = 1
11771

118-
self.limiter_type_scalars = opts.LimiterType.NONE
119-
self.limiter_type_velocity = opts.LimiterType.NONE
120-
121-
self.initial_projection = False
122-
123-
self.do_advection = True
124-
12572
self.tout = [self.scale_factor * 1.0 * 3000.0 / self.t_ref]
12673

12774
self.tol = 1.0e-12
12875
self.stepmax = 31
12976
self.max_iterations = 6000
13077

131-
self.continuous_blending = False
132-
self.no_of_pi_initial = 0
133-
self.no_of_pi_transition = 0
134-
self.no_of_hy_initial = 1
135-
self.no_of_hy_transition = 0
136-
137-
self.blending_weight = 0.0 / 16
138-
self.blending_mean = "rhoY" # 1.0, rhoY
139-
self.blending_conv = "rho" # theta, rho
140-
self.blending_type = "half" # half, full
141-
142-
self.initial_blending = False
14378

14479
self.autogen_fn = False
14580

src/pybella/tests/test_lamb_wave.py

Lines changed: 14 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,29 @@
11
import numpy as np
22

3-
from ..flow_solver.utils import options as opts, boundary as bdry
3+
from ..utils import options as opts
4+
5+
from ..flow_solver.utils import boundary as bdry
46

57
from ..flow_solver.physics import hydrostatics
68

79
from ..utils.data_structures import DiagnosticState
810

911

1012
class UserData(object):
11-
NSPEC = 1
12-
grav = 9.81 # [m s^{-2}]
13-
omega = 0.0 * 1e-5 # [s^{-1}]
14-
15-
R_gas = 287.4 # [J kg^{-1} K^{-1}]
16-
R_vap = 461.0
17-
Q_vap = 2.53e06
18-
gamma = 1.4
19-
cp_gas = gamma * R_gas / (gamma - 1.0)
20-
21-
p_ref = 1e5
22-
T_ref = 300.00 # [K]
23-
rho_ref = p_ref / (R_gas * T_ref)
24-
N_ref = grav / np.sqrt(cp_gas * T_ref)
25-
Cs = np.sqrt(gamma * R_gas * T_ref)
26-
27-
h_ref = 10.0e3 # [m]
28-
t_ref = 100.0 # [s]
29-
u_ref = h_ref / t_ref
30-
31-
i_gravity = np.zeros((3))
32-
i_coriolis = np.zeros((3))
3313

3414
def __init__(self):
35-
self.h_ref = self.h_ref
36-
self.t_ref = self.t_ref
37-
self.T_ref = self.T_ref
38-
self.p_ref = self.p_ref
39-
self.rho_ref = self.rho_ref
40-
self.u_ref = self.u_ref
41-
self.Nsq_ref = self.N_ref * self.N_ref
42-
self.g_ref = self.grav
43-
self.gamm = self.gamma
44-
self.Rg_over_Rv = self.R_gas / self.R_vap
45-
self.Q = self.Q_vap / (self.R_gas * self.T_ref)
46-
self.R_gas = self.R_gas
15+
self.grav= 9.81
16+
self.h_ref = 10.0e3 # [m]
17+
self.t_ref = 100.0 # [s]
18+
self.T_ref = 300.00 # [K]
19+
self.p_ref = 1e5
20+
self.u_ref = self.h_ref / self.t_ref
21+
self.R_gas = 287.4
22+
self.gamm = 1.4
23+
self.Cs = np.sqrt(self.gamm * self.R_gas * self.T_ref)
24+
self.cp_gas = self.gamm * self.R_gas / (self.gamm - 1.0)
25+
self.N_ref = self.grav / np.sqrt(self.cp_gas * self.T_ref)
4726
self.Rg = self.R_gas / (self.h_ref**2 / self.t_ref**2 / self.T_ref)
48-
self.cp_gas = self.cp_gas
49-
50-
self.nspec = self.NSPEC
5127

5228
self.is_nonhydrostatic = 1
5329
self.is_compressible = 1
@@ -61,16 +37,12 @@ def __init__(self):
6137
self.coriolis_strength = np.zeros((3))
6238

6339
self.gravity_strength[1] = self.grav * self.h_ref / (self.R_gas * self.T_ref)
64-
self.coriolis_strength[2] = 2.0 * self.omega * self.t_ref
6540

6641
gravity_mask = (self.gravity_strength > np.finfo(np.float64).eps) | (np.arange(3) == 1)
6742
self.i_gravity = gravity_mask.astype(int)
6843
if np.any(gravity_mask):
6944
self.gravity_direction = np.where(gravity_mask)[0][-1] # Use last matching index
7045

71-
coriolis_mask = self.coriolis_strength > np.finfo(np.float64).eps
72-
self.i_coriolis = coriolis_mask.astype(int)
73-
7446
j = 4.0
7547
Lx = 1.0 * np.pi * self.Cs / self.N_ref * j
7648
self.xmin = -Lx / self.h_ref
@@ -80,14 +52,6 @@ def __init__(self):
8052
self.zmin = -1.0
8153
self.zmax = 1.0
8254

83-
self.u_wind_speed = 0.0 * self.u_ref
84-
self.v_wind_speed = 0.0
85-
self.w_wind_speed = 0.0
86-
87-
self.bdry_type = np.empty((3), dtype=object)
88-
self.bdry_type[0] = opts.BdryType.PERIODIC
89-
self.bdry_type[1] = opts.BdryType.WALL
90-
self.bdry_type[2] = opts.BdryType.WALL
9155
self.ATMOSPHERIC_EXTENSION = True
9256
self.rayleigh_bdry_switch = False
9357

@@ -103,29 +67,9 @@ def __init__(self):
10367
self.dtfixed0 = 10.0 / self.t_ref
10468
self.dtfixed = self.dtfixed0
10569

106-
self.do_advection = True
107-
self.limiter_type_scalars = opts.LimiterType.NONE
108-
self.limiter_type_velocity = opts.LimiterType.NONE
109-
11070
self.tol = 1.0e-30
11171
self.max_iterations = 10000
11272

113-
# blending parameters
114-
self.perturb_type = "pos_perturb"
115-
self.blending_mean = "rhoY" # 1.0, rhoY
116-
self.blending_conv = "rho" # theta, rho
117-
self.blending_type = "half" # half, full
118-
119-
self.continuous_blending = False
120-
self.no_of_pi_initial = 1
121-
self.no_of_pi_transition = 0
122-
self.no_of_hy_initial = 0
123-
self.no_of_hy_transition = 0
124-
125-
self.blending_weight = 0.0 / 16
126-
self.initial_blending = False
127-
self.initial_projection = True
128-
12973
self.tout = [360.0]
13074
# self.tout = np.arange(0,361,1.0)
13175
# self.tout = np.append(self.tout, [720.0])
@@ -153,11 +97,6 @@ def __init__(self):
15397
self.stratification = self.stratification_wrapper
15498
self.init_forcing = self.forcing
15599

156-
self.rayleigh_forcing = False
157-
self.rayleigh_forcing_type = "func" # func or file
158-
self.rayleigh_forcing_fn = None
159-
self.rayleigh_forcing_path = None
160-
161100
def stratification_wrapper(self, dy):
162101
return lambda y: self.stratification_function(y, dy)
163102

@@ -294,11 +233,6 @@ def sol_init(Sol, mpv, elem, node, th, ud, seeds=None):
294233
if ud.bdry_type[1] == opts.BdryType.RAYLEIGH:
295234
ud.tcy, ud.tny = bdry.get_tau_y(ud, elem, node, 0.5)
296235

297-
if ud.rayleigh_forcing:
298-
ud.forcing_tcy, ud.forcing_tny = bdry.get_bottom_tau_y(
299-
ud, elem, node, 0.2, cutoff=0.3
300-
)
301-
302236
A0 = 1.0e-1 / ud.u_ref
303237
Msq = ud.Msq
304238
g = ud.gravity_strength[1] * ud.Rg

0 commit comments

Comments
 (0)