19 const int FourierFuncType = 1;
20 const int PolyFuncType = 2;
21 const int ArrheniusFuncType = 3;
22 const int GaussianFuncType = 4;
23 const int SumFuncType = 20;
24 const int DiffFuncType = 25;
25 const int ProdFuncType = 30;
26 const int RatioFuncType = 40;
27 const int PeriodicFuncType = 50;
28 const int CompositeFuncType = 60;
29 const int TimesConstantFuncType = 70;
30 const int PlusConstantFuncType = 80;
31 const int SinFuncType = 100;
32 const int CosFuncType = 102;
33 const int ExpFuncType = 104;
34 const int PowFuncType = 106;
35 const int ConstFuncType = 110;
36 const int TabulatedFuncType = 120;
61 virtual int ID()
const;
67 virtual doublereal
eval(doublereal t)
const;
85 virtual doublereal isProportional(
Func1& other);
87 virtual std::string write(
const std::string& arg)
const;
93 void setC(doublereal
c);
102 virtual int order()
const;
104 Func1& func1_dup()
const;
106 Func1& func2_dup()
const;
108 Func1* parent()
const;
110 void setParent(
Func1* p);
125 Func1& newTimesConstFunction(
Func1& f1, doublereal c);
126 Func1& newPlusConstFunction(
Func1& f1, doublereal c);
136 Sin1(doublereal omega = 1.0) :
145 Sin1& operator=(
const Sin1& right) {
146 if (&right ==
this) {
149 Func1::operator=(right);
155 return (
Func1&) *nfunc;
158 virtual std::string write(
const std::string& arg)
const;
160 virtual int ID()
const {
164 virtual doublereal
eval(doublereal t)
const {
179 Cos1(doublereal omega = 1.0) :
188 Cos1& operator=(
const Cos1& right) {
189 if (&right ==
this) {
192 Func1::operator=(right);
198 return (
Func1&) *nfunc;
200 virtual std::string write(
const std::string& arg)
const;
201 virtual int ID()
const {
204 virtual doublereal
eval(doublereal t)
const {
215 Exp1(doublereal A = 1.0) :
223 Exp1& operator=(
const Exp1& right) {
224 if (&right ==
this) {
227 Func1::operator=(right);
230 virtual std::string write(
const std::string& arg)
const;
231 virtual int ID()
const {
235 return *(
new Exp1(m_c));
237 virtual doublereal
eval(doublereal t)
const {
257 Pow1& operator=(
const Pow1& right) {
258 if (&right ==
this) {
261 Func1::operator=(right);
264 virtual std::string write(
const std::string& arg)
const;
265 virtual int ID()
const {
269 return *(
new Pow1(m_c));
271 virtual doublereal
eval(doublereal t)
const {
289 Tabulated1(
size_t n,
const double* tvals,
const double* fvals,
290 const std::string& method =
"linear");
292 virtual std::string write(
const std::string& arg)
const;
293 virtual int ID()
const {
294 return TabulatedFuncType;
296 virtual double eval(
double t)
const;
333 if (&right ==
this) {
336 Func1::operator=(right);
340 virtual std::string write(
const std::string& arg)
const;
341 virtual int ID()
const {
342 return ConstFuncType;
344 virtual doublereal
eval(doublereal t)
const {
348 return *(
new Const1(m_c));
368 m_f1->setParent(
this);
369 m_f2->setParent(
this);
379 *
this = Sum1::operator=(b);
382 Sum1& operator=(
const Sum1& right) {
383 if (&right ==
this) {
386 Func1::operator=(right);
389 m_f1->setParent(
this);
390 m_f2->setParent(
this);
395 virtual int ID()
const {
399 virtual doublereal
eval(doublereal t)
const {
400 return m_f1->
eval(t) + m_f2->
eval(t);
406 return newSumFunction(f1d, f2d);
412 return newSumFunction(d1, d2);
418 virtual std::string write(
const std::string& arg)
const;
431 m_f1->setParent(
this);
432 m_f2->setParent(
this);
442 *
this = Diff1::operator=(b);
446 if (&right ==
this) {
449 Func1::operator=(right);
452 m_f1->setParent(
this);
453 m_f2->setParent(
this);
458 virtual int ID()
const {
462 virtual doublereal
eval(doublereal t)
const {
463 return m_f1->
eval(t) - m_f2->
eval(t);
469 return newDiffFunction(f1d, f2d);
478 virtual std::string write(
const std::string& arg)
const;
492 m_f1->setParent(
this);
493 m_f2->setParent(
this);
503 *
this = Product1::operator=(b);
507 if (&right ==
this) {
510 Func1::operator=(right);
513 m_f1->setParent(
this);
514 m_f2->setParent(
this);
519 virtual int ID()
const {
526 return newProdFunction(f1d, f2d);
529 virtual std::string write(
const std::string& arg)
const;
531 virtual doublereal
eval(doublereal t)
const {
532 return m_f1->
eval(t) * m_f2->
eval(t);
538 return newSumFunction(a1, a2);
555 m_f1->setParent(
this);
564 *
this = TimesConstant1::operator=(b);
568 if (&right ==
this) {
571 Func1::operator=(right);
573 m_f1->setParent(
this);
577 virtual int ID()
const {
578 return TimesConstantFuncType;
589 return (other.
c()/
c());
595 virtual doublereal isProportional(Func1& other) {
603 virtual doublereal
eval(doublereal t)
const {
604 return m_f1->
eval(t) * m_c;
609 Func1* d = &newTimesConstFunction(f1d, m_c);
613 virtual std::string write(
const std::string& arg)
const;
630 m_f1->setParent(
this);
639 *
this = PlusConstant1::operator=(b);
643 if (&right ==
this) {
646 Func1::operator=(right);
648 m_f1->setParent(
this);
653 virtual int ID()
const {
654 return PlusConstantFuncType;
663 virtual doublereal
eval(doublereal t)
const {
664 return m_f1->
eval(t) + m_c;
669 virtual std::string write(
const std::string& arg)
const;
687 m_f1->setParent(
this);
688 m_f2->setParent(
this);
698 *
this = Ratio1::operator=(b);
702 if (&right ==
this) {
705 Func1::operator=(right);
708 m_f1->setParent(
this);
709 m_f2->setParent(
this);
714 virtual int ID()
const {
715 return RatioFuncType;
718 virtual doublereal
eval(doublereal t)
const {
719 return m_f1->
eval(t) / m_f2->
eval(t);
725 return newRatioFunction(f1d, f2d);
731 Func1& s = newDiffFunction(a1, a2);
733 return newRatioFunction(s, p);
736 virtual std::string write(
const std::string& arg)
const;
753 m_f1->setParent(
this);
754 m_f2->setParent(
this);
764 *
this = Composite1::operator=(b);
768 if (&right ==
this) {
771 Func1::operator=(right);
774 m_f1->setParent(
this);
775 m_f2->setParent(
this);
780 virtual int ID()
const {
781 return CompositeFuncType;
784 virtual doublereal
eval(doublereal t)
const {
791 return newCompositeFunction(f1d, f2d);
799 Func1* p = &newProdFunction(*d3, *d2);
803 virtual std::string write(
const std::string& arg)
const;
826 Gaussian(
double A,
double t0,
double fwhm) :
830 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
835 *
this = Gaussian::operator=(b);
839 if (&right ==
this) {
842 Func1::operator=(right);
852 return *((
Func1*)np);
855 virtual doublereal
eval(doublereal t)
const {
856 doublereal x = (t - m_t0)/m_tau;
857 return m_A * std::exp(-x*x);
861 doublereal m_A, m_t0, m_tau;
871 Poly1(
size_t n,
const double*
c) :
874 std::copy(
c,
c+m_cpoly.size(), m_cpoly.begin());
879 *
this = Poly1::operator=(b);
883 if (&right ==
this) {
886 Func1::operator=(right);
887 m_cpoly = right.m_cpoly;
894 return *((
Func1*)np);
897 virtual doublereal
eval(doublereal t)
const {
898 doublereal r = m_cpoly[m_cpoly.size()-1];
899 for (
size_t n = 1; n < m_cpoly.size(); n++) {
901 r += m_cpoly[m_cpoly.size() - n - 1];
922 Fourier1(
size_t n,
double omega,
double a0,
923 const double* a,
const double* b) :
929 std::copy(a, a+n, m_ccos.begin());
930 std::copy(b, b+n, m_csin.begin());
935 *
this = Fourier1::operator=(b);
939 if (&right ==
this) {
942 Func1::operator=(right);
943 m_omega = right.m_omega;
944 m_a0_2 = right.m_a0_2;
945 m_ccos = right.m_ccos;
946 m_csin = right.m_csin;
953 return *((
Func1*)np);
956 virtual doublereal
eval(doublereal t)
const {
958 doublereal sum = m_a0_2;
959 for (n = 0; n < m_ccos.size(); n++) {
961 sum += m_ccos[n]*std::cos(m_omega*nn*t)
962 + m_csin[n]*std::sin(m_omega*nn*t);
968 doublereal m_omega, m_a0_2;
987 for (
size_t i = 0; i < n; i++) {
997 *
this = Arrhenius1::operator=(b);
1001 if (&right ==
this) {
1004 Func1::operator=(right);
1014 return *((
Func1*)np);
1017 virtual doublereal
eval(doublereal t)
const {
1018 doublereal sum = 0.0;
1019 for (
size_t n = 0; n < m_A.size(); n++) {
1020 sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t);
1043 *
this = Periodic1::operator=(b);
1047 if (&right ==
this) {
1050 Func1::operator=(right);
1057 return *((
Func1*)np);
1064 virtual doublereal
eval(doublereal t)
const {
1065 int np = int(t/m_c);
1066 doublereal time = t - np*m_c;
1067 return m_func->
eval(time);
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
virtual int order() const
Return the order of the function, if it makes sense.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
The Const1 class implements a constant.
virtual Func1 & duplicate() const
Duplicate the current function.
Const1(double A)
Constructor.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
implements the cos() function
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
Difference of two functions.
virtual int order() const
Return the order of the function, if it makes sense.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
implements the exponential function
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
Fourier cosine/sine series.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
Base class for 'functor' classes that evaluate a function of one variable.
void setC(doublereal c)
Function to set the stored constant.
virtual doublereal eval(doublereal t) const
Evaluate the function.
Func1 & func2() const
accessor function for m_f2
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.
doublereal operator()(doublereal t) const
Calls method eval to evaluate the function.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
doublereal c() const
accessor function for the stored constant
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
A function plus a constant.
virtual int order() const
Return the order of the function, if it makes sense.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
implements the power function (pow)
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
Product of two functions.
virtual int order() const
Return the order of the function, if it makes sense.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
virtual int order() const
Return the order of the function, if it makes sense.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
implements the sin() function
virtual Func1 & duplicate() const
Duplicate the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual int order() const
Return the order of the function, if it makes sense.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
The Tabulated1 class implements a tabulated function.
vector_fp m_tvec
Vector of time values.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual double eval(double t) const
Evaluate the function.
vector_fp m_fvec
Vector of function values.
bool m_isLinear
Boolean indicating interpolation method.
virtual Func1 & derivative() const
Creates a derivative to the current function.
Tabulated1(size_t n, const double *tvals, const double *fvals, const std::string &method="linear")
Constructor.
Product of two functions.
virtual int order() const
Return the order of the function, if it makes sense.
virtual Func1 & duplicate() const
Duplicate the current function.
virtual Func1 & derivative() const
Creates a derivative to the current function.
virtual doublereal eval(doublereal t) const
Evaluate the function.
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Namespace for the Cantera kernel.