79 Func1(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
80 : m_f1_shared(f1), m_f2_shared(f2)
86 Func1(shared_ptr<Func1> f1,
double A) : m_c(A), m_f1_shared(f1) {
90 virtual ~
Func1() =
default;
97 virtual string type()
const {
109 virtual double eval(
double t)
const;
136 virtual double isProportional(
Func1& other);
139 virtual string write(
const string& arg)
const;
157 virtual int order()
const;
161 Func1* m_f1 =
nullptr;
162 Func1* m_f2 =
nullptr;
164 shared_ptr<Func1> m_f1_shared;
165 shared_ptr<Func1> m_f2_shared;
170 shared_ptr<Func1>
newSumFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
174 shared_ptr<Func1>
newDiffFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
178 shared_ptr<Func1>
newProdFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
182 shared_ptr<Func1>
newRatioFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
206 Sin1(
double omega=1.0) {
211 Sin1(
const vector<double>& params);
213 string write(
const string& arg)
const override;
219 double eval(
double t)
const override{
223 shared_ptr<Func1>
derivative()
const override;
237 Cos1(
double omega=1.0) {
242 Cos1(
const vector<double>& params);
244 string write(
const string& arg)
const override;
250 double eval(
double t)
const override {
253 shared_ptr<Func1>
derivative()
const override;
271 Exp1(
const vector<double>& params);
273 string write(
const string& arg)
const override;
279 double eval(
double t)
const override {
283 shared_ptr<Func1>
derivative()
const override;
302 Log1(
const vector<double>& params);
308 double eval(
double t)
const override {
312 shared_ptr<Func1>
derivative()
const override;
314 string write(
const string& arg)
const override;
331 Pow1(
const vector<double>& params);
333 string write(
const string& arg)
const override;
339 double eval(
double t)
const override {
342 shared_ptr<Func1>
derivative()
const override;
365 Tabulated1(
size_t n,
const double* tvals,
const double* fvals,
366 const string& method=
"linear");
379 string write(
const string& arg)
const override;
383 return "tabulated-linear";
385 return "tabulated-previous";
388 double eval(
double t)
const override;
389 shared_ptr<Func1>
derivative()
const override;
411 Const1(
const vector<double>& params);
413 string write(
const string& arg)
const override;
419 double eval(
double t)
const override {
423 return make_shared<Const1>(0.0);
443 Sum1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
458 double eval(
double t)
const override {
459 return m_f1->
eval(t) + m_f2->
eval(t);
463 return newSumFunction(m_f1_shared->derivative(), m_f2_shared->derivative());
470 string write(
const string& arg)
const override;
488 Diff1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
503 double eval(
double t)
const override {
504 return m_f1->
eval(t) - m_f2->
eval(t);
508 return newDiffFunction(m_f1_shared->derivative(), m_f2_shared->derivative());
515 string write(
const string& arg)
const override;
534 Product1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
549 string write(
const string& arg)
const override;
551 double eval(
double t)
const override {
552 return m_f1->
eval(t) * m_f2->
eval(t);
555 shared_ptr<Func1>
derivative()
const override;
586 return "times-constant";
591 return (other.
c()/
c());
597 double isProportional(Func1& other)
override {
605 double eval(
double t)
const override {
606 return m_f1->
eval(t) * m_c;
613 string write(
const string& arg)
const override;
644 return "plus-constant";
647 double eval(
double t)
const override {
648 return m_f1->
eval(t) + m_c;
652 return m_f1_shared->derivative();
655 string write(
const string& arg)
const override;
678 Ratio1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
693 double eval(
double t)
const override {
694 return m_f1->
eval(t) / m_f2->
eval(t);
697 shared_ptr<Func1>
derivative()
const override;
699 string write(
const string& arg)
const override;
721 Composite1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
736 double eval(
double t)
const override {
740 shared_ptr<Func1>
derivative()
const override;
742 string write(
const string& arg)
const override;
768 Gaussian1(
double A,
double t0,
double fwhm) {
771 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
782 double eval(
double t)
const override {
783 double x = (t - m_t0)/m_tau;
784 return m_A * std::exp(-x*x);
788 double m_A, m_t0, m_tau;
803 Poly1(
size_t n,
const double*
c) {
805 std::copy(
c,
c+m_cpoly.size(), m_cpoly.begin());
810 Poly1(
const vector<double>& params);
816 double eval(
double t)
const override {
817 double r = m_cpoly[m_cpoly.size()-1];
818 for (
size_t n = 1; n < m_cpoly.size(); n++) {
820 r += m_cpoly[m_cpoly.size() - n - 1];
826 vector<double> m_cpoly;
842 Fourier1(
size_t n,
double omega,
double a0,
const double* a,
const double* b) {
847 std::copy(a, a+n, m_ccos.begin());
848 std::copy(b, b+n, m_csin.begin());
853 Fourier1(
const vector<double>& params);
859 double eval(
double t)
const override {
862 for (n = 0; n < m_ccos.size(); n++) {
864 sum += m_ccos[n]*std::cos(m_omega*nn*t)
865 + m_csin[n]*std::sin(m_omega*nn*t);
871 double m_omega, m_a0_2;
872 vector<double> m_ccos, m_csin;
891 for (
size_t i = 0; i < n; i++) {
907 double eval(
double t)
const override {
909 for (
size_t n = 0; n < m_A.size(); n++) {
910 sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t);
916 vector<double> m_A, m_b, m_E;
946 double eval(
double t)
const override {
948 double time = t - np*m_c;
949 return m_f1->
eval(time);
Implements a sum of Arrhenius terms.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
Implements a composite function.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
int order() const override
Return the order of the function, if it makes sense.
string write(const string &arg) const override
Write LaTeX string describing function.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
string write(const string &arg) const override
Write LaTeX string describing function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Implements the cos() function.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
string write(const string &arg) const override
Write LaTeX string describing function.
Implements the difference of two functions.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
int order() const override
Return the order of the function, if it makes sense.
string write(const string &arg) const override
Write LaTeX string describing function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Implements the exp() (exponential) function.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
string write(const string &arg) const override
Write LaTeX string describing function.
Implements a Fourier cosine/sine series.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
Base class for 'functor' classes that evaluate a function of one variable.
string typeName() const
Returns a string with the class name of the functor.
virtual shared_ptr< Func1 > derivative() const
Creates a derivative to the current function.
virtual string type() const
Returns a string describing the type of the function.
shared_ptr< Func1 > derivative3() const
Creates a derivative to the current function.
virtual double eval(double t) const
Evaluate the function.
virtual string write(const string &arg) const
Write LaTeX string describing function.
double operator()(double t) const
Calls method eval to evaluate the function.
shared_ptr< Func1 > func2_shared() const
Accessor function for m_f2_shared.
virtual int order() const
Return the order of the function, if it makes sense.
bool isIdentical(Func1 &other) const
Routine to determine if two functions are the same.
shared_ptr< Func1 > func1_shared() const
Accessor function for m_f1_shared.
double c() const
Accessor function for the stored constant.
Implements a Gaussian function.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
Implements the log() (natural logarithm) function.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
string write(const string &arg) const override
Write LaTeX string describing function.
Implements a periodic function.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
Implements the sum of a function and a constant.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
int order() const override
Return the order of the function, if it makes sense.
string write(const string &arg) const override
Write LaTeX string describing function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Implements a polynomial of degree n.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
Implements the pow() (power) function.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
string write(const string &arg) const override
Write LaTeX string describing function.
Implements the product of two functions.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
int order() const override
Return the order of the function, if it makes sense.
string write(const string &arg) const override
Write LaTeX string describing function.
Implements the ratio of two functions.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
int order() const override
Return the order of the function, if it makes sense.
string write(const string &arg) const override
Write LaTeX string describing function.
Implements the sin() function.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
string write(const string &arg) const override
Write LaTeX string describing function.
Implements the sum of two functions.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
int order() const override
Return the order of the function, if it makes sense.
string write(const string &arg) const override
Write LaTeX string describing function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Implements a tabulated function.
double eval(double t) const override
Evaluate the function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
string type() const override
Returns a string describing the type of the function.
string write(const string &arg) const override
Write LaTeX string describing function.
void setMethod(const string &method)
Set the interpolation method.
vector< double > m_tvec
Vector of time values.
bool m_isLinear
Boolean indicating interpolation method.
vector< double > m_fvec
Vector of function values.
Tabulated1(size_t n, const double *tvals, const double *fvals, const string &method="linear")
Constructor.
Implements the product of a function and a constant.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
int order() const override
Return the order of the function, if it makes sense.
string write(const string &arg) const override
Write LaTeX string describing function.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
This file contains definitions of constants, types and terms that are used in internal routines and a...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
shared_ptr< Func1 > newCompositeFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Composite of two functions.
shared_ptr< Func1 > newProdFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Product of two functions.
shared_ptr< Func1 > newDiffFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Difference of two functions.
shared_ptr< Func1 > newTimesConstFunction(shared_ptr< Func1 > f, double c)
Product of function and constant.
shared_ptr< Func1 > newSumFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Sum of two functions.
shared_ptr< Func1 > newRatioFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Ratio of two functions.
shared_ptr< Func1 > newPlusConstFunction(shared_ptr< Func1 > f, double c)
Sum of function and constant.
Namespace for the Cantera kernel.