ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Constants.H
Go to the documentation of this file.
1 #ifndef ERF_CONSTANTS_H_
2 #define ERF_CONSTANTS_H_
3 
4 #include <cmath>
5 #include <limits>
6 #include <AMReX_REAL.H>
7 #include <AMReX_GpuQualifiers.H>
8 #include <AMReX_Math.H>
10 
11 // Safe overly large value to fill data so that it is not uninitialized
12 // but we can easily identify if the value is used in a computation
13 // Would like to use the following but std::sqrt will not be allowable
14 // in constexpr until C++26
15 // const amrex::Real bogus_large_value = std::sqrt(std::numeric_limits<amrex::Real>::max());
16 #ifdef AMREX_USE_FLOAT
17 constexpr amrex::Real bogus_large_value = amrex::Real(1.e18);
18 #else
20 #endif
21 
22 // lsm_undefined: sentinel written into the LSM MultiFabs for cells
23 // the land model did NOT process (e.g. sea-ice / open-water points, where Noah-MP returns the
24 // -9999 fill value instead of a computed flux). The surface layer detects this
25 // and falls back to the Monin-Obukhov (MOST) flux for those cells -- analogous
26 // to how WRF computes the atmospheric surface flux from a skin temperature via
27 // the surface-layer scheme rather than taking an undefined LSM flux.
29 
30 // The one definition of "this LSM coupling value was computed": finite and below the
31 // lsm_undefined sentinel. amrex::Math::isfinite rather than std::isfinite because the
32 // latter is always false in SYCL device code. Consumers that must also reject other
33 // fill conventions (e.g. Noah-MP's -9999) add their own tests on top of this one.
34 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
36 {
37  return amrex::Math::isfinite(v) && v < lsm_undefined;
38 }
39 
40 // Physical ceiling [mm] on interval precip handed to Noah-MP over one land call.
41 // 500 mm is far above any real rate, so a larger value signals noisy IC/BC or a
42 // corrupt accumulator snapshot; the coupling clamps to this and warns (ERF_NOAHMP.cpp).
44 
45 // Physical Constants
46 constexpr amrex::Real R_d = amrex::Real(287.0); // dry air constant for dry air [J/(kg-K)]
47 constexpr amrex::Real R_v = amrex::Real(461.505); // water vapor constant for water vapor [J/(kg-K)]
48 constexpr amrex::Real Cp_d = amrex::Real(1004.5); // We have set this so that with qv=0 we get identically gamma = amrex::Real(1.4)
49 constexpr amrex::Real Cp_v = amrex::Real(1859.0);
50 constexpr amrex::Real Cp_l = amrex::Real(4200.0);
51 
52 constexpr amrex::Real epsv = R_v / R_d - one;
53 constexpr amrex::Real RdoCp = R_d / Cp_d;
54 constexpr amrex::Real CpoRd = Cp_d / R_d;
55 constexpr amrex::Real RvoRd = R_v / R_d;
56 constexpr amrex::Real RdoRv = R_d / R_v;
57 
58 // epsilo / omeps are the CAM spellings of RdoRv and its complement; they appear
59 // in the saturation-vapor-pressure formulas in Utils/ERF_SatMethods.H.
60 constexpr amrex::Real epsilo = RdoRv;
61 constexpr amrex::Real omeps = one - epsilo;
62 
63 constexpr amrex::Real L_v = amrex::Real(2.5e6); // latent heat of vaporization (J / kg)
64 
65 constexpr amrex::Real p_0 = amrex::Real(1.0e5); // reference surface pressure [Pa]
66 constexpr amrex::Real Gamma = amrex::Real(1.4); // c_p / c_v [-]
67 constexpr amrex::Real KAPPA = amrex::Real(0.41); // von Karman constant
69 
70 // Derived Constants
71 constexpr amrex::Real ip_0 = one/p_0;
72 constexpr amrex::Real iR_d = one/R_d;
74 
75 // Molecular / kinetic-theory constants.
76 constexpr amrex::Real boltz = amrex::Real(1.38065e-23);
77 constexpr amrex::Real avogadro = amrex::Real(6.02214e26);
78 constexpr amrex::Real mwdair = amrex::Real(28.966);
79 
80 static constexpr int ORB_UNDEF_INT = 2000000000; // undefined int
81 #endif
constexpr amrex::Real epsv
Definition: ERF_Constants.H:52
constexpr amrex::Real R_v
Definition: ERF_Constants.H:47
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:67
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:48
constexpr amrex::Real iR_d
Definition: ERF_Constants.H:72
constexpr amrex::Real bogus_large_value
Definition: ERF_Constants.H:19
constexpr amrex::Real avogadro
Definition: ERF_Constants.H:77
static constexpr int ORB_UNDEF_INT
Definition: ERF_Constants.H:80
constexpr amrex::Real epsilo
Definition: ERF_Constants.H:60
constexpr amrex::Real mwdair
Definition: ERF_Constants.H:78
constexpr amrex::Real boltz
Definition: ERF_Constants.H:76
constexpr amrex::Real ip_0
Definition: ERF_Constants.H:71
constexpr amrex::Real p_0
Definition: ERF_Constants.H:65
constexpr amrex::Real lsm_max_precip_interval
Definition: ERF_Constants.H:43
constexpr amrex::Real RvoRd
Definition: ERF_Constants.H:55
constexpr amrex::Real iGamma
Definition: ERF_Constants.H:73
constexpr amrex::Real CpoRd
Definition: ERF_Constants.H:54
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:68
constexpr amrex::Real Cp_l
Definition: ERF_Constants.H:50
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_valid_lsm_value(amrex::Real v)
Definition: ERF_Constants.H:35
constexpr amrex::Real Cp_v
Definition: ERF_Constants.H:49
constexpr amrex::Real R_d
Definition: ERF_Constants.H:46
constexpr amrex::Real lsm_undefined
Definition: ERF_Constants.H:28
constexpr amrex::Real L_v
Definition: ERF_Constants.H:63
constexpr amrex::Real omeps
Definition: ERF_Constants.H:61
constexpr amrex::Real RdoCp
Definition: ERF_Constants.H:53
constexpr amrex::Real RdoRv
Definition: ERF_Constants.H:56
constexpr amrex::Real Gamma
Definition: ERF_Constants.H:66
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
amrex::Real Real
Definition: ERF_ShocInterface.H:19