Canoe
Comprehensive Atmosphere N' Ocean Engine
freedman_mean2.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 FreedmanMean2::c1 = 10.602;
26 const Real FreedmanMean2::c2 = 2.882;
27 const Real FreedmanMean2::c3 = 6.09e-15;
28 const Real FreedmanMean2::c4 = 2.954;
29 const Real FreedmanMean2::c5 = -2.526;
30 const Real FreedmanMean2::c6 = 0.843;
31 const Real FreedmanMean2::c7 = -5.490;
32 const Real FreedmanMean2::c13 = 0.8321;
33 
34 Real FreedmanMean2::GetAttenuation(Real wave1, Real wave2,
35  AirParcel const& var) const {
36  Real p = var.w[IPR];
37  Real T = var.w[IDN];
38  Real c8, c9, c10, c11, c12;
39 
40  if (T < 800.) {
41  c8 = -14.051;
42  c9 = 3.055;
43  c10 = 0.024;
44  c11 = 1.877;
45  c12 = -0.445;
46  } else {
47  c8 = 82.241;
48  c9 = -55.456;
49  c10 = 8.754;
50  c11 = 0.7048;
51  c12 = -0.0414;
52  }
53  Real logp = log10(p * 10.); // Pa to dyn/cm2
54  Real logT = log10(T);
55  Real met = GetPar<Real>("met");
56  Real scale = GetPar<Real>("scale");
57 
58  Real klowp = c1 * atan(logT - c2) -
59  c3 / (logp + c4) * exp(pow(logT - c5, 2.0)) + c7; // Eqn 4
60 
61  // xiz changes
62  klowp += c6 * met;
63 
64  Real khigp = c8 + c9 * logT + c10 * pow(logT, 2.) +
65  logp * (c11 + c12 * logT); // Eqn 5
66 
67  // xiz changes
68  khigp += c13 * met * (0.5 + 1. / M_PI * atan((logT - 2.5) / 0.2)); // Eqn 5
69 
70  Real result = pow(10.0, klowp) + pow(10.0, khigp); // cm^2/g
71 
72  auto pthermo = Thermodynamics::GetInstance();
73  Real dens = p / (pthermo->GetRd() * T); // kg/m^3
74 
75  if (p > 5e1)
76  return scale * 0.1 * dens * result; // -> 1/m
77  else
78  return 0.;
79 }
Real *const w
Definition: air_parcel.hpp:36
static const Real c5
Definition: freedman.hpp:25
static const Real c7
Definition: freedman.hpp:25
static const Real c6
Definition: freedman.hpp:25
static const Real c1
Definition: freedman.hpp:25
Real GetAttenuation(Real wave1, Real wave2, AirParcel const &var) const
Get attenuation coefficient [1/m].
static const Real c13
Definition: freedman.hpp:25
static const Real c2
Definition: freedman.hpp:25
static const Real c4
Definition: freedman.hpp:25
static const Real c3
Definition: freedman.hpp:25
static Thermodynamics const * GetInstance()
Return a pointer to the one and only instance of Thermodynamics.