OGS
SigmoidFunction.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
4
#include "
SigmoidFunction.h
"
5
6
namespace
MaterialPropertyLib
7
{
8
SigmoidFunction::SigmoidFunction
(
double
const
k,
double
const
T_c
,
9
double
const
S_r
)
10
:
k_
(k),
T_c_
(
T_c
),
S_r
(
S_r
)
11
{
12
}
13
14
double
SigmoidFunction::value
(
double
const
& T)
const
15
{
16
double
const
x =
k_
* (T -
T_c_
);
17
18
// Cutting off at the last x producing a (non-normal) return value because
19
// std::exp(x) produces +infinity beyond this point, approximately 709.78.
20
// The reason for using hex representation is that the value is unambiguous.
21
if
(x > 0x1.62e42fefa39efp+9)
22
{
23
return
0.;
24
}
25
26
return
(1. -
S_r
) / (1. + std::exp(x));
27
}
28
29
double
SigmoidFunction::dValue
(
double
const
& T)
const
30
{
31
double
const
f =
value
(T);
32
if
(f * f == 0)
33
{
34
return
0;
35
}
36
double
const
x =
k_
* (T -
T_c_
);
37
return
-
k_
* std::exp(x) * (f * f) / (1. -
S_r
);
38
}
39
40
double
SigmoidFunction::d2Value
(
double
const
& T)
const
41
{
42
double
const
fT =
dValue
(T);
43
if
(fT == 0)
44
{
45
return
0;
46
}
47
48
double
const
f =
value
(T);
49
return
fT * (
k_
+ 2 * fT / f);
50
}
51
52
}
// namespace MaterialPropertyLib
SigmoidFunction.h
MaterialPropertyLib::SigmoidFunction::k_
double const k_
Definition
SigmoidFunction.h:41
MaterialPropertyLib::SigmoidFunction::S_r
double const S_r
Definition
SigmoidFunction.h:44
MaterialPropertyLib::SigmoidFunction::dValue
double dValue(double const &T) const
Definition
SigmoidFunction.cpp:29
MaterialPropertyLib::SigmoidFunction::SigmoidFunction
SigmoidFunction(double const k, double const T_c, double const S_r)
Definition
SigmoidFunction.cpp:8
MaterialPropertyLib::SigmoidFunction::T_c_
double const T_c_
Definition
SigmoidFunction.h:42
MaterialPropertyLib::SigmoidFunction::d2Value
double d2Value(double const &T) const
Definition
SigmoidFunction.cpp:40
MaterialPropertyLib::SigmoidFunction::value
double value(double const &T) const
Definition
SigmoidFunction.cpp:14
MaterialPropertyLib
Definition
ChemicalSolverInterface.h:98
MaterialPropertyLib::T_c
constexpr double T_c
Critical temperature.
Definition
WaterVapourLatentHeatWithCriticalTemperature.cpp:16
MaterialLib
MPL
Utils
SigmoidFunction.cpp
Generated by
1.14.0