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
: k_(k), T_c_(
T_c
)
19
{
20
}
21
22
double
SigmoidFunction::value
(
double
const
& T)
const
23
{
24
double
const
x =
k_
* (T -
T_c_
);
25
26
// Cutting off at the last x producing a (non-normal) return value because
27
// std::exp(x) produces +infinity beyond this point, approximately 709.78.
28
// The reason for using hex representation is that the value is unambiguous.
29
if
(x > 0x1.62e42fefa39efp+9)
30
{
31
return
0.;
32
}
33
34
return
1. / (1. + std::exp(x));
35
}
36
37
double
SigmoidFunction::dValue
(
double
const
& T)
const
38
{
39
double
const
f =
value
(T);
40
41
// Skip any further computations because of f^2 below.
42
if
(f * f == 0)
43
{
44
return
0;
45
}
46
47
return
-
k_
* std::exp(
k_
* (T -
T_c_
)) * (f * f);
48
}
49
50
double
SigmoidFunction::d2Value
(
double
const
& T)
const
51
{
52
double
const
fT =
dValue
(T);
53
54
if
(fT == 0)
55
{
56
return
0;
57
}
58
59
double
const
f =
value
(T);
60
return
fT * (
k_
+ 2 * fT / f);
61
}
62
}
// namespace MaterialPropertyLib
SigmoidFunction.h
MaterialPropertyLib::SigmoidFunction::k_
double const k_
Definition
SigmoidFunction.h:48
MaterialPropertyLib::SigmoidFunction::dValue
double dValue(double const &T) const
Definition
SigmoidFunction.cpp:37
MaterialPropertyLib::SigmoidFunction::SigmoidFunction
SigmoidFunction(double const k, double const T_c)
Definition
SigmoidFunction.cpp:17
MaterialPropertyLib::SigmoidFunction::T_c_
double const T_c_
Definition
SigmoidFunction.h:49
MaterialPropertyLib::SigmoidFunction::d2Value
double d2Value(double const &T) const
Definition
SigmoidFunction.cpp:50
MaterialPropertyLib::SigmoidFunction::value
double value(double const &T) const
Definition
SigmoidFunction.cpp:22
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