ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_EOS.H File Reference
#include <ERF_Constants.H>
#include <AMReX.H>
#include <AMReX_IntVect.H>
#include <AMReX_MFIter.H>
#include <cmath>
Include dependency graph for ERF_EOS.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getThgivenPandT (const amrex::Real T, const amrex::Real P, const amrex::Real rdOcp)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenPandTh (const amrex::Real P, const amrex::Real th, const amrex::Real rdOcp)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh (const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real qv=0.0)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getThgivenRandT (const amrex::Real rho, const amrex::Real T, const amrex::Real rdOcp, const amrex::Real qv=0.0)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh (const amrex::Real rhotheta, const amrex::Real qv=0.)
 
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=0.0)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenTandPress (const amrex::Real T, const amrex::Real p, const amrex::Real qv=0.0)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getdPdRgivenConstantTheta (const amrex::Real rho, const amrex::Real theta, const amrex::Real qv=0.0)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenP (const amrex::Real P, const amrex::Real rdOcp)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenRTh (const amrex::Real rhotheta, const amrex::Real rdOcp, const amrex::Real qv=0.0)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhoThetagivenP (const amrex::Real p, const amrex::Real qv=0.0)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_vapor_pressure (const amrex::Real p_s, const amrex::Real RH)
 

Function Documentation

◆ compute_vapor_pressure()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_vapor_pressure ( const amrex::Real  p_s,
const amrex::Real  RH 
)
185 {
186  return p_s*RH;
187 }

◆ getdPdRgivenConstantTheta()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getdPdRgivenConstantTheta ( const amrex::Real  rho,
const amrex::Real  theta,
const amrex::Real  qv = 0.0 
)

Function to return dP/drho at constant theta

@params[in ] rho density @params[in ] theta potential temperature @params[in ] qv water vapor @params[ out] pressure

131 {
132  // We should be using moist value of theta when using moisture
133  // theta_m = theta * (1 + R_v/R_d*qv)
134  return Gamma * p_0 * std::pow( (R_d * theta * (amrex::Real(1.0) + R_v/R_d*qv) * ip_0), Gamma) * std::pow(rho, Gamma-1.0) ;
135 }
constexpr amrex::Real R_v
Definition: ERF_Constants.H:11
constexpr amrex::Real ip_0
Definition: ERF_Constants.H:24
constexpr amrex::Real p_0
Definition: ERF_Constants.H:18
constexpr amrex::Real R_d
Definition: ERF_Constants.H:10
constexpr amrex::Real Gamma
Definition: ERF_Constants.H:19
@ theta
Definition: ERF_MM5.H:20
@ rho
Definition: ERF_Kessler.H:30
@ qv
Definition: ERF_Kessler.H:36

Referenced by HSEutils::init_isentropic_hse(), and HSEutils::init_isentropic_hse_terrain().

Here is the caller graph for this function:

◆ getExnergivenP()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenP ( const amrex::Real  P,
const amrex::Real  rdOcp 
)

Function to return the Exner function pi given pressure @params[in ] p pressure @params[in ] rdOcp ratio of R_d to c_p @params[ out] Exner function

145 {
146  // Exner function pi in terms of P
147  return std::pow(P * ip_0, rdOcp);
148 }

Referenced by ERF::erf_enforce_hse().

Here is the caller graph for this function:

◆ getExnergivenRTh()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenRTh ( const amrex::Real  rhotheta,
const amrex::Real  rdOcp,
const amrex::Real  qv = 0.0 
)

Function to return the Exner function pi given density times potential temperature

@params[in ] rhotheta density times potential temperature @params[in ] rdOcp ratio of R_d to c_p @params[in ] qv water vapor @params[ out] Exner function

160 {
161  // Exner function pi in terms of (rho theta)
162  // We should be using moist value of theta when using moisture
163  // theta_m = theta * (1 + R_v/R_d*qv)
164  return std::pow(R_d * rhotheta * (1.0 + R_v/R_d*qv) * ip_0, Gamma * rdOcp);
165 }

Referenced by init_bx_scalars_from_input_sounding_hse().

Here is the caller graph for this function:

◆ getPgivenRTh()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh ( const amrex::Real  rhotheta,
const amrex::Real  qv = 0. 
)

Function to return pressure given density times theta

@params[in ] rhotheta density times potential temperature @params[in ] qv water vapor @params[ out] pressure

85 {
86  return p_0 * std::pow(R_d * rhotheta * ( amrex::Real(1.0) + (R_v/R_d)*qv) * ip_0, Gamma);
87 }

Referenced by SAM::Compute_Coefficients(), Kessler::Copy_State_to_Micro(), SAM::Copy_State_to_Micro(), SatAdj::Copy_State_to_Micro(), ERF::derive_diag_profiles(), ERF::derive_diag_profiles_stag(), derived::erf_dersoundspeed(), erf_slow_rhs_pre(), ERF::estTimeStep(), init_bx_scalars_from_input_sounding_hse(), HSEutils::init_isentropic_hse(), HSEutils::init_isentropic_hse_terrain(), Radiation::initialize(), ERF::MakeHorizontalAverages(), and ERF::WritePlotFile().

Here is the caller graph for this function:

◆ getRhogivenTandPress()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenTandPress ( const amrex::Real  T,
const amrex::Real  p,
const amrex::Real  qv = 0.0 
)

Function to return density given temperature and pressure

@params[in ] theta potential temperature @params[in ] p pressure @params[in ] rdOcp ratio of R_d to c_p @params[in ] qv water vapor @params[ out] density

117 {
118  return p / ( R_d * T * (amrex::Real(1.0) + (R_v/R_d)*qv) );
119 }
@ T
Definition: ERF_IndexDefines.H:99

◆ getRhogivenThetaPress()

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 = 0.0 
)

Function to return density given theta and pressure

@params[in ] theta potential temperature @params[in ] p pressure @params[in ] rdOcp ratio of R_d to c_p @params[in ] qv water vapor @params[ out] density

100 {
101  // We should be using moist value of theta when using moisture
102  // theta_m = theta * (1 + R_v/R_d*qv)
103  return std::pow(p_0, rdOcp) * std::pow(p, iGamma) / (R_d * th * (amrex::Real(1.0) + R_v/R_d*qv) );
104 }
constexpr amrex::Real iGamma
Definition: ERF_Constants.H:26

Referenced by InputSoundingData::calc_rho_p(), and HSEutils::Newton_Raphson_hse().

Here is the caller graph for this function:

◆ getRhoThetagivenP()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhoThetagivenP ( const amrex::Real  p,
const amrex::Real  qv = 0.0 
)

Function to return (rho theta) given pressure

@params[in ] p pressure @params[in ] qv water vapor @params[ out] density times potential temperature

176 {
177  // diagnostic relation for the full pressure
178  // see https://erf.readthedocs.io/en/latest/theory/NavierStokesEquations.html
179  // For cases with moisture, theta = theta_m / (1 + R_v/R_d*qv)
180  return std::pow(p*std::pow(p_0, Gamma-1), iGamma) * iR_d / (1.0 + R_v/R_d*qv) ;
181 }
constexpr amrex::Real iR_d
Definition: ERF_Constants.H:25

Referenced by buoyancy_dry_anelastic_T(), ERF::erf_enforce_hse(), init_bx_scalars_from_input_sounding_hse(), ERF::init_from_hse(), and ERF::ReadCheckpointFile().

Here is the caller graph for this function:

◆ getTgivenPandTh()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenPandTh ( const amrex::Real  P,
const amrex::Real  th,
const amrex::Real  rdOcp 
)

Function to return temperature given pressure and potential temperature

@params[in ] P pressure @params[in ] th potential temperature @params[in ] rdOcp ratio of R_d to c_p @params[ out] temperature

33 {
34  return th / std::pow(p_0/P, rdOcp);
35 }

Referenced by buoyancy_dry_anelastic_T(), buoyancy_dry_Tpert(), and buoyancy_moist_Tpert().

Here is the caller graph for this function:

◆ getTgivenRandRTh()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh ( const amrex::Real  rho,
const amrex::Real  rhotheta,
const amrex::Real  qv = 0.0 
)

Function to return temperature given density and potential temperature

@params[in ] rho density @params[in ] rhotheta (density times potential temperature) @params[in ] qv water vapor @params[ out] temperature

47 {
48  // rho and rhotheta are dry values. We should be using moist value of theta when using moisture
49  // theta_m = theta * (1 + R_v/R_d*qv)
50  amrex::Real p_loc = p_0 * std::pow(R_d * rhotheta * (1.0 + R_v/R_d*qv) * ip_0, Gamma);
51 
52  // p = rho_d * R_d * T_v (not T)
53  // T_v = T * (1 + R_v/R_d*qv)
54  return p_loc / (R_d * rho * (1.0 + R_v/R_d*qv) );
55 }

Referenced by buoyancy_dry_Tpert(), buoyancy_moist_Tpert(), SAM::Compute_Coefficients(), Kessler::Copy_State_to_Micro(), SAM::Copy_State_to_Micro(), SatAdj::Copy_State_to_Micro(), derived::erf_dermoisttemp(), derived::erf_dertemp(), Radiation::initialize(), and ERF::WritePlotFile().

Here is the caller graph for this function:

◆ getThgivenPandT()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getThgivenPandT ( const amrex::Real  T,
const amrex::Real  P,
const amrex::Real  rdOcp 
)

Function to return potential temperature given pressure and temperature

@params[in ] P pressure @params[in ] T temperature @params[in ] rdOcp ratio of R_d to c_p @params[ out] potential temperature

19 {
20  return T * std::pow(p_0/P, rdOcp);
21 }

Referenced by SatAdj::AdvanceSatAdj(), SAM::Cloud(), and SAM::Precip().

Here is the caller graph for this function:

◆ getThgivenRandT()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getThgivenRandT ( const amrex::Real  rho,
const amrex::Real  T,
const amrex::Real  rdOcp,
const amrex::Real  qv = 0.0 
)

Function to return potential temperature given density and temperature

@params[in ] rho density @params[in ] T temperature @params[in ] rdOcp ratio of R_d to c_p @params[in ] qv water vapor @params[ out] potential temperature

68 {
69  // p = rho_d * R_d * T_moist
70  amrex::Real p_loc = rho * R_d * T * (1.0 + R_v/R_d*qv);
71 
72  // theta_d = T * (p0/p)^(R_d/C_p)
73  return T * std::pow((p_0/p_loc),rdOcp);
74 }

Referenced by ReadBndryPlanes::read_file().

Here is the caller graph for this function: