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));
298 eccen2 = eccen*eccen;
299 eccen3 = eccen2*eccen;
329 years = - yb4_1950AD;
343 for (
int i(0); i<poblen; ++i) {
344 obsum = obsum + obamp[i]*psecdeg*std::cos( (obrate[i]*psecdeg*years + obphas[i]) *
degrad );
357 for (
int i(0); i<pecclen; ++i) {
358 cossum = cossum + ecamp[i]*std::cos( (ecrate[i]*psecdeg*years+ecphas[i]) *
degrad );
362 for (
int i(0); i<pecclen; ++i) {
363 sinsum = sinsum + ecamp[i]*std::sin( (ecrate[i]*psecdeg*years+ecphas[i]) *
degrad );
368 eccen2 = cossum*cossum + sinsum*sinsum;
369 eccen = std::sqrt(eccen2);
370 eccen3 = eccen2*eccen;
374 if (sinsum ==
zero) {
376 }
else if (sinsum <
zero) {
378 }
else if (sinsum >
zero) {
381 }
else if (cossum <
zero) {
382 fvelp = std::atan(sinsum/cossum) +
PI;
385 fvelp = std::atan(sinsum/cossum) +
two*
PI;
387 fvelp = std::atan(sinsum/cossum);
402 for (
int i(0); i<pmvelen; ++i) {
403 mvsum = mvsum + mvamp[i]*psecdeg*std::sin( (mvrate[i]*psecdeg*years + mvphas[i]) *
degrad);
411 }
while (mvelp <
zero);
441 beta = std::sqrt(
one - eccen2);
469 }
else if (lat == -
PIoTwo) {
479 }
else if (declin == -
PIoTwo) {
488 real cos_h = - std::tan(del) * std::tan(phi);
491 }
else if (cos_h >=
one) {
494 h = std::acos(cos_h);
502 }
else if (t1 < -
PI) {
511 real aa = std::sin(lat) * std::sin(declin);
512 real bb = std::cos(lat) * std::cos(declin);
517 real tt1,tt2,tt3,tt4;
518 if ( (t2 >=
PI) && (t1 <=
PI) && ((
PI - h) <= dt) ) {
520 tt1 = std::min(std::max(t1, -h), h);
521 tt4 = std::min(std::max(t2,
two*
PI - h),
two*
PI + h);
523 }
else if ( (t2 >= -
PI) && (t1 <= -
PI) && ((
PI - h) <= dt) ) {
525 tt1 = std::min(std::max(t1, -
two*
PI - h), -
two*
PI + h);
526 tt4 = std::min(std::max(t2, -h), h);
530 tt2 = std::min(std::max(t2 -
two*
PI, -h), h);
531 }
else if (t2 < -
PI) {
532 tt2 = std::min(std::max(t2 +
two*
PI, -h), h);
534 tt2 = std::min(std::max(t2 , -h), h);
538 tt1 = std::min(std::max(t1 -
two*
PI, -h), h);
539 }
else if (t1 < -
PI) {
540 tt1 = std::min(std::max(t1 +
two*
PI, -h), h);
542 tt1 = std::min(std::max(t1 , -h), h);
550 if ( (tt2 > tt1) || (tt4 > tt3) ) {
551 return (aa * (tt2 - tt1) + bb * (sin(tt2) - sin(tt1))) / dt +
552 (aa * (tt4 - tt3) + bb * (sin(tt4) - sin(tt3))) / dt;
568 real constant_zenith_angle_deg = -
one)
571 if ( constant_zenith_angle_deg >=
zero ) {
572 return std::cos( constant_zenith_angle_deg *
PI/
amrex::Real(180.) );
576 if ( uniform_angle >=
zero) {
577 return std::cos(uniform_angle);
581 bool use_dt_avg =
false;
589 return std::sin(lat)*std::sin(declin) - std::cos(lat)*std::cos(declin) *
590 std::cos((jday-floor(jday))*
real(
two)*
PI + lon);
constexpr amrex::Real three
Definition: ERF_Constants.H:9
constexpr amrex::Real two
Definition: ERF_Constants.H:8
static constexpr int ORB_UNDEF_INT
Definition: ERF_Constants.H:106
constexpr amrex::Real one
Definition: ERF_Constants.H:7
constexpr amrex::Real fourth
Definition: ERF_Constants.H:12
constexpr amrex::Real zero
Definition: ERF_Constants.H:6
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:11
constexpr amrex::Real PI
Definition: ERF_Constants.H:16
constexpr amrex::Real PIoTwo
Definition: ERF_Constants.H:17
amrex::Real beta
Definition: ERF_InitCustomPert_IsentropicVortex.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:562
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:459
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