version 3.11-dev
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
liquidphase2c.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_LIQUID_TWOC_PHASE_HH
13#define DUMUX_LIQUID_TWOC_PHASE_HH
14
15#include <cassert>
16#include <limits>
17
18#include <dune/common/exceptions.hh>
21#include <dumux/io/name.hh>
22
23namespace Dumux::FluidSystems {
24
30template <class Scalar, class MainComponent, class SecondComponent>
32: public Base<Scalar, LiquidPhaseTwoC<Scalar, MainComponent, SecondComponent> >
33{
36
37public:
39
40 static constexpr int numPhases = 1;
41 static constexpr int numComponents = 2;
42
43 static constexpr int liquidPhaseIdx = 0;
44 static constexpr int phase0Idx = liquidPhaseIdx;
45
46 static constexpr int comp0Idx = 0;
47 static constexpr int comp1Idx = 1;
48 static constexpr int mainCompIdx = comp0Idx;
49 static constexpr int secondCompIdx = comp1Idx;
50
54 static void init() {}
55
56 /****************************************
57 * Fluid phase related static parameters
58 ****************************************/
64 static std::string phaseName(int phaseIdx = 0)
65 { return IOName::liquidPhase(); }
66
71 static constexpr bool isMiscible()
72 { return false; }
73
79 static std::string componentName(int compIdx)
80 { return compIdx ? SecondComponent::name() : MainComponent::name(); }
81
85 static std::string name()
86 { return "LiquidPhaseTwoC"; }
87
91 static constexpr bool isGas(int phaseIdx = 0)
92 { return false; }
93
108 static bool isIdealMixture(int phaseIdx = 0)
109 { return true; }
110
114 static constexpr bool isCompressible(int phaseIdx = 0)
115 { return MainComponent::liquidIsCompressible(); }
116
120 static bool isIdealGas(int phaseIdx = 0)
121 { return false; /* we're a liquid! */ }
122
126 static Scalar molarMass(int compIdx)
127 { return compIdx ? SecondComponent::molarMass() : MainComponent::molarMass(); }
128
133 { return MainComponent::criticalTemperature(); }
134
139 { return MainComponent::criticalPressure(); }
140
145 { return MainComponent::tripleTemperature(); }
146
151 { return MainComponent::triplePressure(); }
152
158 { return MainComponent::vaporPressure(T); }
159
166 { return MainComponent::liquidDensity(temperature, pressure); }
167
170 template <class FluidState>
171 static Scalar density(const FluidState &fluidState,
172 const int phaseIdx = 0)
173 {
174 const Scalar T = fluidState.temperature(phaseIdx);
175 const Scalar p = fluidState.pressure(phaseIdx);
176
177 // See: Eq. (7) in Class et al. (2002a)
178 // This assumes each gas molecule displaces exactly one
179 // molecule in the liquid.
180 const Scalar pureComponentMolarDensity = MainComponent::liquidMolarDensity(T, p);
181
182 return pureComponentMolarDensity
183 * (MainComponent::molarMass()*fluidState.moleFraction(phase0Idx, mainCompIdx)
184 + SecondComponent::molarMass()*fluidState.moleFraction(phase0Idx, secondCompIdx));
185 }
186
189 template <class FluidState>
190 static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
191 {
192 const Scalar T = fluidState.temperature(phaseIdx);
193 const Scalar p = fluidState.pressure(phaseIdx);
194
195 // assume pure component or that each gas molecule displaces exactly one
196 // molecule in the liquid.
197 return MainComponent::liquidMolarDensity(T, p);
198 }
199
206 { return MainComponent::liquidPressure(temperature, density); }
207
214 { return MainComponent::liquidEnthalpy(temperature, pressure); }
215
218 template <class FluidState>
219 static Scalar enthalpy(const FluidState &fluidState,
220 const int phaseIdx)
221 {
222 return enthalpy(fluidState.temperature(phaseIdx),
223 fluidState.pressure(phaseIdx));
224 }
225
232 template <class FluidState>
233 static Scalar componentEnthalpy(const FluidState &fluidState,
234 int phaseIdx,
235 int componentIdx)
236 {
237 const Scalar T = fluidState.temperature(phaseIdx);
238 const Scalar p = fluidState.pressure(phaseIdx);
239
240 if (componentIdx == mainCompIdx)
241 return MainComponent::liquidEnthalpy(T, p);
242 else if (componentIdx == secondCompIdx)
243 return SecondComponent::liquidEnthalpy(T, p);
244 else
245 DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << componentIdx);
246 }
247
254 { return MainComponent::liquidInternalEnergy(temperature, pressure); }
255
262 { return MainComponent::liquidViscosity(temperature, pressure); }
263
266 template <class FluidState>
267 static Scalar viscosity(const FluidState &fluidState,
268 const int phaseIdx)
269 {
270 return viscosity(fluidState.temperature(phaseIdx),
271 fluidState.pressure(phaseIdx));
272 }
273
276 template <class FluidState>
277 static Scalar fugacityCoefficient(const FluidState &fluidState,
278 int phaseIdx,
279 int compIdx)
280 {
281 assert(0 <= phaseIdx && phaseIdx < numPhases);
282 assert(0 <= compIdx && compIdx < numComponents);
283
284 if (phaseIdx == compIdx)
285 // We could calculate the real fugacity coefficient of
286 // the component in the fluid. Probably that's not worth
287 // the effort, since the fugacity coefficient of the other
288 // component is infinite anyway...
289 return 1.0;
290 return std::numeric_limits<Scalar>::infinity();
291 }
292
295 template <class FluidState>
296 static Scalar diffusionCoefficient(const FluidState &fluidState,
297 int phaseIdx,
298 int compIdx)
299 {
300 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Diffusion coefficients");
301 }
302
305 template <class FluidState>
306 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
307 {
308 assert(phaseIdx < numPhases);
309 return BinaryCoefficients::liquidDiffCoeff(fluidState.temperature(phaseIdx), fluidState.pressure(phaseIdx));
310 }
311
318 { return MainComponent::liquidThermalConductivity(temperature, pressure); }
319
322 template <class FluidState>
323 static Scalar thermalConductivity(const FluidState &fluidState,
324 const int phaseIdx)
325 {
326 return thermalConductivity(fluidState.temperature(phaseIdx),
327 fluidState.pressure(phaseIdx));
328 }
329
336 { return MainComponent::liquidHeatCapacity(temperature, pressure); }
337
340 template <class FluidState>
341 static Scalar heatCapacity(const FluidState &fluidState,
342 const int phaseIdx)
343 {
344 return heatCapacity(fluidState.temperature(phaseIdx),
345 fluidState.pressure(phaseIdx));
346 }
347};
348
349} // end namespace Dumux::FluidSystems
350
351#endif
Binary coefficients for water and another component.
Definition: h2o_constant.hh:30
Fluid system base class.
Definition: fluidsystems/base.hh:32
Scalar Scalar
export the scalar type
Definition: fluidsystems/base.hh:35
A liquid phase consisting of a two components, a main component and a conservative tracer component.
Definition: liquidphase2c.hh:33
static constexpr int liquidPhaseIdx
index of the liquid phase
Definition: liquidphase2c.hh:43
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: liquidphase2c.hh:71
static constexpr bool isCompressible(int phaseIdx=0)
Returns true if the fluid is assumed to be compressible.
Definition: liquidphase2c.hh:114
static constexpr int numComponents
Number of components in the fluid system.
Definition: liquidphase2c.hh:41
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in the specified phase.
Definition: liquidphase2c.hh:233
static Scalar thermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the fluid .
Definition: liquidphase2c.hh:317
static constexpr int mainCompIdx
index of the main component
Definition: liquidphase2c.hh:48
static const Scalar internalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy the pure component as a liquid.
Definition: liquidphase2c.hh:253
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: liquidphase2c.hh:190
static std::string phaseName(int phaseIdx=0)
Return the human readable name of a fluid phase.
Definition: liquidphase2c.hh:64
static Scalar pressure(Scalar temperature, Scalar density)
The pressure of the component at a given density and temperature.
Definition: liquidphase2c.hh:205
static Scalar density(Scalar temperature, Scalar pressure)
The density of the phase at a given pressure and temperature.
Definition: liquidphase2c.hh:165
static Scalar criticalTemperature()
Returns the critical temperature of the main component.
Definition: liquidphase2c.hh:132
static Scalar tripleTemperature()
Returns the temperature at the main component's triple point.
Definition: liquidphase2c.hh:144
static constexpr int comp0Idx
index of the first component
Definition: liquidphase2c.hh:46
static bool isIdealMixture(int phaseIdx=0)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: liquidphase2c.hh:108
static Scalar viscosity(const FluidState &fluidState, const int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: liquidphase2c.hh:267
static Scalar triplePressure()
Returns the pressure at the main component's triple point.
Definition: liquidphase2c.hh:150
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: liquidphase2c.hh:306
static Scalar viscosity(Scalar temperature, Scalar pressure)
The dynamic liquid viscosity of the pure component.
Definition: liquidphase2c.hh:261
static std::string name()
A human readable name for the fluid system.
Definition: liquidphase2c.hh:85
static std::string componentName(int compIdx)
A human readable name for the component.
Definition: liquidphase2c.hh:79
static Scalar heatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the fluid .
Definition: liquidphase2c.hh:335
static bool isIdealGas(int phaseIdx=0)
Returns true if the fluid is assumed to be an ideal gas.
Definition: liquidphase2c.hh:120
static Scalar density(const FluidState &fluidState, const int phaseIdx=0)
Calculate the density of a fluid phase.
Definition: liquidphase2c.hh:171
static Scalar enthalpy(const FluidState &fluidState, const int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition: liquidphase2c.hh:219
static void init()
Initialize the fluid system's static parameters generically.
Definition: liquidphase2c.hh:54
static constexpr int phase0Idx
index of the only phase
Definition: liquidphase2c.hh:44
static const Scalar enthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy the pure component as a liquid.
Definition: liquidphase2c.hh:213
static constexpr int secondCompIdx
index of the secondary component
Definition: liquidphase2c.hh:49
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the main component at a given temperature.
Definition: liquidphase2c.hh:157
static Scalar molarMass(int compIdx)
The mass in of one mole of the component.
Definition: liquidphase2c.hh:126
static Scalar heatCapacity(const FluidState &fluidState, const int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: liquidphase2c.hh:341
static Scalar criticalPressure()
Returns the critical pressure of the main component.
Definition: liquidphase2c.hh:138
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: liquidphase2c.hh:323
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: liquidphase2c.hh:277
static constexpr bool isGas(int phaseIdx=0)
Returns whether the fluid is gaseous.
Definition: liquidphase2c.hh:91
static constexpr int comp1Idx
index of the second component
Definition: liquidphase2c.hh:47
static constexpr int numPhases
Number of phases in the fluid system.
Definition: liquidphase2c.hh:40
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: liquidphase2c.hh:296
The a parameter cache which does nothing.
Definition: nullparametercache.hh:22
Fluid system base class.
Binary coefficients for water and a "constant" component.
A collection of input/output field names for common physical quantities.
Definition: h2o.hh:901
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
std::string liquidPhase() noexcept
I/O name of liquid phase.
Definition: name.hh:107