Canoe
Comprehensive Atmosphere N' Ocean Engine
freedman_mean.cpp
Go to the documentation of this file.
1 // C/C++ headers
2 #include <algorithm>
3 #include <cassert> // assert
4 #include <cmath>
5 #include <cstring>
6 #include <iostream>
7 #include <stdexcept>
8 
9 // athena
10 #include <athena/athena_arrays.hpp>
11 #include <athena/mesh/mesh.hpp>
12 
13 // canoe
14 #include <air_parcel.hpp>
15 #include <impl.hpp>
16 
17 // snap
19 
20 // opacity
21 #include "freedman.hpp"
22 
23 // coefficient from Richard S. Freedman 2014. APJS
24 
25 const Real FreedmanMean::c1 = 10.602;
26 const Real FreedmanMean::c2 = 2.882;
27 const Real FreedmanMean::c3 = 6.09e-15;
28 const Real FreedmanMean::c4 = 2.954;
29 const Real FreedmanMean::c5 = -2.526;
30 const Real FreedmanMean::c6 = 0.843;
31 const Real FreedmanMean::c7 = -5.490;
32 
33 Real FreedmanMean::GetAttenuation(Real wave1, Real wave2,
34  AirParcel const& var) const {
35  Real p = var.w[IPR];
36  Real T = var.w[IDN];
37  Real c8, c9, c10, c11, c12;
38 
39  if (T < 800.) {
40  c8 = -14.051;
41  c9 = 3.055;
42  c10 = 0.024;
43  c11 = 1.877;
44  c12 = -0.445;
45  } else {
46  c8 = 82.241;
47  c9 = -55.456;
48  c10 = 8.754;
49  c11 = 0.7048;
50  c12 = -0.0414;
51  }
52  Real logp = log10(p * 10.); // Pa to dyn/cm2
53  Real logT = log10(T);
54 
55  Real klowp = c1 * atan(logT - c2) -
56  c3 / (logp + c4) * exp(pow(logT - c5, 2.0)) + c7; // Eqn 4
57 
58  Real khigp = c8 + c9 * logT + c10 * pow(logT, 2.) +
59  logp * (c11 + c12 * logT); // Eqn 5
60 
61  Real result = pow(10.0, klowp) + pow(10.0, khigp); // cm^2/g
62 
63  auto pthermo = Thermodynamics::GetInstance();
64  Real dens = p / (pthermo->GetRd() * T); // kg/m^3
65 
66  if (p > 5e1)
67  return 0.1 * dens * result; // -> 1/m
68  else
69  return 0.;
70 }
Real *const w
Definition: air_parcel.hpp:36
static const Real c2
Definition: freedman.hpp:16
static const Real c6
Definition: freedman.hpp:16
static const Real c4
Definition: freedman.hpp:16
Real GetAttenuation(Real wave1, Real wave2, AirParcel const &var) const
Get attenuation coefficient [1/m].
static const Real c1
Definition: freedman.hpp:16
static const Real c5
Definition: freedman.hpp:16
static const Real c7
Definition: freedman.hpp:16
static const Real c3
Definition: freedman.hpp:16
static Thermodynamics const * GetInstance()
Return a pointer to the one and only instance of Thermodynamics.