Canoe
Comprehensive Atmosphere N' Ocean Engine
giants_enroll_vapor_functions_v1.hpp
Go to the documentation of this file.
1 // application
2 #include <application/application.hpp>
3 
4 // canoe
5 #include <air_parcel.hpp>
6 #include <configure.hpp>
7 #include <index_map.hpp>
8 
9 // thermodynamics
16 
17 // water svp
19  std::vector<IndexSet> const& cloud_index_set) {
20  auto pindex = IndexMap::GetInstance();
21  if (!pindex->HasVapor("H2O")) return;
22 
23  Application::Logger app("snap");
24  app->Log("Enrolling H2O vapor pressures");
25 
26  int iH2O = pindex->GetVaporId("H2O");
27 
28  svp_func1[iH2O][0] = [](AirParcel const& qfrac, int, int) {
29  return sat_vapor_p_H2O_BriggsS(qfrac.w[IDN]);
30  };
31 
32  for (int n = 1; n < cloud_index_set[iH2O].size(); ++n) {
33  svp_func1[iH2O][n] = NullSatVaporPres1;
34  }
35 }
36 
37 // ammonia svp
39  std::vector<IndexSet> const& cloud_index_set) {
40  auto pindex = IndexMap::GetInstance();
41  if (!pindex->HasVapor("NH3")) return;
42 
43  Application::Logger app("snap");
44  app->Log("Enrolling NH3 vapor pressures");
45 
46  int iNH3 = pindex->GetVaporId("NH3");
47 
48  svp_func1[iNH3][0] = [](AirParcel const& qfrac, int, int) {
49  return sat_vapor_p_NH3_BriggsS(qfrac.w[IDN]);
50  };
51 
52  for (int n = 1; n < cloud_index_set[iNH3].size(); ++n) {
53  svp_func1[iNH3][n] = NullSatVaporPres1;
54  }
55 }
56 
57 // hydrogen sulfide svp
59  std::vector<IndexSet> const& cloud_index_set) {
60  auto pindex = IndexMap::GetInstance();
61  if (!pindex->HasVapor("H2S")) return;
62 
63  Application::Logger app("snap");
64  app->Log("Enrolling H2S vapor pressures");
65 
66  int iH2S = pindex->GetVaporId("H2S");
67 
68  svp_func1[iH2S][0] = [](AirParcel const& qfrac, int, int) {
69  return sat_vapor_p_H2S_Antoine(qfrac.w[IDN]);
70  };
71 
72  for (int n = 1; n < cloud_index_set[iH2S].size(); ++n) {
73  svp_func1[iH2S][n] = NullSatVaporPres1;
74  }
75 }
76 
77 // ammonium hydrosulfide svp
80  std::map<IndexPair, ReactionInfo>& cloud_reaction_map) {
81  auto pindex = IndexMap::GetInstance();
82  if (!pindex->HasVapor("NH3") || !pindex->HasVapor("H2S") ||
83  !pindex->HasCloud("NH4SH(s)"))
84  return;
85 
86  Application::Logger app("snap");
87  app->Log("Enrolling NH4SH vapor pressure");
88 
89  // ammonium hydrosulfide svp
90  int iNH3 = pindex->GetVaporId("NH3");
91  int iH2S = pindex->GetVaporId("H2S");
92  int iNH4SH = pindex->GetCloudId("NH4SH(s)");
93 
94  auto ij = std::minmax(iNH3, iH2S);
95 
96  svp_func2[ij] = [](AirParcel const& qfrac, int, int, int) {
97  return sat_vapor_p_NH4SH_Lewis(qfrac.w[IDN]);
98  };
99 
100  cloud_reaction_map[ij] = std::make_pair<ReactionIndx, ReactionStoi>(
101  {iNH3, iH2S, iNH4SH}, {1, 1, 1});
102 }
103 
105  Application::Logger app("snap");
106  app->Log("Enrolling vapor functions");
107 
112 }
double sat_vapor_p_NH3_BriggsS(double T)
double sat_vapor_p_NH4SH_Lewis(double T)
Real *const w
Definition: air_parcel.hpp:36
static IndexMap const * GetInstance()
Definition: index_map.cpp:29
void enrollVaporFunctions()
custom functions for vapor (to be overridden by user mods)
std::map< IndexPair, ReactionInfo > cloud_reaction_map_
reaction information map
std::vector< IndexSet > cloud_index_set_
cloud index set
std::vector< std::vector< SatVaporPresFunc1 > > SVPFunc1Container
std::map< IndexPair, SatVaporPresFunc2 > SVPFunc2Container
SVPFunc1Container svp_func1_
saturation vapor pressure function: Vapor -> Cloud
SVPFunc2Container svp_func2_
saturation vapor pressure function: Vapor + Vapor -> Cloud
Real NullSatVaporPres1(AirParcel const &air, int i, int j)
void enroll_vapor_function_NH3(Thermodynamics::SVPFunc1Container &svp_func1, std::vector< IndexSet > const &cloud_index_set)
void enroll_vapor_function_NH4SH(Thermodynamics::SVPFunc2Container &svp_func2, std::map< IndexPair, ReactionInfo > &cloud_reaction_map)
void enroll_vapor_function_H2S(Thermodynamics::SVPFunc1Container &svp_func1, std::vector< IndexSet > const &cloud_index_set)
void enroll_vapor_function_H2O(Thermodynamics::SVPFunc1Container &svp_func1, std::vector< IndexSet > const &cloud_index_set)
double sat_vapor_p_H2S_Antoine(double T)
double sat_vapor_p_H2O_BriggsS(double T)