Canoe
Comprehensive Atmosphere N' Ocean Engine
mwr_absorber_h2o.cpp
Go to the documentation of this file.
1 // canoe
2 #include <air_parcel.hpp>
3 #include <configure.hpp>
4 
5 // application
6 #include <application/exceptions.hpp>
7 
8 // opacity
10 #include "mwr_absorbers.hpp"
11 
12 namespace GiantPlanets {
13 
15  if (!HasPar("xHe")) {
16  throw NotFoundError("MwrAbsorberH2O", "parameter 'xHe'");
17  }
18 
19  if (!HasPar("scale")) {
20  throw NotFoundError("MwrAbsorberH2O", "parameter 'scale'");
21  }
22 }
23 
24 Real MwrAbsorberH2O::GetAttenuation(Real wave1, Real wave2,
25  AirParcel const& var) const {
26  Real P = var.w[IPR] / 1.E5; // pa -> bar
27  Real T = var.w[IDN];
28  Real xdry = 1.;
29  for (int i = 1; i <= NVAPOR; ++i) xdry -= var.w[i];
30  Real XHe = GetPar<Real>("xHe") * xdry;
31  Real XH2 = xdry - XHe;
32  Real XH2O = var.w[GetSpeciesIndex(0)];
33 
34  Real abs;
35  Real wave = (wave1 + wave2) / 2.;
36 
37  if (model_name_ == "deBoer") {
38  abs = attenuation_H2O_deBoer(wave, P, T, XH2, XHe, XH2O);
39  } else if (model_name_ == "Waters") {
40  abs = attenuation_H2O_Waters(wave, P, T, XH2, XHe, XH2O);
41  } else if (model_name_ == "Goodman") {
42  abs = attenuation_H2O_Goodman(wave, P, T, XH2, XHe, XH2O);
43  } else { // Karpowicz
44  abs = attenuation_H2O_Karpowicz(wave, P, T, XH2, XHe, XH2O,
45  GetPar<Real>("scale"));
46  }
47 
48  return 100. * abs; // 1/cm -> 1/m
49 }
50 
51 } // namespace GiantPlanets
double attenuation_H2O_Karpowicz(double freq, double P_idl, double T, double XH2, double XHe, double XH2O, double scale)
double attenuation_H2O_deBoer(double freq, double P, double T, double XH2, double XHe, double XH2O)
double attenuation_H2O_Goodman(double freq, double P, double T, double XH2, double XHe, double XH2O)
double attenuation_H2O_Waters(double freq, double P, double T, double XH2, double XHe, double XH2O)
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.