OGS
DimensionLessGibbsFreeEnergyRegion1.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5using namespace boost::math::differentiation;
6
7#include <cmath>
8using std::pow;
9
10namespace MaterialLib
11{
12namespace Fluid
13{
14static const double ni[34] = {
15 1.4632971213167E-01, -8.4548187169114E-01, -3.7563603672040E+00,
16 3.3855169168385E+00, -9.5791963387872E-01, 1.5772038513228E-01,
17 -1.6616417199501E-02, 8.1214629983568E-04, 2.8319080123804E-04,
18 -6.0706301565874E-04, -1.8990068218419E-02, -3.2529748770505E-02,
19 -2.1841717175414E-02, -5.2838357969930E-05, -4.7184321073267E-04,
20 -3.0001780793026E-04, 4.7661393906987E-05, -4.4141845330846E-06,
21 -7.2694996297594E-16, -3.1679644845054E-05, -2.8270797985312E-06,
22 -8.5205128120103E-10, -2.2425281908000E-06, -6.5171222895601E-07,
23 -1.4341729937924E-13, -4.0516996860117E-07, -1.2734301741641E-09,
24 -1.7424871230634E-10, -6.8762131295531E-19, 1.4478307828521E-20,
25 2.6335781662795E-23, -1.1947622640071E-23, 1.8228094581404E-24,
26 -9.35370872924580E-26};
27
28static const double li[34] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
29 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4,
30 4, 5, 8, 8, 21, 23, 29, 30, 31, 32};
31
32static const double ji[34] = {
33 -2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1,
34 3, 17, -4, 0, 6, -5, -2, 10, -8, -11, -6, -29, -31, -38, -39, -40, -41};
35
36template <typename S, typename T>
38 const T pi)
39{
40 promote<S, T> val = 0.;
41 for (int i = 0; i < 34; i++)
42 {
43 val += ni[i] * pow(7.1 - pi, li[i]) * pow(tau - 1.222, ji[i]);
44 }
45
46 return val;
47}
48
49template <typename S, typename T>
51 const T pi)
52{
53 promote<S, T> val = 0.;
54 for (int i = 0; i < 34; i++)
55 {
56 val += ni[i] * ji[i] * pow(7.1 - pi, li[i]) *
57 pow(tau - 1.222, ji[i] - 1.0);
58 }
59
60 return val;
61}
62
63template <typename S, typename T>
65 const S tau, const T pi)
66{
67 promote<S, T> val = 0.;
68 for (int i = 0; i < 34; i++)
69 {
70 val += ni[i] * ji[i] * (ji[i] - 1.0) * pow(7.1 - pi, li[i]) *
71 pow(tau - 1.222, ji[i] - 2.0);
72 }
73
74 return val;
75}
76
77template <typename S, typename T>
79 const T pi)
80{
81 promote<S, T> val = 0.;
82 for (int i = 0; i < 34; i++)
83 {
84 val = val - ni[i] * li[i] * pow(7.1 - pi, li[i] - 1.0) *
85 pow(tau - 1.222, ji[i]);
86 }
87
88 return val;
89}
90
91template <typename S, typename T>
93 const S tau, const T pi)
94{
95 promote<S, T> val = 0.;
96 for (int i = 0; i < 34; i++)
97 {
98 val += ni[i] * li[i] * (li[i] - 1.0) * pow(7.1 - pi, li[i] - 2.0) *
99 pow(tau - 1.222, ji[i]);
100 }
101
102 return val;
103}
104
105template <typename S, typename T>
107 const S tau, const T pi)
108{
109 promote<S, T> val = 0.;
110 for (int i = 0; i < 34; i++)
111 {
112 val = val - ni[i] * ji[i] * li[i] * pow(7.1 - pi, li[i] - 1.0) *
113 pow(tau - 1.222, ji[i] - 1.0);
114 }
115
116 return val;
117}
118
119#ifndef DOXYGEN_DOCU_ONLY
120// Explicit template instantiations for double, double
121template boost::math::differentiation::promote<double, double>
122DimensionLessGibbsFreeEnergyRegion1::get_gamma(const double, const double);
123
124template boost::math::differentiation::promote<double, double>
126
127template boost::math::differentiation::promote<double, double>
129 const double);
130
131template boost::math::differentiation::promote<double, double>
133 const double);
134
135template boost::math::differentiation::promote<double, double>
137 const double);
138
139template boost::math::differentiation::promote<double, double>
141 const double);
142
143// For autodiff types
144using fvar1 = boost::math::differentiation::autodiff_fvar<double, 0ul, 1ul>;
145using fvar2 = boost::math::differentiation::autodiff_fvar<double, 0ul, 2ul>;
146
147template boost::math::differentiation::promote<fvar1, double>
149
150template boost::math::differentiation::promote<fvar2, double>
152#endif // DOXYGEN_DOCU_ONLY
153
154} // namespace Fluid
155} // namespace MaterialLib
static boost::math::differentiation::promote< S, T > get_dgamma_dtau(const S tau, const T pi)
static boost::math::differentiation::promote< S, T > get_dgamma_dtau_dtau(const S tau, const T pi)
static boost::math::differentiation::promote< S, T > get_dgamma_dtau_dpi(const S tau, const T pi)
static boost::math::differentiation::promote< S, T > get_dgamma_dpi_dpi(const S tau, const T pi)
static boost::math::differentiation::promote< S, T > get_dgamma_dpi(const S tau, const T pi)
static boost::math::differentiation::promote< S, T > get_gamma(const S tau, const T pi)