ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Orbit.H
Go to the documentation of this file.
1 #ifndef ERF_ORBIT_H_
2 #define ERF_ORBIT_H_
3 
4 #include <AMReX.H>
5 #include <AMReX_MultiFab.H>
6 #include <ERF_Rrtmgp.H>
7 #include <ERF_Constants.H>
8 
9 void
10 zenith (int& calday,
11  amrex::MultiFab* clat,
12  amrex::MultiFab* clon,
13  const amrex::Vector<int> &rank_offsets,
14  real1d& coszrs,
15  int& ncol,
16  const amrex::Real& eccen,
17  const amrex::Real& mvelpp,
18  const amrex::Real& lambm0,
19  const amrex::Real& obliqr,
20  amrex::Real uniform_angle=-1.0);
21 
22 
23 AMREX_GPU_HOST
24 AMREX_FORCE_INLINE
25 amrex::Real
26 shr_orb_cosz (const amrex::Real& jday,
27  const amrex::Real& lat,
28  const amrex::Real& lon,
29  const amrex::Real& declin,
30  amrex::Real uniform_angle)
31 {
32  amrex::Real cos_sol_zen_ang;
33 
34  // If uniform angle is specified we use that.
35  // NOTE: uniform angle is in degrees
36  if (uniform_angle>0.0) {
37  cos_sol_zen_ang = std::cos(uniform_angle * PI/180.0);
38  }
39  // Default method
40  else {
41  cos_sol_zen_ang = std::sin(lat)*std::sin(declin) - std::cos(lat)*std::cos(declin) *
42  std::cos((jday-std::floor(jday))*2.0*PI + lon);
43  }
44 
45  return cos_sol_zen_ang;
46 }
47 
48 
49 AMREX_GPU_HOST
50 AMREX_FORCE_INLINE
51 void
52 shr_orb_decl (const amrex::Real& calday,
53  const amrex::Real& eccen ,
54  const amrex::Real& mvelpp,
55  const amrex::Real& lambm0,
56  const amrex::Real& obliqr,
57  amrex::Real& delta,
58  amrex::Real& eccf)
59 {
60 
61  static constexpr amrex::Real day_p_yr = 365.0;
62  static constexpr amrex::Real ve = 80.5;
63 
64  // Compute eccentricity factor and solar declination using
65  // day value where a round day (such as 213.0) refers to 0z at
66  // Greenwich longitude.
67 
68  // Use formulas from Berger, Andre 1978: Long-Term Variations of Daily
69  // Insolation and Quaternary Climatic Changes. J. of the Atmo. Sci.
70  // 35:2362-2367.
71 
72  // To get the earths true longitude (position in orbit; lambda in Berger
73  // 1978) which is necessary to find the eccentricity factor and declination,
74  // must first calculate the mean longitude (lambda m in Berger 1978) at
75  // the present day. This is done by adding to lambm0 (the mean longitude
76  // at the vernal equinox, set as March 21 at noon, when lambda=0; in radians)
77  // an increment (delta lambda m in Berger 1978) that is the number of
78  // days past or before (a negative increment) the vernal equinox divided by
79  // the days in a model year times the 2*pi radians in a complete orbit.
80  amrex::Real lambm = lambm0 + (calday - ve)*2.0*PI/day_p_yr;
81  amrex::Real lmm = lambm - mvelpp;
82 
83  // The earths true longitude, in radians, is then found from
84  // the formula in Berger 1978:
85  amrex::Real sinl = std::sin(lmm);
86  amrex::Real lamb = lambm + eccen*(2.0*sinl + eccen*(1.25*sin(2.0*lmm)
87  + eccen*((13.0/12.0)*sin(3.0*lmm) - 0.25*sinl)));
88 
89 
90  // Using the obliquity, eccentricity, moving vernal equinox longitude of
91  // perihelion (plus), and earths true longitude, the declination (delta)
92  // and the normalized earth/sun distance (rho in Berger 1978; actually inverse
93  // rho will be used), and thus the eccentricity factor (eccf), can be
94  // calculated from formulas given in Berger 1978.
95  amrex::Real invrho = (1.0 + eccen*std::cos(lamb - mvelpp)) / (1.0 - eccen*eccen);
96 
97  // Set solar declination and eccentricity factor
98  delta = std::asin(std::sin(obliqr)*std::sin(lamb));
99  eccf = invrho*invrho;
100 }
101 #endif
constexpr amrex::Real PI
Definition: ERF_Constants.H:6
void zenith(int &calday, amrex::MultiFab *clat, amrex::MultiFab *clon, const amrex::Vector< int > &rank_offsets, real1d &coszrs, int &ncol, const amrex::Real &eccen, const amrex::Real &mvelpp, const amrex::Real &lambm0, const amrex::Real &obliqr, amrex::Real uniform_angle=-1.0)
AMREX_GPU_HOST AMREX_FORCE_INLINE amrex::Real shr_orb_cosz(const amrex::Real &jday, const amrex::Real &lat, const amrex::Real &lon, const amrex::Real &declin, amrex::Real uniform_angle)
Definition: ERF_Orbit.H:26
AMREX_GPU_HOST AMREX_FORCE_INLINE void shr_orb_decl(const amrex::Real &calday, const amrex::Real &eccen, const amrex::Real &mvelpp, const amrex::Real &lambm0, const amrex::Real &obliqr, amrex::Real &delta, amrex::Real &eccf)
Definition: ERF_Orbit.H:52