20 inline double SQUARE(
double x) {
return x * x; }
21 inline double atm_from_bar(
double P) {
return 0.9869232667160128 * P; }
22 static double const pi = 3.14159265358979;
26 double T,
double XH2,
double XHe,
27 double XNH3,
double XH2O)
32 #if defined(FAKE_CUTOFF_TO_AVOID_SINGULARITY_IN_BELLOTTI_ABS)
40 constexpr
double T_Bellotti_cutoff = 1250;
41 if (T > T_Bellotti_cutoff) {
42 T = T_Bellotti_cutoff;
49 bool use_mm_parameters(freq >= 30 ?
true :
false);
51 double const ppscale = 2.99792458e18;
52 double const gcon = 25.923;
53 double const cmghz = 29.9792458;
54 double const hckt0 = 0.0047959232;
59 double const PNH3 = P_idl * XNH3;
60 double const PH2 = P_idl * XH2;
61 double const PHe = P_idl * XHe;
62 double const PH2O = P_idl * XH2O;
64 double const dens = cdens * (P_idl * XNH3) / T;
66 double const beta300 = 300.0 / T;
67 double const beta295 = 295.0 / T;
68 double const beta300_25 = pow(beta300, 2.5);
69 double gh2, zh2, ghe, zhe, gnh3, znh3, gh2o, zh2o, dd, Dinv;
72 gh2 = 1.7465 * PH2 * pow(beta300, 0.8202);
73 ghe = 0.9779 * PHe * pow(beta300, 1.0);
74 gnh3 = 0.7298 * PNH3 * pow(beta295, 1.0);
75 gh2o = 4.8901 * PH2O * pow(beta300, 0.5);
77 zh2 = 1.2163 * PH2 * pow(beta300, 0.8873);
82 znh3 = 0.5152 * PNH3 * pow(beta295, 0.6667);
83 zh2o = 2.731 * PH2O * pow(beta300, 1.0);
90 gh2 = 1.69369709 * PH2 * pow(beta300, 0.80847492);
91 ghe = 0.69968615 * PHe * pow(beta300, 1.);
92 gnh3 = 0.75232086 * PNH3 * pow(beta295, 1.0);
94 gh2o = 5.2333 * PH2O * pow(beta300, 0.6224);
96 zh2 = 1.32634109 * PH2 * pow(beta300, 0.81994711);
101 znh3 = 0.61622276 * PNH3 * pow(beta295, 1.38318269);
103 zh2o = 5.2333 * PH2O * pow(beta300, 2.1248);
110 double alpha_inv(0.0);
112 for (
int i = 0; i < Ninv; i++) {
115 double fx = freq / f;
116 double sjkt = x.
I0 * beta300_25 * exp(hckt0 * (x.
E0) * (1.0 - beta300));
129 (gam - zet) *
SQUARE(freq) +
134 double fline = cmghz * 2.0 * fx * num / (
pi * den);
136 alpha_inv += Dinv * dens * sjkt * fx * fline;
143 double alpha_rot(0.0);
144 double const gH2_rot = 0.2984 * PH2 * pow(beta300, 0.8730);
145 double const gHe_rot = 0.75 * PHe * pow(beta300, 0.6667);
146 double const gNH3_rot = 3.1789 * PNH3 * pow(beta300, 1.0);
147 double const Drot = 2.4268;
150 for (
int i = 0; i < Nrot; i++) {
153 double fx = freq / f;
162 double fline = 4.0 /
pi * cmghz * fx * gam /
165 alpha_rot += Drot * dens * (x.
I0) * fx * beta300_25 *
166 exp(hckt0 * (x.
E0) * (1.0 - beta300)) * fline;
170 double alpha_rv(0.0);
171 double const gH2_nu2 = 1.4 * PH2 * pow(beta300, 0.73);
172 double const gHe_nu2 = 0.68 * PHe * pow(beta300, 0.5716);
173 double const gNH3_nu2 = 9.5 * PNH3 * pow(beta300, 1.0);
174 double const Drv = 1.1206;
177 for (
int i = 0; i < Nrv; i++) {
180 double fx = freq / f;
182 double gam = gH2_nu2 + gHe_nu2 + gNH3_nu2;
188 double fline = 4.0 /
pi * cmghz * fx * gam /
191 alpha_rv += Drv * dens * (x.
I0) * fx * beta300_25 *
192 exp(hckt0 * (x.
E0) * (1.0 - beta300)) * fline;
194 alpha_final = alpha_inv + alpha_rot + alpha_rv;
197 alpha_final = alpha_inv;
204 double XH2,
double XHe,
double XNH3,
210 #if defined(FAKE_CUTOFF_TO_AVOID_SINGULARITY_IN_BELLOTTI_ABS)
218 constexpr
double T_Bellotti_cutoff = 1250;
219 if (T > T_Bellotti_cutoff) {
220 T = T_Bellotti_cutoff;
229 double const ppscale = 2.99792458e18;
230 double const gcon = 25.923;
231 double const cmghz = 29.9792458;
232 double const hckt0 = 0.0047959232;
237 double const PNH3 = P_idl * XNH3;
238 double const PH2 = P_idl * XH2;
239 double const PHe = P_idl * XHe;
240 double const PH2O = P_idl * XH2O;
242 double const dens = cdens * (P_idl * XNH3) / T;
244 double const beta300 = 300.0 / T;
245 double const beta295 = 295.0 / T;
246 double const beta300_25 = pow(beta300, 2.5);
247 double gh2, zh2, ghe, zhe, gnh3, znh3, gh2o, zh2o, dd, Dinv;
250 gh2 = 1.6948 * PH2 * pow(beta300, 1.0);
251 ghe = 0.6385 * PHe * pow(beta300, 0.7995);
252 gnh3 = 0.7 * PNH3 * pow(beta295, 1.0);
254 gh2o = 5.2333 * PH2O * pow(beta300, 0.6224);
256 zh2 = 1.2718 * PH2 * pow(beta300, 0.9988);
257 zhe = 0.1316 * PHe * pow(beta300, -0.9129);
258 znh3 = 0.4879 * PNH3 * pow(beta295, 0.7885);
260 zh2o = 5.2333 * PH2O * pow(beta300, 2.1248);
266 double alpha_inv(0.0);
268 for (
int i = 0; i < Ninv; i++) {
271 double fx = freq / f;
272 double sjkt = x.
I0 * beta300_25 * exp(hckt0 * (x.
E0) * (1.0 - beta300));
285 (gam - zet) *
SQUARE(freq) +
290 double fline = cmghz * 2.0 * fx * num / (
pi * den);
292 alpha_inv += Dinv * dens * sjkt * fx * fline;
295 double alpha_rot(0.0);
297 double const gH2_rot = 1.7761 * PH2 * pow(beta300, 0.5);
298 double const gHe_rot = 0.6175 * PHe * pow(beta300, 0.5663);
299 double const gNH3_rot = 3.1518 * PNH3 * pow(beta300, 1.0);
300 double const Drot = 2.7252;
303 for (
int i = 0; i < Nrot; i++) {
306 double fx = freq / f;
314 double fline = 4.0 /
pi * cmghz * fx * gam /
317 alpha_rot += Drot * dens * (x.
I0) * fx * beta300_25 *
318 exp(hckt0 * (x.
E0) * (1.0 - beta300)) * fline;
322 double alpha_rv(0.0);
324 double const gH2_nu2 = 0.5982 * PH2 * pow(beta300, 0.5);
325 double const gHe_nu2 = 0.6175 * PHe * pow(beta300, 0.5505);
326 double const gNH3_nu2 = 5.0894 * PNH3 * pow(beta300, 0.9996);
327 double const Drv = 0.7286;
330 for (
int i = 0; i < Nrv; i++) {
333 double fx = freq / f;
335 double gam = gH2_nu2 + gHe_nu2 + gNH3_nu2;
340 double fline = 4.0 /
pi * cmghz * fx * gam /
343 alpha_rv += Drv * dens * (x.
I0) * fx * beta300_25 *
344 exp(hckt0 * (x.
E0) * (1.0 - beta300)) * fline;
347 return alpha_inv + alpha_rot + alpha_rv;
351 double XH2,
double XHe,
double XNH3,
double XH2O,
362 bool use_v2011(
false);
363 bool use_high_pressure_parameters(P_idl >= 15 ?
true :
false);
364 bool use_low_pressure_parameters(!use_high_pressure_parameters);
371 use_high_pressure_parameters =
false;
372 use_low_pressure_parameters =
false;
375 use_high_pressure_parameters =
true;
376 use_low_pressure_parameters =
false;
379 use_high_pressure_parameters =
false;
380 use_low_pressure_parameters =
true;
385 double const ppscale = 2.99792458e18;
386 double const gcon = 25.923;
387 double const cmghz = 29.9792458;
388 double const hckt0 = 0.0047959232;
393 double const PNH3 = P_idl * XNH3;
394 double const PH2 = P_idl * XH2;
395 double const PHe = P_idl * XHe;
396 double const PH2O = P_idl * XH2O;
398 double const dens = cdens * (P_idl * XNH3) / T;
400 double const beta300 = 300.0 / T;
401 double const beta295 = 295.0 / T;
402 double const beta300_25 = pow(beta300, 2.5);
405 double alpha_inv(0.0);
406 double gh2, zh2, ghe, zhe, gnh3, znh3, gh2o, zh2o, dd, Dinv;
408 gh2 = 1.7947 * PH2 * pow(beta300, 0.8357);
409 ghe = 0.75 * PHe * pow(beta300, 0.6667);
410 gnh3 = 0.7719 * PNH3 * pow(beta295, 1.0);
411 gh2o = 4.8901 * PH2O * pow(beta300, 0.5);
413 zh2 = 1.2031 * PH2 * pow(beta300, 0.8610);
414 zhe = 0.3 * PHe * pow(beta300, 0.6667);
415 znh3 = 0.5620 * PNH3 * pow(beta295, 0.6206);
416 zh2o = 2.731 * PH2O * pow(beta300, 1.0);
421 if (use_low_pressure_parameters) {
422 gh2 = 1.7465 * PH2 * pow(beta300, 0.8202);
423 ghe = 0.9779 * PHe * pow(beta300, 1.0);
424 gnh3 = 0.7298 * PNH3 * pow(beta295, 1.0);
425 gh2o = 4.8901 * PH2O * pow(beta300, 0.5);
427 zh2 = 1.2163 * PH2 * pow(beta300, 0.8873);
428 zhe = 0.0291 * PHe * pow(beta300, 0.8994);
429 znh3 = 0.5152 * PNH3 * pow(beta295, 0.6667);
430 zh2o = 2.731 * PH2O * pow(beta300, 1.0);
434 }
else if (use_high_pressure_parameters) {
435 gh2 = 1.6361 * PH2 * pow(beta300, 0.8);
436 ghe = 0.4555 * PHe * pow(beta300, 0.5);
437 gnh3 = 0.7298 * PNH3 * pow(beta295, 1.0);
438 gh2o = 4.8901 * PH2O * pow(beta300, 0.5);
440 zh2 = 1.1313 * PH2 * pow(beta300, 0.6234);
441 zhe = 0.1 * PHe * pow(beta300, 0.5);
442 znh3 = 0.5152 * PNH3 * pow(beta295, 0.6667);
443 zh2o = 2.731 * PH2O * pow(beta300, 1.0);
451 for (
int i = 0; i < Ninv; i++) {
454 double fx = freq / f;
455 double sjkt = x.
I0 * beta300_25 * exp(hckt0 * (x.
E0) * (1.0 - beta300));
467 (gam - zet) *
SQUARE(freq) +
472 double fline = cmghz * 2.0 * fx * num / (
pi * den);
474 alpha_inv += Dinv * dens * sjkt * fx * fline;
478 double alpha_rot(0.0);
479 double const gH2_rot = 0.2984 * PH2 * pow(beta300, 0.8730);
480 double const gHe_rot = 0.75 * PHe * pow(beta300, 0.6667);
481 double const gNH3_rot = 3.1789 * PNH3 * pow(beta300, 1.0);
482 double const Drot = 2.4268;
485 for (
int i = 0; i < Nrot; i++) {
488 double fx = freq / f;
496 double fline = 4.0 /
pi * cmghz * fx * gam /
499 alpha_rot += Drot * dens * (x.
I0) * fx * beta300_25 *
500 exp(hckt0 * (x.
E0) * (1.0 - beta300)) * fline;
504 double alpha_rv(0.0);
505 double const gH2_nu2 = 1.4 * PH2 * pow(beta300, 0.73);
506 double const gHe_nu2 = 0.68 * PHe * pow(beta300, 0.5716);
507 double const gNH3_nu2 = 9.5 * PNH3 * pow(beta300, 1.0);
508 double const Drv = 1.1206;
511 for (
int i = 0; i < Nrv; i++) {
514 double fx = freq / f;
516 double gam = gH2_nu2 + gHe_nu2 + gNH3_nu2;
521 double fline = 4.0 /
pi * cmghz * fx * gam /
524 alpha_rv += Drv * dens * (x.
I0) * fx * beta300_25 *
525 exp(hckt0 * (x.
E0) * (1.0 - beta300)) * fline;
528 return alpha_inv + alpha_rot + alpha_rv;
532 double XH2,
double XHe,
double XNH3,
double XH2O,
543 static bool first =
true;
546 double const gh2 = 1.64;
547 double const cgh2 = 0.7756;
548 double const zh2 = 1.262;
549 double const czh2 = 0.7964;
551 double const ghe = 0.75;
552 double const cghe = 0.6667;
553 double const zhe = 0.3;
554 double const czhe = 0.6667;
556 double const gnh3 = 0.852;
557 double const cgnh3 = 1.0;
558 double const znh3 = 0.5296;
559 double const cznh3 = 1.554;
562 double const ppscale = 3.00e18;
563 double const gcon = 25.923;
564 double const cmghz = 29.979;
566 double const dd = -0.0498;
567 double const ddd = 0.9301;
568 double const hckt0 = 0.004796;
569 double const cdens = 7.244e21;
575 for (
int i = 0; i <
NINV; i++) {
576 hif0[i] = 1.0e-3 *
hireals[i][0];
578 hiint[i] = pow(10.0,
hireals[i][2]) / ppscale;
583 for (
int i = 0; i <
NROT; i++) {
584 hrf0[i] = 1.0e-3 *
hrreals[i][0];
586 hrint[i] = pow(10.0,
hrreals[i][2]) / ppscale;
595 double const PNH3 = P_idl * XNH3;
596 double const PH2 = P_idl * XH2;
597 double const PHe = P_idl * XHe;
598 double const PH2O = P_idl * XH2O;
601 double const dens = cdens * (P_idl * XNH3) / T;
602 double const beta300 = 300.0 / T;
603 double const beta295 = 295.0 / T;
605 double const beta300_25 = pow(beta300, 2.5);
606 double const beta300_cgh2 = pow(beta300, cgh2);
607 double const beta300_cghe = pow(beta300, cghe);
608 double const beta300_czh2 = pow(beta300, czh2);
609 double const beta300_czhe = pow(beta300, czhe);
610 double const beta295_cgnh3 = pow(beta295, cgnh3);
611 double const beta295_cznh3 = pow(beta295, cznh3);
614 double const gh2o = 4.8901;
615 double const cgh2o = 0.5;
616 double const zh2o = 2.731;
617 double const czh2o = 1;
618 double const beta300_cgh2o = pow(beta300, cgh2o);
619 double const beta300_czh2o = pow(beta300, czh2o);
623 double dtau_inv(0.0);
624 double dtau_rot(0.0);
627 for (
int i = 0; i <
NINV; ++i) {
628 double fx = freq / hif0[i];
630 hiint[i] * beta300_25 * exp(hckt0 * hie0[i] * (1.0 - beta300));
632 double gam = gh2 * PH2 * beta300_cgh2 + ghe * PHe * beta300_cghe;
633 double zet = zh2 * PH2 * beta300_czh2 + zhe * PHe * beta300_czhe;
635 gam += gh2o * PH2O * beta300_cgh2o;
636 zet += zh2o * PH2O * beta300_czh2o;
640 double gam0 = gcon * double(hik[i]) / sqrt(
double(hij[i] * (hij[i] + 1)));
641 gam += gnh3 * gam0 * PNH3 * beta295_cgnh3;
642 zet += znh3 * gam0 * PNH3 * beta295_cznh3;
646 (gam - zet) *
SQUARE(freq) +
651 double fline = cmghz * 2.0 * fx * num / (
pi * den);
652 double alpha = ddd * dens * sjkt * fx * fline;
657 double const beta296 = 296 / T;
658 double const gH2_rot = PH2 * pow(beta296, cgh2);
659 double const gHe_rot = PHe * pow(beta296, cghe);
660 double const gNH3_rot = PNH3 * pow(beta296, cgnh3);
663 for (
int i = 0; i <
NROT; i++) {
665 double fx = freq / hrf0[i];
670 gam += gh2o * PH2O * beta300_cgh2o;
674 double fline = 4.0 /
pi * cmghz * fx * gam /
677 double dtaua = ddd * dens * hrint[i] * fx * beta300_25 *
678 exp(hckt0 * hre0[i] * (1.0 - beta300)) * fline;
683 #ifdef ABSORPTION_KLUDGE
684 constexpr
double P_top = 150;
685 constexpr
double P_bot = 4000;
686 constexpr
double scale_bot = 2.0;
690 dtau *= ((P - P_top) * scale_bot + (P_bot - P)) / (P_bot - P_top);
693 if (T > 750.) dtau *= pow(750. / T, power);
703 for (
int L = 1; L <= I - 1; L++) {
712 inline double shape(
double NU0,
double GAMMA,
double NU,
double DELTA,
714 double const NUSQ =
SQUARE(NU);
715 double const NU0SQ =
SQUARE(NU0);
716 double const GSQ =
SQUARE(GAMMA);
717 double const ZSQ =
SQUARE(ZETA);
718 double const T = (NU0 + DELTA) * (NU0 + DELTA);
719 return 2.0 * GAMMA * (NUSQ / NU0SQ) *
720 (((GAMMA - ZETA) * NUSQ + (GAMMA + ZETA) * (T + GSQ - ZSQ)) /
721 ((NUSQ - T - GSQ + ZSQ) * (NUSQ - T - GSQ + ZSQ) + 4.0 * NUSQ * GSQ));
725 double XHe,
double XNH3) {
739 double DTAU = 0.0, DTAUA = 0.0;
745 double const TESTPR = 1.0e-4;
746 double const EXPON = 4.0e0;
747 double const GAMFAC = 1.0e0;
748 double const BOLTZ = 2.084e4;
749 double const XMU = 1.476;
750 double const DROT = -1.09107e5;
751 double const B = 2.98107e5;
755 double const collsw = 1.0;
756 double const ZFAC = 1.0;
757 double const DFAC = 1.0;
761 if (T <= 0.0)
throw "Non-positive temperature";
763 double const PCROSS = pow(((PNH3 + PH2 / 8.0) / TESTPR), EXPON);
764 double const SWITCH = ((PCROSS <= 9.0) ? 1.0 - exp(-PCROSS) : 1.0);
765 double const FACT = pow(T, 3.5);
766 double const TBOLTZ = T * BOLTZ;
767 double const FACH2 = 2.318 * PH2 * pow((300.0 / T), (2. / 3.));
768 double const FACHE = (35.403 * PHe) / pow(T, (2. / 3.));
769 double const FNH3 = collsw * 224.2 * PNH3 / T;
770 double const DELTA = -SWITCH * 0.45 * PNH3 * DFAC;
775 1.00745 + 3.08301e-2 * (PH2 / T) + 5.52505e-2 * pow((PH2 / T), 2.0);
777 for (
int J = 1; J <= 16; J++) {
778 double ENJ = B * J * (J + 1);
779 double FJMUSQ = (2 * J + 1) * XMU * XMU / (J * (J + 1));
781 for (
int K = 1;
K <= J;
K++) {
783 if (
FI[I] <= 1.0 ||
GAMIN[I] <= 1.0)
continue;
785 double EN = -(ENJ + DROT *
K *
K) / TBOLTZ;
786 double FXMUSQ = FJMUSQ *
K *
K;
787 double FACNH3 = FNH3 *
GAMIN[I];
788 double GAMMA = GAMFAC * (FACNH3 + FACH2 + FACHE);
790 SWITCH * (0.655 * FACNH3 + 0.83 * FACH2 + 0.3797 * FACHE) * ZFAC;
791 double GK = (
K % 3 == 0 ? 3.0 : 1.5);
793 double TEXP = 1.132e3 * GK * FXMUSQ *
FI[I] *
FI[I] * PNH3 * exp(EN) /
795 double R =
shape(
FI[I], GAMMA, freq, DELTA, ZETA);
798 DTAUA = 0.5 * FACMP * TEXP * R;
808 double FACNH3 = 20.0 * FNH3;
809 double GAMMA = GAMFAC * (FACNH3 + FACH2 + FACHE);
811 SWITCH * (0.655 * FACNH3 + 0.83 * FACH2 + 0.3797 * FACHE) * ZFAC;
813 for (
int L = 0; L < 49; L++) {
814 int const J =
JROT[L];
815 int const K =
KROT[L];
816 double const F =
FROT[L];
818 double R =
shape(F, GAMMA, freq, DELTA, ZETA);
819 double FXMUSQ = XMU * XMU * ((J + 1) * (J + 1) -
K *
K) / (J + 1);
820 double EN = -(B * J * (J + 1) + DROT *
K *
K) / TBOLTZ;
822 double GK = (
K % 3 == 0 ? 3.0 : 1.5);
823 if (
K == 0) GK *= 0.5;
826 1.132e3 * GK * FXMUSQ * F * F * PNH3 * exp(EN) / (GAMMA * FACT);
827 DTAUA = 0.5 * ROTFAC * FACMP * TEXP * R;
double atm_from_bar(double P)
double shape(double NU0, double GAMMA, double NU, double DELTA, double ZETA)
double attenuation_NH3_Bellotti(double freq, double P, double P_idl, double T, double XH2, double XHe, double XNH3, double XH2O)
double attenuation_NH3_radtran(double freq, double P, double T, double XH2, double XHe, double XNH3)
double attenuation_NH3_Hanley(double freq, double P, double P_idl, double T, double XH2, double XHe, double XNH3, double XH2O, double power)
double attenuation_NH3_Bellotti_switch(double freq, double P, double P_idl, double T, double XH2, double XHe, double XNH3, double XH2O)
int Index_NH3(int I, int J)
double attenuation_NH3_Devaraj(double freq, double P, double P_idl, double T, double XH2, double XHe, double XNH3, double XH2O, int version)
static int const JROT[49]
static double const hrints[NROT][9]
static double const hrreals[NROT][4]
static LineParameters_NH3_inversion_JPL5 const NH3_inv_JPL5[]
static double const FI[136]
static LineParameters_NH3_rotovibrational_JPL5 const NH3_rv_JPL5[]
static double const hireals[NINV][4]
static LineParameters_NH3_rotational_JPL5 const NH3_rot_Hanley[]
static double const FROT[49]
static LineParameters_NH3_rotational_JPL5 const NH3_rot_JPL5[]
static int const KROT[49]
static double const GAMIN[136]
static double const hiints[NINV][9]