8 ParmParse pp_erf(
"erf");
63 "prob.bubble_dT and prob.bubble_x_c, bubble_y_c, bubble_z_c must be finite numbers");
66 "prob.bubble_dT needs positive, finite prob.bubble_x_r, bubble_y_r and bubble_z_r");
68 amrex::AllPrint() <<
"Level " << lev <<
": adding a warm bubble prob.bubble_dT = " <<
bubble_dT
72 << (sc.fixed_density[lev] ?
"at the fixed density" :
"at constant pressure")
78 const bool bubble_keys_given =
79 pp_prob.contains(
"bubble_x_c") ||
pp_prob.contains(
"bubble_y_c") ||
80 pp_prob.contains(
"bubble_z_c") ||
pp_prob.contains(
"bubble_x_r") ||
82 if (bubble_keys_given) {
84 amrex::Abort(
"prob.bubble_x_c/y_c/z_c/x_r/y_r/z_r are set but prob.bubble_dT is not: "
85 "set prob.bubble_dT (the bubble's theta excess in K) or remove them");
87 amrex::AllPrint() <<
"WARNING: prob.bubble_dT = 0, so the prob.bubble_* centre and "
88 <<
"radii are not used" << std::endl;
100 const Real
dx = geomdata.CellSize(0);
101 const Real
dy = geomdata.CellSize(1);
137 #ifndef AMREX_USE_GPU
141 amrex::Print() <<
"Adding random rho*theta perturbations" << std::endl;
143 amrex::Print() <<
"Adding random theta perturbations" << std::endl;
147 amrex::Print() <<
"Adding sinusoidal temperature perturbations "
149 <<
" periods" << std::endl;
157 amrex::Print() <<
"WARNING: prob.pert_deltaT has no effect at level " << lev
158 <<
" because fixed_density is set there" << std::endl;
162 ParallelForRNG(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k,
const amrex::RandomEngine& engine) noexcept
166 const Real
z = z_cc(i,j,k);
178 rand_double = amrex::Random(engine);
192 const Real
rr = std::sqrt(rx*rx + ry*ry + rz*rz);
193 if (
rr <= amrex::Real(1)) {
203 const Real rho_new = rhotheta / (rhotheta /
rho + dtheta);
231 const Real damp = std::exp(-
myhalf * zl * zl);
240 const Real Tnew = Told +
tfac * damp * z_agl * std::cos(
cval * (
x -
xc));
272 state_pert(i, j, k,
RhoKE_comp) *= amrex::max(
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenThetaPress(const amrex::Real th, const amrex::Real p, const amrex::Real rdOcp, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:96
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh(const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:46
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getThgivenTandP(const amrex::Real T, const amrex::Real P, const amrex::Real rdOcp)
Definition: ERF_EOS.H:18
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:81
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:65
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78
#define RhoKE_comp
Definition: ERF_IndexDefines.H:63
Real bubble_x_c
Definition: ERF_InitCustomPert_ABL.H:49
const bool bubble_dT_given
Definition: ERF_InitCustomPert_ABL.H:48
const Real prob_lo_z
Definition: ERF_InitCustomPert_ABL.H:104
const Real prob_lo_y
Definition: ERF_InitCustomPert_ABL.H:103
Real bubble_z_c
Definition: ERF_InitCustomPert_ABL.H:51
Real bubble_y_r
Definition: ERF_InitCustomPert_ABL.H:53
int deterministic_ic_pert
Definition: ERF_InitCustomPert_ABL.H:4
Real bubble_x_r
Definition: ERF_InitCustomPert_ABL.H:52
Real T_0_Pert_Mag
Definition: ERF_InitCustomPert_ABL.H:28
const bool add_sinusoidal_T
Definition: ERF_InitCustomPert_ABL.H:120
Real pert_ref_height
Definition: ERF_InitCustomPert_ABL.H:34
const bool use_moisture
Definition: ERF_InitCustomPert_ABL.H:127
Real KE_0
Definition: ERF_InitCustomPert_ABL.H:21
const Real dy
Definition: ERF_InitCustomPert_ABL.H:101
Real rho_0
Definition: ERF_InitCustomPert_ABL.H:18
const Real zc
Definition: ERF_InitCustomPert_ABL.H:112
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:128
Real bubble_z_r
Definition: ERF_InitCustomPert_ABL.H:54
Real rhoKE_0
Definition: ERF_InitCustomPert_ABL.H:22
const Real yc
Definition: ERF_InitCustomPert_ABL.H:111
ParmParse pp_prob("prob")
const bool bubble_reporter
Definition: ERF_InitCustomPert_ABL.H:59
Real bubble_dT
Definition: ERF_InitCustomPert_ABL.H:47
const Real prob_lo_x
Definition: ERF_InitCustomPert_ABL.H:102
const bool bubble_fixed_density
Definition: ERF_InitCustomPert_ABL.H:96
constexpr int temperature_hash_comp
Definition: ERF_InitCustomPert_ABL.H:16
long random_seed
Definition: ERF_InitCustomPert_ABL.H:6
Real T_0
Definition: ERF_InitCustomPert_ABL.H:19
Real pert_deltaV
Definition: ERF_InitCustomPert_ABL.H:33
const Real prob_hi_y
Definition: ERF_InitCustomPert_ABL.H:106
const std::uint64_t ic_pert_seed
Definition: ERF_InitCustomPert_ABL.H:13
const Real tfac
Definition: ERF_InitCustomPert_ABL.H:123
const Real prob_hi_x
Definition: ERF_InitCustomPert_ABL.H:105
const Real cval
Definition: ERF_InitCustomPert_ABL.H:122
Real KE_decay_order
Definition: ERF_InitCustomPert_ABL.H:25
Real pert_deltaU
Definition: ERF_InitCustomPert_ABL.H:32
const Real prob_hi_z
Definition: ERF_InitCustomPert_ABL.H:107
Real KE_decay_height
Definition: ERF_InitCustomPert_ABL.H:24
const bool add_bubble
Definition: ERF_InitCustomPert_ABL.H:55
bool pert_rhotheta
Definition: ERF_InitCustomPert_ABL.H:29
Real pert_periods_T
Definition: ERF_InitCustomPert_ABL.H:97
int fix_random_seed
Definition: ERF_InitCustomPert_ABL.H:5
Real A_0
Definition: ERF_InitCustomPert_ABL.H:20
Real bubble_y_c
Definition: ERF_InitCustomPert_ABL.H:50
const Real xc
Definition: ERF_InitCustomPert_ABL.H:110
Real pert_deltaT
Definition: ERF_InitCustomPert_ABL.H:40
ParallelForRNG(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k, const amrex::RandomEngine &engine) noexcept { const Real x=prob_lo_x+(i+myhalf) *dx;const Real y=prob_lo_y+(j+myhalf) *dy;const Real z=z_cc(i, j, k);const Real z_agl=z - erf_prob_heights::z_ground_cc(i, j, z_sfc_nd);const Real r=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc)+(z-zc) *(z-zc));if((z_agl<=pert_ref_height) &&(T_0_Pert_Mag !=amrex::Real(0))) { Real rand_double;if(deterministic_ic_pert) { rand_double=erf_hash_rng::hash_uniform(i, j, k, temperature_hash_comp, lev, ic_pert_seed);} else { rand_double=amrex::Random(engine);} state_pert(i, j, k, RhoTheta_comp)=(rand_double *amrex::Real(2) - amrex::Real(1)) *T_0_Pert_Mag;if(!pert_rhotheta) { state_pert(i, j, k, RhoTheta_comp) *=r_hse(i, j, k);} } if(add_bubble) { const Real rx=(x - bubble_x_c)/bubble_x_r;const Real ry=(y - bubble_y_c)/bubble_y_r;const Real rz=(z - bubble_z_c)/bubble_z_r;const Real rr=std::sqrt(rx *rx+ry *ry+rz *rz);if(rr<=amrex::Real(1)) { const Real cb=std::cos(myhalf *PI *rr);const Real dtheta=bubble_dT *cb *cb;const Real rho=state(i, j, k, Rho_comp);const Real rhotheta=state(i, j, k, RhoTheta_comp);if(bubble_fixed_density) { state_pert(i, j, k, RhoTheta_comp)+=rho *dtheta;} else { const Real rho_new=rhotheta/(rhotheta/rho+dtheta);state_pert(i, j, k, Rho_comp)+=rho_new - rho;if(use_moisture) { state_pert(i, j, k, RhoQ1_comp)+=(rho_new - rho) *state(i, j, k, RhoQ1_comp)/rho;} } } } if(add_sinusoidal_T) { const Real zl=z_agl/pert_ref_height;const Real damp=std::exp(-myhalf *zl *zl);const Real rho=state(i, j, k, Rho_comp);const Real rhotheta=state(i, j, k, RhoTheta_comp);const Real qv=(use_moisture) ? state(i, j, k, RhoQ1_comp)/rho :amrex::Real(0);const Real Told=getTgivenRandRTh(rho, rhotheta, qv);const Real P=getPgivenRTh(rhotheta, qv);const Real Tnew=Told+tfac *damp *z_agl *std::cos(cval *(x - xc));const Real theta_new=getThgivenTandP(Tnew, P, rdOcp);const Real rho_new=getRhogivenThetaPress(theta_new, P, rdOcp, qv);state_pert(i, j, k, Rho_comp)+=rho_new - rho;if(use_moisture) { state_pert(i, j, k, RhoQ1_comp)+=(rho_new - rho) *qv;} } state_pert(i, j, k, RhoScalar_comp)=A_0 *std::exp(-amrex::Real(10.) *r *r);if(state_pert.nComp() > RhoKE_comp) { if(rhoKE_0 > 0) { state_pert(i, j, k, RhoKE_comp)=rhoKE_0;} else { state_pert(i, j, k, RhoKE_comp)=r_hse(i, j, k) *KE_0;} if(KE_decay_height > 0) { state_pert(i, j, k, RhoKE_comp) *=amrex::max(std::pow(1 - amrex::min(z_agl/KE_decay_height, amrex::Real(1)), KE_decay_order), amrex::Real(1e-12));} } })
const Real dx
Definition: ERF_InitCustomPert_ABL.H:100
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
@ None
Definition: ERF_LSM_Types.H:6
@ P
Definition: ERF_IndexDefines.H:221
@ rho
Definition: ERF_Kessler.H:25
@ qv
Definition: ERF_Kessler.H:31
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real hash_uniform(int i, int j, int k, int comp, int lev, std::uint64_t seed) noexcept
Definition: ERF_HashRNG.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real z_ground_cc(int i, int j, amrex::Array4< amrex::Real const > const &z_sfc_nd) noexcept
Definition: ERF_ProbHeights.H:49
real(c_double), parameter cb
Definition: ERF_module_model_constants.F90:49
real(c_double), private rr
Definition: ERF_module_mp_morr_two_moment.F90:224