version 3.10-dev
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-FileCopyrightInfo: 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 {
24namespace FluidSystems {
25
31template <class Scalar, class MainComponent, class SecondComponent>
33: public Base<Scalar, LiquidPhaseTwoC<Scalar, MainComponent, SecondComponent> >
34{
37
38public:
40
41 static constexpr int numPhases = 1;
42 static constexpr int numComponents = 2;
43
44 static constexpr int liquidPhaseIdx = 0;
45 static constexpr int phase0Idx = liquidPhaseIdx;
46
47 static constexpr int comp0Idx = 0;
48 static constexpr int comp1Idx = 1;
49 static constexpr int mainCompIdx = comp0Idx;
50 static constexpr int secondCompIdx = comp1Idx;
51
55 static void init() {}
56
57 /****************************************
58 * Fluid phase related static parameters
59 ****************************************/
65 static std::string phaseName(int phaseIdx = 0)
66 { return IOName::liquidPhase(); }
67
72 static constexpr bool isMiscible()
73 { return false; }
74
80 static std::string componentName(int compIdx)
81 { return compIdx ? SecondComponent::name() : MainComponent::name(); }
82
86 static std::string name()
87 { return "LiquidPhaseTwoC"; }
88
92 static constexpr bool isGas(int phaseIdx = 0)
93 { return false; }
94
109 static bool isIdealMixture(int phaseIdx = 0)
110 { return true; }
111
115 static constexpr bool isCompressible(int phaseIdx = 0)
116 { return MainComponent::liquidIsCompressible(); }
117
121 static bool isIdealGas(int phaseIdx = 0)
122 { return false; /* we're a liquid! */ }
123
127 static Scalar molarMass(int compIdx)
128 { return compIdx ? SecondComponent::molarMass() : MainComponent::molarMass(); }
129
134 { return MainComponent::criticalTemperature(); }
135
140 { return MainComponent::criticalPressure(); }
141
146 { return MainComponent::tripleTemperature(); }
147
152 { return MainComponent::triplePressure(); }
153
159 { return MainComponent::vaporPressure(T); }
160
167 { return MainComponent::liquidDensity(temperature, pressure); }
168
171 template <class FluidState>
172 static Scalar density(const FluidState &fluidState,
173 const int phaseIdx = 0)
174 {
175 const Scalar T = fluidState.temperature(phaseIdx);
176 const Scalar p = fluidState.pressure(phaseIdx);
177
178 // See: Eq. (7) in Class et al. (2002a)
179 // This assumes each gas molecule displaces exactly one
180 // molecule in the liquid.
181 const Scalar pureComponentMolarDensity = MainComponent::liquidMolarDensity(T, p);
182
183 return pureComponentMolarDensity
184 * (MainComponent::molarMass()*fluidState.moleFraction(phase0Idx, mainCompIdx)
185 + SecondComponent::molarMass()*fluidState.moleFraction(phase0Idx, secondCompIdx));
186 }
187
190 template <class FluidState>
191 static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
192 {
193 const Scalar T = fluidState.temperature(phaseIdx);
194 const Scalar p = fluidState.pressure(phaseIdx);
195
196 // assume pure component or that each gas molecule displaces exactly one
197 // molecule in the liquid.
198 return MainComponent::liquidMolarDensity(T, p);
199 }
200
207 { return MainComponent::liquidPressure(temperature, density); }
208
215 { return MainComponent::liquidEnthalpy(temperature, pressure); }
216
219 template <class FluidState>
220 static Scalar enthalpy(const FluidState &fluidState,
221 const int phaseIdx)
222 {
223 return enthalpy(fluidState.temperature(phaseIdx),
224 fluidState.pressure(phaseIdx));
225 }
226
233 template <class FluidState>
234 static Scalar componentEnthalpy(const FluidState &fluidState,
235 int phaseIdx,
236 int componentIdx)
237 {
238 const Scalar T = fluidState.temperature(phaseIdx);
239 const Scalar p = fluidState.pressure(phaseIdx);
240
241 if (componentIdx == mainCompIdx)
242 return MainComponent::liquidEnthalpy(T, p);
243 else if (componentIdx == secondCompIdx)
244 return SecondComponent::liquidEnthalpy(T, p);
245 else
246 DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << componentIdx);
247 }
248
255 { return MainComponent::liquidInternalEnergy(temperature, pressure); }
256
263 { return MainComponent::liquidViscosity(temperature, pressure); }
264
267 template <class FluidState>
268 static Scalar viscosity(const FluidState &fluidState,
269 const int phaseIdx)
270 {
271 return viscosity(fluidState.temperature(phaseIdx),
272 fluidState.pressure(phaseIdx));
273 }
274
277 template <class FluidState>
278 static Scalar fugacityCoefficient(const FluidState &fluidState,
279 int phaseIdx,
280 int compIdx)
281 {
282 assert(0 <= phaseIdx && phaseIdx < numPhases);
283 assert(0 <= compIdx && compIdx < numComponents);
284
285 if (phaseIdx == compIdx)
286 // We could calculate the real fugacity coefficient of
287 // the component in the fluid. Probably that's not worth
288 // the effort, since the fugacity coefficient of the other
289 // component is infinite anyway...
290 return 1.0;
291 return std::numeric_limits<Scalar>::infinity();
292 }
293
296 template <class FluidState>
297 static Scalar diffusionCoefficient(const FluidState &fluidState,
298 int phaseIdx,
299 int compIdx)
300 {
301 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Diffusion coefficients");
302 }
303
306 template <class FluidState>
307 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
308 {
309 assert(phaseIdx < numPhases);
310 return BinaryCoefficients::liquidDiffCoeff(fluidState.temperature(phaseIdx), fluidState.pressure(phaseIdx));
311 }
312
319 { return MainComponent::liquidThermalConductivity(temperature, pressure); }
320
323 template <class FluidState>
324 static Scalar thermalConductivity(const FluidState &fluidState,
325 const int phaseIdx)
326 {
327 return thermalConductivity(fluidState.temperature(phaseIdx),
328 fluidState.pressure(phaseIdx));
329 }
330
337 { return MainComponent::liquidHeatCapacity(temperature, pressure); }
338
341 template <class FluidState>
342 static Scalar heatCapacity(const FluidState &fluidState,
343 const int phaseIdx)
344 {
345 return heatCapacity(fluidState.temperature(phaseIdx),
346 fluidState.pressure(phaseIdx));
347 }
348};
349
350} // namespace FluidSystems
351
352} // namespace Dumux
353
354#endif
Binary coefficients for water and another component.
Definition: h2o_constant.hh:31
Fluid system base class.
Definition: fluidsystems/base.hh:33
Scalar Scalar
export the scalar type
Definition: fluidsystems/base.hh:36
A liquid phase consisting of a two components, a main component and a conservative tracer component.
Definition: liquidphase2c.hh:34
static constexpr int liquidPhaseIdx
index of the liquid phase
Definition: liquidphase2c.hh:44
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: liquidphase2c.hh:72
static constexpr bool isCompressible(int phaseIdx=0)
Returns true if the fluid is assumed to be compressible.
Definition: liquidphase2c.hh:115
static constexpr int numComponents
Number of components in the fluid system.
Definition: liquidphase2c.hh:42
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in the specified phase.
Definition: liquidphase2c.hh:234
static Scalar thermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the fluid .
Definition: liquidphase2c.hh:318
static constexpr int mainCompIdx
index of the main component
Definition: liquidphase2c.hh:49
static const Scalar internalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy the pure component as a liquid.
Definition: liquidphase2c.hh:254
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: liquidphase2c.hh:191
static std::string phaseName(int phaseIdx=0)
Return the human readable name of a fluid phase.
Definition: liquidphase2c.hh:65
static Scalar pressure(Scalar temperature, Scalar density)
The pressure of the component at a given density and temperature.
Definition: liquidphase2c.hh:206
static Scalar density(Scalar temperature, Scalar pressure)
The density of the phase at a given pressure and temperature.
Definition: liquidphase2c.hh:166
static Scalar criticalTemperature()
Returns the critical temperature of the main component.
Definition: liquidphase2c.hh:133
static Scalar tripleTemperature()
Returns the temperature at the main component's triple point.
Definition: liquidphase2c.hh:145
static constexpr int comp0Idx
index of the first component
Definition: liquidphase2c.hh:47
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:109
static Scalar viscosity(const FluidState &fluidState, const int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: liquidphase2c.hh:268
static Scalar triplePressure()
Returns the pressure at the main component's triple point.
Definition: liquidphase2c.hh:151
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:307
static Scalar viscosity(Scalar temperature, Scalar pressure)
The dynamic liquid viscosity of the pure component.
Definition: liquidphase2c.hh:262
static std::string name()
A human readable name for the fluid system.
Definition: liquidphase2c.hh:86
static std::string componentName(int compIdx)
A human readable name for the component.
Definition: liquidphase2c.hh:80
static Scalar heatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the fluid .
Definition: liquidphase2c.hh:336
static bool isIdealGas(int phaseIdx=0)
Returns true if the fluid is assumed to be an ideal gas.
Definition: liquidphase2c.hh:121
static Scalar density(const FluidState &fluidState, const int phaseIdx=0)
Calculate the density of a fluid phase.
Definition: liquidphase2c.hh:172
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:220
static void init()
Initialize the fluid system's static parameters generically.
Definition: liquidphase2c.hh:55
static constexpr int phase0Idx
index of the only phase
Definition: liquidphase2c.hh:45
static const Scalar enthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy the pure component as a liquid.
Definition: liquidphase2c.hh:214
static constexpr int secondCompIdx
index of the secondary component
Definition: liquidphase2c.hh:50
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the main component at a given temperature.
Definition: liquidphase2c.hh:158
static Scalar molarMass(int compIdx)
The mass in of one mole of the component.
Definition: liquidphase2c.hh:127
static Scalar heatCapacity(const FluidState &fluidState, const int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: liquidphase2c.hh:342
static Scalar criticalPressure()
Returns the critical pressure of the main component.
Definition: liquidphase2c.hh:139
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: liquidphase2c.hh:324
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:278
static constexpr bool isGas(int phaseIdx=0)
Returns whether the fluid is gaseous.
Definition: liquidphase2c.hh:92
static constexpr int comp1Idx
index of the second component
Definition: liquidphase2c.hh:48
static constexpr int numPhases
Number of phases in the fluid system.
Definition: liquidphase2c.hh:41
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:297
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.
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
Definition: adapt.hh:17