OGS
DimensionlessGibbsFreeEnergyRegion2.cpp
Go to the documentation of this file.
1
11
12#include <array>
13#include <cmath>
14
15#include "BaseLib/Error.h"
16
17namespace MaterialLib
18{
19namespace Fluid
20{
21namespace DimensionlessGibbsFreeEnergyRegion2
22{
23static constexpr std::array<int, 9> J0 = {0, 1, -5, -4, -3, -2, -1, 2, 3};
24static constexpr std::array<double, 9> n0 = {
25 -0.96927686500217e1, 0.10086655968018e2, -0.56087911283020e-2,
26 0.71452738081455e-1, -0.40710498223928, 0.14240819171444e1,
27 -0.43839511319450e1, -0.28408632460772, 0.21268463753307e-1};
28
29static constexpr std::array<double, 43> n = {
30 -0.17731742473213e-2, -0.17834862292358e-1, -0.45996013696365e-1,
31 -0.57581259083432e-1, -0.50325278727930e-1, -0.33032641670203e-4,
32 -0.18948987516315e-3, -0.39392777243355e-2, -0.43797295650573e-1,
33 -0.26674547914087e-4, 0.20481737692309e-7, 0.43870667284435e-6,
34 -0.32277677238570e-4, -0.15033924542148e-2, -0.40668253562649e-1,
35 -0.78847309559367e-9, 0.12790717852285e-7, 0.48225372718507e-6,
36 0.22922076337661e-5, -0.16714766451061e-10, -0.21171472321355e-2,
37 -0.23895741934104e2, -0.59059564324270e-17, -0.12621808899101e-5,
38 -0.38946842435739e-1, 0.11256211360459e-10, -0.82311340897998e1,
39 0.19809712802088e-7, 0.10406965210174e-18, -0.10234747095929e-12,
40 -0.10018179379511e-8, -0.80882908646985e-10, 0.10693031879409,
41 -0.33662250574171, 0.89185845355421e-24, 0.30629316876232e-12,
42 -0.42002467698208e-5, -0.59056029685639e-25, 0.37826947613457e-5,
43 -0.12768608934681e-14, 0.73087610595061e-28, 0.55414715350778e-16,
44 -0.94369707241210e-6};
45
46static constexpr std::array<int, 43> I = {
47 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
48 4, 4, 4, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 10, 10,
49 10, 16, 16, 18, 20, 20, 20, 21, 22, 23, 24, 24, 24};
50
51static constexpr std::array<int, 43> J = {
52 0, 1, 2, 3, 6, 1, 2, 4, 7, 36, 0, 1, 3, 6, 35,
53 1, 2, 3, 7, 3, 16, 35, 0, 11, 25, 8, 36, 13, 4, 10,
54 14, 29, 50, 57, 20, 35, 48, 21, 53, 39, 26, 40, 58};
55
56double computeGamma0(const double tau, const double pi)
57{
58 if ((pi < 0.) || (pi == 0.))
59 {
61 "The dimensionless Gibbs free energy in IAPWS-IF97 region2 can not "
62 "be calculated from a non-positive pressure.");
63 }
64
65 double val = std::log(pi);
66 for (int i = 0; i < 9; i++)
67 {
68 val += n0[i] * std::pow(tau, J0[i]);
69 }
70
71 return val;
72}
73
74double getGamma(const double tau, const double pi)
75{
76 double val = computeGamma0(tau, pi);
77 for (int i = 0; i < 43; i++)
78 {
79 val += n[i] * std::pow(pi, I[i]) * std::pow(tau - 0.5, J[i]);
80 }
81
82 return val;
83}
84
85double getdGammadTau(const double tau, const double pi)
86{
87 double val1 = 0.;
88 double val2 = 0.;
89 for (int i = 0; i < 9; i++)
90 {
91 val1 += n0[i] * J0[i] * std::pow(tau, J0[i] - 1);
92 }
93
94 for (int i = 0; i < 43; i++)
95 {
96 val2 +=
97 n[i] * J[i] * std::pow(pi, I[i]) * std::pow(tau - 0.5, J[i] - 1);
98 }
99
100 return val1 + val2;
101}
102
103double getdGammadPi(const double tau, const double pi)
104{
105 if ((pi < 0.) || (pi == 0.))
106 {
107 OGS_FATAL(
108 "The dimensionless Gibbs free energy in IAPWS-IF97 region2 can not "
109 "be calculated from a non-positive pressure.");
110 }
111
112 double val = 1 / pi;
113 for (int i = 0; i < 43; i++)
114 {
115 val += n[i] * I[i] * std::pow(pi, I[i] - 1) * std::pow(tau - 0.5, J[i]);
116 }
117
118 return val;
119}
120
121} // namespace DimensionlessGibbsFreeEnergyRegion2
122} // namespace Fluid
123} // namespace MaterialLib
#define OGS_FATAL(...)
Definition Error.h:26