OGS
PhaseTransitionEvaporation.cpp
Go to the documentation of this file.
1 
11 
13 
14 namespace ProcessLib
15 {
16 namespace TH2M
17 {
19  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
20  : PhaseTransitionModel(media),
21  n_components_gas_{numberOfComponents(media, "Gas")},
22  gas_phase_vapour_component_index_{findComponentIndex(
23  media, "Gas", MaterialPropertyLib::PropertyType::vapour_pressure)},
24  // dry air component is complement of vapour component index
25  gas_phase_dry_air_component_index_{gas_phase_vapour_component_index_ ^ 1}
26 {
27  DBUG("Create PhaseTransitionEvaporation constitutive model.");
28 
29  if (n_components_gas_ != 2)
30  {
31  OGS_FATAL(
32  "The current implementation of PhaseTransitionModelEvaporation "
33  "requires the specification of exactly two components in the gas "
34  "phase.");
35  }
36 
37  // It is always the first (begin) medium that holds fluid phases.
38  auto const medium = media.begin()->second;
39  auto const& gas_phase = medium->phase("Gas");
40  auto const& liquid_phase = medium->phase("AqueousLiquid");
41 
42  // check for minimum requirement definitions in media object
43  std::array const required_vapour_component_properties = {
48  std::array const required_dry_air_component_properties = {
51  std::array const required_liquid_properties = {
53 
55  gas_phase.component(gas_phase_vapour_component_index_),
56  required_vapour_component_properties);
58  gas_phase.component(gas_phase_dry_air_component_index_),
59  required_dry_air_component_properties);
60  checkRequiredProperties(liquid_phase, required_liquid_properties);
61 }
62 
65  PhaseTransitionModelVariables const& phase_transition_model_variables,
66  const MaterialPropertyLib::Medium* medium,
68  ParameterLib::SpatialPosition pos, double const t, const double dt) const
69 {
70  // primary variables
71  auto const pGR = std::get<double>(variables[static_cast<int>(
73  auto const pCap = std::get<double>(variables[static_cast<int>(
75  auto const T = std::get<double>(variables[static_cast<int>(
77 
78  auto const& liquid_phase = medium->phase("AqueousLiquid");
79  auto const& gas_phase = medium->phase("Gas");
80 
82 
83  auto const& vapour_component =
84  gas_phase.component(gas_phase_vapour_component_index_);
85  auto const& dry_air_component =
86  gas_phase.component(gas_phase_dry_air_component_index_);
87 
88  // specific latent heat (of evaporation)
89  const auto dh_evap =
90  vapour_component
92  .template value<double>(variables, pos, t, dt);
93 
94  variables[static_cast<int>(
96 
97  // vapour pressure over flat interface
98  const auto p_vap_flat =
99  vapour_component
101  .template value<double>(variables, pos, t, dt);
102 
103  const auto dp_vap_flat_dT =
104  vapour_component
106  .template dValue<double>(variables,
108  pos, t, dt);
109 
110  // molar mass of evaporating component (should be the same as
111  // solventComponent.molar_mass!)
112  auto const M_W =
113  vapour_component.property(MaterialPropertyLib::PropertyType::molar_mass)
114  .template value<double>(variables, pos, t, dt);
115  // molar mass of dry air component (should be the same as
116  // solvateComponent.molar_mass!)
117  auto const M_C =
118  dry_air_component
120  .template value<double>(variables, pos, t, dt);
121 
122  // copy previous state before modification.
123  PhaseTransitionModelVariables cv = phase_transition_model_variables;
124  cv.rhoLR = liquid_phase.property(MaterialPropertyLib::PropertyType::density)
125  .template value<double>(variables, pos, t, dt);
126  cv.rhoWLR = cv.rhoLR;
127 
128  // Kelvin-Laplace correction for menisci
129  const double K = std::exp(-pCap * M_W / cv.rhoLR / R / T);
130  const double dK_dT = pCap * M_W / cv.rhoLR / R / T / T * K;
131 
132  // vapour pressure inside porespace (== water partial pressure in gas phase)
133  cv.pWGR = p_vap_flat * K;
134 
135  auto const dp_vap_dT = dp_vap_flat_dT * K + p_vap_flat * dK_dT;
136 
137  // gas phase molar fractions
138  cv.xnWG = std::clamp(cv.pWGR / pGR, 0., 1.);
139  cv.xnCG = 1. - cv.xnWG;
140 
141  // molar mass of the gas phase as a mixture of 'air' and vapour
142  auto const MG = cv.xnCG * M_C + cv.xnWG * M_W;
143  variables[static_cast<int>(MaterialPropertyLib::Variable::molar_mass)] = MG;
144 
145  // gas phase mixture density
147  .template value<double>(variables, pos, t, dt);
148 
149  auto const drhoGR_dpGR =
151  .template dValue<double>(
153  t, dt);
154 
155  auto const drhoGR_dT =
157  .template dValue<double>(variables,
159  pos, t, dt);
160 
161  // gas phase mass fractions
162  cv.xmCG = cv.xnCG * M_C / MG;
163  cv.xmWG = 1. - cv.xmCG;
164 
165  auto beta_pGR = 1. / cv.rhoGR * drhoGR_dpGR;
166  cv.dxmWG_dpGR = cv.xmWG * beta_pGR;
168 
169  auto beta_TGR = -1. / cv.rhoGR * drhoGR_dT;
170 
171  // component partial densities in the gas phase
172  cv.rhoCGR = cv.xmCG * cv.rhoGR;
173  cv.rhoWGR = cv.xmWG * cv.rhoGR;
174 
175  auto drhoWGR_dT = M_W / R / T / T * (T * dp_vap_dT - cv.pWGR);
176 
177  cv.dxmWG_dT = 1. / cv.rhoGR * drhoWGR_dT + cv.xmWG * beta_TGR;
178  cv.dxmCG_dT = -cv.dxmWG_dT;
179 
180  // specific heat capacities of dry air and vapour
181  auto const cpCG =
182  dry_air_component
184  .template value<double>(variables, pos, t, dt);
185  auto const cpWG =
186  vapour_component
188  .template value<double>(variables, pos, t, dt);
189 
190  // specific enthalpy of dry air and vapour components
191  cv.hCG = cpCG * T;
192  cv.hWG = cpWG * T + dh_evap;
193 
194  // specific enthalpy of gas phase and derivatives
195  cv.hG = cv.xmCG * cv.hCG + cv.xmWG * cv.hWG;
196 
197  // specific heat capacities of liquid phase
198  auto const cpL =
199  liquid_phase
201  .template value<double>(variables, pos, t, dt);
202 
203  // specific enthalpy of liquid phase and derivatives
204  cv.hL = cpL * T;
205 
206  // specific inner energies of gas and liquid phases
207  cv.uG = cv.hG - pGR / cv.rhoGR;
208  cv.uL = cv.hL;
209 
211  vapour_component.property(MaterialPropertyLib::PropertyType::diffusion)
212  .template value<double>(variables, pos, t, dt);
213 
214  // gas phase viscosity
216  .template value<double>(variables, pos, t, dt);
217 
218  // gas phase thermal conductivity
219  cv.lambdaGR =
220  gas_phase
222  .template value<double>(variables, pos, t, dt);
223 
224  // liquid phase viscosity
225  cv.muLR =
226  liquid_phase.property(MaterialPropertyLib::PropertyType::viscosity)
227  .template value<double>(variables, pos, t, dt);
228 
229  // liquid phase thermal conductivity
230  cv.lambdaLR =
231  liquid_phase
233  .template value<double>(variables, pos, t, dt);
234 
235  return cv;
236 }
237 
238 } // namespace TH2M
239 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
Phase const & phase(std::size_t index) const
Definition: Medium.cpp:30
std::array< VariableType, static_cast< int >(Variable::number_of_variables)> VariableArray
Definition: VariableType.h:108
void checkRequiredProperties(Component const &c, Container const &required_properties)
Definition: Component.h:96
int numberOfComponents(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media, std::string phase_name)
int findComponentIndex(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media, std::string phase_name, MaterialPropertyLib::PropertyType property_type)
PhaseTransitionEvaporation(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
PhaseTransitionModelVariables updateConstitutiveVariables(PhaseTransitionModelVariables const &phase_transition_model_variables, const MaterialPropertyLib::Medium *medium, MaterialPropertyLib::VariableArray variables, ParameterLib::SpatialPosition pos, double const t, double const dt) const override