version 3.10.0
Loading...
Searching...
No Matches
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-FileCopyrightText: 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::Components {
26
42template<int id, class Scalar>
44: public Components::Base<Scalar, Constant<id, Scalar> >
45, public Components::Liquid<Scalar, Constant<id, Scalar> >
46, public Components::Gas<Scalar, Constant<id, Scalar> >
47, public Components::Solid<Scalar, Constant<id, Scalar> >
48{
49 using IdealGas = Dumux::IdealGas<Scalar>;
50
51public:
55 static constexpr bool gasIsCompressible()
56 { return false; }
57
61 static constexpr bool gasViscosityIsConstant()
62 { return true; }
63
67 static constexpr bool gasIsIdeal()
68 { return true; }
69
73 static constexpr bool liquidIsCompressible()
74 { return false; }
75
79 static constexpr bool liquidViscosityIsConstant()
80 { return true; }
81
85 static const std::string& name()
86 {
87 static const std::string name = getParamFromGroup<std::string>(std::to_string(id), "Component.Name", "component");
88 return name;
89 }
90
95 {
96 static const Scalar molarMass = getParamFromGroup<Scalar>(std::to_string(id), "Component.MolarMass");
97 return molarMass;
98 }
99
104 {
105 static const Scalar tripleTemperature = getParamFromGroup<Scalar>(std::to_string(id), "Component.TripleTemperature");
106 return tripleTemperature;
107 }
108
113 {
114 static const Scalar triplePressure = getParamFromGroup<Scalar>(std::to_string(id), "Component.TriplePressure");
115 return triplePressure;
116 }
117
122 {
123 static const Scalar vaporizationEnthalpy = getParamFromGroup<Scalar>(std::to_string(id), "Component.EnthalpyOfVaporization");
125 }
126
127
134 static Scalar liquidDensity(Scalar temperature, Scalar pressure)
135 {
136 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidDensity");
137 return density;
138 }
139
147 static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
148 { return liquidDensity(temperature, pressure)/molarMass(); }
149
161 static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
162 {
163 static const Scalar dynamicViscosity = [&]
164 {
165 if (hasParamInGroup(std::to_string(id), "Component.LiquidKinematicViscosity"))
166 {
167 if (hasParamInGroup(std::to_string(id), "Component.LiquidDynamicViscosity"))
168 DUNE_THROW(Dune::InvalidStateException, "Found both Component.LiquidKinematicViscosity and Component.LiquidDynamicViscosity."
169 << " Please only specify either the kinematic or the dynamic viscosity for all constant components to avoid ambiguities.");
170
171 return getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidKinematicViscosity") * liquidDensity(temperature, pressure);
172 }
173 else
174 return getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidDynamicViscosity");
175 }();
176
177 return dynamicViscosity;
178 }
179
185 static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
186 {
187 static const Scalar thermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidThermalConductivity");
188 return thermalConductivity;
189 }
190
196 static Scalar liquidInternalEnergy(Scalar temperature, Scalar pressure)
197 {
198 // u = c * dT for incompressible fluids
199 const Scalar heatCapacity = liquidHeatCapacity(temperature, pressure);
200 static const Scalar tRef = getParamFromGroup<Scalar>(std::to_string(id), "Component.ReferenceTemperature", 293.15);
201 return heatCapacity * (temperature - tRef);
202 }
203
210 static Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
211 {
212 const Scalar u = liquidInternalEnergy(temperature, pressure);
213 const Scalar rho = liquidDensity(temperature, pressure);
214 return u + pressure / rho;
215 }
216
223 static Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
224 {
225 static const Scalar heatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.LiquidHeatCapacity");
226 return heatCapacity;
227 }
228
235 static Scalar gasDensity(Scalar temperature, Scalar pressure)
236 {
237 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasDensity");
238 return density;
239 }
240
248 static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
249 { return gasDensity(temperature, pressure)/molarMass(); }
250
251
263 static Scalar gasViscosity(Scalar temperature, Scalar pressure)
264 {
265 static const Scalar dynamicViscosity = [&]
266 {
267 if (hasParamInGroup(std::to_string(id), "Component.GasKinematicViscosity"))
268 {
269 if (hasParamInGroup(std::to_string(id), "Component.GasDynamicViscosity"))
270 DUNE_THROW(Dune::InvalidStateException, "Found both Component.GasKinematicViscosity and Component.GasDynamicViscosity."
271 << " Please only specify either the kinematic or the dynamic viscosity for all constant components to avoid ambiguities.");
272
273 return getParamFromGroup<Scalar>(std::to_string(id), "Component.GasKinematicViscosity") * gasDensity(temperature, pressure);
274 }
275 else
276 return getParamFromGroup<Scalar>(std::to_string(id), "Component.GasDynamicViscosity");
277 }();
278
279 return dynamicViscosity;
280 }
281
287 static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
288 {
289 static const Scalar thermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasThermalConductivity");
290 return thermalConductivity;
291 }
292
306 static Scalar gasInternalEnergy(Scalar temperature, Scalar pressure)
307 {
308 // 1/molarMass: conversion from [J/(mol K)] to [J/(kg K)]
309 // R*T/molarMass: pressure *spec. volume for an ideal gas
310 return gasEnthalpy(temperature, pressure) - 1/molarMass()* IdealGas::R*temperature;
311
312 }
313
320 static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
321 {
322 static const Scalar tRef = getParamFromGroup<Scalar>(std::to_string(id), "Component.ReferenceTemperature", 293.15);
323 return gasHeatCapacity(temperature, pressure)*(temperature - tRef) + vaporizationEnthalpy();
324 }
325
332 static Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
333 {
334 static const Scalar heatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.GasHeatCapacity");
335 return heatCapacity;
336 }
337
347 {
348 const Scalar p2 = triplePressure();
349 const Scalar T2 = tripleTemperature();
350 const Scalar exponent = -(vaporizationEnthalpy()*molarMass())/IdealGas::R*(1/T - 1/T2);
351
352 using std::exp;
353 const Scalar vaporPressure = p2*exp(exponent);
354 return vaporPressure;
355 }
356
363 static Scalar solidDensity(Scalar temperature)
364 {
365 static const Scalar density = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidDensity");
366 return density;
367 }
368
374 {
375 static const Scalar solidThermalConductivity = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidThermalConductivity");
377 }
378
383 static Scalar solidHeatCapacity(Scalar temperature)
384 {
385 static const Scalar solidHeatCapacity = getParamFromGroup<Scalar>(std::to_string(id), "Component.SolidHeatCapacity");
386 return solidHeatCapacity;
387 }
388};
389
390} // end namespace Dumux::Components
391
392#endif
Base class for all components Components provide the thermodynamic relations for the liquid,...
Definition components/base.hh:46
Scalar Scalar
Definition components/base.hh:50
A component which returns run time specified values for all fluid properties.
Definition constant.hh:48
static Scalar solidDensity(Scalar temperature)
The density in of the component at a given pressure in and temperature in .
Definition constant.hh:363
static const std::string & name()
A human readable name for the component.
Definition constant.hh:85
static Scalar solidThermalConductivity(Scalar temperature)
Thermal conductivity of the component as a solid.
Definition constant.hh:373
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the component as a gas.
Definition constant.hh:287
static Scalar triplePressure()
Returns the pressure at the component's triple point.
Definition constant.hh:112
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the component as a liquid.
Definition constant.hh:185
static Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the component as a liquid.
Definition constant.hh:210
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density in at a given pressure and temperature.
Definition constant.hh:147
static Scalar gasInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the component as a gas.
Definition constant.hh:306
static constexpr bool gasIsCompressible()
Returns true if the gas phase is assumed to be compressible.
Definition constant.hh:55
static Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the component as a liquid.
Definition constant.hh:223
static Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the component as a gas.
Definition constant.hh:332
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density in at a given pressure and temperature.
Definition constant.hh:248
static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the component as a gas.
Definition constant.hh:320
static Scalar tripleTemperature()
Returns the temperature at the components's triple point.
Definition constant.hh:103
static Scalar solidHeatCapacity(Scalar temperature)
Specific isobaric heat capacity of the component as a solid.
Definition constant.hh:383
static constexpr bool gasViscosityIsConstant()
Returns true if the gas phase viscosity is constant.
Definition constant.hh:61
static Scalar liquidInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the component as a liquid.
Definition constant.hh:196
static Scalar gasDensity(Scalar temperature, Scalar pressure)
Sets the gas density in .
Definition constant.hh:235
static constexpr bool liquidViscosityIsConstant()
Returns true if the liquid phase viscosity is constant.
Definition constant.hh:79
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition constant.hh:67
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
Sets the liquid density in .
Definition constant.hh:134
static Scalar molarMass()
The mass in of one mole of the component.
Definition constant.hh:94
static constexpr bool liquidIsCompressible()
Returns true if the liquid phase is assumed to be compressible.
Definition constant.hh:73
static Scalar vaporPressure(Scalar T)
The vapor pressure in of a the component at a given temperature.
Definition constant.hh:346
static Scalar vaporizationEnthalpy()
The vaporization enthalpy in needed to vaporize one kilogram of the liquid component to the gaseous ...
Definition constant.hh:121
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
Sets the liquid dynamic viscosity in .
Definition constant.hh:161
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
Sets the gas dynamic viscosity in .
Definition constant.hh:263
Interface for components that have a gas state.
Definition gas.hh:28
Interface for components that have a liquid state.
Definition liquid.hh:28
Interface for components that have a solid state.
Definition solid.hh:28
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.
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:149
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.
Definition air.hh:22
const Scalar PengRobinsonMixture< Scalar, StaticParameters >::u
Definition pengrobinsonmixture.hh:138
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Interface for components that have a solid state.