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

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

where \(S_r\) is residual saturation, representing the amount of liquid water remaining after the water-ice phase transition is complete. \(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 38 of file SigmoidFunction.h.

#include <SigmoidFunction.h>

Public Member Functions

 SigmoidFunction (double const k, double const T_c, double const S_r)
 
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_
 
double const S_r
 

Constructor & Destructor Documentation

◆ SigmoidFunction()

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

Member Function Documentation

◆ d2Value()

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

Definition at line 49 of file SigmoidFunction.cpp.

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}
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 38 of file SigmoidFunction.cpp.

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}

References k_, S_r, T_c_, and value().

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

◆ value()

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

Definition at line 23 of file SigmoidFunction.cpp.

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}

References k_, S_r, and T_c_.

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

Member Data Documentation

◆ k_

double const MaterialPropertyLib::SigmoidFunction::k_
private

Definition at line 50 of file SigmoidFunction.h.

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

◆ S_r

double const MaterialPropertyLib::SigmoidFunction::S_r
private

Definition at line 53 of file SigmoidFunction.h.

Referenced by dValue(), and value().

◆ T_c_

double const MaterialPropertyLib::SigmoidFunction::T_c_
private

Definition at line 51 of file SigmoidFunction.h.

Referenced by dValue(), and value().


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