1 #ifndef ERF_ORB_COS_ZENITH_H
2 #define ERF_ORB_COS_ZENITH_H
51 lambm = lambm0 + (calday - ve)*
two*
PI/dayspy;
69 invrho = (
one + eccen*std::cos(lamb - mvelpp)) / (
one - eccen*eccen);
73 delta = std::asin(std::sin(obliqr)*std::sin(lamb));
294 real obliq_in = obliq;
295 real eccen_in = eccen;
296 real mvelp_in = mvelp;
306 eccen2 = eccen*eccen;
307 eccen3 = eccen2*eccen;
337 years = - yb4_1950AD;
351 for (
int i(0); i<poblen; ++i) {
352 obsum = obsum + obamp[i]*psecdeg*std::cos( (obrate[i]*psecdeg*years + obphas[i]) *
degrad );
365 for (
int i(0); i<pecclen; ++i) {
366 cossum = cossum + ecamp[i]*std::cos( (ecrate[i]*psecdeg*years+ecphas[i]) *
degrad );
370 for (
int i(0); i<pecclen; ++i) {
371 sinsum = sinsum + ecamp[i]*std::sin( (ecrate[i]*psecdeg*years+ecphas[i]) *
degrad );
376 eccen2 = cossum*cossum + sinsum*sinsum;
377 eccen = std::sqrt(eccen2);
378 eccen3 = eccen2*eccen;
382 if (sinsum ==
zero) {
384 }
else if (sinsum <
zero) {
386 }
else if (sinsum >
zero) {
389 }
else if (cossum <
zero) {
390 fvelp = std::atan(sinsum/cossum) +
PI;
393 fvelp = std::atan(sinsum/cossum) +
two*
PI;
395 fvelp = std::atan(sinsum/cossum);
410 for (
int i(0); i<pmvelen; ++i) {
411 mvsum = mvsum + mvamp[i]*psecdeg*std::sin( (mvrate[i]*psecdeg*years + mvphas[i]) *
degrad);
419 if (obliq_in >=
zero) { obliq = obliq_in; }
420 if (mvelp_in >=
zero) { mvelp = mvelp_in; }
421 if (eccen_in >=
zero) {
423 eccen2 = eccen*eccen;
424 eccen3 = eccen2*eccen;
431 }
while (mvelp <
zero);
459 beta = std::sqrt(
one - eccen2);
487 }
else if (lat == -
PIoTwo) {
497 }
else if (declin == -
PIoTwo) {
506 real cos_h = - std::tan(del) * std::tan(phi);
509 }
else if (cos_h >=
one) {
512 h = std::acos(cos_h);
520 }
else if (t1 < -
PI) {
529 real aa = std::sin(lat) * std::sin(declin);
530 real bb = std::cos(lat) * std::cos(declin);
535 real tt1,tt2,tt3,tt4;
536 if ( (t2 >=
PI) && (t1 <=
PI) && ((
PI - h) <= dt) ) {
538 tt1 = std::min(std::max(t1, -h), h);
539 tt4 = std::min(std::max(t2,
two*
PI - h),
two*
PI + h);
541 }
else if ( (t2 >= -
PI) && (t1 <= -
PI) && ((
PI - h) <= dt) ) {
543 tt1 = std::min(std::max(t1, -
two*
PI - h), -
two*
PI + h);
544 tt4 = std::min(std::max(t2, -h), h);
548 tt2 = std::min(std::max(t2 -
two*
PI, -h), h);
549 }
else if (t2 < -
PI) {
550 tt2 = std::min(std::max(t2 +
two*
PI, -h), h);
552 tt2 = std::min(std::max(t2 , -h), h);
556 tt1 = std::min(std::max(t1 -
two*
PI, -h), h);
557 }
else if (t1 < -
PI) {
558 tt1 = std::min(std::max(t1 +
two*
PI, -h), h);
560 tt1 = std::min(std::max(t1 , -h), h);
568 if ( (tt2 > tt1) || (tt4 > tt3) ) {
569 return (aa * (tt2 - tt1) + bb * (sin(tt2) - sin(tt1))) / dt +
570 (aa * (tt4 - tt3) + bb * (sin(tt4) - sin(tt3))) / dt;
586 real constant_zenith_angle_deg = -
one)
589 if ( constant_zenith_angle_deg >=
zero ) {
590 return std::cos( constant_zenith_angle_deg *
PI/
amrex::Real(180.) );
594 if ( uniform_angle >=
zero) {
595 return std::cos(uniform_angle);
599 bool use_dt_avg =
false;
607 return std::sin(lat)*std::sin(declin) - std::cos(lat)*std::cos(declin) *
608 std::cos((jday-floor(jday))*
real(
two)*
PI + lon);
constexpr amrex::Real three
Definition: ERF_Constants.H:11
constexpr amrex::Real two
Definition: ERF_Constants.H:10
static constexpr int ORB_UNDEF_INT
Definition: ERF_Constants.H:138
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real fourth
Definition: ERF_Constants.H:14
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
constexpr amrex::Real PI
Definition: ERF_Constants.H:42
constexpr amrex::Real PIoTwo
Definition: ERF_Constants.H:43
amrex::Real beta
Definition: ERF_InitCustomPert_DataAssimilation_ISV.H:10
double real
Definition: ERF_OrbCosZenith.H:9
AMREX_GPU_HOST AMREX_FORCE_INLINE real orbital_cos_zenith(real &jday, real &lat, real &lon, real &declin, real dt_avg=-one, real uniform_angle=-one, real constant_zenith_angle_deg=-one)
Definition: ERF_OrbCosZenith.H:580
AMREX_GPU_HOST AMREX_FORCE_INLINE real orbital_avg_cos_zenith(real &jday, real &lat, real &lon, real &declin, real &dt_avg)
Definition: ERF_OrbCosZenith.H:477
AMREX_GPU_HOST AMREX_FORCE_INLINE void orbital_decl(real &calday, real &eccen, real &mvelpp, real &lambm0, real &obliqr, real &delta, real &eccf)
Definition: ERF_OrbCosZenith.H:15
AMREX_GPU_HOST AMREX_FORCE_INLINE void orbital_params(int &iyear_AD, real &eccen, real &obliq, real &mvelp, real &obliqr, real &lambm0, real &mvelpp)
Definition: ERF_OrbCosZenith.H:81
amrex::Real Real
Definition: ERF_ShocInterface.H:19
real(c_double), parameter degrad
Definition: ERF_module_model_constants.F90:75