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(span<const 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(span<const 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(span<const 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(span<const 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(span<const double> params);
314 string write(
const string& arg)
const override;
320 double eval(
double t)
const override {
323 shared_ptr<Func1>
derivative()
const override;
345 Tabulated1(span<const double> tvals, span<const double> fvals,
346 const string& method=
"linear");
363 string write(
const string& arg)
const override;
367 return "tabulated-linear";
369 return "tabulated-previous";
372 double eval(
double t)
const override;
373 shared_ptr<Func1>
derivative()
const override;
395 Const1(span<const double> params);
397 string write(
const string& arg)
const override;
403 double eval(
double t)
const override {
407 return make_shared<Const1>(0.0);
422 Sum1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
428 double eval(
double t)
const override {
429 return m_f1->eval(t) + m_f2->eval(t);
440 string write(
const string& arg)
const override;
453 Diff1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
459 double eval(
double t)
const override {
460 return m_f1->eval(t) - m_f2->eval(t);
471 string write(
const string& arg)
const override;
485 Product1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
491 string write(
const string& arg)
const override;
493 double eval(
double t)
const override {
494 return m_f1->eval(t) * m_f2->eval(t);
497 shared_ptr<Func1>
derivative()
const override;
517 return "times-constant";
520 double eval(
double t)
const override {
521 return m_f1->eval(t) * m_c;
528 string write(
const string& arg)
const override;
548 return "plus-constant";
551 double eval(
double t)
const override {
552 return m_f1->eval(t) + m_c;
556 return m_f1->derivative();
559 string write(
const string& arg)
const override;
577 Ratio1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
583 double eval(
double t)
const override {
584 return m_f1->eval(t) / m_f2->eval(t);
587 shared_ptr<Func1>
derivative()
const override;
589 string write(
const string& arg)
const override;
606 Composite1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
612 double eval(
double t)
const override {
613 return m_f1->eval(m_f2->eval(t));
616 shared_ptr<Func1>
derivative()
const override;
618 string write(
const string& arg)
const override;
644 Gaussian1(
double A,
double t0,
double fwhm) {
647 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
662 double eval(
double t)
const override {
663 double x = (t - m_t0)/m_tau;
664 return m_A * std::exp(-x*x);
668 double m_A, m_t0, m_tau;
689 Poly1(span<const double> params);
692 return "polynomial3";
699 double eval(
double t)
const override {
700 double r = m_cpoly[0];
701 for (
size_t n = 1; n < m_cpoly.size(); n++) {
708 string write(
const string& arg)
const override;
711 vector<double> m_cpoly;
726 Fourier1(
double omega,
double a0, span<const double> a, span<const double> b) {
727 if (a.size() != b.size()) {
729 "Expected matching sin/cos coefficient lengths, got {} and {}.",
734 m_ccos.assign(a.begin(), a.end());
735 m_csin.assign(b.begin(), b.end());
740 Fourier1(span<const double> params);
750 double eval(
double t)
const override {
753 for (n = 0; n < m_ccos.size(); n++) {
755 sum += m_ccos[n]*std::cos(m_omega*nn*t)
756 + m_csin[n]*std::sin(m_omega*nn*t);
762 double m_omega, m_a0_2;
763 vector<double> m_ccos, m_csin;
790 double eval(
double t)
const override {
792 for (
size_t n = 0; n < m_A.size(); n++) {
793 sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t);
799 vector<double> m_A, m_b, m_E;
818 double eval(
double t)
const override {
820 double time = t - np*m_c;
821 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.
Base class for exceptions thrown by Cantera classes.
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.