Athena++/Atmosphere
Planetary Atmosphere Simulator
thermodynamic_funcs.hpp
Go to the documentation of this file.
1 
9 #ifndef THERMODYNAMICS_FUNCS_HPP
10 #define THERMODYNAMICS_FUNCS_HPP
11 
12 #include "thermodynamics.hpp"
13 #include "../particles/particles.hpp"
14 
16 template<typename T>
17 Real PotentialTemp(T w, Real p0, Thermodynamics *pthermo) {
18  Real chi = pthermo->GetChi(w);
19  Real temp = pthermo->GetTemp(w);
20  return temp*pow(p0/w[IPR], chi);
21 }
22 
24 template<typename T>
26  Real temp = pthermo->GetTemp(w);
27  Real IE = w[IDN]*pthermo->GetMeanCp(w)*temp;
28  Real rho = w[IDN];
29  /*if (ppart != nullptr) {
30  for (int n = 0; n < NVAPOR; ++n) {
31  for (int t = 0; t < ppart->u.GetDim4(); ++t) {
32  rho += ppart->u(t,k,j,i);
33  IE -= ppart->u(t,k,j,i)*pthermo->GetLatent(1+NVAPOR+n);
34  IE += ppart->u(t,k,j,i)*ppart->GetCv(t)*temp;
35  }
36  ppart = ppart->next;
37  }
38  }*/
39  return IE/rho + gz;
40 }
41 
43 template<typename T>
44 Real RelativeHumidity(T w, int iv, Thermodynamics *pthermo) {
45  Real dw[1+NVAPOR];
46  pthermo->SaturationSurplus(dw, w, VariableType::prim);
47  return w[iv]/(w[iv] - dw[iv]);
48 }
49 
51 /*Real MoistEntropy(AthenaArray<Real> const& w, Thermodynamics *pthermo, Particles *ppart,
52  int k, int j, int i) {
53 #if (NVAPOR > 0)
54  Real gamma = pthermo->pmy_block->peos->GetGamma();
55  Real tem[1] = {pthermo->GetTemp(prim)};
56  update_gamma(gamma, tem);
57  Real cpd = Rd_*gamma/(gamma - 1.);
58  Real temp = tem[0]
59  Real pres = prim[IPR];
60 
61  Real qd = 1.;
62  for (int n = 1; n <= NVAPOR; ++n)
63  qd -= prim[n];
64 
65  Real qc[1+NVAPOR];
66  std::fill(qc, qc + 1 + NVAPOR, 0.);
67  for (int n = 1 + NVAPOR; n <= NVAPOR; ++n)
68  qc[1+(n-1)%NVAPOR] += prim[n] + 1.0E-10; // prevent devide by 0
69 
70  Real lv = 0.;
71  for (int n = 1 + NVAPOR; n < NMASS; ++n) {
72  int ng = 1 + (n-1)%NVAPOR;
73  Real ratio = (prim[n] + 1.0E-10)/qc[ng];
74  lv += GetLatent(n,temp)*prim[ng]*ratio;
75  }
76 
77  Real st = 1.;
78  for (int n = 1 + NVAPOR; n < NMASS; ++n) {
79  int ng = 1 + (n-1)%NVAPOR;
80  Real ratio = (prim[n] + 1.0E-10)/qc[ng];
81  st += (prim[n] + prim[ng]*ratio)*(GetCpRatio(n) - 1.);
82  }
83  Real lv_ov_cpt = lv/(cpd*st*temp);
84 
85  Real chi = Rd_/cpd*qd/st;
86 
87  Real xv = 1.;
88  for (int n = 1; n <= NVAPOR; ++n)
89  xv += prim[n]/qd/mu_ratios_[n];
90 
91  Real pd = pres/xv;
92 
93  Real rh = 1.;
94  for (int n = 1; n <= NVAPOR; ++n) {
95  Real eta = prim[n]/qd/mu_ratios_[n];
96  Real pv = pres*eta/xv;
97  int nc = n + NVAPOR;
98  Real esat;
99  if (n == AMMONIA_VAPOR_ID)
100  esat = sat_vapor_p_NH3_BriggsS(temp);
101  else if (n == WATER_VAPOR_ID)
102  esat = sat_vapor_p_H2O_BriggsS(temp);
103  else
104  esat = SatVaporPresIdeal(temp/t3_[nc], p3_[nc], beta_[nc], delta_[nc]);
105  rh *= pow(pv/esat, -eta*Rd_/(cpd*st));
106  }
107 
108  return temp*pow(p0/pd, chi)*exp(lv_ov_cpt)*rh;
109 #else
110  return PotentialTemp(prim, p0, pthermo);
111 #endif
112 }*/
113 
115 
116 
117 #endif /* end of include guard THERMODYNAMICS_FUNCS_HPP */
118 
@ IPR
Definition: athena.hpp:139
double Real
Definition: athena.hpp:29
@ IDN
Definition: athena.hpp:135
Real GetChi(T w) const
Real GetMeanCp(T w) const
Real GetTemp(T w) const
Temperature.
void SaturationSurplus(Real dv[], T v, VariableType vtype) const
Real gz[18][8]
float temp
Definition: fit_ammonia.py:6
Real RelativeHumidity(T w, int iv, Thermodynamics *pthermo)
Relative humidity.
Real PotentialTemp(T w, Real p0, Thermodynamics *pthermo)
Potential temperature.
Real saha_ionization_electron_density(Real T, Real num, Real ion_ev)
Equivalent potential temperature.
Definition: ionization.cpp:13
Real MoistStaticEnergy(T w, Real gz, Thermodynamics *pthermo)
Moist static energy.