Canoe
Comprehensive Atmosphere N' Ocean Engine
cal_dlnT_dlnP.cpp
Go to the documentation of this file.
1 // canoe
2 #include <air_parcel.hpp>
3 
4 // snap
5 #include "thermodynamics.hpp"
6 
7 Real Thermodynamics::calDlnTDlnP(AirParcel const& qfrac, Real latent[]) const {
8  // calculate gammad
9  Real gammad = GetGammad(qfrac);
10 
11  Real q_gas = 1.;
12  for (int n = 0; n < NCLOUD; ++n) q_gas -= qfrac.c[n];
13 
14  Real f_sig = 1.;
15  // vapor
16  for (int n = 1; n <= NVAPOR; ++n)
17  f_sig += qfrac.w[n] * (cp_ratio_mole_[n] - 1.);
18  // cloud
19  for (int n = 0; n < NCLOUD; ++n)
20  f_sig += qfrac.c[n] * (cp_ratio_mole_[1 + NVAPOR + n] - 1.);
21  Real cphat_ov_r = gammad / (gammad - 1.) * f_sig / q_gas;
22 
23  // vapor
24  Real xd = q_gas;
25  for (int n = 1; n <= NVAPOR; ++n) xd -= qfrac.w[n];
26 
27  Real c1 = 0., c2 = 0., c3 = 0.;
28  for (int iv = 1; iv <= NVAPOR; ++iv) {
29  c1 += qfrac.w[iv] / xd * latent[iv];
30  c2 += qfrac.w[iv] / xd * latent[iv] * latent[iv];
31  c3 += qfrac.w[iv] / xd;
32  }
33 
34  return (1. + c1) / (cphat_ov_r + (c2 + c1 * c1) / (1. + c3));
35 }
Real *const w
Definition: air_parcel.hpp:36
Real *const c
cloud data
Definition: air_parcel.hpp:39
std::array< Real, Size > cp_ratio_mole_
ratio of specific heat capacities [J/mol] at constant pressure
Real calDlnTDlnP(AirParcel const &qfrac, Real latent[]) const
Calculate moist adiabatic temperature gradient.
Real GetGammad(AirParcel const &var) const
adiaibatic index of dry air [1]