ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_TwoStreamRadiation.H File Reference
#include <memory>
#include <string>
#include <AMReX_BoxArray.H>
#include <AMReX_DistributionMapping.H>
#include <AMReX_Geometry.H>
#include <AMReX_MultiFab.H>
#include <AMReX_REAL.H>
#include <AMReX_Vector.H>
#include <ERF_RadStruct.H>
#include <ERF_LandSurface.H>
#include <ERF_RadiationDiagnostics.H>
#include <ERF_TwoStreamCanopyForcing.H>
Include dependency graph for ERF_TwoStreamRadiation.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TwoStreamRadiation
 The two-stream radiation model (erf.radiation_model = TwoStream). More...
 
struct  TwoStreamRadiation::OrbitalCache
 
struct  TwoStreamRadiation::FluxDiag
 
struct  TwoStreamSunDate
 The calendar sun of the two-stream model at one time (see two_stream_sun_date()). More...
 

Functions

void copy_surface_plane (const amrex::MultiFab &src2d, amrex::MultiFab &dst)
 Copy a 2D field (k = 0 only) into the k = 0 plane of a surface-model field. More...
 
TwoStreamSunDate two_stream_sun_date (const RadChoice &rc, TwoStreamRadiation::OrbitalCache &orbit, double epoch_time)
 The calendar sun of the two-stream model at a UTC epoch time (start_time + t). More...
 

Variables

constexpr amrex::Real two_stream_tsi_reference = 1360.9
 RRTMGP's reference total solar irradiance [W/m^2], scaled by the date's Earth-Sun distance factor. More...
 

Function Documentation

◆ copy_surface_plane()

void copy_surface_plane ( const amrex::MultiFab &  src2d,
amrex::MultiFab &  dst 
)

Copy a 2D field (k = 0 only) into the k = 0 plane of a surface-model field.

Surface-model fields keep their surface values in the k = 0 plane, which may lie in the field's z ghost region (SLM stores soil layers at k < 0), and carry x/y ghost cells the source need not have. Only the i,j extent of each destination VALID box is written, so ghost columns and every other k are left alone. The two fields must share a horizontal layout: the destination's boxes flattened to k = 0 equal the source's, on the same DistributionMapping – which holds for ERF's ba2d and a land model's data built from the same level grids, and is asserted rather than assumed.

◆ two_stream_sun_date()

TwoStreamSunDate two_stream_sun_date ( const RadChoice &  rc,
TwoStreamRadiation::OrbitalCache &  orbit,
double  epoch_time 
)

The calendar sun of the two-stream model at a UTC epoch time (start_time + t).

The date as the RRTMGP interface forms it, the orbit of the year (or the erf.rad_orbital_* overrides) cached in orbit, and the declination and distance factor of ERF_OrbCosZenith.H. The two-stream sweep places its sun from this, with the column's position, and so does the immersed-boundary balance with erf.ibseb.sun_mode = two_stream.

The calendar sun of the two-stream model at a UTC epoch time: the calendar day with the time of day as its fraction, the declination and the Earth-Sun distance factor, from the date as the RRTMGP interface forms it and the orbital code of ERF_OrbCosZenith.H (orbital_params once per year into orbit, with the erf.rad_orbital_* overrides passed to it, then orbital_decl per call). set_solar_state() takes the sun of every sweep from here, and the immersed-boundary balance its erf.ibseb.sun_mode = two_stream sun, so the two cannot drift apart.

102 {
103  // Calendar date of this call (UTC), as the RRTMGP interface forms it.
104  time_t timestamp = time_t(epoch_time);
105  struct tm timeinfo{};
106 #if defined(_WIN32)
107  gmtime_s(&timeinfo, &timestamp);
108 #else
109  gmtime_r(&timestamp, &timeinfo);
110 #endif
111  const int year = (rc.rad_orbital_year >= 0) ? rc.rad_orbital_year : timeinfo.tm_year + 1900;
112  const int mon = timeinfo.tm_mon + 1;
113  const int day = timeinfo.tm_mday;
114  const int sec = timeinfo.tm_hour*3600 + timeinfo.tm_min*60 + timeinfo.tm_sec;
115 
116  // Orbital parameters of the year (Berger 1978) unless overridden: a few
117  // hundred series terms and six vectors, so once per year, not per step.
118  if (orbit.year != year) {
119  int iyear = year;
120  double eccen = rc.rad_orbital_eccentricity;
121  double obliq = rc.rad_orbital_obliquity;
122  double mvelp = rc.rad_orbital_mvelp;
123  double obliqr = 0.0, lambm0 = 0.0, mvelpp = 0.0;
124  orbital_params(iyear, eccen, obliq, mvelp, obliqr, lambm0, mvelpp);
125  orbit.year = year;
126  orbit.eccen = eccen; orbit.obliqr = obliqr; orbit.lambm0 = lambm0; orbit.mvelpp = mvelpp;
127  }
128 
129  // Declination and Earth-Sun distance factor of the day.
130  double calday = orbital_calday(year, mon, day, sec);
131  double eccen = orbit.eccen, mvelpp = orbit.mvelpp, lambm0 = orbit.lambm0, obliqr = orbit.obliqr;
132  double delta = 0.0, eccf = 1.0;
133  orbital_decl(calday, eccen, mvelpp, lambm0, obliqr, delta, eccf);
134 
135  TwoStreamSunDate out;
136  out.calday = calday;
137  out.declin = delta;
138  out.eccf = eccf;
139  return out;
140 }
if(KE_decay_height > 0 &&state_pert.nComp() > RhoKE_comp)
Definition: ERF_InitCustomPert_ABL.H:76
AMREX_GPU_HOST AMREX_FORCE_INLINE double orbital_calday(int year, int mon, int day, int sec)
Definition: ERF_OrbCosZenith.H:485
AMREX_GPU_HOST AMREX_FORCE_INLINE void orbital_decl(double &calday, double &eccen, double &mvelpp, double &lambm0, double &obliqr, double &delta, double &eccf)
Definition: ERF_OrbCosZenith.H:18
AMREX_GPU_HOST AMREX_FORCE_INLINE void orbital_params(int &iyear_AD, double &eccen, double &obliq, double &mvelp, double &obliqr, double &lambm0, double &mvelpp)
Definition: ERF_OrbCosZenith.H:84
constexpr std::array< amrex::Real, num_veg_params > rc
Definition: ERF_SLM_DefaultParams.H:22
double obliqr
Definition: ERF_TwoStreamRadiation.H:296
int year
Definition: ERF_TwoStreamRadiation.H:294
double lambm0
Definition: ERF_TwoStreamRadiation.H:297
double mvelpp
Definition: ERF_TwoStreamRadiation.H:298
double eccen
Definition: ERF_TwoStreamRadiation.H:295
The calendar sun of the two-stream model at one time (see two_stream_sun_date()).
Definition: ERF_TwoStreamRadiation.H:383
double eccf
Earth-Sun distance factor (d0/d)^2.
Definition: ERF_TwoStreamRadiation.H:386
double declin
Solar declination [rad].
Definition: ERF_TwoStreamRadiation.H:385
double calday
Day of the year (1 = 1 January), UTC time of day as the fraction.
Definition: ERF_TwoStreamRadiation.H:384

Referenced by ERF::ibseb_set_two_stream_sun().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ two_stream_tsi_reference

constexpr amrex::Real two_stream_tsi_reference = 1360.9
inlineconstexpr

RRTMGP's reference total solar irradiance [W/m^2], scaled by the date's Earth-Sun distance factor.

Referenced by ERF::ibseb_set_two_stream_sun().