21const int FourierFuncType = 1;
22const int PolyFuncType = 2;
23const int ArrheniusFuncType = 3;
24const int GaussianFuncType = 4;
25const int SumFuncType = 20;
26const int DiffFuncType = 25;
27const int ProdFuncType = 30;
28const int RatioFuncType = 40;
29const int PeriodicFuncType = 50;
30const int CompositeFuncType = 60;
31const int TimesConstantFuncType = 70;
32const int PlusConstantFuncType = 80;
33const int SinFuncType = 100;
34const int CosFuncType = 102;
35const int ExpFuncType = 104;
36const int PowFuncType = 106;
37const int ConstFuncType = 110;
38const int TabulatedFuncType = 120;
100 Func1(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
101 : m_f1_shared(f1), m_f2_shared(f2)
107 Func1(shared_ptr<Func1> f1,
double A) : m_c(A), m_f1_shared(f1) {
111 virtual ~Func1() =
default;
128 virtual int ID()
const;
144 virtual double eval(
double t)
const;
171 virtual double isProportional(
Func1& other);
174 virtual string write(
const string& arg)
const;
204 virtual int order()
const;
220 Func1* m_f1 =
nullptr;
221 Func1* m_f2 =
nullptr;
222 Func1* m_parent =
nullptr;
224 shared_ptr<Func1> m_f1_shared;
225 shared_ptr<Func1> m_f2_shared;
230Func1& newSumFunction(Func1& f1, Func1& f2);
231Func1& newDiffFunction(Func1& f1, Func1& f2);
232Func1& newProdFunction(Func1& f1, Func1& f2);
233Func1& newRatioFunction(Func1& f1, Func1& f2);
234Func1& newCompositeFunction(Func1& f1, Func1& f2);
235Func1& newTimesConstFunction(Func1& f1,
double c);
236Func1& newPlusConstFunction(Func1& f1,
double c);
241shared_ptr<Func1> newSumFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
245shared_ptr<Func1> newDiffFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
249shared_ptr<Func1> newProdFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
253shared_ptr<Func1> newRatioFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
257shared_ptr<Func1> newCompositeFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
261shared_ptr<Func1> newTimesConstFunction(shared_ptr<Func1> f1,
double c);
265shared_ptr<Func1> newPlusConstFunction(shared_ptr<Func1> f1,
double c);
277 Sin1(
double omega=1.0) {
282 Sin1(
const vector<double>& params);
288 Sin1& operator=(
const Sin1& right) {
289 if (&right ==
this) {
296 string write(
const string& arg)
const override;
298 int ID()
const override {
306 double eval(
double t)
const override{
326 Cos1(
double omega=1.0) {
331 Cos1(
const vector<double>& params);
337 Cos1& operator=(
const Cos1& right) {
338 if (&right ==
this) {
346 string write(
const string& arg)
const override;
347 int ID()
const override {
354 double eval(
double t)
const override {
376 Exp1(
const vector<double>& params);
381 Exp1& operator=(
const Exp1& right) {
382 if (&right ==
this) {
388 string write(
const string& arg)
const override;
389 int ID()
const override {
396 double eval(
double t)
const override {
421 Log1(
const vector<double>& params);
427 double eval(
double t)
const override {
433 string write(
const string& arg)
const override;
450 Pow1(
const vector<double>& params);
455 Pow1& operator=(
const Pow1& right) {
456 if (&right ==
this) {
462 string write(
const string& arg)
const override;
463 int ID()
const override {
470 double eval(
double t)
const override {
498 Tabulated1(
size_t n,
const double* tvals,
const double* fvals,
499 const string& method=
"linear");
512 string write(
const string& arg)
const override;
513 int ID()
const override {
514 return TabulatedFuncType;
518 return "tabulated-linear";
520 return "tabulated-previous";
523 double eval(
double t)
const override;
548 Const1(
const vector<double>& params);
555 if (&right ==
this) {
562 string write(
const string& arg)
const override;
563 int ID()
const override {
564 return ConstFuncType;
570 double eval(
double t)
const override {
576 return make_shared<Const1>(0.0);
598 Sum1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
611 *
this = Sum1::operator=(b);
614 Sum1& operator=(
const Sum1& right) {
615 if (&right ==
this) {
627 int ID()
const override {
634 double eval(
double t)
const override {
635 return m_f1->
eval(t) + m_f2->
eval(t);
642 return newSumFunction(m_f1_shared->derivative3(), m_f2_shared->derivative3());
649 string write(
const string& arg)
const override;
669 Diff1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
682 *
this = Diff1::operator=(b);
686 if (&right ==
this) {
698 int ID()
const override {
706 double eval(
double t)
const override {
707 return m_f1->
eval(t) - m_f2->
eval(t);
714 return newDiffFunction(m_f1_shared->derivative3(), m_f2_shared->derivative3());
721 string write(
const string& arg)
const override;
742 Product1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
755 *
this = Product1::operator=(b);
759 if (&right ==
this) {
771 int ID()
const override {
779 string write(
const string& arg)
const override;
781 double eval(
double t)
const override {
782 return m_f1->
eval(t) * m_f2->
eval(t);
821 *
this = TimesConstant1::operator=(b);
825 if (&right ==
this) {
834 int ID()
const override {
835 return TimesConstantFuncType;
838 return "times-constant";
843 return (other.
c()/
c());
849 double isProportional(Func1& other)
override {
857 double eval(
double t)
const override {
858 return m_f1->
eval(t) * m_c;
865 return newTimesConstFunction(m_f1_shared->derivative3(), m_c);
868 string write(
const string& arg)
const override;
901 *
this = PlusConstant1::operator=(b);
905 if (&right ==
this) {
915 int ID()
const override {
916 return PlusConstantFuncType;
919 return "plus-constant";
922 double eval(
double t)
const override {
923 return m_f1->
eval(t) + m_c;
930 return m_f1_shared->derivative3();
933 string write(
const string& arg)
const override;
958 Ratio1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
971 *
this = Ratio1::operator=(b);
975 if (&right ==
this) {
987 int ID()
const override {
988 return RatioFuncType;
994 double eval(
double t)
const override {
995 return m_f1->
eval(t) / m_f2->
eval(t);
1003 string write(
const string& arg)
const override;
1027 Composite1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) :
Func1(f1, f2) {}
1040 *
this = Composite1::operator=(b);
1044 if (&right ==
this) {
1056 int ID()
const override {
1057 return CompositeFuncType;
1063 double eval(
double t)
const override {
1072 string write(
const string& arg)
const override;
1098 Gaussian1(
double A,
double t0,
double fwhm) {
1101 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
1106 Gaussian1(
const vector<double>& params);
1110 *
this = Gaussian1::operator=(b);
1114 if (&right ==
this) {
1120 m_tau = right.m_tau;
1129 double eval(
double t)
const override {
1130 double x = (t - m_t0)/m_tau;
1131 return m_A * std::exp(-x*x);
1135 double m_A, m_t0, m_tau;
1153 Gaussian(
double A,
double t0,
double fwhm);
1172 Poly1(
size_t n,
const double*
c) {
1173 m_cpoly.resize(n+1);
1174 std::copy(
c,
c+m_cpoly.size(), m_cpoly.begin());
1179 Poly1(
const vector<double>& params);
1183 *
this = Poly1::operator=(b);
1187 if (&right ==
this) {
1191 m_cpoly = right.m_cpoly;
1197 return "polynomial";
1202 double eval(
double t)
const override {
1203 double r = m_cpoly[m_cpoly.size()-1];
1204 for (
size_t n = 1; n < m_cpoly.size(); n++) {
1206 r += m_cpoly[m_cpoly.size() - n - 1];
1212 vector<double> m_cpoly;
1228 Fourier1(
size_t n,
double omega,
double a0,
const double* a,
const double* b) {
1233 std::copy(a, a+n, m_ccos.begin());
1234 std::copy(b, b+n, m_csin.begin());
1239 Fourier1(
const vector<double>& params);
1243 *
this = Fourier1::operator=(b);
1247 if (&right ==
this) {
1251 m_omega = right.m_omega;
1252 m_a0_2 = right.m_a0_2;
1253 m_ccos = right.m_ccos;
1254 m_csin = right.m_csin;
1265 double eval(
double t)
const override {
1267 double sum = m_a0_2;
1268 for (n = 0; n < m_ccos.size(); n++) {
1270 sum += m_ccos[n]*std::cos(m_omega*nn*t)
1271 + m_csin[n]*std::sin(m_omega*nn*t);
1277 double m_omega, m_a0_2;
1278 vector<double> m_ccos, m_csin;
1297 for (
size_t i = 0; i < n; i++) {
1311 *
this = Arrhenius1::operator=(b);
1315 if (&right ==
this) {
1332 double eval(
double t)
const override {
1334 for (
size_t n = 0; n < m_A.size(); n++) {
1335 sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t);
1341 vector<double> m_A, m_b, m_E;
1360 *
this = Periodic1::operator=(b);
1366 if (&right ==
this) {
1386 double eval(
double t)
const override {
1387 int np = int(t/m_c);
1388 double time = t - np*m_c;
1389 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.
Func1 & duplicate() const override
Duplicate the current function.
Implements a composite function.
Func1 & derivative() const override
Creates a derivative to the current function.
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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Func1 & derivative() const override
Creates a derivative to the current 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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements the cos() function.
Func1 & derivative() const override
Creates a derivative to the current 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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements the difference of two functions.
Func1 & derivative() const override
Creates a derivative to the current function.
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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements the exp() (exponential) function.
Func1 & derivative() const override
Creates a derivative to the current 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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current 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.
Func1 & duplicate() const override
Duplicate the current 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 string type() const
Returns a string describing the type of the function.
Func1 & operator=(const Func1 &right)
void setC(double c)
Function to set the stored constant.
virtual double eval(double t) const
Evaluate the function.
virtual shared_ptr< Func1 > derivative3() const
Creates a derivative to the current function.
shared_ptr< Func1 > func1_shared() const
Accessor function for m_f1_shared.
Func1 & func1_dup() const
Func1 & func2() const
accessor function for m_f2
virtual string write(const string &arg) const
Write LaTeX string describing function.
double operator()(double t) const
Calls method eval to evaluate the function.
Func1 & func1() const
accessor function for m_f1
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.
virtual Func1 & duplicate() const
Duplicate the current function.
shared_ptr< Func1 > func2_shared() const
Accessor function for m_f2_shared.
virtual Func1 & derivative() const
Creates a derivative to the current function.
double c() const
Accessor function for the stored constant.
Func1 & func2_dup() const
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.
Func1 & duplicate() const override
Duplicate the current function.
Implements the log() (natural logarithm) 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 > derivative3() const override
Creates a derivative to the current 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.
Func1 & duplicate() const override
Duplicate the current function.
Implements the sum of a function and a constant.
Func1 & derivative() const override
Creates a derivative to the current function.
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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate 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.
Func1 & duplicate() const override
Duplicate the current function.
Implements the pow() (power) function.
Func1 & derivative() const override
Creates a derivative to the current 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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements the product of two functions.
Func1 & derivative() const override
Creates a derivative to the current function.
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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements the ratio of two functions.
Func1 & derivative() const override
Creates a derivative to the current function.
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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements the sin() function.
Func1 & derivative() const override
Creates a derivative to the current 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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements the sum of two functions.
Func1 & derivative() const override
Creates a derivative to the current function.
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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements a tabulated function.
Func1 & derivative() const override
Creates a derivative to the current 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.
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.
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate the current function.
Implements the product of a function and a constant.
Func1 & derivative() const override
Creates a derivative to the current function.
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 > derivative3() const override
Creates a derivative to the current function.
Func1 & duplicate() const override
Duplicate 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...
Namespace for the Cantera kernel.