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