Cantera  4.0.0a1
Loading...
Searching...
No Matches
Func1.h
Go to the documentation of this file.
1/**
2 * @file Func1.h
3 */
4
5// This file is part of Cantera. See License.txt in the top-level directory or
6// at https://cantera.org/license.txt for license and copyright information.
7
8#ifndef CT_FUNC1_H
9#define CT_FUNC1_H
10
13
14#include <iostream>
15
16namespace Cantera
17{
18
19class TimesConstant1;
20
21//! @defgroup func1 Functor Objects
22//! Functors implement functions of a single variable @f$ f(x) @f$.
23//! Functor objects can be combined to form compound expressions, which allows for
24//! the implementation of generic mathematical expressions.
25//! @ingroup numerics
26
27//! @defgroup func1basic Basic Functors
28//! Basic functors implement standard mathematical expressions with a single
29//! parameter.
30//! The following simple functor types are implemented:
31//! - @c "sin" (class Sin1), @c "cos" (class Cos1),
32//! - @c "exp" (class Exp1), @c "log" (class Log1),
33//! - @c "pow" (class Pow1),
34//! - @c "constant" (class Const1).
35//! @ingroup func1
36
37//! @defgroup func1advanced Advanced Functors
38//! Advanced functors implement expressions that require multiple parameters.
39//! The following advanced functor types are implemented:
40//! - @c "tabulated-linear" and @c "tabulated-previous" (class Tabulated1),
41//! - @c "polynomial3" (class Poly1),
42//! - @c "Fourier" (class Fourier1),
43//! - @c "Gaussian" (class Gaussian1),
44//! - @c "Arrhenius" (class Arrhenius1).
45//! @ingroup func1
46
47//! @defgroup func1compound Compound Functors
48//! Compound functors implement expressions that are composed of other functors.
49//! The following compound functor types are implemented:
50//! - @c "sum" (class Sum1),
51//! - @c "diff" (class Diff1),
52//! - @c "product" (class Product1),
53//! - @c "ratio" (class Ratio1),
54//! - @c "composite" (class Composite1),
55//! @ingroup func1
56
57//! @defgroup func1modified Modified Functors
58//! Modified functors implement expressions that involve one functor and
59//! a single parameter.
60//! The following modified functor types are implemented:
61//! - @c "times-constant" (class TimesConstant1),
62//! - @c "plus-constant" (class PlusConstant1),
63//! - @c "periodic" (class Periodic1).
64//! @ingroup func1
65
66//! @defgroup func1helper Helper Functions
67//! Helper functions detect simplifications that can be made to compound expressions.
68//! @ingroup func1
69
70/**
71 * Base class for 'functor' classes that evaluate a function of one variable.
72 * @ingroup func1
73 */
74class Func1
75{
76public:
77 Func1() = default;
78
79 Func1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : m_f1(f1), m_f2(f2) {}
80
81 Func1(shared_ptr<Func1> f1, double A) : m_c(A), m_f1(f1) {}
82
83 virtual ~Func1() = default;
84
85 Func1(const Func1& right) = delete;
86 Func1& operator=(const Func1& right) = delete;
87
88 //! Returns a string describing the type of the function
89 //! @since New in %Cantera 3.0.
90 virtual string type() const {
91 return "functor";
92 }
93
94 //! Returns a string with the class name of the functor
95 //! @since New in %Cantera 3.0.
96 string typeName() const;
97
98 //! Calls method eval to evaluate the function
99 double operator()(double t) const;
100
101 //! Evaluate the function.
102 virtual double eval(double t) const;
103
104 //! Creates a derivative to the current function
105 /*!
106 * @return shared pointer to new derivative function.
107 * @since Starting in %Cantera 3.1, the return type is a `shared_ptr`.
108 */
109 virtual shared_ptr<Func1> derivative() const;
110
111 //! Routine to determine if two functions are the same.
112 /*!
113 * Two functions are the same if they are the same function. For example, either
114 * ID and stored constant are the same, or the #m_f1 and #m_f2 are identical if they
115 * are non-null. Functors of the base class Func1 are by default not identical, as
116 * they are used by callback functions that cannot be differentiated. In instances
117 * where exact comparisons are not implemented, `false` is returned to prevent false
118 * positives that could lead to incorrect simplifications of compound functors.
119 */
120 virtual bool isIdentical(shared_ptr<Func1> other) const;
121
122 //! Write LaTeX string describing function.
123 virtual string write(const string& arg) const;
124
125 //! Accessor function for the stored constant #m_c.
126 double c() const;
127
128 //! Accessor function for #m_f1.
129 //! @since New in %Cantera 3.0.
130 shared_ptr<Func1> func1_shared() const {
131 return m_f1;
132 }
133
134 //! Accessor function for #m_f2.
135 //! @since New in %Cantera 3.0.
136 shared_ptr<Func1> func2_shared() const {
137 return m_f2;
138 }
139
140 //! Return the order of the function, if it makes sense
141 virtual int order() const;
142
143protected:
144 double m_c = 0.0;
145 shared_ptr<Func1> m_f1;
146 shared_ptr<Func1> m_f2;
147};
148
149//! Sum of two functions.
150//! @ingroup func1helper
151shared_ptr<Func1> newSumFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
152
153//! Difference of two functions.
154//! @ingroup func1helper
155shared_ptr<Func1> newDiffFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
156
157//! Product of two functions.
158//! @ingroup func1helper
159shared_ptr<Func1> newProdFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
160
161//! Ratio of two functions.
162//! @ingroup func1helper
163shared_ptr<Func1> newRatioFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
164
165//! Composite of two functions.
166//! @ingroup func1helper
167shared_ptr<Func1> newCompositeFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
168
169//! Product of function and constant.
170//! @ingroup func1helper
171shared_ptr<Func1> newTimesConstFunction(shared_ptr<Func1> f1, double c);
172
173//! Sum of function and constant.
174//! @ingroup func1helper
175shared_ptr<Func1> newPlusConstFunction(shared_ptr<Func1> f1, double c);
176
177//! Implements the @c sin() function.
178/*!
179 * The functor class with type @c "sin" returns @f$ f(x) = \sin(\omega x) @f$,
180 * where the argument @f$ x @f$ is in radians.
181 * @param omega Frequency @f$ \omega @f$ (default=1.0)
182 * @ingroup func1basic
183 */
184class Sin1 : public Func1
185{
186public:
187 Sin1(double omega=1.0) {
188 m_c = omega;
189 }
190
191 //! Constructor uses single parameter (frequency)
192 Sin1(span<const double> params);
193
194 string write(const string& arg) const override;
195
196 string type() const override {
197 return "sin";
198 }
199
200 double eval(double t) const override{
201 return sin(m_c*t);
202 }
203
204 shared_ptr<Func1> derivative() const override;
205};
206
207
208//! Implements the @c cos() function.
209/*!
210 * The functor class with type @c "cos" returns @f$ f(x) = \cos(\omega x) @f$,
211 * where the argument @f$ x @f$ is in radians.
212 * @param omega Frequency @f$ \omega @f$ (default=1.0)
213 * @ingroup func1basic
214 */
215class Cos1 : public Func1
216{
217public:
218 Cos1(double omega=1.0) {
219 m_c = omega;
220 }
221
222 //! Constructor uses single parameter (frequency)
223 Cos1(span<const double> params);
224
225 string write(const string& arg) const override;
226
227 string type() const override {
228 return "cos";
229 }
230
231 double eval(double t) const override {
232 return cos(m_c * t);
233 }
234 shared_ptr<Func1> derivative() const override;
235};
236
237
238//! Implements the @c exp() (exponential) function.
239/*!
240 * The functor class with type @c "exp" returns @f$ f(x) = \exp(a x) @f$.
241 * @param a Factor (default=1.0)
242 * @ingroup func1basic
243 */
244class Exp1 : public Func1
245{
246public:
247 Exp1(double a=1.0) {
248 m_c = a;
249 }
250
251 //! Constructor uses single parameter (exponent factor)
252 Exp1(span<const double> params);
253
254 string write(const string& arg) const override;
255
256 string type() const override {
257 return "exp";
258 }
259
260 double eval(double t) const override {
261 return exp(m_c*t);
262 }
263
264 shared_ptr<Func1> derivative() const override;
265};
266
267
268//! Implements the @c log() (natural logarithm) function.
269/*!
270 * The functor class with type @c "log" returns @f$ f(x) = \ln(a x) @f$.
271 * @param a Factor (default=1.0)
272 * @ingroup func1basic
273 * @since New in %Cantera 3.0
274 */
275class Log1 : public Func1
276{
277public:
278 Log1(double a=1.0) {
279 m_c = a;
280 }
281
282 //! Constructor uses single parameter (factor)
283 Log1(span<const double> params);
284
285 string type() const override {
286 return "log";
287 }
288
289 double eval(double t) const override {
290 return log(m_c * t);
291 }
292
293 shared_ptr<Func1> derivative() const override;
294
295 string write(const string& arg) const override;
296};
297
298//! Implements the @c pow() (power) function.
299/*!
300 * The functor class with type @c "pow" returns @f$ f(x) = x^n @f$.
301 * @param n Exponent
302 * @ingroup func1basic
303 */
304class Pow1 : public Func1
305{
306public:
307 Pow1(double n) {
308 m_c = n;
309 }
310
311 //! Constructor uses single parameter (exponent)
312 Pow1(span<const double> params);
313
314 string write(const string& arg) const override;
315
316 string type() const override {
317 return "pow";
318 }
319
320 double eval(double t) const override {
321 return pow(t, m_c);
322 }
323 shared_ptr<Func1> derivative() const override;
324};
325
326//! Implements a tabulated function.
327/*!
328 * The functor class is based on tabulated arrays @c tvals and @c fvals, where
329 * @c tvals contain independent variables and @c fvals are corresponding function
330 * values. Depending on configuration, the function is either interpolated linearly
331 * between the tabulated points (type @c "tabulated-linear" ; default), or yields
332 * the last tabulated value until a new tabulated time value is reached (type
333 * @c "tabulated-previous" ).
334 * @ingroup func1advanced
335 */
336class Tabulated1 : public Func1
337{
338public:
339 //! Constructor.
340 /*!
341 * @param tvals Time value array
342 * @param fvals Function value array
343 * @param method Interpolation method ('linear' or 'previous')
344 */
345 Tabulated1(span<const double> tvals, span<const double> fvals,
346 const string& method="linear");
347
348 //! Constructor uses @f$ 2 n @f$ parameters in the following order:
349 //! @f$ [t_0, t_1, \dots, t_{n-1}, f_0, f_1, \dots, f_{n-1}] @f$
350 Tabulated1(span<const double> params);
351
352 //! Set the interpolation method
353 //! @param method Evaluation method. If @c "linear" (default), a linear
354 //! interpolation between tabulated values is used; if @c "previous", the
355 //! last tabulated value is held until a new tabulated time value is reached.
356 //! @since New in %Cantera 3.0
357 void setMethod(const string& method);
358
359 bool isIdentical(shared_ptr<Func1> other) const override {
360 return false; // base class check is insufficient
361 }
362
363 string write(const string& arg) const override;
364
365 string type() const override {
366 if (m_isLinear) {
367 return "tabulated-linear";
368 }
369 return "tabulated-previous";
370 }
371
372 double eval(double t) const override;
373 shared_ptr<Func1> derivative() const override;
374private:
375 vector<double> m_tvec; //!< Vector of time values
376 vector<double> m_fvec; //!< Vector of function values
377 bool m_isLinear; //!< Boolean indicating interpolation method
378};
379
380
381//! Implements a constant.
382/*!
383 * The functor class with type @c "constant" returns @f$ f(x) = a @f$.
384 * @param a Constant
385 * @ingroup func1basic
386 */
387class Const1 : public Func1
388{
389public:
390 Const1(double a) {
391 m_c = a;
392 }
393
394 //! Constructor uses single parameter (constant)
395 Const1(span<const double> params);
396
397 string write(const string& arg) const override;
398
399 string type() const override {
400 return "constant";
401 }
402
403 double eval(double t) const override {
404 return m_c;
405 }
406 shared_ptr<Func1> derivative() const override {
407 return make_shared<Const1>(0.0);
408 }
409};
410
411
412/**
413 * Implements the sum of two functions.
414 * The functor class with type @c "sum" returns @f$ f(x) = f_1(x) + f_2(x) @f$.
415 * @param f1 Functor @f$ f_1(x) @f$
416 * @param f2 Functor @f$ f_2(x) @f$
417 * @ingroup func1compound
418 */
419class Sum1 : public Func1
420{
421public:
422 Sum1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
423
424 string type() const override {
425 return "sum";
426 }
427
428 double eval(double t) const override {
429 return m_f1->eval(t) + m_f2->eval(t);
430 }
431
432 shared_ptr<Func1> derivative() const override {
433 return newSumFunction(m_f1->derivative(), m_f2->derivative());
434 }
435
436 int order() const override {
437 return 0;
438 }
439
440 string write(const string& arg) const override;
441};
442
443/**
444 * Implements the difference of two functions.
445 * The functor class with type @c "diff" returns @f$ f(x) = f_1(x) - f_2(x) @f$.
446 * @param f1 Functor @f$ f_1(x) @f$
447 * @param f2 Functor @f$ f_2(x) @f$
448 * @ingroup func1compound
449 */
450class Diff1 : public Func1
451{
452public:
453 Diff1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
454
455 string type() const override {
456 return "diff";
457 }
458
459 double eval(double t) const override {
460 return m_f1->eval(t) - m_f2->eval(t);
461 }
462
463 shared_ptr<Func1> derivative() const override {
464 return newDiffFunction(m_f1->derivative(), m_f2->derivative());
465 }
466
467 int order() const override {
468 return 0;
469 }
470
471 string write(const string& arg) const override;
472};
473
474
475/**
476 * Implements the product of two functions.
477 * The functor class with type @c "product" returns @f$ f(x) = f_1(x) f_2(x) @f$.
478 * @param f1 Functor @f$ f_1(x) @f$
479 * @param f2 Functor @f$ f_2(x) @f$
480 * @ingroup func1compound
481 */
482class Product1 : public Func1
483{
484public:
485 Product1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
486
487 string type() const override {
488 return "product";
489 }
490
491 string write(const string& arg) const override;
492
493 double eval(double t) const override {
494 return m_f1->eval(t) * m_f2->eval(t);
495 }
496
497 shared_ptr<Func1> derivative() const override;
498
499 int order() const override {
500 return 1;
501 }
502};
503
504/**
505 * Implements the product of a function and a constant.
506 * The functor class with type @c "times-constant" returns @f$ f(x) = a f_1(x) @f$.
507 * @param f1 Functor @f$ f_1(x) @f$
508 * @param a Constant @f$ a @f$
509 * @ingroup func1modified
510 */
511class TimesConstant1 : public Func1
512{
513public:
514 TimesConstant1(shared_ptr<Func1> f1, double a) : Func1(f1, a) {}
515
516 string type() const override {
517 return "times-constant";
518 }
519
520 double eval(double t) const override {
521 return m_f1->eval(t) * m_c;
522 }
523
524 shared_ptr<Func1> derivative() const override {
525 return newTimesConstFunction(m_f1->derivative(), m_c);
526 }
527
528 string write(const string& arg) const override;
529
530 int order() const override {
531 return 0;
532 }
533};
534
535/**
536 * Implements the sum of a function and a constant.
537 * The functor class with type @c "plus-constant" returns @f$ f(x) = f_1(x) + a @f$.
538 * @param f1 Functor @f$ f_1(x) @f$
539 * @param a Constant @f$ a @f$
540 * @ingroup func1modified
541 */
542class PlusConstant1 : public Func1
543{
544public:
545 PlusConstant1(shared_ptr<Func1> f1, double a) : Func1(f1, a) {}
546
547 string type() const override {
548 return "plus-constant";
549 }
550
551 double eval(double t) const override {
552 return m_f1->eval(t) + m_c;
553 }
554
555 shared_ptr<Func1> derivative() const override {
556 return m_f1->derivative();
557 }
558
559 string write(const string& arg) const override;
560
561 int order() const override {
562 return 0;
563 }
564};
565
566
567/**
568 * Implements the ratio of two functions.
569 * The functor class with type @c "ratio" returns @f$ f(x) = f_1(x) / f_2(x) @f$.
570 * @param f1 Functor @f$ f_1(x) @f$
571 * @param f2 Functor @f$ f_2(x) @f$
572 * @ingroup func1compound
573 */
574class Ratio1 : public Func1
575{
576public:
577 Ratio1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
578
579 string type() const override {
580 return "ratio";
581 }
582
583 double eval(double t) const override {
584 return m_f1->eval(t) / m_f2->eval(t);
585 }
586
587 shared_ptr<Func1> derivative() const override;
588
589 string write(const string& arg) const override;
590
591 int order() const override {
592 return 1;
593 }
594};
595
596/**
597 * Implements a composite function.
598 * The functor class with type @c "composite" returns @f$ f(x) = f_1\left(f_2(x)\right) @f$.
599 * @param f1 Functor @f$ f_1(x) @f$
600 * @param f2 Functor @f$ f_2(x) @f$
601 * @ingroup func1compound
602 */
603class Composite1 : public Func1
604{
605public:
606 Composite1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
607
608 string type() const override {
609 return "composite";
610 }
611
612 double eval(double t) const override {
613 return m_f1->eval(m_f2->eval(t));
614 }
615
616 shared_ptr<Func1> derivative() const override;
617
618 string write(const string& arg) const override;
619
620 int order() const override {
621 return 2;
622 }
623};
624
625// The functors below are the old-style ones. They still work,
626// but can't do derivatives.
627
628/**
629 * Implements a Gaussian function.
630 * The functor class with type @c "Gaussian" returns
631 * @f[
632 * f(t) = A e^{-[(t - t_0)/\tau]^2}
633 * @f]
634 * where @f$ \tau = \mathrm{fwhm} / (2 \sqrt{\ln 2}) @f$.
635 * @param A peak value
636 * @param t0 offset
637 * @param fwhm full width at half max
638 * @ingroup func1advanced
639 * @since New in %Cantera 3.0.
640 */
641class Gaussian1 : public Func1
642{
643public:
644 Gaussian1(double A, double t0, double fwhm) {
645 m_A = A;
646 m_t0 = t0;
647 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
648 }
649
650 //! Constructor uses 3 parameters in the following order:
651 //! @f$ [A, t_0, \mathrm{fwhm}] @f$
652 Gaussian1(span<const double> params);
653
654 string type() const override {
655 return "Gaussian";
656 }
657
658 bool isIdentical(shared_ptr<Func1> other) const override {
659 return false; // base class check is insufficient
660 }
661
662 double eval(double t) const override {
663 double x = (t - m_t0)/m_tau;
664 return m_A * std::exp(-x*x);
665 }
666
667protected:
668 double m_A, m_t0, m_tau;
669};
670
671
672/**
673 * Implements a polynomial of degree @e n.
674 * The functor class with type @c "polynomial3" returns
675 * @f[
676 * f(x) = a_n x^n + \dots + a_1 x + a_0
677 * @f]
678 * with coefficients provided in the order @f$ [a_n, \dots, a_1, a_0] @f$ (consistent
679 * with MATLAB and NumPy conventions). Note that %Cantera 3.1 reversed the coefficient
680 * order with respect to its earlier definition.
681 * @since Changed in %Cantera 3.1.
682 * @ingroup func1advanced
683 */
684class Poly1 : public Func1
685{
686public:
687 //! Constructor uses @f$ n + 1 @f$ parameters in the following order:
688 //! @f$ [a_n, \dots, a_1, a_0] @f$
689 Poly1(span<const double> params);
690
691 string type() const override {
692 return "polynomial3";
693 }
694
695 bool isIdentical(shared_ptr<Func1> other) const override {
696 return false; // base class check is insufficient
697 }
698
699 double eval(double t) const override {
700 double r = m_cpoly[0];
701 for (size_t n = 1; n < m_cpoly.size(); n++) {
702 r *= t;
703 r += m_cpoly[n];
704 }
705 return r;
706 }
707
708 string write(const string& arg) const override;
709
710protected:
711 vector<double> m_cpoly;
712};
713
714
715/**
716 * Implements a Fourier cosine/sine series.
717 * The functor class with type @c "Fourier" returns
718 * @f[
719 * f(t) = \frac{a_0}{2} + \sum_{n=1}^N a_n \cos (n \omega t) + b_n \sin (n \omega t)
720 * @f]
721 * @ingroup func1advanced
722 */
723class Fourier1 : public Func1
724{
725public:
726 Fourier1(double omega, double a0, span<const double> a, span<const double> b) {
727 if (a.size() != b.size()) {
728 throw CanteraError("Fourier1::Fourier1",
729 "Expected matching sin/cos coefficient lengths, got {} and {}.",
730 a.size(), b.size());
731 }
732 m_omega = omega;
733 m_a0_2 = 0.5*a0;
734 m_ccos.assign(a.begin(), a.end());
735 m_csin.assign(b.begin(), b.end());
736 }
737
738 //! Constructor uses @f$ 2 n + 2 @f$ parameters in the following order:
739 //! @f$ [a_0, a_1, \dots, a_n, \omega, b_1, \dots, b_n] @f$
740 Fourier1(span<const double> params);
741
742 string type() const override {
743 return "Fourier";
744 }
745
746 bool isIdentical(shared_ptr<Func1> other) const override {
747 return false; // base class check is insufficient
748 }
749
750 double eval(double t) const override {
751 size_t n, nn;
752 double sum = m_a0_2;
753 for (n = 0; n < m_ccos.size(); n++) {
754 nn = n + 1;
755 sum += m_ccos[n]*std::cos(m_omega*nn*t)
756 + m_csin[n]*std::sin(m_omega*nn*t);
757 }
758 return sum;
759 }
760
761protected:
762 double m_omega, m_a0_2;
763 vector<double> m_ccos, m_csin;
764};
765
766
767/**
768 * Implements a sum of Arrhenius terms.
769 * The functor class with type @c "Arrhenius" returns
770 * @f[
771 * f(T) = \sum_{n=1}^N A_n T^b_n \exp(-E_n/T)
772 * @f]
773 * @ingroup func1advanced
774 */
775class Arrhenius1 : public Func1
776{
777public:
778 //! Constructor uses @f$ 3 n @f$ parameters in the following order:
779 //! @f$ [A_1, b_1, E_1, A_2, b_2, E_2, \dots, A_n, b_n, E_n] @f$
780 Arrhenius1(span<const double> params);
781
782 string type() const override {
783 return "Arrhenius";
784 }
785
786 bool isIdentical(shared_ptr<Func1> other) const override {
787 return false; // base class check is insufficient
788 }
789
790 double eval(double t) const override {
791 double sum = 0.0;
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);
794 }
795 return sum;
796 }
797
798protected:
799 vector<double> m_A, m_b, m_E;
800};
801
802/**
803 * Implements a periodic function.
804 * Takes any function and makes it periodic with period @f$ T @f$.
805 * @param f Functor to be made periodic
806 * @param T Period
807 * @ingroup func1modified
808 */
809class Periodic1 : public Func1
810{
811public:
812 Periodic1(shared_ptr<Func1> f, double A) : Func1(f, A) {}
813
814 string type() const override {
815 return "periodic";
816 }
817
818 double eval(double t) const override {
819 int np = int(t/m_c);
820 double time = t - np*m_c;
821 return m_f1->eval(time);
822 }
823};
824
825}
826
827#endif
Implements a sum of Arrhenius terms.
Definition Func1.h:776
double eval(double t) const override
Evaluate the function.
Definition Func1.h:790
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:782
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
Definition Func1.h:786
Base class for exceptions thrown by Cantera classes.
Implements a composite function.
Definition Func1.h:604
double eval(double t) const override
Evaluate the function.
Definition Func1.h:612
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:506
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:608
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:620
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:500
Implements a constant.
Definition Func1.h:388
double eval(double t) const override
Evaluate the function.
Definition Func1.h:403
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.h:406
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:399
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:441
Implements the cos() function.
Definition Func1.h:216
double eval(double t) const override
Evaluate the function.
Definition Func1.h:231
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:111
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:227
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:117
Implements the difference of two functions.
Definition Func1.h:451
double eval(double t) const override
Evaluate the function.
Definition Func1.h:459
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.h:463
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:455
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:467
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:489
Implements the exp() (exponential) function.
Definition Func1.h:245
double eval(double t) const override
Evaluate the function.
Definition Func1.h:260
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:137
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:256
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:146
Implements a Fourier cosine/sine series.
Definition Func1.h:724
double eval(double t) const override
Evaluate the function.
Definition Func1.h:750
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:742
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
Definition Func1.h:746
Base class for 'functor' classes that evaluate a function of one variable.
Definition Func1.h:75
string typeName() const
Returns a string with the class name of the functor.
Definition Func1.cpp:16
virtual shared_ptr< Func1 > derivative() const
Creates a derivative to the current function.
Definition Func1.cpp:33
virtual string type() const
Returns a string describing the type of the function.
Definition Func1.h:90
virtual double eval(double t) const
Evaluate the function.
Definition Func1.cpp:28
shared_ptr< Func1 > func1_shared() const
Accessor function for m_f1.
Definition Func1.h:130
virtual string write(const string &arg) const
Write LaTeX string describing function.
Definition Func1.cpp:416
double operator()(double t) const
Calls method eval to evaluate the function.
Definition Func1.cpp:22
virtual bool isIdentical(shared_ptr< Func1 > other) const
Routine to determine if two functions are the same.
Definition Func1.cpp:39
virtual int order() const
Return the order of the function, if it makes sense.
Definition Func1.cpp:69
shared_ptr< Func1 > func2_shared() const
Accessor function for m_f2.
Definition Func1.h:136
double c() const
Accessor function for the stored constant m_c.
Definition Func1.cpp:64
Implements a Gaussian function.
Definition Func1.h:642
double eval(double t) const override
Evaluate the function.
Definition Func1.h:662
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:654
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
Definition Func1.h:658
Implements the log() (natural logarithm) function.
Definition Func1.h:276
double eval(double t) const override
Evaluate the function.
Definition Func1.h:289
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:164
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:285
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:173
Implements a periodic function.
Definition Func1.h:810
double eval(double t) const override
Evaluate the function.
Definition Func1.h:818
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:814
Implements the sum of a function and a constant.
Definition Func1.h:543
double eval(double t) const override
Evaluate the function.
Definition Func1.h:551
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.h:555
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:547
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:561
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:532
Implements a polynomial of degree n.
Definition Func1.h:685
double eval(double t) const override
Evaluate the function.
Definition Func1.h:699
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:691
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
Definition Func1.h:695
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:226
Implements the pow() (power) function.
Definition Func1.h:305
double eval(double t) const override
Evaluate the function.
Definition Func1.h:320
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:192
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:316
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:421
Implements the product of two functions.
Definition Func1.h:483
double eval(double t) const override
Evaluate the function.
Definition Func1.h:493
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:472
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:487
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:499
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:459
Implements the ratio of two functions.
Definition Func1.h:575
double eval(double t) const override
Evaluate the function.
Definition Func1.h:583
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:451
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:579
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:591
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:446
Implements the sin() function.
Definition Func1.h:185
double eval(double t) const override
Evaluate the function.
Definition Func1.h:200
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:94
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:196
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:85
Implements the sum of two functions.
Definition Func1.h:420
double eval(double t) const override
Evaluate the function.
Definition Func1.h:428
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.h:432
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:424
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:436
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:478
Implements a tabulated function.
Definition Func1.h:337
double eval(double t) const override
Evaluate the function.
Definition Func1.cpp:365
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:388
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:365
bool isIdentical(shared_ptr< Func1 > other) const override
Routine to determine if two functions are the same.
Definition Func1.h:359
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:436
void setMethod(const string &method)
Set the interpolation method.
Definition Func1.cpp:353
vector< double > m_tvec
Vector of time values.
Definition Func1.h:375
bool m_isLinear
Boolean indicating interpolation method.
Definition Func1.h:377
vector< double > m_fvec
Vector of function values.
Definition Func1.h:376
Implements the product of a function and a constant.
Definition Func1.h:512
double eval(double t) const override
Evaluate the function.
Definition Func1.h:520
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.h:524
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:516
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:530
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:513
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.
Definition Func1.cpp:733
shared_ptr< Func1 > newProdFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Product of two functions.
Definition Func1.cpp:654
shared_ptr< Func1 > newDiffFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Difference of two functions.
Definition Func1.cpp:630
shared_ptr< Func1 > newTimesConstFunction(shared_ptr< Func1 > f, double c)
Product of function and constant.
Definition Func1.cpp:753
shared_ptr< Func1 > newSumFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Sum of two functions.
Definition Func1.cpp:603
shared_ptr< Func1 > newRatioFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Ratio of two functions.
Definition Func1.cpp:707
shared_ptr< Func1 > newPlusConstFunction(shared_ptr< Func1 > f, double c)
Sum of function and constant.
Definition Func1.cpp:767
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595