Canoe
Comprehensive Atmosphere N' Ocean Engine
mwr_absorber_cia.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("MwrAbsorberCIA", "parameter 'xHe'");
17  }
18 
19  if (!HasPar("xCH4")) {
20  throw NotFoundError("MwrAbsorberCIA", "parameter 'xCH4'");
21  }
22 
23  if (!HasPar("mix")) {
24  throw NotFoundError("MwrAbsorberCIA", "parameter 'mix'");
25  }
26 }
27 
28 Real MwrAbsorberCIA::GetAttenuation(Real wave1, Real wave2,
29  AirParcel const& var) const {
30  Real P = 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  Real XHe = GetPar<Real>("xHe") * xdry;
35  Real XCH4 = GetPar<Real>("xCH4") * xdry;
36  Real XH2 = (1. - GetPar<Real>("xHe") - GetPar<Real>("xCH4")) * xdry;
37  Real mix = GetPar<Real>("mix");
38  Real wave = (wave1 + wave2) / 2.;
39 
40  // 1/cm -> 1/m
41  return 100. * attenuation_CIA(wave, P, T, XH2, XHe, XCH4, mix);
42 }
43 
44 } // namespace GiantPlanets
double attenuation_CIA(double freq, double P, double T, double XH2, double XHe, double XCH4, double mix)
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.
This file contains declaration of Absorber.