version 3.10-dev
1pliquid.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_PHASE_HH
13#define DUMUX_LIQUID_PHASE_HH
14
15#include <cassert>
16#include <limits>
17
18#include <dune/common/exceptions.hh>
19
22#include <dumux/io/name.hh>
23
24namespace Dumux {
25namespace FluidSystems {
26
31template <class Scalar, class ComponentT>
33: public Base<Scalar, OnePLiquid<Scalar, ComponentT> >
34{
36
37 static_assert(ComponentTraits<ComponentT>::hasLiquidState, "The component does not implement a liquid state!");
38
39public:
40 using Component = ComponentT;
42
43 static constexpr int numPhases = 1;
44 static constexpr int numComponents = 1;
45
46 static constexpr int phase0Idx = 0;
47 static constexpr int comp0Idx = 0;
48
52 static void init()
53 { }
54
55 /****************************************
56 * Fluid phase related static parameters
57 ****************************************/
63 static std::string phaseName(int phaseIdx = 0)
64 { return IOName::liquidPhase(); }
65
71 static std::string componentName(int compIdx = 0)
72 { return Component::name(); }
73
77 static std::string name()
78 { return Component::name(); }
79
83 static constexpr bool isMiscible()
84 { return false; }
85
89 static constexpr bool isGas(int phaseIdx = 0)
90 { return false; }
91
106 static constexpr bool isIdealMixture(int phaseIdx = 0)
107 { return true; }
108
112 static constexpr bool isCompressible(int phaseIdx = 0)
113 { return Component::liquidIsCompressible(); }
114
118 static constexpr bool viscosityIsConstant(int phaseIdx = 0)
119 { return Component::liquidViscosityIsConstant(); }
120
124 static constexpr bool isIdealGas(int phaseIdx = 0)
125 { return false; /* we're a liquid! */ }
126
130 static Scalar molarMass(int compIdx = 0)
131 { return Component::molarMass(); }
132
136 static Scalar criticalTemperature(int compIdx = 0)
137 { return Component::criticalTemperature(); }
138
142 static Scalar criticalPressure(int compIdx = 0)
143 { return Component::criticalPressure(); }
144
148 static Scalar tripleTemperature(int compIdx = 0)
149 { return Component::tripleTemperature(); }
150
154 static Scalar triplePressure(int compIdx = 0)
155 { return Component::triplePressure(); }
156
162 { return Component::vaporPressure(T); }
163
168 { return Component::liquidDensity(temperature, pressure); }
169
172 template <class FluidState>
173 static Scalar density(const FluidState &fluidState,
174 const int phaseIdx)
175 {
176 return density(fluidState.temperature(phaseIdx),
177 fluidState.pressure(phaseIdx));
178 }
179
182 template <class FluidState>
183 static Scalar molarDensity(const FluidState &fluidState, const int phaseIdx)
184 {
185 return molarDensity(fluidState.temperature(phaseIdx),
186 fluidState.pressure(phaseIdx));
187 }
188
195 { return Component::liquidMolarDensity(temperature, pressure); }
196
203 { return Component::liquidPressure(temperature, density); }
204
211 { return Component::liquidEnthalpy(temperature, pressure); }
212
215 template <class FluidState>
216 static Scalar enthalpy(const FluidState &fluidState,
217 const int phaseIdx)
218 {
219 return enthalpy(fluidState.temperature(phaseIdx),
220 fluidState.pressure(phaseIdx));
221 }
222
229 { return Component::liquidInternalEnergy(temperature, pressure); }
230
237 { return Component::liquidViscosity(temperature, pressure); }
238
241 template <class FluidState>
242 static Scalar viscosity(const FluidState &fluidState,
243 const int phaseIdx)
244 {
245 return viscosity(fluidState.temperature(phaseIdx),
246 fluidState.pressure(phaseIdx));
247 }
248
251 template <class FluidState>
252 static Scalar fugacityCoefficient(const FluidState &fluidState,
253 int phaseIdx,
254 int compIdx)
255 {
256 assert(0 <= phaseIdx && phaseIdx < numPhases);
257 assert(0 <= compIdx && compIdx < numComponents);
258
259 if (phaseIdx == compIdx)
260 // We could calculate the real fugacity coefficient of
261 // the component in the fluid. Probably that's not worth
262 // the effort, since the fugacity coefficient of the other
263 // component is infinite anyway...
264 return 1.0;
265 return std::numeric_limits<Scalar>::infinity();
266 }
267
270 template <class FluidState>
271 static Scalar diffusionCoefficient(const FluidState &fluidState,
272 int phaseIdx,
273 int compIdx)
274 {
275 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Diffusion coefficients");
276 }
277
280 template <class FluidState>
281 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
282 int phaseIdx,
283 int compIIdx,
284 int compJIdx)
285 {
286 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Binary diffusion coefficients");
287 }
288
295 { return Component::liquidThermalConductivity(temperature, pressure); }
296
299 template <class FluidState>
300 static Scalar thermalConductivity(const FluidState &fluidState,
301 const int phaseIdx)
302 {
303 return thermalConductivity(fluidState.temperature(phaseIdx),
304 fluidState.pressure(phaseIdx));
305 }
306
313 { return Component::liquidHeatCapacity(temperature, pressure); }
314
317 template <class FluidState>
318 static Scalar heatCapacity(const FluidState &fluidState,
319 const int phaseIdx)
320 {
321 return heatCapacity(fluidState.temperature(phaseIdx),
322 fluidState.pressure(phaseIdx));
323 }
324};
325
326} // namespace FluidSystems
327} // namespace
328
329#endif
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 single component.
Definition: 1pliquid.hh:34
static constexpr int numComponents
Number of components in the fluid system.
Definition: 1pliquid.hh:44
static constexpr bool isCompressible(int phaseIdx=0)
Returns true if the fluid is assumed to be compressible.
Definition: 1pliquid.hh:112
static const Scalar enthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy the pure component as a liquid.
Definition: 1pliquid.hh:210
static Scalar molarDensity(const FluidState &fluidState, const int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: 1pliquid.hh:183
static Scalar enthalpy(const FluidState &fluidState, const int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition: 1pliquid.hh:216
static std::string phaseName(int phaseIdx=0)
Return the human readable name of a fluid phase.
Definition: 1pliquid.hh:63
static constexpr bool isGas(int phaseIdx=0)
Returns whether the fluid is a liquid.
Definition: 1pliquid.hh:89
static constexpr bool isIdealGas(int phaseIdx=0)
Returns true if the fluid is assumed to be an ideal gas.
Definition: 1pliquid.hh:124
static constexpr bool isIdealMixture(int phaseIdx=0)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: 1pliquid.hh:106
static void init()
Initialize the fluid system's static parameters generically.
Definition: 1pliquid.hh:52
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: 1pliquid.hh:271
static Scalar molarMass(int compIdx=0)
The mass in of one mole of the component.
Definition: 1pliquid.hh:130
static Scalar triplePressure(int compIdx=0)
Returns the pressure at the component's triple point.
Definition: 1pliquid.hh:154
static Scalar criticalPressure(int compIdx=0)
Returns the critical pressure of the component.
Definition: 1pliquid.hh:142
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: 1pliquid.hh:300
static Scalar density(const FluidState &fluidState, const int phaseIdx)
Calculate the density of a fluid phase.
Definition: 1pliquid.hh:173
static std::string name()
A human readable name for the component.
Definition: 1pliquid.hh:77
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: 1pliquid.hh:281
static constexpr bool isMiscible()
There is only one phase, so not mass transfer between phases can occur.
Definition: 1pliquid.hh:83
static Scalar viscosity(const FluidState &fluidState, const int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: 1pliquid.hh:242
static Scalar density(Scalar temperature, Scalar pressure)
The density of the component at a given pressure and temperature.
Definition: 1pliquid.hh:167
static Scalar pressure(Scalar temperature, Scalar density)
The pressure of the component at a given density and temperature.
Definition: 1pliquid.hh:202
static Scalar thermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the fluid .
Definition: 1pliquid.hh:294
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the component at a given temperature.
Definition: 1pliquid.hh:161
static Scalar heatCapacity(const FluidState &fluidState, const int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: 1pliquid.hh:318
static const Scalar internalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy the pure component as a liquid.
Definition: 1pliquid.hh:228
static Scalar viscosity(Scalar temperature, Scalar pressure)
The dynamic liquid viscosity of the pure component.
Definition: 1pliquid.hh:236
static Scalar heatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the fluid .
Definition: 1pliquid.hh:312
static Scalar tripleTemperature(int compIdx=0)
Returns the temperature at the component's triple point.
Definition: 1pliquid.hh:148
static constexpr int comp0Idx
index of the only component
Definition: 1pliquid.hh:47
static Scalar criticalTemperature(int compIdx=0)
Returns the critical temperature of the component.
Definition: 1pliquid.hh:136
static constexpr int phase0Idx
index of the only phase
Definition: 1pliquid.hh:46
static Scalar molarDensity(Scalar temperature, Scalar pressure)
The density of the component at a given pressure and temperature.
Definition: 1pliquid.hh:194
static constexpr bool viscosityIsConstant(int phaseIdx=0)
Returns true if the fluid viscosity is constant.
Definition: 1pliquid.hh:118
ComponentT Component
Definition: 1pliquid.hh:40
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: 1pliquid.hh:252
static std::string componentName(int compIdx=0)
A human readable name for the component.
Definition: 1pliquid.hh:71
static constexpr int numPhases
Number of phases in the fluid system.
Definition: 1pliquid.hh:43
The a parameter cache which does nothing.
Definition: nullparametercache.hh:22
Component traits, i.e. information extracted from components.
Fluid system base class.
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
Component traits, i.e. information extracted from components.
Definition: componenttraits.hh:31