version 3.8
constant.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_COMPONENTS_CONSTANT_HH
13#define DUMUX_COMPONENTS_CONSTANT_HH
14
15#include <dune/common/exceptions.hh>
17
19
24
25namespace Dumux {
26namespace Components {
27
43template<int id, class Scalar>
45: public Components::Base<Scalar, Constant<id, Scalar> >
46, public Components::Liquid<Scalar, Constant<id, Scalar> >
47, public Components::Gas<Scalar, Constant<id, Scalar> >
48, public Components::Solid<Scalar, Constant<id, Scalar> >
49{
51
52public:
56 static constexpr bool gasIsCompressible()
57 { return false; }
58
62 static constexpr bool gasViscosityIsConstant()
63 { return true; }
64
68 static constexpr bool gasIsIdeal()
69 { return true; }
70
74 static constexpr bool liquidIsCompressible()
75 { return false; }
76
80 static constexpr bool liquidViscosityIsConstant()
81 { return true; }
82
86 static const std::string& name()
87 {
88 static const std::string name = getParamFromGroup<std::string>(std::to_string(id), "Component.Name", "component");
89 return name;
90 }
91
96 {
97 static const Scalar molarMass = getParamFromGroup<Scalar>(std::to_string(id), "Component.MolarMass");
98 return molarMass;
99 }
100
105 {
106 static const Scalar tripleTemperature = getParamFromGroup<Scalar>(std::to_string(id), "Component.TripleTemperature");
107 return tripleTemperature;
108 }
109
114 {
115 static const Scalar triplePressure = getParamFromGroup<Scalar>(std::to_string(id), "Component.TriplePressure");
116 return triplePressure;
117 }
118
123 {
124 static const Scalar vaporizationEnthalpy = getParamFromGroup<Scalar>(std::to_string(id), "Component.EnthalpyOfVaporization");
126 }
127
128
136 {
137 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidDensity");
138 return density;
139 }
140
150
163 {
164 static const Scalar dynamicViscosity = [&]
165 {
166 if (hasParamInGroup(std::to_string(id), "Component.LiquidKinematicViscosity"))
167 {
168 if (hasParamInGroup(std::to_string(id), "Component.LiquidDynamicViscosity"))
169 DUNE_THROW(Dune::InvalidStateException, "Found both Component.LiquidKinematicViscosity and Component.LiquidDynamicViscosity."
170 << " Please only specify either the kinematic or the dynamic viscosity for all constant components to avoid ambiguities.");
171
172 return getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidKinematicViscosity") * liquidDensity(temperature, pressure);
173 }
174 else
175 return getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidDynamicViscosity");
176 }();
177
178 return dynamicViscosity;
179 }
180
187 {
188 static const Scalar thermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidThermalConductivity");
189 return thermalConductivity;
190 }
191
198 {
199 // u = c * dT for incompressible fluids
200 const Scalar heatCapacity = liquidHeatCapacity(temperature, pressure);
201 static const Scalar tRef = getParamFromGroup<Scalar>(std::to_string(id), "Component.ReferenceTemperature", 293.15);
202 return heatCapacity * (temperature - tRef);
203 }
204
212 {
215 return u + pressure / rho;
216 }
217
225 {
226 static const Scalar heatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidHeatCapacity");
227 return heatCapacity;
228 }
229
237 {
238 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasDensity");
239 return density;
240 }
241
251
252
265 {
266 static const Scalar dynamicViscosity = [&]
267 {
268 if (hasParamInGroup(std::to_string(id), "Component.GasKinematicViscosity"))
269 {
270 if (hasParamInGroup(std::to_string(id), "Component.GasDynamicViscosity"))
271 DUNE_THROW(Dune::InvalidStateException, "Found both Component.GasKinematicViscosity and Component.GasDynamicViscosity."
272 << " Please only specify either the kinematic or the dynamic viscosity for all constant components to avoid ambiguities.");
273
274 return getParamFromGroup<Scalar>(std::to_string(id), "Component.GasKinematicViscosity") * gasDensity(temperature, pressure);
275 }
276 else
277 return getParamFromGroup<Scalar>(std::to_string(id), "Component.GasDynamicViscosity");
278 }();
279
280 return dynamicViscosity;
281 }
282
289 {
290 static const Scalar thermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasThermalConductivity");
291 return thermalConductivity;
292 }
293
308 {
309 // 1/molarMass: conversion from [J/(mol K)] to [J/(kg K)]
310 // R*T/molarMass: pressure *spec. volume for an ideal gas
312
313 }
314
322 {
323 static const Scalar tRef = getParamFromGroup<Scalar>(std::to_string(id), "Component.ReferenceTemperature", 293.15);
325 }
326
334 {
335 static const Scalar heatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasHeatCapacity");
336 return heatCapacity;
337 }
338
348 {
349 const Scalar p2 = triplePressure();
350 const Scalar T2 = tripleTemperature();
351 const Scalar exponent = -(vaporizationEnthalpy()*molarMass())/IdealGas::R*(1/T - 1/T2);
352
353 using std::exp;
354 const Scalar vaporPressure = p2*exp(exponent);
355 return vaporPressure;
356 }
357
365 {
366 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidDensity");
367 return density;
368 }
369
375 {
376 static const Scalar solidThermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidThermalConductivity");
378 }
379
385 {
386 static const Scalar solidHeatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidHeatCapacity");
387 return solidHeatCapacity;
388 }
389};
390
391} // end namespace Components
392
393} // end namespace Dumux
394
395#endif
Base class for all components Components provide the thermodynamic relations for the liquid,...
Definition: components/base.hh:47
Scalar Scalar
export the scalar type used by the component
Definition: components/base.hh:51
A component which returns run time specified values for all fluid properties.
Definition: constant.hh:49
static Scalar solidDensity(Scalar temperature)
The density in of the component at a given pressure in and temperature in .
Definition: constant.hh:364
static const std::string & name()
A human readable name for the component.
Definition: constant.hh:86
static Scalar solidThermalConductivity(Scalar temperature)
Thermal conductivity of the component as a solid.
Definition: constant.hh:374
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the component as a gas.
Definition: constant.hh:288
static Scalar triplePressure()
Returns the pressure at the component's triple point.
Definition: constant.hh:113
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the component as a liquid.
Definition: constant.hh:186
static Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the component as a liquid.
Definition: constant.hh:211
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density in at a given pressure and temperature.
Definition: constant.hh:148
static Scalar gasInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the component as a gas.
Definition: constant.hh:307
static constexpr bool gasIsCompressible()
Returns true if the gas phase is assumed to be compressible.
Definition: constant.hh:56
static Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the component as a liquid.
Definition: constant.hh:224
static Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the component as a gas.
Definition: constant.hh:333
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density in at a given pressure and temperature.
Definition: constant.hh:249
static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the component as a gas.
Definition: constant.hh:321
static Scalar tripleTemperature()
Returns the temperature at the components's triple point.
Definition: constant.hh:104
static Scalar solidHeatCapacity(Scalar temperature)
Specific isobaric heat capacity of the component as a solid.
Definition: constant.hh:384
static constexpr bool gasViscosityIsConstant()
Returns true if the gas phase viscosity is constant.
Definition: constant.hh:62
static Scalar liquidInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the component as a liquid.
Definition: constant.hh:197
static Scalar gasDensity(Scalar temperature, Scalar pressure)
Sets the gas density in .
Definition: constant.hh:236
static constexpr bool liquidViscosityIsConstant()
Returns true if the liquid phase viscosity is constant.
Definition: constant.hh:80
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: constant.hh:68
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
Sets the liquid density in .
Definition: constant.hh:135
static Scalar molarMass()
The mass in of one mole of the component.
Definition: constant.hh:95
static constexpr bool liquidIsCompressible()
Returns true if the liquid phase is assumed to be compressible.
Definition: constant.hh:74
static Scalar vaporPressure(Scalar T)
The vapor pressure in of a the component at a given temperature.
Definition: constant.hh:347
static Scalar vaporizationEnthalpy()
The vaporization enthalpy in needed to vaporize one kilogram of the liquid component to the gaseous ...
Definition: constant.hh:122
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
Sets the liquid dynamic viscosity in .
Definition: constant.hh:162
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
Sets the gas dynamic viscosity in .
Definition: constant.hh:264
Interface for components that have a gas state.
Definition: gas.hh:29
Interface for components that have a liquid state.
Definition: liquid.hh:29
Interface for components that have a solid state.
Definition: solid.hh:29
Relations valid for an ideal gas.
Definition: idealgas.hh:25
static constexpr Scalar R
The ideal gas constant .
Definition: idealgas.hh:28
Base class for all components Components provide the thermodynamic relations for the liquid,...
Interface for components that have a gas state.
bool hasParamInGroup(const std::string &paramGroup, const std::string &param)
Check whether a key exists in the parameter tree with a model group prefix.
Definition: parameters.hh:165
Relations valid for an ideal gas.
Interface for components that have a liquid state.
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:22
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Interface for components that have a solid state.