79 Func1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : m_f1(f1), m_f2(f2) {}
81 Func1(shared_ptr<Func1> f1,
double A) : m_c(A), m_f1(f1) {}
83 virtual ~Func1() =
default;
90 virtual string type()
const {
102 virtual double eval(
double t)
const;
120 virtual bool isIdentical(shared_ptr<Func1> other)
const;
123 virtual string write(
const string& arg)
const;
141 virtual int order()
const;
145 shared_ptr<Func1> m_f1;
146 shared_ptr<Func1> m_f2;
151shared_ptr<Func1>
newSumFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
155shared_ptr<Func1>
newDiffFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
159shared_ptr<Func1>
newProdFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
163shared_ptr<Func1>
newRatioFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
187 Sin1(
double omega=1.0) {
192 Sin1(
const vector<double>& params);
194 string write(
const string& arg)
const override;
200 double eval(
double t)
const override{
204 shared_ptr<Func1>
derivative()
const override;
218 Cos1(
double omega=1.0) {
223 Cos1(
const vector<double>& params);
225 string write(
const string& arg)
const override;
231 double eval(
double t)
const override {
234 shared_ptr<Func1>
derivative()
const override;
252 Exp1(
const vector<double>& params);
254 string write(
const string& arg)
const override;
260 double eval(
double t)
const override {
264 shared_ptr<Func1>
derivative()
const override;
283 Log1(
const vector<double>& params);
289 double eval(
double t)
const override {
293 shared_ptr<Func1>
derivative()
const override;
295 string write(
const string& arg)
const override;
312 Pow1(
const vector<double>& params);
314 string write(
const string& arg)
const override;
320 double eval(
double t)
const override {
323 shared_ptr<Func1>
derivative()
const override;
346 Tabulated1(
size_t n,
const double* tvals,
const double* fvals,
347 const string& method=
"linear");
364 string write(
const string& arg)
const override;
368 return "tabulated-linear";
370 return "tabulated-previous";
373 double eval(
double t)
const override;
374 shared_ptr<Func1>
derivative()
const override;
396 Const1(
const vector<double>& params);
398 string write(
const string& arg)
const override;
404 double eval(
double t)
const override {
408 return make_shared<Const1>(0.0);
423 Sum1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
429 double eval(
double t)
const override {
430 return m_f1->eval(t) + m_f2->eval(t);
441 string write(
const string& arg)
const override;
454 Diff1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
460 double eval(
double t)
const override {
461 return m_f1->eval(t) - m_f2->eval(t);
472 string write(
const string& arg)
const override;
486 Product1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
492 string write(
const string& arg)
const override;
494 double eval(
double t)
const override {
495 return m_f1->eval(t) * m_f2->eval(t);
498 shared_ptr<Func1>
derivative()
const override;
518 return "times-constant";
521 double eval(
double t)
const override {
522 return m_f1->eval(t) * m_c;
529 string write(
const string& arg)
const override;
549 return "plus-constant";
552 double eval(
double t)
const override {
553 return m_f1->eval(t) + m_c;
557 return m_f1->derivative();
560 string write(
const string& arg)
const override;
578 Ratio1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
584 double eval(
double t)
const override {
585 return m_f1->eval(t) / m_f2->eval(t);
588 shared_ptr<Func1>
derivative()
const override;
590 string write(
const string& arg)
const override;
607 Composite1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
613 double eval(
double t)
const override {
614 return m_f1->eval(m_f2->eval(t));
617 shared_ptr<Func1>
derivative()
const override;
619 string write(
const string& arg)
const override;
645 Gaussian1(
double A,
double t0,
double fwhm) {
648 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
663 double eval(
double t)
const override {
664 double x = (t - m_t0)/m_tau;
665 return m_A * std::exp(-x*x);
669 double m_A, m_t0, m_tau;
688 Poly1(
size_t n,
const double*
c) {
690 std::copy(
c,
c+m_cpoly.size(), m_cpoly.begin());
695 Poly1(
const vector<double>& params);
698 return "polynomial3";
705 double eval(
double t)
const override {
706 double r = m_cpoly[0];
707 for (
size_t n = 1; n < m_cpoly.size(); n++) {
714 string write(
const string& arg)
const override;
717 vector<double> m_cpoly;
732 Fourier1(
size_t n,
double omega,
double a0,
const double* a,
const double* b) {
737 std::copy(a, a+n, m_ccos.begin());
738 std::copy(b, b+n, m_csin.begin());
743 Fourier1(
const vector<double>& params);
753 double eval(
double t)
const override {
756 for (n = 0; n < m_ccos.size(); n++) {
758 sum += m_ccos[n]*std::cos(m_omega*nn*t)
759 + m_csin[n]*std::sin(m_omega*nn*t);
765 double m_omega, m_a0_2;
766 vector<double> m_ccos, m_csin;
785 for (
size_t i = 0; i < n; i++) {
805 double eval(
double t)
const override {
807 for (
size_t n = 0; n < m_A.size(); n++) {
808 sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t);
814 vector<double> m_A, m_b, m_E;
833 double eval(
double t)
const override {
835 double time = t - np*m_c;
836 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.
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
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.
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 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.
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 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.
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
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.
virtual double eval(double t) const
Evaluate the function.
shared_ptr< Func1 > func1_shared() const
Accessor function for m_f1.
virtual string write(const string &arg) const
Write LaTeX string describing function.
double operator()(double t) const
Calls method eval to evaluate the function.
virtual bool isIdentical(shared_ptr< Func1 > other) const
Routine to determine if two functions are the same.
virtual int order() const
Return the order of the function, if it makes sense.
shared_ptr< Func1 > func2_shared() const
Accessor function for m_f2.
double c() const
Accessor function for the stored constant m_c.
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.
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
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.
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 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.
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
string write(const string &arg) const override
Write LaTeX string describing 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.
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 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.
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
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.
Implements the product of a function and a constant.
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.
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.