version 3.8
region4.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//
18#ifndef DUMUX_IAPWS_REGION4_HH
19#define DUMUX_IAPWS_REGION4_HH
20
21#include <cmath>
22#include <iostream>
23
24#include <dune/common/math.hh>
25
26namespace Dumux::IAPWS {
27
39template <class Scalar>
41{
42public:
52 static Scalar saturationPressure(Scalar temperature)
53 {
54 constexpr Scalar n[10] = {
55 0.11670521452767e4, -0.72421316703206e6, -0.17073846940092e2,
56 0.12020824702470e5, -0.32325550322333e7, 0.14915108613530e2,
57 -0.48232657361591e4, 0.40511340542057e6, -0.23855557567849,
58 0.65017534844798e3
59 };
60
61 const Scalar sigma = temperature + n[8]/(temperature - n[9]);
62
63 const Scalar A = (sigma + n[0])*sigma + n[1];
64 const Scalar B = (n[2]*sigma + n[3])*sigma + n[4];
65 const Scalar C = (n[5]*sigma + n[6])*sigma + n[7];
66
67 using std::sqrt;
68 Scalar tmp = 2*C/(sqrt(B*B - 4*A*C) - B);
69 tmp *= tmp;
70 tmp *= tmp;
71
72 return 1e6*tmp;
73 }
74
83 static Scalar vaporTemperature(Scalar pressure)
84 {
85 constexpr Scalar n[10] = {
86 0.11670521452767e4, -0.72421316703206e6, -0.17073846940092e2,
87 0.12020824702470e5, -0.32325550322333e7, 0.14915108613530e2,
88 -0.48232657361591e4, 0.40511340542057e6, -0.23855557567849,
89 0.65017534844798e3
90 };
91
92 using std::pow;
93 using Dune::power;
94 const Scalar beta = pow((pressure/1e6 /*from Pa to MPa*/), (1./4.));
95 const Scalar beta2 = power(beta, 2);
96 const Scalar E = beta2 + n[2] * beta + n[5];
97 const Scalar F = n[0]*beta2 + n[3]*beta + n[6];
98 const Scalar G = n[1]*beta2 + n[4]*beta + n[7];
99
100 using std::sqrt;
101 const Scalar D = ( 2.*G)/(-F -sqrt(power(F,2) - 4.*E*G));
102 return (n[9] + D - sqrt(power(n[9]+D , 2) - 4.* (n[8] + n[9]*D)) ) * 0.5;
103 }
104};
105
106} // end namespace Dumux::IAPWS
107
108#endif
Implements the equations for region 4 of the IAPWS '97 formulation.
Definition: region4.hh:41
static Scalar saturationPressure(Scalar temperature)
Returns the saturation pressure in of pure water at a given temperature.
Definition: region4.hh:52
static Scalar vaporTemperature(Scalar pressure)
Returns the saturation temperature in of pure water at a given pressure.
Definition: region4.hh:83
Definition: common.hh:28
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