OGS
MaterialPropertyLib::SigmoidFunction Class Referencefinal

Detailed Description

Sigmoid function with scalar argument and two constant parameters

The sigmoid function is a smooth step function with the range \([0,1]\) defined by the following formula

\[ \left[1 + \exp(k(T - T_\mathrm{c})) \right]^{-1} \]

where \(T_\mathrm{c}\) is the critical value (e.g. a phase change temperature). The parameter \(k\) is proportional to the slope at the characteristic value and controls thus the steepness. Letting \(k\) go to infinity, the heaviside step function is obtained.

Definition at line 36 of file SigmoidFunction.h.

#include <SigmoidFunction.h>

Public Member Functions

 SigmoidFunction (double const k, double const T_c)
 
double value (double const &T) const
 
double dValue (double const &T) const
 
double d2Value (double const &T) const
 

Private Attributes

double const k_
 
double const T_c_
 

Constructor & Destructor Documentation

◆ SigmoidFunction()

MaterialPropertyLib::SigmoidFunction::SigmoidFunction ( double const k,
double const T_c )

Definition at line 17 of file SigmoidFunction.cpp.

Member Function Documentation

◆ d2Value()

double MaterialPropertyLib::SigmoidFunction::d2Value ( double const & T) const

Definition at line 50 of file SigmoidFunction.cpp.

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}
double dValue(double const &T) const
double value(double const &T) const

References dValue(), k_, and value().

Referenced by MaterialPropertyLib::TemperatureDependentFraction::d2Value().

◆ dValue()

double MaterialPropertyLib::SigmoidFunction::dValue ( double const & T) const

Definition at line 37 of file SigmoidFunction.cpp.

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}

References k_, T_c_, and value().

Referenced by d2Value(), and MaterialPropertyLib::TemperatureDependentFraction::dValue().

◆ value()

double MaterialPropertyLib::SigmoidFunction::value ( double const & T) const

Definition at line 22 of file SigmoidFunction.cpp.

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}

References k_, and T_c_.

Referenced by d2Value(), dValue(), and MaterialPropertyLib::TemperatureDependentFraction::value().

Member Data Documentation

◆ k_

double const MaterialPropertyLib::SigmoidFunction::k_
private

Definition at line 48 of file SigmoidFunction.h.

Referenced by d2Value(), dValue(), and value().

◆ T_c_

double const MaterialPropertyLib::SigmoidFunction::T_c_
private

Definition at line 49 of file SigmoidFunction.h.

Referenced by dValue(), and value().


The documentation for this class was generated from the following files: