ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_InitCustomPert_MultiSpeciesBubble.H File Reference

Go to the source code of this file.

Functions

ParmParse pp_prob ("prob")
 
pp_prob query ("T_0", T_0)
 
pp_prob query ("x_c", x_c)
 
pp_prob query ("y_c", y_c)
 
pp_prob query ("z_c", z_c)
 
pp_prob query ("x_r", x_r)
 
pp_prob query ("y_r", y_r)
 
pp_prob query ("z_r", z_r)
 
pp_prob query ("T_pert", T_pert)
 
pp_prob query ("T_pert_is_airtemp", T_pert_is_airtemp)
 
pp_prob query ("perturb_rho", perturb_rho)
 
pp_prob query ("do_moist_bubble", do_moist_bubble)
 
pp_prob query ("theta_pert", theta_pert)
 
pp_prob query ("eq_pot_temp", eq_pot_temp)
 
pp_prob query ("qt_init", qt_init)
 
pp_prob query ("use_empircal_psat", use_empirical)
 
m_species clear ()
 
ParmParse pp_sdm ("super_droplets_moisture")
 
 if (pp_sdm.contains(species_input.c_str()))
 
 for (int i=0;i< m_num_species;i++)
 
 AMREX_ALWAYS_ASSERT (sc.moisture_type==MoistureType::SuperDroplets)
 
 if (T_0<=0)
 
 if (do_moist_bubble)
 
 AMREX_ALWAYS_ASSERT (n_sp *m_ncomp_per_species==ncomp_species)
 
Gpu::DeviceVector< Realqv_init_d (n_sp)
 
 ParallelFor (bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+0.5) *dx[0];const Real y=prob_lo[1]+(j+0.5) *dx[1];const Real z=prob_lo[2]+(k+0.5) *dx[2];amrex::Real L=0.0;if(x_r > 0) L+=std::pow((x - x_c)/x_r, 2);if(y_r > 0) L+=std::pow((y - y_c)/y_r, 2);if(z_r > 0) L+=std::pow((z - z_c)/z_r, 2);L=std::sqrt(L);if(L< 1.0) { auto rho=state(i, j, k, Rho_comp)+state_pert(i, j, k, Rho_comp);for(int ns=0;ns< n_sp;ns++) { state_pert(i, j, k, nstart+2 *ns)=rho *qv_arr[ns];state_pert(i, j, k, nstart+2 *ns+1)=0.0;} } })
 

Variables

Real T_0 = 300.0
 
Real x_c = 0.0
 
Real y_c = 0.0
 
Real z_c = 0.0
 
Real x_r = 0.0
 
Real y_r = 0.0
 
Real z_r = 0.0
 
Real T_pert = -15.0
 
bool T_pert_is_airtemp = true
 
bool perturb_rho = true
 
bool do_moist_bubble = false
 
Real theta_pert = 2.0
 
Real eq_pot_temp = 320.0
 
Real qt_init = 0.02
 
bool use_empirical = false
 
std::vector< std::string > m_species
 
int m_num_species = 0
 
const int m_ncomp_per_species = 2
 
const int m_nstart_sp = RhoQ3_comp+1
 
std::string species_input = "species"
 
std::vector< amrex::Realm_qv_init_species = std::vector<amrex::Real>(m_num_species,0.0)
 
const auto khi = geomdata.Domain().bigEnd()[2]
 
const Real dz = geomdata.CellSize()[2]
 
const Real rdOcp = sc.rdOcp
 
 else
 
auto n_sp = m_num_species
 
auto nstart = m_nstart_sp
 
int ncomp_species = state_pert.nComp() - nstart
 
auto qv_arr = qv_init_d.data()
 

Function Documentation

◆ AMREX_ALWAYS_ASSERT() [1/2]

AMREX_ALWAYS_ASSERT ( n_sp m_ncomp_per_species = =ncomp_species)

◆ AMREX_ALWAYS_ASSERT() [2/2]

AMREX_ALWAYS_ASSERT ( sc.  moisture_type = =MoistureType::SuperDroplets)

◆ clear()

m_species clear ( )

◆ for()

for ( )
48  {
49  std::string key_str = "qv_init_" + m_species[i];
50  pp_prob.query(key_str.c_str(), m_qv_init_species[i]);
51  }
ParmParse pp_prob("prob")
std::vector< amrex::Real > m_qv_init_species
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:47
std::vector< std::string > m_species
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:27

Referenced by ComputeTurbulentViscosity(), fine_compute_interior_ghost_rhs(), and ERF::Write3DPlotFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ if() [1/3]

if ( do_moist_bubble  )
69  {
70  Vector<Real> h_r(khi+2);
71  Vector<Real> h_p(khi+2);
72  Vector<Real> h_t(khi+2);
73  Vector<Real> h_q_v(khi+2);
74 
75  Gpu::DeviceVector<Real> d_r(khi+2);
76  Gpu::DeviceVector<Real> d_p(khi+2);
77  Gpu::DeviceVector<Real> d_t(khi+2);
78  Gpu::DeviceVector<Real> d_q_v(khi+2);
79 
80  HSEutils::init_isentropic_hse_no_terrain(h_t.data(), h_r.data(), h_p.data(),
82 
83  Gpu::copy(Gpu::hostToDevice, h_r.begin(), h_r.end(), d_r.begin());
84  Gpu::copy(Gpu::hostToDevice, h_p.begin(), h_p.end(), d_p.begin());
85  Gpu::copy(Gpu::hostToDevice, h_t.begin(), h_t.end(), d_t.begin());
86  Gpu::copy(Gpu::hostToDevice, h_q_v.begin(), h_q_v.end(), d_q_v.begin());
87 
88  Real* theta_back = d_t.data();
89  Real* p_back = d_p.data();
90  Real* q_v_back = d_q_v.data();
91 
92  int which_zone = -1;
93 
94  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
95  {
96  // Geometry (note we must include these here to get the data on device)
97  const auto prob_lo = geomdata.ProbLo();
98  const auto dx = geomdata.CellSize();
99 
100  const auto x = prob_lo[0] + (i + 0.5) * dx[0];
101  const auto y = prob_lo[1] + (j + 0.5) * dx[1];
102  const auto z = prob_lo[2] + (k + 0.5) * dx[2];
103 
104  Real rad, delta_theta, theta_total, rho, RH;
105 
106  // Introduce the warm bubble.
107  // Assume that the bubble is pressure matched with the background
108  rad = 0.0;
109  if (x_r > 0) rad += std::pow((x - x_c)/x_r, 2);
110  if (y_r > 0) rad += std::pow((y - y_c)/y_r, 2);
111  if (z_r > 0) rad += std::pow((z - z_c)/z_r, 2);
112  rad = std::sqrt(rad);
113 
114  if (rad <= 1.0){
115  delta_theta = theta_pert*std::pow(cos(PI*rad/2.0),2);
116  } else {
117  delta_theta = 0.0;
118  }
119 
120  theta_total = theta_back[k]*(delta_theta/300.0 + 1);
121  Real T = getTgivenPandTh(p_back[k], theta_total, (R_d/Cp_d));
122  rho = p_back[k]/(R_d*T*(1.0 + (R_v/R_d)*q_v_back[k]));
123  RH = 1.0; // compute_relative_humidity();
124  Real q_v_hot = HSEutils::vapor_mixing_ratio(p_back[k], T, RH, use_empirical, which_zone);
125 
126  // Compute background quantities
127  Real T_back = getTgivenPandTh(p_back[k], theta_back[k], (R_d/Cp_d));
128  Real rho_back = p_back[k]/(R_d*T_back*(1.0 + (R_v/R_d)*q_v_back[k]));
129 
130  // This version perturbs rho but not p
131  state_pert(i, j, k, RhoTheta_comp) = rho*theta_total - rho_back*theta_back[k]*(1.0 + (R_v/R_d)*q_v_back[k]);
132  state_pert(i, j, k, Rho_comp) = rho - rho_back*(1.0 + qt_init);
133 
134  // mean states
135  state_pert(i, j, k, RhoQ1_comp) = rho*q_v_hot;
136  });
137  } else {
constexpr amrex::Real R_v
Definition: ERF_Constants.H:11
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:12
constexpr amrex::Real PI
Definition: ERF_Constants.H:6
constexpr amrex::Real R_d
Definition: ERF_Constants.H:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenPandTh(const amrex::Real P, const amrex::Real th, const amrex::Real rdOcp)
Definition: ERF_EOS.H:32
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:42
const Real dx
Definition: ERF_InitCustomPert_ABL.H:23
state_pert(i, j, k, RhoTheta_comp)
Real T_back
Definition: ERF_InitCustomPert_Bubble.H:111
Real rho_back
Definition: ERF_InitCustomPert_Bubble.H:112
Real T
Definition: ERF_InitCustomPert_Bubble.H:105
background fields should have been initialized with erf init_type<< std::endl;} Real qt_init=0.02;pp_prob.query("qt_init", qt_init);Real eq_pot_temp=320.0;pp_prob.query("eq_pot_temp", eq_pot_temp);bool use_empirical=false;pp_prob.query("use_empircal_psat", use_empirical);if(do_moist_bubble) { Vector< Real > h_r(khi+2);Vector< Real > h_p(khi+2);Vector< Real > h_t(khi+2);Vector< Real > h_q_v(khi+2);Gpu::DeviceVector< Real > d_r(khi+2);Gpu::DeviceVector< Real > d_p(khi+2);Gpu::DeviceVector< Real > d_t(khi+2);Gpu::DeviceVector< Real > d_q_v(khi+2);HSEutils::init_isentropic_hse_no_terrain(h_t.data(), h_r.data(), h_p.data(), h_q_v.data(), dz, khi, qt_init, eq_pot_temp, use_empirical, false);Gpu::copyAsync(Gpu::hostToDevice, h_r.begin(), h_r.end(), d_r.begin());Gpu::copyAsync(Gpu::hostToDevice, h_p.begin(), h_p.end(), d_p.begin());Gpu::copyAsync(Gpu::hostToDevice, h_t.begin(), h_t.end(), d_t.begin());Gpu::copyAsync(Gpu::hostToDevice, h_q_v.begin(), h_q_v.end(), d_q_v.begin());Real *theta_back=d_t.data();Real *p_back=d_p.data();Real *q_v_back=d_q_v.data();int moisture_type=1;if(sc.moisture_type==MoistureType::SAM) { moisture_type=1;} else if(sc.moisture_type==MoistureType::SAM_NoIce||sc.moisture_type==MoistureType::SAM_NoPrecip_NoIce) { moisture_type=2;} ParallelFor(bx,[=] AMREX_GPU_DEVICE(int i, int j, int k) { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+0.5) *dx[0];const Real y=prob_lo[1]+(j+0.5) *dx[1];const Real z=prob_lo[2]+(k+0.5) *dx[2];Real rad, delta_theta, theta_total, rho, RH;rad=0.0;if(x_r > rad
Definition: ERF_InitCustomPert_Bubble.H:93
Real q_v_hot
Definition: ERF_InitCustomPert_Bubble.H:108
theta_total
Definition: ERF_InitCustomPert_Bubble.H:104
RH
Definition: ERF_InitCustomPert_Bubble.H:107
rho
Definition: ERF_InitCustomPert_Bubble.H:106
const amrex::Real * prob_lo
Definition: ERF_InitCustomPert_IsentropicVortex.H:16
Real theta_pert
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:22
Real z_c
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:8
Real x_r
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:11
Real x_c
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:6
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+0.5) *dx[0];const Real y=prob_lo[1]+(j+0.5) *dx[1];const Real z=prob_lo[2]+(k+0.5) *dx[2];amrex::Real L=0.0;if(x_r > 0) L+=std::pow((x - x_c)/x_r, 2);if(y_r > 0) L+=std::pow((y - y_c)/y_r, 2);if(z_r > 0) L+=std::pow((z - z_c)/z_r, 2);L=std::sqrt(L);if(L< 1.0) { auto rho=state(i, j, k, Rho_comp)+state_pert(i, j, k, Rho_comp);for(int ns=0;ns< n_sp;ns++) { state_pert(i, j, k, nstart+2 *ns)=rho *qv_arr[ns];state_pert(i, j, k, nstart+2 *ns+1)=0.0;} } })
Real z_r
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:13
Real y_c
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:7
Real eq_pot_temp
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:23
bool use_empirical
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:25
const Real dz
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:56
const auto khi
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:55
Real qt_init
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:24
Real y_r
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:12
Vector< Real > h_t(khi+2)
Gpu::DeviceVector< Real > d_t(khi+2)
Vector< Real > h_q_v(khi+2)
Gpu::DeviceVector< Real > d_p(khi+2)
Gpu::DeviceVector< Real > d_q_v(khi+2)
Vector< Real > h_r(khi+2)
Vector< Real > h_p(khi+2)
Gpu::DeviceVector< Real > d_r(khi+2)
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Real vapor_mixing_ratio(const Real p_b, const Real T_b, const Real RH, const bool use_empirical, int which_zone)
Definition: ERF_HSEUtils.H:337
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE void init_isentropic_hse_no_terrain(Real *theta, Real *r, Real *p, Real *q_v, const Real &dz, const int &khi, const Real q_t, const Real eq_pot_temp, const bool use_empirical, const bool T_from_theta=false, const Real z_tr_1=-1., const Real z_tr_2=-1., const Real theta_0=0., const Real theta_tr=0., const Real T_tr=0.)
Definition: ERF_HSEUtils.H:504
Here is the call graph for this function:

◆ if() [2/3]

if ( pp_sdm.  containsspecies_input.c_str())
36  {
37  int num_species = pp_sdm.countval(species_input.c_str());
38  std::string sp_name;
39  for (int i = 0; i < num_species; i++) {
40  pp_sdm.get(species_input.c_str(), sp_name, i);
41  m_species.push_back(sp_name);
42  }
43  }
std::string species_input
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:35
ParmParse pp_sdm("super_droplets_moisture")
Here is the call graph for this function:

◆ if() [3/3]

if ( T_0<=  0)
60  {
61  amrex::Print() << "Ignoring T_0 = " << T_0
62  << ", background fields should have been initialized with erf.init_type"
63  << std::endl;
64  }
Real T_0
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:3

◆ ParallelFor()

ParallelFor ( bx  ,
[=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=prob_lo[0]+(i+0.5) *dx[0];const Real y=prob_lo[1]+(j+0.5) *dx[1];const Real z=prob_lo[2]+(k+0.5) *dx[2];amrex::Real L=0.0;if(x_r > 0) L+=std::pow((x - x_c)/x_r, 2);if(y_r > 0) L+=std::pow((y - y_c)/y_r, 2);if(z_r > 0) L+=std::pow((z - z_c)/z_r, 2);L=std::sqrt(L);if(L< 1.0) { auto rho=state(i, j, k, Rho_comp)+state_pert(i, j, k, Rho_comp);for(int ns=0;ns< n_sp;ns++) { state_pert(i, j, k, nstart+2 *ns)=rho *qv_arr[ns];state_pert(i, j, k, nstart+2 *ns+1)=0.0;} } }   
)

Referenced by if().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pp_prob()

ParmParse pp_prob ( "prob"  )

Referenced by for().

Here is the caller graph for this function:

◆ pp_sdm()

ParmParse pp_sdm ( "super_droplets_moisture"  )

Referenced by if().

Here is the caller graph for this function:

◆ query() [1/15]

pp_prob query ( "do_moist_bubble"  ,
do_moist_bubble   
)

◆ query() [2/15]

pp_prob query ( "eq_pot_temp"  ,
eq_pot_temp   
)

◆ query() [3/15]

pp_prob query ( "perturb_rho"  ,
perturb_rho   
)

◆ query() [4/15]

pp_prob query ( "qt_init"  ,
qt_init   
)

◆ query() [5/15]

pp_prob query ( "T_0"  ,
T_0   
)

◆ query() [6/15]

pp_prob query ( "T_pert"  ,
T_pert   
)

◆ query() [7/15]

pp_prob query ( "T_pert_is_airtemp"  ,
T_pert_is_airtemp   
)

◆ query() [8/15]

pp_prob query ( "theta_pert"  ,
theta_pert   
)

◆ query() [9/15]

pp_prob query ( "use_empircal_psat"  ,
use_empirical   
)

◆ query() [10/15]

pp_prob query ( "x_c"  ,
x_c   
)

◆ query() [11/15]

pp_prob query ( "x_r"  ,
x_r   
)

◆ query() [12/15]

pp_prob query ( "y_c"  ,
y_c   
)

◆ query() [13/15]

pp_prob query ( "y_r"  ,
y_r   
)

◆ query() [14/15]

pp_prob query ( "z_c"  ,
z_c   
)

◆ query() [15/15]

pp_prob query ( "z_r"  ,
z_r   
)

◆ qv_init_d()

Gpu::DeviceVector<Real> qv_init_d ( n_sp  )

Variable Documentation

◆ do_moist_bubble

bool do_moist_bubble = false

◆ dz

const Real dz = geomdata.CellSize()[2]

Referenced by if().

◆ else

else

◆ eq_pot_temp

◆ khi

const auto khi = geomdata.Domain().bigEnd()[2]

Referenced by if().

◆ m_ncomp_per_species

const int m_ncomp_per_species = 2

◆ m_nstart_sp

const int m_nstart_sp = RhoQ3_comp+1

◆ m_num_species

m_num_species = 0

◆ m_qv_init_species

std::vector<amrex::Real> m_qv_init_species = std::vector<amrex::Real>(m_num_species,0.0)

Referenced by for().

◆ m_species

std::vector<std::string> m_species

Referenced by for(), and if().

◆ n_sp

auto n_sp = m_num_species

Referenced by ParallelFor().

◆ ncomp_species

int ncomp_species = state_pert.nComp() - nstart

◆ nstart

auto nstart = m_nstart_sp

Referenced by ParallelFor().

◆ perturb_rho

bool perturb_rho = true

◆ qt_init

Real qt_init = 0.02

Referenced by if().

◆ qv_arr

◆ rdOcp

const Real rdOcp = sc.rdOcp

◆ species_input

std::string species_input = "species"

Referenced by if().

◆ T_0

Real T_0 = 300.0

Referenced by if().

◆ T_pert

Real T_pert = -15.0

◆ T_pert_is_airtemp

bool T_pert_is_airtemp = true

◆ theta_pert

Real theta_pert = 2.0

Referenced by if().

◆ use_empirical

◆ x_c

Real x_c = 0.0

Referenced by if(), and ParallelFor().

◆ x_r

Real x_r = 0.0

Referenced by if(), and ParallelFor().

◆ y_c

Real y_c = 0.0

Referenced by if(), and ParallelFor().

◆ y_r

Real y_r = 0.0

Referenced by if(), and ParallelFor().

◆ z_c

Real z_c = 0.0

Referenced by if(), and ParallelFor().

◆ z_r

Real z_r = 0.0

Referenced by if(), and ParallelFor().