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;
85 Func1(
const Func1& right) =
delete;
86 Func1& operator=(
const Func1& right) =
delete;
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);
184class Sin1 :
public Func1
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;
215class Cos1 :
public Func1
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;
244class Exp1 :
public Func1
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;
275class Log1 :
public Func1
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;
304class Pow1 :
public Func1
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;
387class Const1 :
public Func1
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);
419class Sum1 :
public Func1
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;
450class Diff1 :
public Func1
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;
482class Product1 :
public Func1
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;
511class TimesConstant1 :
public Func1
514 TimesConstant1(shared_ptr<Func1> f1,
double a) : Func1(f1, a) {}
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;
542class PlusConstant1 :
public Func1
545 PlusConstant1(shared_ptr<Func1> f1,
double a) : Func1(f1, a) {}
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;
574class Ratio1 :
public Func1
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;
603class Composite1 :
public Func1
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;
641class Gaussian1 :
public Func1
644 Gaussian1(
double A,
double t0,
double fwhm) {
647 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
652 Gaussian1(span<const double> params);
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;
723class Fourier1 :
public Func1
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;
809class Periodic1 :
public Func1
812 Periodic1(shared_ptr<Func1> f,
double A) : Func1(f, A) {}
818 double eval(
double t)
const override {
820 double time = t - np*m_c;
821 return m_f1->eval(time);
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the function.
Arrhenius1(span< const double > params)
Constructor uses parameters in the following order: .
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.
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.
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.
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.
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 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.
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.
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.
double eval(double t) const override
Evaluate the function.
string type() const override
Returns a string describing the type of the 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.
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.
Poly1(span< const double > params)
Constructor uses parameters in the following order: .
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.
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.
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.
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.
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.
Tabulated1(span< const double > tvals, span< 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.
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.