3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_COMPONENTS_CONSTANT_HH
25#define DUMUX_COMPONENTS_CONSTANT_HH
26
27#include <dune/common/exceptions.hh>
29
31
36
37namespace Dumux {
38namespace Components {
39
55template<int id, class Scalar>
57: public Components::Base<Scalar, Constant<id, Scalar> >
58, public Components::Liquid<Scalar, Constant<id, Scalar> >
59, public Components::Gas<Scalar, Constant<id, Scalar> >
60, public Components::Solid<Scalar, Constant<id, Scalar> >
61{
63
64public:
68 static constexpr bool gasIsCompressible()
69 { return false; }
70
74 static constexpr bool gasViscosityIsConstant()
75 { return true; }
76
80 static constexpr bool gasIsIdeal()
81 { return true; }
82
86 static constexpr bool liquidIsCompressible()
87 { return false; }
88
92 static constexpr bool liquidViscosityIsConstant()
93 { return true; }
94
98 static const std::string& name()
99 {
100 static const std::string name = getParamFromGroup<std::string>(std::to_string(id), "Component.Name", "component");
101 return name;
102 }
103
108 {
109 static const Scalar molarMass = getParamFromGroup<Scalar>(std::to_string(id), "Component.MolarMass");
110 return molarMass;
111 }
112
117 {
118 static const Scalar tripleTemperature = getParamFromGroup<Scalar>(std::to_string(id), "Component.TripleTemperature");
119 return tripleTemperature;
120 }
121
126 {
127 static const Scalar triplePressure = getParamFromGroup<Scalar>(std::to_string(id), "Component.TriplePressure");
128 return triplePressure;
129 }
130
135 {
136 static const Scalar vaporizationEnthalpy = getParamFromGroup<Scalar>(std::to_string(id), "Component.EnthalpyOfVaporization");
138 }
139
140
148 {
149 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidDensity");
150 return density;
151 }
152
162
175 {
176 static const Scalar dynamicViscosity = [&]
177 {
178 if (hasParamInGroup(std::to_string(id), "Component.LiquidKinematicViscosity"))
179 {
180 if (hasParamInGroup(std::to_string(id), "Component.LiquidDynamicViscosity"))
181 DUNE_THROW(Dune::InvalidStateException, "Found both Component.LiquidKinematicViscosity and Component.LiquidDynamicViscosity."
182 << " Please only specify either the kinematic or the dynamic viscosity for all constant components to avoid ambiguities.");
183
184 return getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidKinematicViscosity") * liquidDensity(temperature, pressure);
185 }
186 else
187 return getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidDynamicViscosity");
188 }();
189
190 return dynamicViscosity;
191 }
192
199 {
200 static const Scalar thermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidThermalConductivity");
201 return thermalConductivity;
202 }
203
210 {
211 // u = c * dT for incompressible fluids
212 const Scalar heatCapacity = liquidHeatCapacity(temperature, pressure);
213 static const Scalar tRef = getParamFromGroup<Scalar>(std::to_string(id), "Component.ReferenceTemperature", 293.15);
214 return heatCapacity * (temperature - tRef);
215 }
216
224 {
227 return u + pressure / rho;
228 }
229
237 {
238 static const Scalar heatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidHeatCapacity");
239 return heatCapacity;
240 }
241
249 {
250 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasDensity");
251 return density;
252 }
253
263
264
277 {
278 static const Scalar dynamicViscosity = [&]
279 {
280 if (hasParamInGroup(std::to_string(id), "Component.GasKinematicViscosity"))
281 {
282 if (hasParamInGroup(std::to_string(id), "Component.GasDynamicViscosity"))
283 DUNE_THROW(Dune::InvalidStateException, "Found both Component.GasKinematicViscosity and Component.GasDynamicViscosity."
284 << " Please only specify either the kinematic or the dynamic viscosity for all constant components to avoid ambiguities.");
285
286 return getParamFromGroup<Scalar>(std::to_string(id), "Component.GasKinematicViscosity") * gasDensity(temperature, pressure);
287 }
288 else
289 return getParamFromGroup<Scalar>(std::to_string(id), "Component.GasDynamicViscosity");
290 }();
291
292 return dynamicViscosity;
293 }
294
301 {
302 static const Scalar thermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasThermalConductivity");
303 return thermalConductivity;
304 }
305
320 {
321 // 1/molarMass: conversion from [J/(mol K)] to [J/(kg K)]
322 // R*T/molarMass: pressure *spec. volume for an ideal gas
324
325 }
326
334 {
335 static const Scalar tRef = getParamFromGroup<Scalar>(std::to_string(id), "Component.ReferenceTemperature", 293.15);
337 }
338
346 {
347 static const Scalar heatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasHeatCapacity");
348 return heatCapacity;
349 }
350
360 {
361 const Scalar p2 = triplePressure();
362 const Scalar T2 = tripleTemperature();
363 const Scalar exponent = -(vaporizationEnthalpy()*molarMass())/IdealGas::R*(1/T - 1/T2);
364
365 using std::exp;
366 const Scalar vaporPressure = p2*exp(exponent);
367 return vaporPressure;
368 }
369
377 {
378 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidDensity");
379 return density;
380 }
381
387 {
388 static const Scalar solidThermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidThermalConductivity");
390 }
391
397 {
398 static const Scalar solidHeatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidHeatCapacity");
399 return solidHeatCapacity;
400 }
401};
402
403} // end namespace Components
404
405} // end namespace Dumux
406
407#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Interface for components that have a gas state.
Interface for components that have a liquid state.
Interface for components that have a solid state.
Relations valid for an ideal gas.
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:177
Definition: adapt.hh:29
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Base class for all components Components provide the thermodynamic relations for the liquid,...
Definition: components/base.hh:59
Scalar Scalar
export the scalar type used by the component
Definition: components/base.hh:63
A component which returns run time specified values for all fluid properties.
Definition: constant.hh:61
static Scalar solidDensity(Scalar temperature)
The density in of the component at a given pressure in and temperature in .
Definition: constant.hh:376
static const std::string & name()
A human readable name for the component.
Definition: constant.hh:98
static Scalar solidThermalConductivity(Scalar temperature)
Thermal conductivity of the component as a solid.
Definition: constant.hh:386
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the component as a gas.
Definition: constant.hh:300
static Scalar triplePressure()
Returns the pressure at the component's triple point.
Definition: constant.hh:125
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the component as a liquid.
Definition: constant.hh:198
static Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the component as a liquid.
Definition: constant.hh:223
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density in at a given pressure and temperature.
Definition: constant.hh:160
static Scalar gasInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the component as a gas.
Definition: constant.hh:319
static constexpr bool gasIsCompressible()
Returns true if the gas phase is assumed to be compressible.
Definition: constant.hh:68
static Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the component as a liquid.
Definition: constant.hh:236
static Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the component as a gas.
Definition: constant.hh:345
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density in at a given pressure and temperature.
Definition: constant.hh:261
static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the component as a gas.
Definition: constant.hh:333
static Scalar tripleTemperature()
Returns the temperature at the components's triple point.
Definition: constant.hh:116
static Scalar solidHeatCapacity(Scalar temperature)
Specific isobaric heat capacity of the component as a solid.
Definition: constant.hh:396
static constexpr bool gasViscosityIsConstant()
Returns true if the gas phase viscosity is constant.
Definition: constant.hh:74
static Scalar liquidInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the component as a liquid.
Definition: constant.hh:209
static Scalar gasDensity(Scalar temperature, Scalar pressure)
Sets the gas density in .
Definition: constant.hh:248
static constexpr bool liquidViscosityIsConstant()
Returns true if the liquid phase viscosity is constant.
Definition: constant.hh:92
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: constant.hh:80
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
Sets the liquid density in .
Definition: constant.hh:147
static Scalar molarMass()
The mass in of one mole of the component.
Definition: constant.hh:107
static constexpr bool liquidIsCompressible()
Returns true if the liquid phase is assumed to be compressible.
Definition: constant.hh:86
static Scalar vaporPressure(Scalar T)
The vapor pressure in of a the component at a given temperature.
Definition: constant.hh:359
static Scalar vaporizationEnthalpy()
The vaporization enthalpy in needed to vaporize one kilogram of the liquid component to the gaseous ...
Definition: constant.hh:134
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
Sets the liquid dynamic viscosity in .
Definition: constant.hh:174
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
Sets the gas dynamic viscosity in .
Definition: constant.hh:276
Interface for components that have a gas state.
Definition: gas.hh:41
Interface for components that have a liquid state.
Definition: liquid.hh:41
Interface for components that have a solid state.
Definition: solid.hh:41
Relations valid for an ideal gas.
Definition: idealgas.hh:37
static constexpr Scalar R
The ideal gas constant .
Definition: idealgas.hh:40
Base class for all components Components provide the thermodynamic relations for the liquid,...