version 3.8
co2.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_CO2_HH
13#define DUMUX_CO2_HH
14
15#include <cmath>
16#include <iostream>
17
18#include <dune/common/stdstreams.hh>
19#include <dune/common/math.hh>
20
22
27
28namespace Dumux {
29namespace Components {
30
42template <class Scalar, class CO2Tables>
43class CO2
44: public Components::Base<Scalar, CO2<Scalar, CO2Tables> >
45, public Components::Liquid<Scalar, CO2<Scalar, CO2Tables> >
46, public Components::Gas<Scalar, CO2<Scalar, CO2Tables> >
47{
48 static const Scalar R;
49
50 static bool warningThrown;
51
52public:
56 static std::string name()
57 { return "CO2"; }
58
62 static constexpr Scalar molarMass()
63 { return 44e-3; /* [kg/mol] */ }
64
69 { return 273.15 + 30.95; /* [K] */ }
70
75 { return 73.8e5; /* [Pa] */ }
76
81 { return 273.15 - 56.35; /* [K] */ }
82
87 { return 5.11e5; /* [N/m^2] */ }
88
93 { return CO2Tables::tabulatedEnthalpy.minPress(); /* [Pa] */ }
94
99 { return CO2Tables::tabulatedEnthalpy.maxPress(); /* [Pa] */ }
100
105 { return CO2Tables::tabulatedEnthalpy.minTemp(); /* [K] */ }
106
111 { return CO2Tables::tabulatedEnthalpy.maxTemp(); /* [K] */ }
112
116 static constexpr bool gasIsIdeal()
117 { return false; }
118
128 {
129 static const Scalar a[4] =
130 { -7.0602087, 1.9391218, -1.6463597, -3.2995634 };
131 static const Scalar t[4] =
132 { 1.0, 1.5, 2.0, 4.0 };
133
134 // this is on page 1524 of the reference
135 Scalar exponent = 0;
136 Scalar Tred = T/criticalTemperature();
137
138 using std::pow;
139 for (int i = 0; i < 4; ++i)
140 exponent += a[i]*pow(1 - Tred, t[i]);
141 exponent *= 1.0/Tred;
142
143 using std::exp;
144 return exp(exponent)*criticalPressure();
145 }
146
154 {
155 if ((temperature < criticalTemperature() || pressure < criticalPressure()) && !warningThrown)
156 {
157 Dune::dwarn << "Subcritical values: Be aware to use "
158 <<"Tables with sufficient resolution!"<< std::endl;
159 warningThrown=true;
160 }
161 return
162 CO2Tables::tabulatedEnthalpy.at(temperature, pressure);
163 }
164
172 {
173 if ((temperature < criticalTemperature() || pressure < criticalPressure()) && !warningThrown)
174 {
175 Dune::dwarn << "Subcritical values: Be aware to use "
176 <<"Tables with sufficient resolution!"<< std::endl;
177 warningThrown=true;
178 }
179
181 }
182
190 {
193
194 return h - (pressure / rho);
195 }
196
204 {
207
208 return h - (pressure / rho);
209 }
210
217 {
218 if ((temperature < criticalTemperature() || pressure < criticalPressure()) && !warningThrown)
219 {
220 Dune::dwarn << "Subcritical values: Be aware to use "
221 <<"Tables with sufficient resolution!"<< std::endl;
222 warningThrown=true;
223 }
224 return CO2Tables::tabulatedDensity.at(temperature, pressure);
225 }
226
236
243 {
244 if ((temperature < criticalTemperature() || pressure < criticalPressure()) && !warningThrown)
245 {
246 Dune::dwarn << "Subcritical values: Be aware to use "
247 <<"Tables with sufficient resolution!"<< std::endl;
248 warningThrown=true;
249 }
250 return CO2Tables::tabulatedDensity.at(temperature, pressure);
251 }
252
262
270 {
271 DUNE_THROW(NumericalProblem, "CO2::gasPressure()");
272 }
273
282 {
283 DUNE_THROW(NumericalProblem, "CO2::liquidPressure()");
284 }
285
295 {
296 //temperature difference :
297 Scalar dT = 1.; // 1K temperature increment
298 Scalar temperature2 = temperature+dT;
299
300 // enthalpy difference
302 Scalar hnew = liquidEnthalpy(temperature2, pressure);
303 Scalar dh = hold-hnew;
304
305 //specific heat capacity
306 return dh/dT ;
307 }
308
309
318 {
319 static const double a0 = 0.235156;
320 static const double a1 = -0.491266;
321 static const double a2 = 5.211155E-2;
322 static const double a3 = 5.347906E-2;
323 static const double a4 = -1.537102E-2;
324
325 static const double d11 = 0.4071119E-2;
326 static const double d21 = 0.7198037E-4;
327 static const double d64 = 0.2411697E-16;
328 static const double d81 = 0.2971072E-22;
329 static const double d82 = -0.1627888E-22;
330
331 static const double ESP = 251.196;
332
333 double mu0, SigmaStar, TStar;
334 double dmu, rho;
335 double visco_CO2;
336
337 if(temperature < 275.) // regularisation
338 {
339 temperature = 275;
340 Dune::dgrave << "Temperature below 275K in viscosity function:"
341 << "Regularizing temperature to 275K. " << std::endl;
342 }
343
344
345 TStar = temperature/ESP;
346
347 /* mu0: viscosity in zero-density limit */
348 using std::exp;
349 using std::log;
350 using std::sqrt;
351 SigmaStar = exp(a0 + a1*log(TStar)
352 + a2*log(TStar)*log(TStar)
353 + a3*log(TStar)*log(TStar)*log(TStar)
354 + a4*log(TStar)*log(TStar)*log(TStar)*log(TStar) );
355 mu0 = 1.00697*sqrt(temperature) / SigmaStar;
356
357 /* dmu : excess viscosity at elevated density */
358 rho = gasDensity(temperature, pressure); /* CO2 mass density [kg/m^3] */
359
360 using Dune::power;
361 dmu = d11*rho + d21*rho*rho + d64*power(rho,6)/(TStar*TStar*TStar)
362 + d81*power(rho,8) + d82*power(rho,8)/TStar;
363
364 visco_CO2 = (mu0 + dmu)/1.0E6; /* conversion to [Pa s] */
365
366 return visco_CO2;
367 }
368
375 {
376 // no difference for supercritical CO2
378 }
379
390 {
391 return 0.087;
392 }
393};
394
395template <class Scalar, class CO2Tables>
396const Scalar CO2<Scalar, CO2Tables>::R = Constants<Scalar>::R;
397
398template <class Scalar, class CO2Tables>
399bool CO2<Scalar, CO2Tables>::warningThrown = false;
400
401} // end namespace Components
402
403} // end namespace Dumux
404
405#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 class for the CO2 fluid properties.
Definition: co2.hh:47
static Scalar maxTabulatedTemperature()
Returns the maximal tabulated temperature of the used table.
Definition: co2.hh:110
static Scalar minTabulatedPressure()
Returns the minimal tabulated pressure of the used table.
Definition: co2.hh:92
static Scalar gasInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of CO2 .
Definition: co2.hh:188
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of CO2.
Definition: co2.hh:389
static Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of liquid CO2 .
Definition: co2.hh:170
static Scalar vaporPressure(Scalar T)
The vapor pressure in of pure CO2 at a given temperature.
Definition: co2.hh:127
static Scalar liquidInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of liquid CO2 .
Definition: co2.hh:202
static constexpr Scalar molarMass()
The mass in of one mole of CO2.
Definition: co2.hh:62
static Scalar gasPressure(Scalar temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition: co2.hh:269
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of CO2 gas in at a given pressure and temperature.
Definition: co2.hh:234
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of CO2 at a given pressure and temperature .
Definition: co2.hh:216
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: co2.hh:116
static Scalar minTabulatedTemperature()
Returns the minimal tabulated temperature of the used table.
Definition: co2.hh:104
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
The density of pure CO2 at a given pressure and temperature .
Definition: co2.hh:242
static Scalar criticalTemperature()
Returns the critical temperature of CO2.
Definition: co2.hh:68
static Scalar liquidPressure(Scalar temperature, Scalar density)
The pressure of liquid water in at a given density and temperature.
Definition: co2.hh:281
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of pure CO2.
Definition: co2.hh:374
static std::string name()
A human readable name for the CO2.
Definition: co2.hh:56
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of CO2. Equations given in: - Vesovic et al., 1990.
Definition: co2.hh:317
static Scalar criticalPressure()
Returns the critical pressure of CO2.
Definition: co2.hh:74
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density of CO2 in at a given pressure and temperature.
Definition: co2.hh:260
static Scalar tripleTemperature()
Returns the temperature at CO2's triple point.
Definition: co2.hh:80
static Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the component as a liquid. USE WITH CAUTION! Exploits enthalpy fu...
Definition: co2.hh:294
static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of gaseous CO2 .
Definition: co2.hh:152
static Scalar maxTabulatedPressure()
Returns the maximal tabulated pressure of the used table.
Definition: co2.hh:98
static Scalar triplePressure()
Returns the pressure at CO2's triple point.
Definition: co2.hh:86
Interface for components that have a gas state.
Definition: gas.hh:29
Interface for components that have a liquid state.
Definition: liquid.hh:29
A central place for various physical constants occurring in some equations.
Definition: constants.hh:27
Exception thrown if a fixable numerical problem occurs.
Definition: exceptions.hh:27
Base class for all components Components provide the thermodynamic relations for the liquid,...
A central place for various physical constants occurring in some equations.
Some exceptions thrown in DuMux
Interface for components that have a gas state.
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