| Cantera 3.0.0

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
11#include "cantera/base/ct_defs.h"
12#include "cantera/base/ctexceptions.h"
13
14#include <iostream>
15
16 namespace Cantera
17{
18
19// Magic numbers are only used by legacy C API methods
20// Example: traditional MATLAB toolbox
21 const int FourierFuncType = 1;
22 const int PolyFuncType = 2;
23 const int ArrheniusFuncType = 3;
24 const int GaussianFuncType = 4;
25 const int SumFuncType = 20;
26 const int DiffFuncType = 25;
27 const int ProdFuncType = 30;
28 const int RatioFuncType = 40;
29 const int PeriodicFuncType = 50;
30 const int CompositeFuncType = 60;
31 const int TimesConstantFuncType = 70;
32 const int PlusConstantFuncType = 80;
33 const int SinFuncType = 100;
34 const int CosFuncType = 102;
35 const int ExpFuncType = 104;
36 const int PowFuncType = 106;
37 const int ConstFuncType = 110;
38 const int TabulatedFuncType = 120;
39
40 class TimesConstant1;
41
42//! @defgroup func1 Functor Objects
43//! Functors implement functions of a single variable @f$ f(x) @f$.
44//! Functor objects can be combined to form compound expressions, which allows for
45//! the implementation of generic mathematical expressions.
46//! @ingroup numerics
47
48//! @defgroup func1simple Simple Functors
49//! Simple functors implement standard mathematical expressions with a single
50//! parameter.
51//! The following simple functor types are implemented:
52//! - @c "sin" (class Sin1), @c "cos" (class Cos1),
53//! - @c "exp" (class Exp1), @c "log" (class Log1),
54//! - @c "pow" (class Pow1),
55//! - @c "constant" (class Const1).
56//! @ingroup func1
57
58//! @defgroup func1advanced Advanced Functors
59//! Advanced functors implement expressions that require multiple parameters.
60//! The following advanced functor types are implemented:
61//! - @c "tabulated-linear" and @c "tabulated-previous" (class Tabulated1),
62//! - @c "polynomial" (class Poly1),
63//! - @c "Fourier" (class Fourier1),
64//! - @c "Gaussian" (class Gaussian1),
65//! - @c "Arrhenius" (class Arrhenius1).
66//! @ingroup func1
67
68//! @defgroup func1compound Compound Functors
69//! Compound functors implement expressions that are composed of other functors.
70//! The following compound functor types are implemented:
71//! - @c "sum" (class Sum1),
72//! - @c "diff" (class Diff1),
73//! - @c "product" (class Product1),
74//! - @c "ratio" (class Ratio1),
75//! - @c "composite" (class Composite1),
76//! @ingroup func1
77
78//! @defgroup func1modified Modified Functors
79//! Modified functors implement expressions that involve one functor and
80//! a single parameter.
81//! The following modified functor types are implemented:
82//! - @c "times-constant" (class TimesConstant1),
83//! - @c "plus-constant" (class PlusConstant1),
84//! - @c "periodic" (class Periodic1).
85//! @ingroup func1
86
87//! @defgroup func1helper Helper Functions
88//! Helper functions detect simplifications that can be made to compound expressions.
89//! @ingroup func1
90
91/**
92 * Base class for 'functor' classes that evaluate a function of one variable.
93 * @ingroup func1
94 */
95 class Func1
96{
97 public:
98 Func1() = default;
99
100 Func1(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
101 : m_f1_shared(f1), m_f2_shared(f2)
102 {
103 m_f1 = f1.get();
104 m_f2 = f2.get();
105 }
106
107 Func1(shared_ptr<Func1> f1, double A) : m_c(A), m_f1_shared(f1) {
108 m_f1 = f1.get();
109 }
110
111 virtual ~Func1() = default;
112
113 //! @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
114 Func1(const Func1& right);
115
116 //! @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
117 Func1& operator=(const Func1& right);
118
119 //! Duplicate the current function.
120 /*!
121 * This duplicates the current function, returning a reference to the newly
122 * created function.
123 * @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
124 */
125 virtual Func1& duplicate() const;
126
127 //! @deprecated To be removed after %Cantera 3.0. Replaced by type.
128 virtual int ID() const;
129
130 //! Returns a string describing the type of the function
131 //! @since New in %Cantera 3.0.
132 virtual string type() const {
133 return "functor";
134 }
135
136 //! Returns a string with the class name of the functor
137 //! @since New in %Cantera 3.0.
138 string typeName() const;
139
140 //! Calls method eval to evaluate the function
141 double operator()(double t) const;
142
143 //! Evaluate the function.
144 virtual double eval(double t) const;
145
146 //! Creates a derivative to the current function
147 /*!
148 * This will create a new derivative function and return a reference to the
149 * function.
150 * @deprecated To be changed after %Cantera 3.0; for new behavior, see derivative3.
151 */
152 virtual Func1& derivative() const;
153
154 //! Creates a derivative to the current function
155 /*!
156 * This will create a new derivative function
157 * @return shared pointer to new derivative function.
158 * @since New in %Cantera 3.0.
159 */
160 virtual shared_ptr<Func1> derivative3() const;
161
162 //! Routine to determine if two functions are the same.
163 /*!
164 * Two functions are the same if they are the same function. This means
165 * that the ID and stored constant is the same. This means that the m_f1
166 * and m_f2 are identical if they are non-null.
167 */
168 bool isIdentical(Func1& other) const;
169
170 virtual double isProportional(TimesConstant1& other);
171 virtual double isProportional(Func1& other);
172
173 //! Write LaTeX string describing function.
174 virtual string write(const string& arg) const;
175
176 //! Accessor function for the stored constant
177 double c() const;
178
179 //! Function to set the stored constant
180 //! @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
181 void setC(double c);
182
183 //! accessor function for m_f1
184 //! @deprecated To be removed after %Cantera 3.0; replaced by func1_shared().
185 Func1& func1() const;
186
187 //! Accessor function for m_f1_shared
188 //! @since New in %Cantera 3.0.
189 shared_ptr<Func1> func1_shared() const {
190 return m_f1_shared;
191 }
192
193 //! accessor function for m_f2
194 //! @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
195 Func1& func2() const;
196
197 //! Accessor function for m_f2_shared
198 //! @since New in %Cantera 3.0.
199 shared_ptr<Func1> func2_shared() const {
200 return m_f2_shared;
201 }
202
203 //! Return the order of the function, if it makes sense
204 virtual int order() const;
205
206 //! @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
207 Func1& func1_dup() const;
208
209 //! @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
210 Func1& func2_dup() const;
211
212 //! @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
213 Func1* parent() const;
214
215 //! @deprecated To be removed after %Cantera 3.0. Only used by deprecated methods.
216 void setParent(Func1* p);
217
218 protected:
219 double m_c = 0.0;
220 Func1* m_f1 = nullptr;
221 Func1* m_f2 = nullptr;
222 Func1* m_parent = nullptr;
223
224 shared_ptr<Func1> m_f1_shared;
225 shared_ptr<Func1> m_f2_shared;
226};
227
228
229// all functions using references are deprecated
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);
237
238
239//! Sum of two functions.
240//! @ingroup func1helper
241 shared_ptr<Func1> newSumFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
242
243//! Difference of two functions.
244//! @ingroup func1helper
245 shared_ptr<Func1> newDiffFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
246
247//! Product of two functions.
248//! @ingroup func1helper
249 shared_ptr<Func1> newProdFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
250
251//! Ratio of two functions.
252//! @ingroup func1helper
253 shared_ptr<Func1> newRatioFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
254
255//! Composite of two functions.
256//! @ingroup func1helper
257 shared_ptr<Func1> newCompositeFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2);
258
259//! Product of function and constant.
260//! @ingroup func1helper
261 shared_ptr<Func1> newTimesConstFunction(shared_ptr<Func1> f1, double c);
262
263//! Sum of function and constant.
264//! @ingroup func1helper
265 shared_ptr<Func1> newPlusConstFunction(shared_ptr<Func1> f1, double c);
266
267//! Implements the @c sin() function.
268/*!
269 * The functor class with type @c "sin" returns @f$ f(x) = \cos(\omega x) @f$,
270 * where the argument @f$ x @f$ is in radians.
271 * @param omega Frequency @f$ \omega @f$ (default=1.0)
272 * @ingroup func1simple
273 */
274 class Sin1 : public Func1
275{
276 public:
277 Sin1(double omega=1.0) {
278 m_c = omega;
279 }
280
281 //! Constructor uses single parameter (frequency)
282 Sin1(const vector<double>& params);
283
284 Sin1(const Sin1& b) :
285 Func1(b) {
286 }
287
288 Sin1& operator=(const Sin1& right) {
289 if (&right == this) {
290 return *this;
291 }
292 Func1::operator=(right);
293 return *this;
294 }
295
296 string write(const string& arg) const override;
297
298 int ID() const override {
299 return SinFuncType;
300 }
301
302 string type() const override {
303 return "sin";
304 }
305
306 double eval(double t) const override{
307 return sin(m_c*t);
308 }
309
310 Func1& duplicate() const override;
311 Func1& derivative() const override;
312 shared_ptr<Func1> derivative3() const override;
313};
314
315
316//! Implements the @c cos() function.
317/*!
318 * The functor class with type @c "cos" returns @f$ f(x) = \cos(\omega x) @f$,
319 * where the argument @f$ x @f$ is in radians.
320 * @param omega Frequency @f$ \omega @f$ (default=1.0)
321 * @ingroup func1simple
322 */
323 class Cos1 : public Func1
324{
325 public:
326 Cos1(double omega=1.0) {
327 m_c = omega;
328 }
329
330 //! Constructor uses single parameter (frequency)
331 Cos1(const vector<double>& params);
332
333 Cos1(const Cos1& b) :
334 Func1(b) {
335 }
336
337 Cos1& operator=(const Cos1& right) {
338 if (&right == this) {
339 return *this;
340 }
341 Func1::operator=(right);
342 return *this;
343 }
344
345 Func1& duplicate() const override;
346 string write(const string& arg) const override;
347 int ID() const override {
348 return CosFuncType;
349 }
350 string type() const override {
351 return "cos";
352 }
353
354 double eval(double t) const override {
355 return cos(m_c * t);
356 }
357 Func1& derivative() const override;
358 shared_ptr<Func1> derivative3() const override;
359};
360
361
362//! Implements the @c exp() (exponential) function.
363/*!
364 * The functor class with type @c "exp" returns @f$ f(x) = \exp(a x) @f$.
365 * @param a Factor (default=1.0)
366 * @ingroup func1simple
367 */
368 class Exp1 : public Func1
369{
370 public:
371 Exp1(double a=1.0) {
372 m_c = a;
373 }
374
375 //! Constructor uses single parameter (exponent factor)
376 Exp1(const vector<double>& params);
377
378 Exp1(const Exp1& b) :
379 Func1(b) {
380 }
381 Exp1& operator=(const Exp1& right) {
382 if (&right == this) {
383 return *this;
384 }
385 Func1::operator=(right);
386 return *this;
387 }
388 string write(const string& arg) const override;
389 int ID() const override {
390 return ExpFuncType;
391 }
392 string type() const override {
393 return "exp";
394 }
395
396 double eval(double t) const override {
397 return exp(m_c*t);
398 }
399
400 Func1& duplicate() const override;
401 Func1& derivative() const override;
402 shared_ptr<Func1> derivative3() const override;
403};
404
405
406//! Implements the @c log() (natural logarithm) function.
407/*!
408 * The functor class with type @c "log" returns @f$ f(x) = \ln(a x) @f$.
409 * @param a Factor (default=1.0)
410 * @ingroup func1simple
411 * @since New in %Cantera 3.0
412 */
413 class Log1 : public Func1
414{
415 public:
416 Log1(double a=1.0) {
417 m_c = a;
418 }
419
420 //! Constructor uses single parameter (factor)
421 Log1(const vector<double>& params);
422
423 string type() const override {
424 return "log";
425 }
426
427 double eval(double t) const override {
428 return log(m_c * t);
429 }
430
431 shared_ptr<Func1> derivative3() const override;
432
433 string write(const string& arg) const override;
434};
435
436//! Implements the @c pow() (power) function.
437/*!
438 * The functor class with type @c "pow" returns @f$ f(x) = x^n @f$.
439 * @param n Exponent
440 * @ingroup func1simple
441 */
442 class Pow1 : public Func1
443{
444 public:
445 Pow1(double n) {
446 m_c = n;
447 }
448
449 //! Constructor uses single parameter (exponent)
450 Pow1(const vector<double>& params);
451
452 Pow1(const Pow1& b) :
453 Func1(b) {
454 }
455 Pow1& operator=(const Pow1& right) {
456 if (&right == this) {
457 return *this;
458 }
459 Func1::operator=(right);
460 return *this;
461 }
462 string write(const string& arg) const override;
463 int ID() const override {
464 return PowFuncType;
465 }
466 string type() const override {
467 return "pow";
468 }
469
470 double eval(double t) const override {
471 return pow(t, m_c);
472 }
473 Func1& duplicate() const override;
474 Func1& derivative() const override;
475 shared_ptr<Func1> derivative3() const override;
476};
477
478//! Implements a tabulated function.
479/*!
480 * The functor class is based on tabulated arrays @c tvals and @c fvals, where
481 * @c tvals contain independent variables and @c fvals are corresponding function
482 * values. Depending on configuration, the function is either interpolated linearly
483 * between the tabulated points (type @c "tabulated-linear" ; default), or yields
484 * the last tabulated value until a new tabulated time value is reached (type
485 * @c "tabulated-previous" ).
486 * @ingroup func1advanced
487 */
488 class Tabulated1 : public Func1
489{
490 public:
491 //! Constructor.
492 /*!
493 * @param n Size of tabulated value arrays
494 * @param tvals Pointer to time value array
495 * @param fvals Pointer to function value array
496 * @param method Interpolation method ('linear' or 'previous')
497 */
498 Tabulated1(size_t n, const double* tvals, const double* fvals,
499 const string& method="linear");
500
501 //! Constructor uses @f$ 2 n @f$ parameters in the following order:
502 //! @f$ [t_0, t_1, \dots, t_{n-1}, f_0, f_1, \dots, f_{n-1}] @f$
503 Tabulated1(const vector<double>& params);
504
505 //! Set the interpolation method
506 //! @param method Evaluation method. If @c "linear" (default), a linear
507 //! interpolation between tabulated values is used; if @c "previous", the
508 //! last tabulated value is held until a new tabulated time value is reached.
509 //! @since New in %Cantera 3.0
510 void setMethod(const string& method);
511
512 string write(const string& arg) const override;
513 int ID() const override {
514 return TabulatedFuncType;
515 }
516 string type() const override {
517 if (m_isLinear) {
518 return "tabulated-linear";
519 }
520 return "tabulated-previous";
521 }
522
523 double eval(double t) const override;
524 Func1& duplicate() const override;
525 Func1& derivative() const override;
526 shared_ptr<Func1> derivative3() const override;
527 private:
528 vector<double> m_tvec; //!< Vector of time values
529 vector<double> m_fvec; //!< Vector of function values
530 bool m_isLinear; //!< Boolean indicating interpolation method
531};
532
533
534//! Implements a constant.
535/*!
536 * The functor class with type @c "constant" returns @f$ f(x) = a @f$.
537 * @param a Constant
538 * @ingroup func1simple
539 */
540 class Const1 : public Func1
541{
542 public:
543 Const1(double a) {
544 m_c = a;
545 }
546
547 //! Constructor uses single parameter (constant)
548 Const1(const vector<double>& params);
549
550 Const1(const Const1& b) :
551 Func1(b) {
552 }
553
554 Const1& operator=(const Const1& right) {
555 if (&right == this) {
556 return *this;
557 }
558 Func1::operator=(right);
559 return *this;
560 }
561
562 string write(const string& arg) const override;
563 int ID() const override {
564 return ConstFuncType;
565 }
566 string type() const override {
567 return "constant";
568 }
569
570 double eval(double t) const override {
571 return m_c;
572 }
573 Func1& duplicate() const override;
574 Func1& derivative() const override;
575 shared_ptr<Func1> derivative3() const override {
576 return make_shared<Const1>(0.0);
577 }
578};
579
580
581/**
582 * Implements the sum of two functions.
583 * The functor class with type @c "sum" returns @f$ f(x) = f_1(x) + f_2(x) @f$.
584 * @param f1 Functor @f$ f_1(x) @f$
585 * @param f2 Functor @f$ f_2(x) @f$
586 * @ingroup func1compound
587 */
588 class Sum1 : public Func1
589{
590 public:
591 Sum1(Func1& f1, Func1& f2) {
592 m_f1 = &f1;
593 m_f2 = &f2;
594 m_f1->setParent(this);
595 m_f2->setParent(this);
596 }
597
598 Sum1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
599
600 ~Sum1() override {
601 if (!m_f1_shared) {
602 delete m_f1;
603 }
604 if (!m_f2_shared) {
605 delete m_f2;
606 }
607 }
608
609 Sum1(const Sum1& b) :
610 Func1(b) {
611 *this = Sum1::operator=(b);
612 }
613
614 Sum1& operator=(const Sum1& right) {
615 if (&right == this) {
616 return *this;
617 }
618 Func1::operator=(right);
619 m_f1 = &m_f1->duplicate();
620 m_f2 = &m_f2->duplicate();
621 m_f1->setParent(this);
622 m_f2->setParent(this);
623 m_parent = 0;
624 return *this;
625 }
626
627 int ID() const override {
628 return SumFuncType;
629 }
630 string type() const override {
631 return "sum";
632 }
633
634 double eval(double t) const override {
635 return m_f1->eval(t) + m_f2->eval(t);
636 }
637
638 Func1& duplicate() const override;
639 Func1& derivative() const override;
640
641 shared_ptr<Func1> derivative3() const override {
642 return newSumFunction(m_f1_shared->derivative3(), m_f2_shared->derivative3());
643 }
644
645 int order() const override {
646 return 0;
647 }
648
649 string write(const string& arg) const override;
650};
651
652/**
653 * Implements the difference of two functions.
654 * The functor class with type @c "diff" returns @f$ f(x) = f_1(x) - f_2(x) @f$.
655 * @param f1 Functor @f$ f_1(x) @f$
656 * @param f2 Functor @f$ f_2(x) @f$
657 * @ingroup func1compound
658 */
659 class Diff1 : public Func1
660{
661 public:
662 Diff1(Func1& f1, Func1& f2) {
663 m_f1 = &f1;
664 m_f2 = &f2;
665 m_f1->setParent(this);
666 m_f2->setParent(this);
667 }
668
669 Diff1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
670
671 ~Diff1() override {
672 if (!m_f1_shared) {
673 delete m_f1;
674 }
675 if (!m_f2_shared) {
676 delete m_f2;
677 }
678 }
679
680 Diff1(const Diff1& b) :
681 Func1(b) {
682 *this = Diff1::operator=(b);
683 }
684
685 Diff1& operator=(const Diff1& right) {
686 if (&right == this) {
687 return *this;
688 }
689 Func1::operator=(right);
690 m_f1 = &m_f1->duplicate();
691 m_f2 = &m_f2->duplicate();
692 m_f1->setParent(this);
693 m_f2->setParent(this);
694 m_parent = 0;
695 return *this;
696 }
697
698 int ID() const override {
699 return DiffFuncType;
700 }
701
702 string type() const override {
703 return "diff";
704 }
705
706 double eval(double t) const override {
707 return m_f1->eval(t) - m_f2->eval(t);
708 }
709
710 Func1& duplicate() const override;
711 Func1& derivative() const override;
712
713 shared_ptr<Func1> derivative3() const override {
714 return newDiffFunction(m_f1_shared->derivative3(), m_f2_shared->derivative3());
715 }
716
717 int order() const override {
718 return 0;
719 }
720
721 string write(const string& arg) const override;
722};
723
724
725/**
726 * Implements the product of two functions.
727 * The functor class with type @c "product" returns @f$ f(x) = f_1(x) f_2(x) @f$.
728 * @param f1 Functor @f$ f_1(x) @f$
729 * @param f2 Functor @f$ f_2(x) @f$
730 * @ingroup func1compound
731 */
732 class Product1 : public Func1
733{
734 public:
735 Product1(Func1& f1, Func1& f2) {
736 m_f1 = &f1;
737 m_f2 = &f2;
738 m_f1->setParent(this);
739 m_f2->setParent(this);
740 }
741
742 Product1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
743
744 ~Product1() override {
745 if (!m_f1_shared) {
746 delete m_f1;
747 }
748 if (!m_f2_shared) {
749 delete m_f2;
750 }
751 }
752
753 Product1(const Product1& b) :
754 Func1(b) {
755 *this = Product1::operator=(b);
756 }
757
758 Product1& operator=(const Product1& right) {
759 if (&right == this) {
760 return *this;
761 }
762 Func1::operator=(right);
763 m_f1 = &m_f1->duplicate();
764 m_f2 = &m_f2->duplicate();
765 m_f1->setParent(this);
766 m_f2->setParent(this);
767 m_parent = 0;
768 return *this;
769 }
770
771 int ID() const override {
772 return ProdFuncType;
773 }
774
775 string type() const override {
776 return "product";
777 }
778
779 string write(const string& arg) const override;
780
781 double eval(double t) const override {
782 return m_f1->eval(t) * m_f2->eval(t);
783 }
784
785 Func1& duplicate() const override;
786 Func1& derivative() const override;
787
788 shared_ptr<Func1> derivative3() const override;
789
790 int order() const override {
791 return 1;
792 }
793};
794
795/**
796 * Implements the product of a function and a constant.
797 * The functor class with type @c "times-constant" returns @f$ f(x) = a f_1(x) @f$.
798 * @param f1 Functor @f$ f_1(x) @f$
799 * @param a Constant @f$ a @f$
800 * @ingroup func1modified
801 */
802 class TimesConstant1 : public Func1
803{
804 public:
805 TimesConstant1(Func1& f1, double a) {
806 m_f1 = &f1;
807 m_c = a;
808 m_f1->setParent(this);
809 }
810
811 TimesConstant1(shared_ptr<Func1> f1, double a) : Func1(f1, a) {}
812
813 ~TimesConstant1() override {
814 if (!m_f1_shared) {
815 delete m_f1;
816 }
817 }
818
819 TimesConstant1(const TimesConstant1& b) :
820 Func1(b) {
821 *this = TimesConstant1::operator=(b);
822 }
823
824 TimesConstant1& operator=(const TimesConstant1& right) {
825 if (&right == this) {
826 return *this;
827 }
828 Func1::operator=(right);
829 m_f1 = &m_f1->duplicate();
830 m_f1->setParent(this);
831 m_parent = 0;
832 return *this;
833 }
834 int ID() const override {
835 return TimesConstantFuncType;
836 }
837 string type() const override {
838 return "times-constant";
839 }
840
841 double isProportional(TimesConstant1& other) override {
842 if (func1().isIdentical(other.func1())) {
843 return (other.c()/c());
844 } else {
845 return 0.0;
846 }
847 }
848
849 double isProportional(Func1& other) override {
850 if (func1().isIdentical(other)) {
851 return 1.0/c();
852 } else {
853 return 0.0;
854 }
855 }
856
857 double eval(double t) const override {
858 return m_f1->eval(t) * m_c;
859 }
860
861 Func1& duplicate() const override;
862 Func1& derivative() const override;
863
864 shared_ptr<Func1> derivative3() const override {
865 return newTimesConstFunction(m_f1_shared->derivative3(), m_c);
866 }
867
868 string write(const string& arg) const override;
869
870 int order() const override {
871 return 0;
872 }
873};
874
875/**
876 * Implements the sum of a function and a constant.
877 * The functor class with type @c "plus-constant" returns @f$ f(x) = f_1(x) + a @f$.
878 * @param f1 Functor @f$ f_1(x) @f$
879 * @param a Constant @f$ a @f$
880 * @ingroup func1modified
881 */
882 class PlusConstant1 : public Func1
883{
884 public:
885 PlusConstant1(Func1& f1, double a) {
886 m_f1 = &f1;
887 m_c = a;
888 m_f1->setParent(this);
889 }
890
891 PlusConstant1(shared_ptr<Func1> f1, double a) : Func1(f1, a) {}
892
893 ~PlusConstant1() override {
894 if (!m_f1_shared) {
895 delete m_f1;
896 }
897 }
898
899 PlusConstant1(const PlusConstant1& b) :
900 Func1(b) {
901 *this = PlusConstant1::operator=(b);
902 }
903
904 PlusConstant1& operator=(const PlusConstant1& right) {
905 if (&right == this) {
906 return *this;
907 }
908 Func1::operator=(right);
909 m_f1 = &m_f1->duplicate();
910 m_f1->setParent(this);
911 m_parent = 0;
912 return *this;
913 }
914
915 int ID() const override {
916 return PlusConstantFuncType;
917 }
918 string type() const override {
919 return "plus-constant";
920 }
921
922 double eval(double t) const override {
923 return m_f1->eval(t) + m_c;
924 }
925
926 Func1& duplicate() const override;
927 Func1& derivative() const override;
928
929 shared_ptr<Func1> derivative3() const override {
930 return m_f1_shared->derivative3();
931 }
932
933 string write(const string& arg) const override;
934
935 int order() const override {
936 return 0;
937 }
938};
939
940
941/**
942 * Implements the ratio of two functions.
943 * The functor class with type @c "ratio" returns @f$ f(x) = f_1(x) / f_2(x) @f$.
944 * @param f1 Functor @f$ f_1(x) @f$
945 * @param f2 Functor @f$ f_2(x) @f$
946 * @ingroup func1compound
947 */
948 class Ratio1 : public Func1
949{
950 public:
951 Ratio1(Func1& f1, Func1& f2) {
952 m_f1 = &f1;
953 m_f2 = &f2;
954 m_f1->setParent(this);
955 m_f2->setParent(this);
956 }
957
958 Ratio1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
959
960 ~Ratio1() override {
961 if (!m_f1_shared) {
962 delete m_f1;
963 }
964 if (!m_f2_shared) {
965 delete m_f2;
966 }
967 }
968
969 Ratio1(const Ratio1& b) :
970 Func1(b) {
971 *this = Ratio1::operator=(b);
972 }
973
974 Ratio1& operator=(const Ratio1& right) {
975 if (&right == this) {
976 return *this;
977 }
978 Func1::operator=(right);
979 m_f1 = &m_f1->duplicate();
980 m_f2 = &m_f2->duplicate();
981 m_f1->setParent(this);
982 m_f2->setParent(this);
983 m_parent = 0;
984 return *this;
985 }
986
987 int ID() const override {
988 return RatioFuncType;
989 }
990 string type() const override {
991 return "ratio";
992 }
993
994 double eval(double t) const override {
995 return m_f1->eval(t) / m_f2->eval(t);
996 }
997
998 Func1& duplicate() const override;
999 Func1& derivative() const override;
1000
1001 shared_ptr<Func1> derivative3() const override;
1002
1003 string write(const string& arg) const override;
1004
1005 int order() const override {
1006 return 1;
1007 }
1008};
1009
1010/**
1011 * Implements a composite function.
1012 * The functor class with type @c "composite" returns @f$ f(x) = f_1\left(f_2(x)\right) @f$.
1013 * @param f1 Functor @f$ f_1(x) @f$
1014 * @param f2 Functor @f$ f_2(x) @f$
1015 * @ingroup func1compound
1016 */
1017 class Composite1 : public Func1
1018{
1019 public:
1020 Composite1(Func1& f1, Func1& f2) {
1021 m_f1 = &f1;
1022 m_f2 = &f2;
1023 m_f1->setParent(this);
1024 m_f2->setParent(this);
1025 }
1026
1027 Composite1(shared_ptr<Func1> f1, shared_ptr<Func1> f2) : Func1(f1, f2) {}
1028
1029 ~Composite1() override {
1030 if (!m_f1_shared) {
1031 delete m_f1;
1032 }
1033 if (!m_f2_shared) {
1034 delete m_f2;
1035 }
1036 }
1037
1038 Composite1(const Composite1& b) :
1039 Func1(b) {
1040 *this = Composite1::operator=(b);
1041 }
1042
1043 Composite1& operator=(const Composite1& right) {
1044 if (&right == this) {
1045 return *this;
1046 }
1047 Func1::operator=(right);
1048 m_f1 = &m_f1->duplicate();
1049 m_f2 = &m_f2->duplicate();
1050 m_f1->setParent(this);
1051 m_f2->setParent(this);
1052 m_parent = 0;
1053 return *this;
1054 }
1055
1056 int ID() const override {
1057 return CompositeFuncType;
1058 }
1059 string type() const override {
1060 return "composite";
1061 }
1062
1063 double eval(double t) const override {
1064 return m_f1->eval(m_f2->eval(t));
1065 }
1066
1067 Func1& duplicate() const override;
1068 Func1& derivative() const override;
1069
1070 shared_ptr<Func1> derivative3() const override;
1071
1072 string write(const string& arg) const override;
1073
1074 int order() const override {
1075 return 2;
1076 }
1077};
1078
1079// The functors below are the old-style ones. They still work,
1080// but can't do derivatives.
1081
1082/**
1083 * Implements a Gaussian function.
1084 * The functor class with type @c "Gaussian" returns
1085 * @f[
1086 * f(t) = A e^{-[(t - t_0)/\tau]^2}
1087 * @f]
1088 * where @f$ \tau = \mathrm{fwhm} / (2 \sqrt{\ln 2}) @f$.
1089 * @param A peak value
1090 * @param t0 offset
1091 * @param fwhm full width at half max
1092 * @ingroup func1advanced
1093 * @since New in %Cantera 3.0.
1094 */
1095 class Gaussian1 : public Func1
1096{
1097 public:
1098 Gaussian1(double A, double t0, double fwhm) {
1099 m_A = A;
1100 m_t0 = t0;
1101 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
1102 }
1103
1104 //! Constructor uses 3 parameters in the following order:
1105 //! @f$ [A, t_0, \mathrm{fwhm}] @f$
1106 Gaussian1(const vector<double>& params);
1107
1108 Gaussian1(const Gaussian1& b) :
1109 Func1(b) {
1110 *this = Gaussian1::operator=(b);
1111 }
1112
1113 Gaussian1& operator=(const Gaussian1& right) {
1114 if (&right == this) {
1115 return *this;
1116 }
1117 Func1::operator=(right);
1118 m_A = right.m_A;
1119 m_t0 = right.m_t0;
1120 m_tau = right.m_tau;
1121 m_parent = 0;
1122 return *this;
1123 }
1124
1125 string type() const override {
1126 return "Gaussian";
1127 }
1128
1129 double eval(double t) const override {
1130 double x = (t - m_t0)/m_tau;
1131 return m_A * std::exp(-x*x);
1132 }
1133
1134 protected:
1135 double m_A, m_t0, m_tau;
1136};
1137
1138
1139/**
1140 * A Gaussian.
1141 * @f[
1142 * f(t) = A e^{-[(t - t_0)/\tau]^2}
1143 * @f]
1144 * where @f[ \tau = \frac{fwhm}{2\sqrt{\ln 2}} @f]
1145 * @param A peak value
1146 * @param t0 offset
1147 * @param fwhm full width at half max
1148 * @ingroup func1advanced
1149 * @deprecated To be removed after %Cantera 3.0; replaced by Gaussian1.
1150 */
1151 class Gaussian : public Gaussian1
1152{
1153 Gaussian(double A, double t0, double fwhm);
1154
1155 Gaussian(const Gaussian& b);
1156
1157 Func1& duplicate() const override;
1158};
1159
1160
1161/**
1162 * Implements a polynomial of degree @e n.
1163 * The functor class with type @c "polynomial" returns
1164 * @f[
1165 * f(x) = a_n x^n + \dots + a_1 x + a_0
1166 * @f]
1167 * @ingroup func1advanced
1168 */
1169 class Poly1 : public Func1
1170{
1171 public:
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());
1175 }
1176
1177 //! Constructor uses @f$ n + 1 @f$ parameters in the following order:
1178 //! @f$ [a_n, \dots, a_1, a_0] @f$
1179 Poly1(const vector<double>& params);
1180
1181 Poly1(const Poly1& b) :
1182 Func1(b) {
1183 *this = Poly1::operator=(b);
1184 }
1185
1186 Poly1& operator=(const Poly1& right) {
1187 if (&right == this) {
1188 return *this;
1189 }
1190 Func1::operator=(right);
1191 m_cpoly = right.m_cpoly;
1192 m_parent = 0;
1193 return *this;
1194 }
1195
1196 string type() const override {
1197 return "polynomial";
1198 }
1199
1200 Func1& duplicate() const override;
1201
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++) {
1205 r *= t;
1206 r += m_cpoly[m_cpoly.size() - n - 1];
1207 }
1208 return r;
1209 }
1210
1211 protected:
1212 vector<double> m_cpoly;
1213};
1214
1215
1216/**
1217 * Implements a Fourier cosine/sine series.
1218 * The functor class with type @c "Fourier" returns
1219 * @f[
1220 * f(t) = \frac{A_0}{2} +
1221 * \sum_{n=1}^N A_n \cos (n \omega t) + B_n \sin (n \omega t)
1222 * @f]
1223 * @ingroup func1advanced
1224 */
1225 class Fourier1 : public Func1
1226{
1227 public:
1228 Fourier1(size_t n, double omega, double a0, const double* a, const double* b) {
1229 m_omega = omega;
1230 m_a0_2 = 0.5*a0;
1231 m_ccos.resize(n);
1232 m_csin.resize(n);
1233 std::copy(a, a+n, m_ccos.begin());
1234 std::copy(b, b+n, m_csin.begin());
1235 }
1236
1237 //! Constructor uses @f$ 2 n + 2 @f$ parameters in the following order:
1238 //! @f$ [a_0, a_1, \dots, a_n, \omega, b_1, \dots, b_n] @f$
1239 Fourier1(const vector<double>& params);
1240
1241 Fourier1(const Fourier1& b) :
1242 Func1(b) {
1243 *this = Fourier1::operator=(b);
1244 }
1245
1246 Fourier1& operator=(const Fourier1& right) {
1247 if (&right == this) {
1248 return *this;
1249 }
1250 Func1::operator=(right);
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;
1255 m_parent = 0;
1256 return *this;
1257 }
1258
1259 string type() const override {
1260 return "Fourier";
1261 }
1262
1263 Func1& duplicate() const override;
1264
1265 double eval(double t) const override {
1266 size_t n, nn;
1267 double sum = m_a0_2;
1268 for (n = 0; n < m_ccos.size(); n++) {
1269 nn = n + 1;
1270 sum += m_ccos[n]*std::cos(m_omega*nn*t)
1271 + m_csin[n]*std::sin(m_omega*nn*t);
1272 }
1273 return sum;
1274 }
1275
1276 protected:
1277 double m_omega, m_a0_2;
1278 vector<double> m_ccos, m_csin;
1279};
1280
1281
1282/**
1283 * Implements a sum of Arrhenius terms.
1284 * The functor class with type @c "Arrhenius" returns
1285 * @f[
1286 * f(T) = \sum_{n=1}^N A_n T^b_n \exp(-E_n/T)
1287 * @f]
1288 * @ingroup func1advanced
1289 */
1290 class Arrhenius1 : public Func1
1291{
1292 public:
1293 Arrhenius1(size_t n, const double* c) {
1294 m_A.resize(n);
1295 m_b.resize(n);
1296 m_E.resize(n);
1297 for (size_t i = 0; i < n; i++) {
1298 size_t loc = 3*i;
1299 m_A[i] = c[loc];
1300 m_b[i] = c[loc+1];
1301 m_E[i] = c[loc+2];
1302 }
1303 }
1304
1305 //! Constructor uses @f$ 3 n @f$ parameters in the following order:
1306 //! @f$ [A_1, b_1, E_1, A_2, b_2, E_2, \dots, A_n, b_n, E_n] @f$
1307 Arrhenius1(const vector<double>& params);
1308
1309 Arrhenius1(const Arrhenius1& b) :
1310 Func1() {
1311 *this = Arrhenius1::operator=(b);
1312 }
1313
1314 Arrhenius1& operator=(const Arrhenius1& right) {
1315 if (&right == this) {
1316 return *this;
1317 }
1318 Func1::operator=(right);
1319 m_A = right.m_A;
1320 m_b = right.m_b;
1321 m_E = right.m_E;
1322 m_parent = 0;
1323 return *this;
1324 }
1325
1326 string type() const override {
1327 return "Arrhenius";
1328 }
1329
1330 Func1& duplicate() const override;
1331
1332 double eval(double t) const override {
1333 double sum = 0.0;
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);
1336 }
1337 return sum;
1338 }
1339
1340 protected:
1341 vector<double> m_A, m_b, m_E;
1342};
1343
1344/**
1345 * Implements a periodic function.
1346 * Takes any function and makes it periodic with period @f$ T @f$.
1347 * @param f Functor to be made periodic
1348 * @param T Period
1349 * @ingroup func1modified
1350 */
1351 class Periodic1 : public Func1
1352{
1353 public:
1354 Periodic1(Func1& f, double T) {
1355 m_f1 = &f;
1356 m_c = T;
1357 }
1358
1359 Periodic1(const Periodic1& b) {
1360 *this = Periodic1::operator=(b);
1361 }
1362
1363 Periodic1(shared_ptr<Func1> f, double A) : Func1(f, A) {}
1364
1365 Periodic1& operator=(const Periodic1& right) {
1366 if (&right == this) {
1367 return *this;
1368 }
1369 Func1::operator=(right);
1370 m_f1 = &right.m_f1->duplicate();
1371 return *this;
1372 }
1373
1374 string type() const override {
1375 return "periodic";
1376 }
1377
1378 Func1& duplicate() const override;
1379
1380 ~Periodic1() override {
1381 if (!m_f1_shared) {
1382 delete m_f1;
1383 }
1384 }
1385
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);
1390 }
1391};
1392
1393}
1394
1395#endif
Cantera::Arrhenius1
Implements a sum of Arrhenius terms.
Definition Func1.h:1291
Cantera::Arrhenius1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:1332
Cantera::Arrhenius1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:1326
Cantera::Arrhenius1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:604
Cantera::Composite1
Implements a composite function.
Definition Func1.h:1018
Cantera::Composite1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:794
Cantera::Composite1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:1063
Cantera::Composite1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:1059
Cantera::Composite1::order
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:1074
Cantera::Composite1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:780
Cantera::Composite1::ID
int ID() const override
Definition Func1.h:1056
Cantera::Composite1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:804
Cantera::Composite1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:786
Cantera::Const1
Implements a constant.
Definition Func1.h:541
Cantera::Const1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:654
Cantera::Const1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:570
Cantera::Const1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:566
Cantera::Const1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:643
Cantera::Const1::ID
int ID() const override
Definition Func1.h:563
Cantera::Const1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.h:575
Cantera::Const1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:648
Cantera::Cos1
Implements the cos() function.
Definition Func1.h:324
Cantera::Cos1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:213
Cantera::Cos1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:354
Cantera::Cos1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:350
Cantera::Cos1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:228
Cantera::Cos1::ID
int ID() const override
Definition Func1.h:347
Cantera::Cos1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:222
Cantera::Cos1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:206
Cantera::Diff1
Implements the difference of two functions.
Definition Func1.h:660
Cantera::Diff1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:774
Cantera::Diff1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:706
Cantera::Diff1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:702
Cantera::Diff1::order
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:717
Cantera::Diff1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:755
Cantera::Diff1::ID
int ID() const override
Definition Func1.h:698
Cantera::Diff1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.h:713
Cantera::Diff1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:766
Cantera::Exp1
Implements the exp() (exponential) function.
Definition Func1.h:369
Cantera::Exp1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:254
Cantera::Exp1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:396
Cantera::Exp1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:392
Cantera::Exp1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:275
Cantera::Exp1::ID
int ID() const override
Definition Func1.h:389
Cantera::Exp1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:266
Cantera::Exp1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:248
Cantera::Fourier1
Implements a Fourier cosine/sine series.
Definition Func1.h:1226
Cantera::Fourier1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:1265
Cantera::Fourier1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:1259
Cantera::Fourier1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:597
Cantera::Func1
Base class for 'functor' classes that evaluate a function of one variable.
Definition Func1.h:96
Cantera::Func1::typeName
string typeName() const
Returns a string with the class name of the functor.
Definition Func1.cpp:49
Cantera::Func1::type
virtual string type() const
Returns a string describing the type of the function.
Definition Func1.h:132
Cantera::Func1::operator=
Func1 & operator=(const Func1 &right)
Definition Func1.cpp:24
Cantera::Func1::setC
void setC(double c)
Function to set the stored constant.
Definition Func1.cpp:112
Cantera::Func1::eval
virtual double eval(double t) const
Evaluate the function.
Definition Func1.cpp:61
Cantera::Func1::derivative3
virtual shared_ptr< Func1 > derivative3() const
Creates a derivative to the current function.
Definition Func1.cpp:75
Cantera::Func1::func1_shared
shared_ptr< Func1 > func1_shared() const
Accessor function for m_f1_shared.
Definition Func1.h:189
Cantera::Func1::func1_dup
Func1 & func1_dup() const
Definition Func1.cpp:133
Cantera::Func1::func2
Func1 & func2() const
accessor function for m_f2
Definition Func1.cpp:123
Cantera::Func1::write
virtual string write(const string &arg) const
Write LaTeX string describing function.
Definition Func1.cpp:618
Cantera::Func1::operator()
double operator()(double t) const
Calls method eval to evaluate the function.
Definition Func1.cpp:55
Cantera::Func1::func1
Func1 & func1() const
accessor function for m_f1
Definition Func1.cpp:118
Cantera::Func1::setParent
void setParent(Func1 *p)
Definition Func1.cpp:148
Cantera::Func1::order
virtual int order() const
Return the order of the function, if it makes sense.
Definition Func1.cpp:128
Cantera::Func1::isIdentical
bool isIdentical(Func1 &other) const
Routine to determine if two functions are the same.
Definition Func1.cpp:81
Cantera::Func1::duplicate
virtual Func1 & duplicate() const
Duplicate the current function.
Definition Func1.cpp:36
Cantera::Func1::ID
virtual int ID() const
Definition Func1.cpp:44
Cantera::Func1::func2_shared
shared_ptr< Func1 > func2_shared() const
Accessor function for m_f2_shared.
Definition Func1.h:199
Cantera::Func1::parent
Func1 * parent() const
Definition Func1.cpp:143
Cantera::Func1::derivative
virtual Func1 & derivative() const
Creates a derivative to the current function.
Definition Func1.cpp:66
Cantera::Func1::c
double c() const
Accessor function for the stored constant.
Definition Func1.cpp:106
Cantera::Func1::func2_dup
Func1 & func2_dup() const
Definition Func1.cpp:138
Cantera::Gaussian1
Implements a Gaussian function.
Definition Func1.h:1096
Cantera::Gaussian1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:1129
Cantera::Gaussian1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:1125
Cantera::Gaussian
A Gaussian.
Definition Func1.h:1152
Cantera::Gaussian::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:583
Cantera::Log1
Implements the log() (natural logarithm) function.
Definition Func1.h:414
Cantera::Log1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:427
Cantera::Log1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:423
Cantera::Log1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:302
Cantera::Log1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:293
Cantera::Periodic1
Implements a periodic function.
Definition Func1.h:1352
Cantera::Periodic1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:1386
Cantera::Periodic1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:1374
Cantera::Periodic1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:611
Cantera::PlusConstant1
Implements the sum of a function and a constant.
Definition Func1.h:883
Cantera::PlusConstant1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:862
Cantera::PlusConstant1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:922
Cantera::PlusConstant1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:918
Cantera::PlusConstant1::order
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:935
Cantera::PlusConstant1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:846
Cantera::PlusConstant1::ID
int ID() const override
Definition Func1.h:915
Cantera::PlusConstant1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.h:929
Cantera::PlusConstant1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:854
Cantera::Poly1
Implements a polynomial of degree n.
Definition Func1.h:1170
Cantera::Poly1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:1202
Cantera::Poly1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:1196
Cantera::Poly1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:590
Cantera::Pow1
Implements the pow() (power) function.
Definition Func1.h:443
Cantera::Pow1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:327
Cantera::Pow1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:470
Cantera::Pow1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:466
Cantera::Pow1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:623
Cantera::Pow1::ID
int ID() const override
Definition Func1.h:463
Cantera::Pow1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:343
Cantera::Pow1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:321
Cantera::Product1
Implements the product of two functions.
Definition Func1.h:733
Cantera::Product1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:714
Cantera::Product1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:781
Cantera::Product1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:775
Cantera::Product1::order
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:790
Cantera::Product1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:693
Cantera::Product1::ID
int ID() const override
Definition Func1.h:771
Cantera::Product1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:722
Cantera::Product1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:706
Cantera::Ratio1
Implements the ratio of two functions.
Definition Func1.h:949
Cantera::Ratio1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:675
Cantera::Ratio1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:994
Cantera::Ratio1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:990
Cantera::Ratio1::order
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:1005
Cantera::Ratio1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:661
Cantera::Ratio1::ID
int ID() const override
Definition Func1.h:987
Cantera::Ratio1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:685
Cantera::Ratio1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:667
Cantera::Sin1
Implements the sin() function.
Definition Func1.h:275
Cantera::Sin1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:180
Cantera::Sin1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:306
Cantera::Sin1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:302
Cantera::Sin1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:164
Cantera::Sin1::ID
int ID() const override
Definition Func1.h:298
Cantera::Sin1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:189
Cantera::Sin1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:173
Cantera::Sum1
Implements the sum of two functions.
Definition Func1.h:589
Cantera::Sum1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:747
Cantera::Sum1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:634
Cantera::Sum1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:630
Cantera::Sum1::order
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:645
Cantera::Sum1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:728
Cantera::Sum1::ID
int ID() const override
Definition Func1.h:627
Cantera::Sum1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.h:641
Cantera::Sum1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:739
Cantera::Tabulated1
Implements a tabulated function.
Definition Func1.h:489
Cantera::Tabulated1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:515
Cantera::Tabulated1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.cpp:480
Cantera::Tabulated1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:516
Cantera::Tabulated1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:638
Cantera::Tabulated1::setMethod
void setMethod(const string &method)
Set the interpolation method.
Definition Func1.cpp:468
Cantera::Tabulated1::ID
int ID() const override
Definition Func1.h:513
Cantera::Tabulated1::m_tvec
vector< double > m_tvec
Vector of time values.
Definition Func1.h:528
Cantera::Tabulated1::m_isLinear
bool m_isLinear
Boolean indicating interpolation method.
Definition Func1.h:530
Cantera::Tabulated1::m_fvec
vector< double > m_fvec
Vector of function values.
Definition Func1.h:529
Cantera::Tabulated1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.cpp:543
Cantera::Tabulated1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:503
Cantera::TimesConstant1
Implements the product of a function and a constant.
Definition Func1.h:803
Cantera::TimesConstant1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:838
Cantera::TimesConstant1::eval
double eval(double t) const override
Evaluate the function.
Definition Func1.h:857
Cantera::TimesConstant1::type
string type() const override
Returns a string describing the type of the function.
Definition Func1.h:837
Cantera::TimesConstant1::order
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:870
Cantera::TimesConstant1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:811
Cantera::TimesConstant1::ID
int ID() const override
Definition Func1.h:834
Cantera::TimesConstant1::derivative3
shared_ptr< Func1 > derivative3() const override
Creates a derivative to the current function.
Definition Func1.h:864
Cantera::TimesConstant1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:830
ct_defs.h
This file contains definitions of constants, types and terms that are used in internal routines and a...
ctexceptions.h
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564