ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
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 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 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 theta, const amrex::Real p, const amrex::Real rdOcp, 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)
 

Function Documentation

◆ 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] theta potential temperature @params[in] p pressure @params[in] rd0cp ratio of R_d to c_p

91 {
92  // We should be using moist value of theta when using moisture
93  // theta_m = theta * (1 + R_v/R_d*qv)
94  return Gamma * p_0 * std::pow( (R_d * theta * (1.0 + R_v/R_d*qv) * ip_0), Gamma) * std::pow(rho, Gamma-1.0) ;
95 }
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: MM5.H:20
@ rho
Definition: Kessler.H:30
@ qv
Definition: 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] rd0cp ratio of R_d to c_p

104 {
105  // Exner function pi in terms of P
106  return std::pow(P * ip_0, rdOcp);
107 }

Referenced by ERF::erf_enforce_hse(), and init_bx_scalars_from_input_sounding_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 densith times potential temperature

@params[in] rhotheta density times potential temperature @params[in] rd0cp ratio of R_d to c_p

117 {
118  // Exner function pi in terms of (rho theta)
119  // We should be using moist value of theta when using moisture
120  // theta_m = theta * (1 + R_v/R_d*qv)
121  return std::pow(R_d * rhotheta * (1.0 + R_v/R_d*qv) * ip_0, Gamma * rdOcp);
122 }

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

63 {
64  return p_0 * std::pow(R_d * rhotheta * (1.0+(R_v/R_d)*qv) * ip_0, Gamma);
65 }

Referenced by SAM::Compute_Coefficients(), Kessler::Copy_State_to_Micro(), SAM::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:

◆ getRhogivenThetaPress()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenThetaPress ( const amrex::Real  theta,
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] rd0cp ratio of R_d to c_p

76 {
77  // We should be using moist value of theta when using moisture
78  // theta_m = theta * (1 + R_v/R_d*qv)
79  return std::pow(p_0, rdOcp) * std::pow(p, iGamma) / (R_d * theta * (1.0 + R_v/R_d*qv) );
80 }
constexpr amrex::Real iGamma
Definition: ERF_Constants.H:26

Referenced by InputSoundingData::calc_rho_p().

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 the density given pressure

@params[in] p pressure

131 {
132  // diagnostic relation for the full pressure
133  // see https://erf.readthedocs.io/en/latest/theory/NavierStokesEquations.html
134  // For cases with mositure theta = theta_m / (1 + R_v/R_d*qv)
135  return std::pow(p*std::pow(p_0, Gamma-1), iGamma) * iR_d / (1.0 + R_v/R_d*qv) ;
136 }
constexpr amrex::Real iR_d
Definition: ERF_Constants.H:25

Referenced by ERF::init_from_hse().

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 theta

30 {
31  // rho and rhotheta are dry values. We should be using moist value of theta when using moisture
32  // theta_m = theta * (1 + R_v/R_d*qv)
33  amrex::Real p_loc = p_0 * std::pow(R_d * rhotheta * (1.0 + R_v/R_d*qv) * ip_0, Gamma);
34  // p = rho_d * R_d * T_v (not T)
35  // T_v = T * (1 + R_v/R_d*qv)
36  return p_loc / (R_d * rho * (1.0 + R_v/R_d*qv) );
37 }

Referenced by SAM::Compute_Coefficients(), Kessler::Copy_State_to_Micro(), SAM::Copy_State_to_Micro(), derived::erf_dertemp(), Radiation::initialize(), make_buoyancy(), 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] pressure @params[in] temperature @params[in] rd0cp ratio of R_d to c_p

18 {
19  return T*std::pow(p_0/P, rdOcp);
20 }
@ T
Definition: IndexDefines.H:67

Referenced by 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] rd0cp ratio of R_d to c_p

48 {
49  // p = rho_d * R_d * T_moist
50  amrex::Real p_loc = rho * R_d * T * (1.0 + R_v/R_d*qv);
51  // theta_d = T * (p0/p)^(R_d/C_p)
52  return T * std::pow((p_0/p_loc),rdOcp);
53 }

Referenced by ReadBndryPlanes::read_file().

Here is the caller graph for this function: