Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
Model< Result(Args...)> Class Template Reference

The class used to represent a model function and its parameters. More...

#include <Model.hpp>

Public Types

using ResultRef = Ref< Result >
 The reference type of result type. More...
 

Public Member Functions

 Model ()
 Construct a default Model function object.
 
 Model (const ModelEvaluator< ResultRef, Args... > &evalfn, const Data &params={})
 Construct a Model function object with given model evaluator function and its parameters. More...
 
 Model (const ModelCalculator< Result, Args... > &calcfn, const Data &params={})
 Construct a Model function object with given direct model calculator and its parameters. More...
 
template<typename Fun , Requires<!isFunction< Fun >> = true>
 Model (const Fun &f)
 Construct a Model function object with either a model evaluator or a model calculator function. More...
 
auto withMemoization () const -> Model
 Return a new Model function object with memoization for the model calculator.
 
auto apply (ResultRef res, const Args &... args) const -> void
 Evaluate the model with given arguments.
 
auto operator() (const Args &... args) const -> Result
 Evaluate the model with given arguments and return the result of the evaluation.
 
auto operator() (ResultRef res, const Args &... args) const -> void
 Evaluate the model with given arguments and return the result of the evaluation.
 
auto initialized () const -> bool
 Return true if this Model function object has been initialized.
 
 operator bool () const
 Return true if this Model function object has been initialized.
 
auto evaluatorFn () const -> const ModelEvaluator< ResultRef, Args... > &
 Return the model evaluator function of this Model function object.
 
auto calculatorFn () const -> const ModelCalculator< Result, Args... > &
 Return the model calculator function of this Model function object.
 
auto params () const -> const Data &
 Return the model parameters of this Model function object.
 

Static Public Member Functions

static auto Constant (String const &name, real const &value) -> Model
 Return a constant Model function object. More...
 

Detailed Description

template<typename Result, typename... Args>
class Reaktoro::Model< Result(Args...)>

The class used to represent a model function and its parameters.

Member Typedef Documentation

◆ ResultRef

using ResultRef = Ref<Result>

The reference type of result type.

In case a custom reference type other than Result& is needed, use REAKTORO_DEFINE_REFERENCE_TYPE_OF(Result, CustomResultRef).

Constructor & Destructor Documentation

◆ Model() [1/3]

Model ( const ModelEvaluator< ResultRef, Args... > &  evalfn,
const Data params = {} 
)
inline

Construct a Model function object with given model evaluator function and its parameters.

Parameters
evalfnThe function that evaluates the model.
paramsThe parameters of the underlying model function.

◆ Model() [2/3]

Model ( const ModelCalculator< Result, Args... > &  calcfn,
const Data params = {} 
)
inline

Construct a Model function object with given direct model calculator and its parameters.

Parameters
calcfnThe function that calculates the model properties and return them.
paramsThe parameters of the underlying model function.

◆ Model() [3/3]

Model ( const Fun &  f)
inline

Construct a Model function object with either a model evaluator or a model calculator function.

This constructor exists so that functions that are not wrapped into an std::function object can be used to construct a Model function object. Without this constructor, an explicit wrap must be performed by the used. For example, Model(ModelCalculator<real(real,real)>([](real T, real P) { return A + B*T + C*T*P; })) can be replaced with Model([](real T, real P) { return A + B*T + C*T*P; }).

Parameters
fA model evaluator or a model calculator function.

Member Function Documentation

◆ Constant()

static auto Constant ( String const &  name,
real const &  value 
) -> Model
inlinestatic

Return a constant Model function object.

Parameters
paramThe parameter with the constant value always returned by the Model function object.

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