Canoe
Comprehensive Atmosphere N' Ocean Engine
mwr_absorber_nh3.cpp
Go to the documentation of this file.
1 // canoe
2 #include <air_parcel.hpp>
3 #include <configure.hpp>
4 
5 // climath
7 
8 // application
9 #include <application/exceptions.hpp>
10 
11 // opacity
12 #include "absorption_functions.hpp"
13 #include "mwr_absorbers.hpp"
14 
15 namespace GiantPlanets {
16 
18  if (!HasPar("xHe")) {
19  throw NotFoundError("MwrAbsorberNH3", "parameter 'xHe'");
20  }
21 
22  if (!HasPar("power")) {
23  throw NotFoundError("MwrAbsorberNH3", "parameter 'power'");
24  }
25 }
26 
27 Real MwrAbsorberNH3::GetAttenuation(Real wave1, Real wave2,
28  AirParcel const& var) const {
29  Real P = var.w[IPR] / 1.E5; // pa -> bar
30  Real P_idl = var.w[IPR] / 1.E5; // pa -> bar
31  Real T = var.w[IDN];
32  Real xdry = 1.;
33  for (int i = 1; i <= NVAPOR; ++i) xdry -= var.w[i];
34 
35  Real XHe = GetPar<Real>("xHe") * xdry;
36  Real XH2 = xdry - XHe;
37  Real XNH3 = var.w[GetSpeciesIndex(0)];
38  Real XH2O = var.w[GetSpeciesIndex(1)];
39 
40  Real abs;
41  Real wave = (wave1 + wave2) / 2.;
42 
43  if (model_name_ == "Bellotti16") {
44  abs = attenuation_NH3_Bellotti(wave, P, P_idl, T, XH2, XHe, XNH3, XH2O);
45  } else if (model_name_ == "BellottiSwitch16") {
46  abs = attenuation_NH3_Bellotti_switch(wave, P, P_idl, T, XH2, XHe, XNH3,
47  XH2O);
48  } else if (model_name_ == "Devaraj") {
49  abs = attenuation_NH3_Devaraj(wave, P, P_idl, T, XH2, XHe, XNH3, XH2O);
50  } else if (model_name_ == "Radtran") {
51  abs = attenuation_NH3_radtran(wave, P, T, XH2, XHe, XNH3);
52  } else if (model_name_ == "Hanley09") {
53  abs = attenuation_NH3_Hanley(wave, P, P_idl, T, XH2, XHe, XNH3, XH2O,
54  GetPar<Real>("power"));
55  } else {
56  throw NotFoundError("MwrAbsorberNH3::GetAttenuation", model_name_);
57  }
58 
59  return 100. * abs; // 1/cm -> 1/m
60 }
61 
62 } // namespace GiantPlanets
double attenuation_NH3_Hanley(double freq, double P, double P_idl, double T, double XH2, double XHe, double XNH3, double XH2O=0, double power=0.)
double attenuation_NH3_Bellotti(double freq, double P, double P_idl, double T, double XH2, double xHe, double XNH3, double XH2O=0)
double attenuation_NH3_Bellotti_switch(double freq, double P, double P_idl, double T, double XH2, double xHe, double XNH3, double XH2O=0)
double attenuation_NH3_Devaraj(double freq, double P, double P_idl, double T, double XH2, double XHe, double XNH3, double XH2O=0, int version=0)
double attenuation_NH3_radtran(double freq, double P, double T, double XH2, double XHe, double XNH3)
std::string model_name_
absorption model model
Definition: absorber.hpp:64
Real *const w
Definition: air_parcel.hpp:36
void CheckFail() const override
This function fails if the check fails.
Real GetAttenuation(Real wave1, Real wave2, AirParcel const &var) const override
Get attenuation coefficient [1/m].
bool HasPar(std::string const &name) const
Check if a parameter exists.
int GetSpeciesIndex(int n) const
This file contains declaration of Absorber.