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 // Finite neutral Obukhov length [m] for immersed columns in MOST and IB-aware PBL schemes.
32 
33 // The one definition of "this LSM coupling value was computed": finite and below the
34 // lsm_undefined sentinel. amrex::Math::isfinite rather than std::isfinite because the
35 // latter is always false in SYCL device code. Consumers that must also reject other
36 // fill conventions (e.g. Noah-MP's -9999) add their own tests on top of this one.
37 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
39 {
40  return amrex::Math::isfinite(v) && v < lsm_undefined;
41 }
42 
43 // Physical ceiling [mm] on interval precip handed to Noah-MP over one land call.
44 // 500 mm is far above any real rate, so a larger value signals noisy IC/BC or a
45 // corrupt accumulator snapshot; the coupling clamps to this and warns (ERF_NOAHMP.cpp).
47 
48 // Physical Constants
49 constexpr amrex::Real R_d = amrex::Real(287.0); // dry air constant for dry air [J/(kg-K)]
50 constexpr amrex::Real R_v = amrex::Real(461.505); // water vapor constant for water vapor [J/(kg-K)]
51 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)
52 constexpr amrex::Real Cp_v = amrex::Real(1859.0);
53 constexpr amrex::Real Cp_l = amrex::Real(4200.0);
54 constexpr amrex::Real Cp_i = amrex::Real(2106.0); // ice at 0 C [J/(kg-K)]
55 
56 constexpr amrex::Real epsv = R_v / R_d - one;
57 constexpr amrex::Real RdoCp = R_d / Cp_d;
58 constexpr amrex::Real CpoRd = Cp_d / R_d;
59 constexpr amrex::Real RvoRd = R_v / R_d;
60 constexpr amrex::Real RdoRv = R_d / R_v;
61 
62 // epsilo / omeps are the CAM spellings of RdoRv and its complement; they appear
63 // in the saturation-vapor-pressure formulas in Utils/ERF_SatMethods.H.
64 constexpr amrex::Real epsilo = RdoRv;
65 constexpr amrex::Real omeps = one - epsilo;
66 
67 constexpr amrex::Real L_v = amrex::Real(2.5e6); // latent heat of vaporization (J / kg)
68 
69 constexpr amrex::Real p_0 = amrex::Real(1.0e5); // reference surface pressure [Pa]
70 constexpr amrex::Real Gamma = amrex::Real(1.4); // c_p / c_v [-]
71 constexpr amrex::Real KAPPA = amrex::Real(0.41); // von Karman constant
73 
74 // Derived Constants
75 constexpr amrex::Real ip_0 = one/p_0;
76 constexpr amrex::Real iR_d = one/R_d;
78 
79 // Molecular / kinetic-theory constants.
80 constexpr amrex::Real boltz = amrex::Real(1.38065e-23);
81 constexpr amrex::Real avogadro = amrex::Real(6.02214e26);
82 constexpr amrex::Real mwdair = amrex::Real(28.966);
83 
84 static constexpr int ORB_UNDEF_INT = 2000000000; // undefined int
85 #endif
constexpr amrex::Real epsv
Definition: ERF_Constants.H:56
constexpr amrex::Real R_v
Definition: ERF_Constants.H:50
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:71
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:51
constexpr amrex::Real iR_d
Definition: ERF_Constants.H:76
constexpr amrex::Real bogus_large_value
Definition: ERF_Constants.H:19
constexpr amrex::Real avogadro
Definition: ERF_Constants.H:81
static constexpr int ORB_UNDEF_INT
Definition: ERF_Constants.H:84
constexpr amrex::Real epsilo
Definition: ERF_Constants.H:64
constexpr amrex::Real mwdair
Definition: ERF_Constants.H:82
constexpr amrex::Real boltz
Definition: ERF_Constants.H:80
constexpr amrex::Real Cp_i
Definition: ERF_Constants.H:54
constexpr amrex::Real ip_0
Definition: ERF_Constants.H:75
constexpr amrex::Real p_0
Definition: ERF_Constants.H:69
constexpr amrex::Real lsm_max_precip_interval
Definition: ERF_Constants.H:46
constexpr amrex::Real RvoRd
Definition: ERF_Constants.H:59
constexpr amrex::Real iGamma
Definition: ERF_Constants.H:77
constexpr amrex::Real CpoRd
Definition: ERF_Constants.H:58
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
constexpr amrex::Real Cp_l
Definition: ERF_Constants.H:53
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_valid_lsm_value(amrex::Real v)
Definition: ERF_Constants.H:38
constexpr amrex::Real Cp_v
Definition: ERF_Constants.H:52
constexpr amrex::Real R_d
Definition: ERF_Constants.H:49
constexpr amrex::Real lsm_undefined
Definition: ERF_Constants.H:28
constexpr amrex::Real L_v
Definition: ERF_Constants.H:67
constexpr amrex::Real omeps
Definition: ERF_Constants.H:65
constexpr amrex::Real RdoCp
Definition: ERF_Constants.H:57
constexpr amrex::Real immersed_neutral_obukhov_length
Definition: ERF_Constants.H:31
constexpr amrex::Real RdoRv
Definition: ERF_Constants.H:60
constexpr amrex::Real Gamma
Definition: ERF_Constants.H:70
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
amrex::Real Real
Definition: ERF_ShocInterface.H:19