ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_MoistPerturbation.H
Go to the documentation of this file.
1 #ifndef ERF_MOIST_PERTURBATION_H_
2 #define ERF_MOIST_PERTURBATION_H_
3 
4 /**
5  * Initial temperature and vapour perturbations of a moist column, applied together.
6  *
7  * Shared by the BOMEX, GATE and RICO setups (and DYCOMS, which uses the RICO one).
8  * rho*theta is held, so the temperature perturbation is stored as a density change;
9  * the vapour mixing ratio after the perturbation is qv + dqv, whatever the density.
10  */
11 
12 #include <AMReX_GpuQualifiers.H>
13 #include <AMReX_REAL.H>
14 
15 #include "ERF_EOS.H"
16 
18 
19 /**
20  * Perturbation of rho and rho*qv for a temperature change dT and a vapour change dqv.
21  *
22  * With perturb_T, the new density gives T = T_old + dT at the pressure of the new state,
23  * P(rho*theta, qv + dqv); with dqv = 0 that is the old pressure. Without perturb_T the
24  * density is left as it is. rho*qv then holds qv + dqv on the new density.
25  *
26  * @param[in] rho dry density of the unperturbed state
27  * @param[in] rhotheta rho*theta of the unperturbed state (held)
28  * @param[in] rhoqv rho*qv of the unperturbed state (0 without moisture)
29  * @param[in] dT temperature change [K]
30  * @param[in] dqv vapour mixing ratio change
31  * @param[in] perturb_T whether the temperature is perturbed
32  * @param[in] moist whether a moisture model is active
33  * @param[in] rdOcp R_d / c_p
34  * @param[out] drho perturbation of rho
35  * @param[out] drhoqv perturbation of rho*qv (0 without moisture)
36  */
37 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
38 void
40  const amrex::Real rhoqv, const amrex::Real dT,
41  const amrex::Real dqv, const bool perturb_T,
42  const bool moist, const amrex::Real rdOcp,
43  amrex::Real& drho, amrex::Real& drhoqv) noexcept
44 {
45  const amrex::Real qv = moist ? rhoqv / rho : amrex::Real(0.0);
46  const amrex::Real qv_new = moist ? qv + dqv : amrex::Real(0.0);
47 
48  amrex::Real rho_new = rho;
49  if (perturb_T) {
50  const amrex::Real T_old = getTgivenRandRTh(rho, rhotheta, qv);
51  const amrex::Real P = getPgivenRTh(rhotheta, qv_new);
52  const amrex::Real theta_new = getThgivenTandP(T_old + dT, P, rdOcp);
53  rho_new = getRhogivenThetaPress(theta_new, P, rdOcp, qv_new);
54  }
55 
56  drho = rho_new - rho;
57  drhoqv = moist ? rho_new * qv_new - rho * qv : amrex::Real(0.0);
58 }
59 
60 } // namespace erf_moist_perturbation
61 
62 #endif
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
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:72
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ P
Definition: ERF_IndexDefines.H:244
@ rho
Definition: ERF_Kessler.H:25
@ qv
Definition: ERF_Kessler.H:31
Definition: ERF_MoistPerturbation.H:17
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void perturb_temperature_and_vapour(const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real rhoqv, const amrex::Real dT, const amrex::Real dqv, const bool perturb_T, const bool moist, const amrex::Real rdOcp, amrex::Real &drho, amrex::Real &drhoqv) noexcept
Definition: ERF_MoistPerturbation.H:39