8 #include "AtmosModel.h"
10 #include "HapkeAtm2.h"
13 #include "NumericalApproximation.h"
14 #include "IException.h"
20 HapkeAtm2::HapkeAtm2(Pvl &pvl, PhotoModel &pmodel) : AtmosModel(pvl, pmodel) {
69 double f1munot, f1mmunot;
70 double xmunot, ymunot;
79 if(p_atmosTau == 0.0) {
91 p_wha2 = 0.5 * p_atmosWha;
110 p_f1m = log(2.0) - p_em * p_e1 + p_e1_2;
111 p_f2m = -1.0 * (p_f1m + p_em * p_e2 - 1.0);
112 p_f3m = -1.0 * (p_f2m + p_em * p_e3 - 0.5);
113 p_g12 = (p_atmosTau * p_e1 * p_e2 + p_f1m + p_f2m) * 0.5;
114 p_g13 = (p_atmosTau * p_e1 * p_e3 + p_f1m + p_f3m) * (1.0 / 3.0);
128 p_f1 = Eulgam() + log(p_atmosTau) + p_e * p_e1;
129 p_f2 = p_f1 + p_e * p_e2 - 1.0;
130 p_f3 = p_f2 + p_e * p_e3 - 0.5;
132 p_g12p = (p_atmosTau * (p_e1 - p_g11p) + p_em * (p_f1 + p_f2)) * 0.25;
133 p_g13p = (p_atmosTau * (0.5 * p_e1 - p_g12p) + p_em * (p_f1 + p_f3)) * 0.2;
136 p_x0 = p_wha2 * (1.0 + p_wha2 * p_g12);
137 p_y0 = p_wha2 * (p_e2 + p_wha2 * p_g12p);
140 p_delta = (1.0 - (p_x0 + p_y0) - (1.0 - p_atmosWha) / (1.0 - (p_x0 - p_y0))) / (p_atmosWha * (0.5 - p_e3));
143 p_alpha0 = 1.0 + p_wha2 * p_g12 + p_delta * (0.5 - p_e3);
144 p_alpha1 = 0.5 + p_wha2 * p_g13 + p_delta * ((1.0 / 3.0) - p_e4);
145 p_beta0 = p_e2 + p_wha2 * p_g12p + p_delta * (0.5 - p_e3);
146 p_beta1 = p_e3 + p_wha2 * p_g13p + p_delta * ((1.0 / 3.0) - p_e4);
149 if(p_atmosWha == 1.0) {
151 p_f4m = -1.0 * (p_f3m + p_em * p_e4 - (1.0 / 3.0));
152 p_g14 = (p_atmosTau * p_e1 * p_e4 + p_f1m + p_f4m) * 0.25;
153 p_f4 = p_f3 + p_e * p_e4 - (1.0 / 3.0);
154 p_g14p = (p_atmosTau * (0.5 * p_e1 - p_g13p) + p_em * (p_f1 + p_f4)) * (1.0 / 6.0);
155 p_alpha2 = (1.0 / 3.0) + p_wha2 * p_g14 + p_delta * (0.25 - p_e5);
156 p_beta2 = p_e4 + p_wha2 * p_g14p + p_delta * (0.25 - p_e5);
157 p_fixcon = (p_beta0 * p_atmosTau - p_alpha1 + p_beta1) /
158 ((p_alpha1 + p_beta1) * p_atmosTau + 2.0 * (p_alpha2 + p_beta2));
162 p_gammax = p_wha2 * p_beta0;
163 p_gammay = 1.0 - p_wha2 * p_alpha0;
172 p_sbar = 1.0 - ((2.0 - p_atmosWha * p_alpha0) * p_alpha1 + p_atmosWha * p_beta0 * p_beta1) + p_atmosHahgsb;
174 SetOldTau(p_atmosTau);
175 SetOldWha(p_atmosWha);
180 munot = cos((
PI / 180.0) * incidence);
181 maxval = max(1.0e-30, hpsq1 + munot * munot);
183 munotp = max(munotp, p_atmosTau / 69.0);
184 mu = cos((
PI / 180.0) * p_emission);
185 maxval = max(1.0e-30, hpsq1 + mu * mu);
187 mup = max(mup, p_atmosTau / 69.0);
190 maxval = max(1.0e-30, munotp);
191 xx = -p_atmosTau / maxval;
200 p_emunot = exp(-p_atmosTau / munotp);
203 maxval = max(1.0e-30, mup);
204 xx = -p_atmosTau / maxval;
212 emu = exp(-p_atmosTau / mup);
217 if(fabs(xx - 1.0) < 1.0e-10) {
219 f1mmunot = xx * (log(1.0 + 1.0 / xx) - p_e1 * p_emunot +
AtmosModel::En(1, p_atmosTau * (1.0 + 1.0 / xx)));
222 f1munot = xx * (log(xx / (1.0 - xx)) + p_e1 / p_emunot +
AtmosModel::Ei(p_atmosTau * (1.0 / xx - 1.0)));
223 f1mmunot = xx * (log(1.0 + 1.0 / xx) - p_e1 * p_emunot +
AtmosModel::En(1, p_atmosTau * (1.0 + 1.0 / xx)));
226 std::string msg =
"Negative length of planetary curvature ";
227 msg +=
"encountered";
232 if(fabs(xx - 1.0) < 1.0e-10) {
234 f1mmu = xx * (log(1.0 + 1.0 / xx) - p_e1 * emu +
AtmosModel::En(1, p_atmosTau * (1.0 + 1.0 / xx)));
237 f1mu = xx * (log(xx / (1.0 - xx)) + p_e1 / emu +
AtmosModel::Ei(p_atmosTau * (1.0 / xx - 1.0)));
238 f1mmu = xx * (log(1.0 + 1.0 / xx) - p_e1 * emu +
AtmosModel::En(1, p_atmosTau * (1.0 + 1.0 / xx)));
241 std::string msg =
"Negative length of planetary curvature ";
242 msg +=
"encountered";
246 xmunot = 1.0 + p_wha2 * f1mmunot + p_delta * munotp * (1.0 - p_emunot);
247 ymunot = p_emunot * (1.0 + p_wha2 * f1munot) + p_delta * munotp * (1.0 - p_emunot);
248 xmu = 1.0 + p_wha2 * f1mmu + p_delta * mup * (1.0 - emu);
249 ymu = emu * (1.0 + p_wha2 * f1mu) + p_delta * mup * (1.0 - emu);
252 if(p_atmosWha == 1.0) {
253 fix = p_fixcon * munotp * (xmunot + ymunot);
254 xmunot = xmunot + fix;
255 ymunot = ymunot + fix;
256 fix = p_fixcon * mup * (xmu + ymu);
267 p_atmosAtmSwitch = 1;
269 p_atmosInc = incidence;
270 p_atmosMunot = cos((
PI / 180.0) * incidence);
271 p_atmosSini = sin((
PI / 180.0) * incidence);
273 gmunot = p_gammax * xmunot + p_gammay * ymunot + hahgt *
AtmosWha() / 360.0;
274 p_atmosInc = p_emission;
275 p_atmosMunot = cos((
PI / 180.0) * p_emission);
276 p_atmosSini = sin((
PI / 180.0) * p_emission);
278 gmu = p_gammax * xmu + p_gammay * ymu + hahgt *
AtmosWha() / 360.0;
281 gmunot = p_gammax * xmunot + p_gammay * ymunot + hahgt;
283 gmu = p_gammax * xmu + p_gammay * ymu + hahgt;
288 phasefn = (1.0 - p_atmosHga * p_atmosHga) / pow(1.0 + 2.0 * p_atmosHga *
289 cos((
PI / 180.0) * phase) + p_atmosHga * p_atmosHga, 1.5);
290 p_pstd = 0.25 * p_atmosWha * munotp / (munotp + mup) * ((xmunot * xmu - ymunot * ymu) +
291 (phasefn - 1.0) * (1.0 - emu * p_emunot));
303 p_atmosAtmSwitch = 3;
305 p_atmosInc = incidence;
306 p_atmosMunot = cos((
PI / 180.0) * incidence);
307 p_atmosSini = sin((
PI / 180.0) * incidence);
309 hahgt0 = hahgt0 *
AtmosWha() * p_atmosMunot / (360.0 * p_atmosSini);
313 p_trans0 = (p_emunot + hahgt0) * emu;
322 p_atmosAtmSwitch = 1;
325 hahgt = .5 * (p_gammax * xmunot + p_gammay * ymunot - p_emunot) + hahgt *
330 p_transs = (p_emunot + hahgt) * emu;