Skip to content

Commit

Permalink
BF02 Bubble (#1364)
Browse files Browse the repository at this point in the history
* Add BF02 verif studies to bubble dir.

* Fix device functions in bubble.

* Results generated.

---------

Co-authored-by: Aaron Lattanzi <[email protected]>
  • Loading branch information
AMLattanzi and Aaron Lattanzi authored Jan 4, 2024
1 parent 53179f4 commit 31ed2ef
Show file tree
Hide file tree
Showing 10 changed files with 614 additions and 123 deletions.
73 changes: 73 additions & 0 deletions Exec/RegTests/Bubble/inputs_BF02_dry_bubble
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 2000
stop_time = 3600.0

amrex.fpe_trap_invalid = 1

fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY
geometry.prob_extent = 20000.0 312.5 10000.0
amr.n_cell = 256 4 128
geometry.is_periodic = 0 1 0
xlo.type = "SlipWall"
xhi.type = "SlipWall"
zlo.type = "SlipWall"
zhi.type = "SlipWall"

# TIME STEP CONTROL
erf.fixed_dt = 0.5
erf.fixed_mri_dt_ratio = 4
#erf.no_substepping = 1
#erf.fixed_dt = 0.1

# DIAGNOSTICS & VERBOSITY
erf.sum_interval = 1 # timesteps between computing mass
erf.v = 1 # verbosity in ERF.cpp
amr.v = 1 # verbosity in Amr.cpp

# REFINEMENT / REGRIDDING
amr.max_level = 0 # maximum level number allowed

# CHECKPOINT FILES
erf.check_file = chk # root name of checkpoint file
erf.check_int = 100 # number of timesteps between checkpoints

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 100 # number of timesteps between plotfiles
erf.plot_vars_1 = density rhotheta rhoadv_0 x_velocity y_velocity z_velocity pressure theta scalar temp pres_hse dens_hse pert_pres pert_dens

# SOLVER CHOICES
erf.use_gravity = true
erf.use_coriolis = false
erf.use_rayleigh_damping = false

erf.dycore_horiz_adv_type = "Upwind_5th"
erf.dycore_vert_adv_type = "Upwind_5th"
erf.dryscal_horiz_adv_type = "Upwind_5th"
erf.dryscal_vert_adv_type = "Upwind_5th"

# PHYSICS OPTIONS
erf.les_type = "None"
erf.pbl_type = "None"
erf.moisture_model = "NullMoist"
erf.buoyancy_type = 1
erf.use_moist_background = false

erf.molec_diff_type = "ConstantAlpha"
erf.rho0_trans = 1.0 # [kg/m^3], used to convert input diffusivities
erf.dynamicViscosity = 1.0 # [kg/(m-s)] ==> nu = 75.0 m^2/s
erf.alpha_T = 1.0 # [m^2/s]
erf.alpha_C = 1.0

# PROBLEM PARAMETERS (optional)
# warm bubble input
prob.T_pert = 2.0 # theta pert magnitude
prob.x_c = 10000.0
prob.z_c = 2000.0
prob.x_r = 2000.0
prob.z_r = 2000.0
prob.T_0 = 300.0
prob.do_moist_bubble = false
prob.T_pert_is_airtemp = false # Perturb theta
82 changes: 82 additions & 0 deletions Exec/RegTests/Bubble/inputs_BF02_moist_bubble
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 2000
stop_time = 3600.0

amrex.fpe_trap_invalid = 1

fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY
geometry.prob_extent = 20000.0 312.5 10000.0
amr.n_cell = 256 4 128
geometry.is_periodic = 0 1 0
xlo.type = "SlipWall"
xhi.type = "SlipWall"
zlo.type = "SlipWall"
zhi.type = "SlipWall"

# TIME STEP CONTROL
erf.fixed_dt = 0.5
erf.fixed_mri_dt_ratio = 4
#erf.no_substepping = 1
#erf.fixed_dt = 0.1

# DIAGNOSTICS & VERBOSITY
erf.sum_interval = 1 # timesteps between computing mass
erf.v = 1 # verbosity in ERF.cpp
amr.v = 1 # verbosity in Amr.cpp

# REFINEMENT / REGRIDDING
amr.max_level = 0 # maximum level number allowed

# CHECKPOINT FILES
erf.check_file = chk # root name of checkpoint file
erf.check_int = 100 # number of timesteps between checkpoints

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 100 # number of timesteps between plotfiles
erf.plot_vars_1 = density rhotheta rhoQ1 rhoQ2 rhoadv_0 x_velocity y_velocity z_velocity pressure theta scalar temp pres_hse dens_hse pert_pres pert_dens eq_pot_temp qt qv qc

# SOLVER CHOICES
erf.use_gravity = true
erf.use_coriolis = false
erf.use_rayleigh_damping = false

erf.dycore_horiz_adv_type = "Upwind_3rd"
erf.dycore_vert_adv_type = "Upwind_3rd"
erf.dryscal_horiz_adv_type = "Upwind_3rd"
erf.dryscal_vert_adv_type = "Upwind_3rd"
erf.moistscal_horiz_adv_type = "Upwind_3rd"
erf.moistscal_vert_adv_type = "Upwind_3rd"

# PHYSICS OPTIONS
erf.les_type = "None"
erf.pbl_type = "None"
erf.moisture_model = "FastEddy"
erf.buoyancy_type = 1
erf.use_moist_background = true

erf.molec_diff_type = "ConstantAlpha"
erf.rho0_trans = 1.0 # [kg/m^3], used to convert input diffusivities
erf.dynamicViscosity = 1.0 # [kg/(m-s)] ==> nu = 75.0 m^2/s
erf.alpha_T = 1.0 # [m^2/s]
erf.alpha_C = 1.0

# INITIAL CONDITIONS
#erf.init_type = "input_sounding"
#erf.input_sounding_file = "BF02_moist_sounding"
#erf.init_sounding_ideal = true

# PROBLEM PARAMETERS (optional)
# warm bubble input
prob.x_c = 10000.0
prob.z_c = 2000.0
prob.x_r = 2000.0
prob.z_r = 2000.0
prob.T_0 = 300.0

prob.do_moist_bubble = true
prob.theta_pert = 2.0
prob.qt_init = 0.02
prob.eq_pot_temp = 320.0
113 changes: 87 additions & 26 deletions Exec/RegTests/Bubble/prob.H
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,37 @@
#include "EOS.H"

struct ProbParm : ProbParmDefaults {
// background conditions
// if init_type != "" then these are perturbations and should be 0
amrex::Real T_0 = 300.0;
amrex::Real U_0 = 0.0;
amrex::Real V_0 = 0.0;
amrex::Real W_0 = 0.0;

// center of thermal perturbation
amrex::Real x_c = 0.0;
amrex::Real y_c = 0.0;
amrex::Real z_c = 0.0;

// radial extent of thermal perturbation
amrex::Real x_r = 0.0;
amrex::Real y_r = 0.0;
amrex::Real z_r = 0.0;

// perturbation temperature
amrex::Real T_pert = -15.0;
bool T_pert_is_airtemp = true; // T_pert input is air temperature
bool perturb_rho = true; // not rho*theta (i.e., p is constant); otherwise perturb rho*theta

// rayleigh damping
amrex::Real dampcoef = 0.0; // inverse time scale [1/s]
amrex::Real zdamp = 5000.0; // damping depth [m] from model top
// background conditions
// if init_type != "" then these are perturbations and should be 0
amrex::Real T_0 = 300.0;
amrex::Real U_0 = 0.0;
amrex::Real V_0 = 0.0;
amrex::Real W_0 = 0.0;

// center of thermal perturbation
amrex::Real x_c = 0.0;
amrex::Real y_c = 0.0;
amrex::Real z_c = 0.0;

// radial extent of thermal perturbation
amrex::Real x_r = 0.0;
amrex::Real y_r = 0.0;
amrex::Real z_r = 0.0;

// perturbation temperature
amrex::Real T_pert = -15.0;
bool T_pert_is_airtemp = true; // T_pert input is air temperature
bool perturb_rho = true; // not rho*theta (i.e., p is constant); otherwise perturb rho*theta

// rayleigh damping
amrex::Real dampcoef = 0.0; // inverse time scale [1/s]
amrex::Real zdamp = 5000.0; // damping depth [m] from model top

// Moist bubble params
bool do_moist_bubble = false;
amrex::Real theta_pert = 2.0;
amrex::Real qt_init = 0.02;
amrex::Real eq_pot_temp = 320.0;
}; // namespace ProbParm

class Problem : public ProblemBase
Expand Down Expand Up @@ -62,11 +68,66 @@ public:
amrex::Array4<amrex::Real const> const& mf_v,
const SolverChoice& sc) override;

void erf_init_dens_hse_moist (amrex::MultiFab& rho_hse,
std::unique_ptr<amrex::MultiFab>& z_phys_nd,
amrex::Geometry const& geom) override;

void init_custom_terrain (
const amrex::Geometry& geom,
amrex::MultiFab& z_phys_nd,
const amrex::Real& time) override;

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
amrex::Real compute_theta (const amrex::Real T_b, const amrex::Real p_b);

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
amrex::Real compute_temperature (const amrex::Real p_b);

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
amrex::Real compute_F_for_temp(const amrex::Real T_b, const amrex::Real p_b);

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
amrex::Real compute_p_k (amrex::Real& p_k,
const amrex::Real p_k_minus_1,
amrex::Real& theta_k,
amrex::Real& rho_k,
amrex::Real& q_v_k,
amrex::Real& T_dp,
amrex::Real& T_b,
const amrex::Real dz,
const amrex::Real rho_k_minus_1);
AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
amrex::Real compute_F (const amrex::Real& p_k,
const amrex::Real& p_k_minus_1,
amrex::Real &theta_k,
amrex::Real& rho_k,
amrex::Real& q_v_k,
amrex::Real& T_dp,
amrex::Real& T_b,
const amrex::Real& dz,
const amrex::Real& rho_k_minus_1);

AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE
void compute_rho (const amrex::Real& pressure,
amrex::Real &theta,
amrex::Real& rho,
amrex::Real& q_v,
amrex::Real& T_dp,
amrex::Real& T_b);

void init_isentropic_hse_no_terrain(amrex::Real *theta,
amrex::Real* r,
amrex::Real* p,
amrex::Real *q_v,
const amrex::Real& dz,
const int& khi);

#include "Prob/init_rayleigh_damping.H"

protected:
Expand Down Expand Up @@ -111,7 +172,7 @@ perturb_rho_theta (const amrex::Real x,
dT = 0.0;
}
else {
dT = pp.T_pert * (std::cos(PI*L) + 1.0)/2.0;
dT = pp.T_pert * std::pow(cos(PI*L/2.0),2);
}

// Temperature that satisfies the EOS given the hydrostatically balanced (r,p)
Expand Down
Loading

0 comments on commit 31ed2ef

Please sign in to comment.