| Cantera 3.0.0

Loading...
Searching...
No Matches
Func1.cpp
Go to the documentation of this file.
1//! @file Func1.cpp
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#include "cantera/numerics/Func1.h"
7#include "cantera/base/global.h"
8#include "cantera/base/ctexceptions.h"
9#include "cantera/base/stringUtils.h"
10
11 using namespace std;
12
13 namespace Cantera
14{
15
16Func1::Func1(const Func1& right) :
17 m_c(right.m_c),
18 m_f1(right.m_f1),
19 m_f2(right.m_f2),
20 m_parent(right.m_parent)
21{
22}
23
24 Func1& Func1::operator=(const Func1& right)
25{
26 if (&right == this) {
27 return *this;
28 }
29 m_c = right.m_c;
30 m_f1 = right.m_f1;
31 m_f2 = right.m_f2;
32 m_parent = right.m_parent;
33 return *this;
34}
35
36 Func1& Func1::duplicate() const
37{
38 warn_deprecated("Func1::duplicate",
39 "To be removed after Cantera 3.0. No longer needed.");
40 Func1* nfunc = new Func1(*this);
41 return *nfunc;
42}
43
44 int Func1::ID() const
45{
46 return 0;
47}
48
49 string Func1::typeName() const
50{
51 return demangle(typeid(*this));
52}
53
54// Calls method eval to evaluate the function
55 double Func1::operator()(double t) const
56{
57 return eval(t);
58}
59
60// Evaluate the function.
61 double Func1::eval(double t) const
62{
63 return 0.0;
64}
65
66 Func1& Func1::derivative() const
67{
68 warn_deprecated("Func1::derivative",
69 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
70 cout << "derivative error... ERR: ID = " << ID() << endl;
71 cout << write("x") << endl;
72 return *(new Func1);
73}
74
75shared_ptr<Func1> Func1::derivative3() const
76{
77 throw CanteraError("Func1::derivative3",
78 "Needs to be overloaded by Func1 specialization.");
79}
80
81 bool Func1::isIdentical(Func1& other) const
82{
83 if (ID() != other.ID() || m_c != other.m_c) {
84 return false;
85 }
86 if (m_f1) {
87 if (!other.m_f1) {
88 return false;
89 }
90 if (!m_f1->isIdentical(*other.m_f1)) {
91 return false;
92 }
93 }
94 if (m_f2) {
95 if (!other.m_f2) {
96 return false;
97 }
98 if (!m_f2->isIdentical(*other.m_f2)) {
99 return false;
100 }
101 }
102 return true;
103}
104
105//! accessor function for the returned constant
106 double Func1::c() const
107{
108 return m_c;
109}
110
111// Function to set the stored constant
112 void Func1::setC(double c)
113{
114 m_c = c;
115}
116
117//! accessor function for m_f1
118 Func1& Func1::func1() const
119{
120 return *m_f1;
121}
122
123 Func1& Func1::func2() const
124{
125 return *m_f2;
126}
127
128 int Func1::order() const
129{
130 return 3;
131}
132
133 Func1& Func1::func1_dup() const
134{
135 return m_f1->duplicate();
136}
137
138 Func1& Func1::func2_dup() const
139{
140 return m_f2->duplicate();
141}
142
143 Func1* Func1::parent() const
144{
145 return m_parent;
146}
147
148 void Func1::setParent(Func1* p)
149{
150 m_parent = p;
151}
152
153/*****************************************************************************/
154
155Sin1::Sin1(const vector<double>& params)
156{
157 if (params.size() != 1) {
158 throw CanteraError("Sin1::Sin1",
159 "Constructor needs exactly one parameter (frequency).");
160 }
161 m_c = params[0];
162}
163
164 string Sin1::write(const string& arg) const
165{
166 if (m_c == 1.0) {
167 return fmt::format("\\sin({})", arg);
168 } else {
169 return fmt::format("\\sin({}{})", m_c, arg);
170 }
171}
172
173 Func1& Sin1::duplicate() const {
174 warn_deprecated("Sin1::duplicate",
175 "To be removed after Cantera 3.0; no longer needed.");
176 Sin1* nfunc = new Sin1(*this);
177 return (Func1&) *nfunc;
178}
179
180 Func1& Sin1::derivative() const
181{
182 warn_deprecated("Sin1::derivative",
183 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
184 Func1* c = new Cos1(m_c);
185 Func1* r = &newTimesConstFunction(*c, m_c);
186 return *r;
187}
188
189shared_ptr<Func1> Sin1::derivative3() const
190{
191 auto c = make_shared<Cos1>(m_c);
192 return newTimesConstFunction(c, m_c);
193}
194
195/*****************************************************************************/
196
197Cos1::Cos1(const vector<double>& params)
198{
199 if (params.size() != 1) {
200 throw CanteraError("Cos1::Cos1",
201 "Constructor needs exactly one parameter (frequency).");
202 }
203 m_c = params[0];
204}
205
206 Func1& Cos1::duplicate() const {
207 warn_deprecated("Cos1::duplicate",
208 "To be removed after Cantera 3.0; no longer needed.");
209 Cos1* nfunc = new Cos1(*this);
210 return (Func1&) *nfunc;
211}
212
213 Func1& Cos1::derivative() const
214{
215 warn_deprecated("Cos1::derivative",
216 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
217 Func1* s = new Sin1(m_c);
218 Func1* r = &newTimesConstFunction(*s, -m_c);
219 return *r;
220}
221
222shared_ptr<Func1> Cos1::derivative3() const
223{
224 auto s = make_shared<Sin1>(m_c);
225 return newTimesConstFunction(s, -m_c);
226}
227
228 string Cos1::write(const string& arg) const
229{
230 if (m_c == 1.0) {
231 return fmt::format("\\cos({})", arg);
232 } else {
233 return fmt::format("\\cos({}{})", m_c, arg);
234 }
235}
236
237/**************************************************************************/
238
239Exp1::Exp1(const vector<double>& params)
240{
241 if (params.size() != 1) {
242 throw CanteraError("Exp1::Exp1",
243 "Constructor needs exactly one parameter (exponent factor).");
244 }
245 m_c = params[0];
246}
247
248 Func1& Exp1::duplicate() const {
249 warn_deprecated("Exp1::duplicate",
250 "To be removed after Cantera 3.0; no longer needed.");
251 return *(new Exp1(m_c));
252}
253
254 Func1& Exp1::derivative() const
255{
256 warn_deprecated("Exp1::derivative",
257 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
258 Func1* f = new Exp1(m_c);
259 if (m_c != 1.0) {
260 return newTimesConstFunction(*f, m_c);
261 } else {
262 return *f;
263 }
264}
265
266shared_ptr<Func1> Exp1::derivative3() const
267{
268 auto f = make_shared<Exp1>(m_c);
269 if (m_c != 1.0) {
270 return newTimesConstFunction(f, m_c);
271 }
272 return f;
273}
274
275 string Exp1::write(const string& arg) const
276{
277 if (m_c == 1.0) {
278 return fmt::format("\\exp({})", arg);
279 } else {
280 return fmt::format("\\exp({}{})", m_c, arg);
281 }
282}
283
284Log1::Log1(const vector<double>& params)
285{
286 if (params.size() != 1) {
287 throw CanteraError("Log1::Log1",
288 "Constructor needs exactly one parameter (factor).");
289 }
290 m_c = params[0];
291}
292
293shared_ptr<Func1> Log1::derivative3() const
294{
295 auto f = make_shared<Pow1>(-1.);
296 if (m_c != 1.0) {
297 return newTimesConstFunction(f, m_c);
298 }
299 return f;
300}
301
302 string Log1::write(const string& arg) const
303{
304 if (m_c == 1.0) {
305 return fmt::format("\\log({})", arg);
306 }
307 return fmt::format("\\log({}{})", m_c, arg);
308}
309
310/******************************************************************************/
311
312Pow1::Pow1(const vector<double>& params)
313{
314 if (params.size() != 1) {
315 throw CanteraError("Pow1::Pow1",
316 "Constructor needs exactly one parameter (exponent).");
317 }
318 m_c = params[0];
319}
320
321 Func1& Pow1::duplicate() const {
322 warn_deprecated("Pow1::duplicate",
323 "To be removed after Cantera 3.0; no longer needed.");
324 return *(new Pow1(m_c));
325}
326
327 Func1& Pow1::derivative() const
328{
329 warn_deprecated("Pow1::derivative",
330 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
331 Func1* r;
332 if (m_c == 0.0) {
333 r = new Const1(0.0);
334 } else if (m_c == 1.0) {
335 r = new Const1(1.0);
336 } else {
337 Func1* f = new Pow1(m_c - 1.0);
338 r = &newTimesConstFunction(*f, m_c);
339 }
340 return *r;
341}
342
343shared_ptr<Func1> Pow1::derivative3() const
344{
345 if (m_c == 0.0) {
346 return make_shared<Const1>(0.0);
347 }
348 if (m_c == 1.0) {
349 return make_shared<Const1>(1.0);
350 }
351 auto f = make_shared<Pow1>(m_c - 1.);
352 return newTimesConstFunction(f, m_c);
353}
354
355/******************************************************************************/
356
357Const1::Const1(const vector<double>& params)
358{
359 if (params.size() != 1) {
360 throw CanteraError("Const1::Const1",
361 "Constructor needs exactly one parameter (constant).");
362 }
363 m_c = params[0];
364}
365
366Poly1::Poly1(const vector<double>& params)
367{
368 if (params.size() == 0) {
369 throw CanteraError("Poly1::Poly1",
370 "Constructor needs an array that is not empty.");
371 }
372 size_t n = params.size() - 1;
373 m_cpoly.resize(n + 1);
374 copy(params.data(), params.data() + m_cpoly.size(), m_cpoly.begin());
375}
376
377Fourier1::Fourier1(const vector<double>& params)
378{
379 if (params.size() < 4) {
380 throw CanteraError("Fourier1::Fourier1",
381 "Constructor needs an array with at least 4 entries.");
382 }
383 if (params.size() % 2 != 0) {
384 throw CanteraError("Fourier1::Fourier1",
385 "Constructor needs an array with an even number of entries.");
386 }
387 size_t n = params.size() / 2 - 1;
388 m_omega = params[n + 1];
389 m_a0_2 = 0.5 * params[0];
390 m_ccos.resize(n);
391 m_csin.resize(n);
392 copy(params.data() + 1, params.data() + n + 1, m_ccos.begin());
393 copy(params.data() + n + 2, params.data() + 2 * n + 2, m_csin.begin());
394}
395
396Gaussian1::Gaussian1(const vector<double>& params)
397{
398 if (params.size() != 3) {
399 throw CanteraError("Gaussian1::Gaussian1",
400 "Constructor needs exactly 3 parameters (amplitude, center, width).");
401 }
402 m_A = params[0];
403 m_t0 = params[1];
404 m_tau = params[2] / (2. * sqrt(log(2.)));
405}
406
407Arrhenius1::Arrhenius1(const vector<double>& params)
408{
409 if (params.size() < 3) {
410 throw CanteraError("Arrhenius1::Arrhenius1",
411 "Constructor needs an array with at least 3 entries.");
412 }
413 if (params.size() % 3 != 0) {
414 throw CanteraError("Arrhenius1::Arrhenius1",
415 "Constructor needs an array with multiples of 3 entries.");
416 }
417 size_t n = params.size() / 3;
418 m_A.resize(n);
419 m_b.resize(n);
420 m_E.resize(n);
421 for (size_t i = 0; i < n; i++) {
422 size_t loc = 3 * i;
423 m_A[i] = params[loc];
424 m_b[i] = params[loc + 1];
425 m_E[i] = params[loc + 2];
426 }
427}
428
429 Tabulated1::Tabulated1(size_t n, const double* tvals, const double* fvals,
430 const string& method)
431{
432 m_tvec.resize(n);
433 std::copy(tvals, tvals + n, m_tvec.begin());
434 for (auto it = std::begin(m_tvec) + 1; it != std::end(m_tvec); it++) {
435 if (*(it - 1) > *it) {
436 throw CanteraError("Tabulated1::Tabulated1",
437 "time values are not increasing monotonically.");
438 }
439 }
440 m_fvec.resize(n);
441 std::copy(fvals, fvals + n, m_fvec.begin());
442 setMethod(method);
443}
444
445 Tabulated1::Tabulated1(const vector<double>& params) : m_isLinear(true)
446{
447 if (params.size() < 4) {
448 throw CanteraError("Tabulated1::Tabulated1",
449 "Constructor needs an array with at least 4 entries.");
450 }
451 if (params.size() % 2 != 0) {
452 throw CanteraError("Tabulated1::Tabulated1",
453 "Constructor needs an array with an even number of entries.");
454 }
455 size_t n = params.size() / 2;
456 m_tvec.resize(n);
457 copy(params.data(), params.data() + n, m_tvec.begin());
458 for (auto it = std::begin(m_tvec) + 1; it != std::end(m_tvec); it++) {
459 if (*(it - 1) > *it) {
460 throw CanteraError("Tabulated1::Tabulated1",
461 "Time values are not monotonically increasing.");
462 }
463 }
464 m_fvec.resize(n);
465 copy(params.data() + n, params.data() + 2 * n, m_fvec.begin());
466}
467
468 void Tabulated1::setMethod(const string& method)
469{
470 if (method == "linear") {
471 m_isLinear = true;
472 } else if (method == "previous") {
473 m_isLinear = false;
474 } else {
475 throw NotImplementedError("Tabulated1::setMethod",
476 "Interpolation method '{}' is not implemented.", method);
477 }
478}
479
480 double Tabulated1::eval(double t) const {
481 size_t siz = m_tvec.size();
482 // constructor ensures that siz > 0
483 if (t <= m_tvec[0]) {
484 return m_fvec[0];
485 } else if (t >= m_tvec[siz-1]) {
486 return m_fvec[siz-1];
487 } else {
488 size_t ix = 0;
489 while (t > m_tvec[ix+1]) {
490 ix++;
491 }
492 if (m_isLinear) {
493 double df = m_fvec[ix+1] - m_fvec[ix];
494 df /= m_tvec[ix+1] - m_tvec[ix];
495 df *= t - m_tvec[ix];
496 return m_fvec[ix] + df;
497 } else {
498 return m_fvec[ix];
499 }
500 }
501}
502
503 Func1& Tabulated1::duplicate() const {
504 warn_deprecated("Tabulated1::duplicate",
505 "To be removed after Cantera 3.0; no longer needed.");
506 if (m_isLinear) {
507 return *(new Tabulated1(m_tvec.size(), &m_tvec[0], &m_fvec[0],
508 "linear"));
509 } else {
510 return *(new Tabulated1(m_tvec.size(), &m_tvec[0], &m_fvec[0],
511 "previous"));
512 }
513}
514
515 Func1& Tabulated1::derivative() const {
516 warn_deprecated("Tabulated1::derivative",
517 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
518 vector<double> tvec;
519 vector<double> dvec;
520 size_t siz = m_tvec.size();
521 if (m_isLinear) {
522 // piece-wise continuous derivative
523 if (siz>1) {
524 for (size_t i=1; i<siz; i++) {
525 double d = (m_fvec[i] - m_fvec[i-1]) /
526 (m_tvec[i] - m_tvec[i-1]);
527 tvec.push_back(m_tvec[i-1]);
528 dvec.push_back(d);
529 }
530 }
531 tvec.push_back(m_tvec[siz-1]);
532 dvec.push_back(0.);
533 } else {
534 // derivative is zero (ignoring discontinuities)
535 tvec.push_back(m_tvec[0]);
536 tvec.push_back(m_tvec[siz-1]);
537 dvec.push_back(0.);
538 dvec.push_back(0.);
539 }
540 return *(new Tabulated1(tvec.size(), &tvec[0], &dvec[0], "previous"));
541}
542
543shared_ptr<Func1> Tabulated1::derivative3() const {
544 vector<double> tvec;
545 vector<double> dvec;
546 size_t siz = m_tvec.size();
547 if (m_isLinear) {
548 // piece-wise continuous derivative
549 if (siz>1) {
550 for (size_t i=1; i<siz; i++) {
551 double d = (m_fvec[i] - m_fvec[i-1]) /
552 (m_tvec[i] - m_tvec[i-1]);
553 tvec.push_back(m_tvec[i-1]);
554 dvec.push_back(d);
555 }
556 }
557 tvec.push_back(m_tvec[siz-1]);
558 dvec.push_back(0.);
559 } else {
560 // derivative is zero (ignoring discontinuities)
561 tvec.push_back(m_tvec[0]);
562 tvec.push_back(m_tvec[siz-1]);
563 dvec.push_back(0.);
564 dvec.push_back(0.);
565 }
566 return make_shared<Tabulated1>(tvec.size(), &tvec[0], &dvec[0], "previous");
567}
568
569/******************************************************************************/
570
571Gaussian::Gaussian(double A, double t0, double fwhm) : Gaussian1(A, t0, fwhm)
572{
573 warn_deprecated("Gaussian::Gaussian", "To be removed after Cantera 3.0. "
574 "Replaced by 'Gaussian1'.");
575}
576
577Gaussian::Gaussian(const Gaussian& b) : Gaussian1(b)
578{
579 warn_deprecated("Gaussian::Gaussian", "To be removed after Cantera 3.0. "
580 "Replaced by 'Gaussian1'.");
581}
582
583 Func1& Gaussian::duplicate() const {
584 warn_deprecated("Gaussian::duplicate",
585 "To be removed after Cantera 3.0; no longer needed.");
586 Gaussian* np = new Gaussian(*this);
587 return *((Func1*)np);
588}
589
590 Func1& Poly1::duplicate() const {
591 warn_deprecated("Poly1::duplicate",
592 "To be removed after Cantera 3.0; no longer needed.");
593 Poly1* np = new Poly1(*this);
594 return *((Func1*)np);
595}
596
597 Func1& Fourier1::duplicate() const {
598 warn_deprecated("Fourier1::duplicate",
599 "To be removed after Cantera 3.0; no longer needed.");
600 Fourier1* np = new Fourier1(*this);
601 return *((Func1*)np);
602}
603
604 Func1& Arrhenius1::duplicate() const {
605 warn_deprecated("Arrhenius1::duplicate",
606 "To be removed after Cantera 3.0; no longer needed.");
607 Arrhenius1* np = new Arrhenius1(*this);
608 return *((Func1*)np);
609}
610
611 Func1& Periodic1::duplicate() const {
612 warn_deprecated("Periodic1::duplicate",
613 "To be removed after Cantera 3.0; no longer needed.");
614 Periodic1* np = new Periodic1(*this);
615 return *((Func1*)np);
616}
617
618 string Func1::write(const string& arg) const
619{
620 return fmt::format("\\mathrm{{{}}}({})", type(), arg);
621}
622
623 string Pow1::write(const string& arg) const
624{
625 if (m_c == 0.5) {
626 return "\\sqrt{" + arg + "}";
627 }
628 if (m_c == -0.5) {
629 return "\\frac{1}{\\sqrt{" + arg + "}}";
630 }
631 if (m_c != 1.0) {
632 return fmt::format("\\left({}\\right)^{{{}}}", arg, m_c);
633 } else {
634 return arg;
635 }
636}
637
638 string Tabulated1::write(const string& arg) const
639{
640 return fmt::format("\\mathrm{{Tabulated}}({})", arg);
641}
642
643 string Const1::write(const string& arg) const
644{
645 return fmt::format("{}", m_c);
646}
647
648 Func1& Const1::duplicate() const {
649 warn_deprecated("Const1::duplicate",
650 "To be removed after Cantera 3.0; no longer needed.");
651 return *(new Const1(m_c));
652}
653
654 Func1& Const1::derivative() const {
655 warn_deprecated("Const1::derivative",
656 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
657 Func1* z = new Const1(0.0);
658 return *z;
659}
660
661 string Ratio1::write(const string& arg) const
662{
663 return "\\frac{" + m_f1->write(arg) + "}{"
664 + m_f2->write(arg) + "}";
665}
666
667 Func1& Ratio1::duplicate() const {
668 warn_deprecated("Ratio1::duplicate",
669 "To be removed after Cantera 3.0; no longer needed.");
670 Func1& f1d = m_f1->duplicate();
671 Func1& f2d = m_f2->duplicate();
672 return newRatioFunction(f1d, f2d);
673}
674
675 Func1& Ratio1::derivative() const {
676 warn_deprecated("Ratio1::derivative",
677 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
678 Func1& a1 = newProdFunction(m_f1->derivative(), m_f2->duplicate());
679 Func1& a2 = newProdFunction(m_f1->duplicate(), m_f2->derivative());
680 Func1& s = newDiffFunction(a1, a2);
681 Func1& p = newProdFunction(m_f2->duplicate(), m_f2->duplicate());
682 return newRatioFunction(s, p);
683}
684
685shared_ptr<Func1> Ratio1::derivative3() const {
686 auto a1 = newProdFunction(m_f1_shared->derivative3(), m_f2_shared);
687 auto a2 = newProdFunction(m_f1_shared, m_f2_shared->derivative3());
688 auto s = newDiffFunction(a1, a2);
689 auto p = newProdFunction(m_f2_shared, m_f2_shared);
690 return newRatioFunction(s, p);
691}
692
693 string Product1::write(const string& arg) const
694{
695 string s = m_f1->write(arg);
696 if (m_f1->order() < order()) {
697 s = "\\left(" + s + "\\right)";
698 }
699 string s2 = m_f2->write(arg);
700 if (m_f2->order() < order()) {
701 s2 = "\\left(" + s2 + "\\right)";
702 }
703 return s + " " + s2;
704}
705
706 Func1& Product1::duplicate() const {
707 warn_deprecated("Product1::duplicate",
708 "To be removed after Cantera 3.0; no longer needed.");
709 Func1& f1d = m_f1->duplicate();
710 Func1& f2d = m_f2->duplicate();
711 return newProdFunction(f1d, f2d);
712}
713
714 Func1& Product1::derivative() const {
715 warn_deprecated("Product1::derivative",
716 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
717 Func1& a1 = newProdFunction(m_f1->duplicate(), m_f2->derivative());
718 Func1& a2 = newProdFunction(m_f2->duplicate(), m_f1->derivative());
719 return newSumFunction(a1, a2);
720}
721
722shared_ptr<Func1> Product1::derivative3() const {
723 auto a1 = newProdFunction(m_f1_shared, m_f2_shared->derivative3());
724 auto a2 = newProdFunction(m_f2_shared, m_f1_shared->derivative3());
725 return newSumFunction(a1, a2);
726}
727
728 string Sum1::write(const string& arg) const
729{
730 string s1 = m_f1->write(arg);
731 string s2 = m_f2->write(arg);
732 if (s2[0] == '-') {
733 return s1 + " - " + s2.substr(1,s2.size());
734 } else {
735 return s1 + " + " + s2;
736 }
737}
738
739 Func1& Sum1::duplicate() const {
740 warn_deprecated("Sum1::duplicate",
741 "To be removed after Cantera 3.0; no longer needed.");
742 Func1& f1d = m_f1->duplicate();
743 Func1& f2d = m_f2->duplicate();
744 return newSumFunction(f1d, f2d);
745}
746
747 Func1& Sum1::derivative() const {
748 warn_deprecated("Sum1::derivative",
749 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
750 Func1& d1 = m_f1->derivative();
751 Func1& d2 = m_f2->derivative();
752 return newSumFunction(d1, d2);
753}
754
755 string Diff1::write(const string& arg) const
756{
757 string s1 = m_f1->write(arg);
758 string s2 = m_f2->write(arg);
759 if (s2[0] == '-') {
760 return s1 + " + " + s2.substr(1,s2.size());
761 } else {
762 return s1 + " - " + s2;
763 }
764}
765
766 Func1& Diff1::duplicate() const {
767 warn_deprecated("Diff1::duplicate",
768 "To be removed after Cantera 3.0; no longer needed.");
769 Func1& f1d = m_f1->duplicate();
770 Func1& f2d = m_f2->duplicate();
771 return newDiffFunction(f1d, f2d);
772}
773
774 Func1& Diff1::derivative() const {
775 warn_deprecated("Diff1::derivative",
776 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
777 return newDiffFunction(m_f1->derivative(), m_f2->derivative());
778}
779
780 string Composite1::write(const string& arg) const
781{
782 string g = m_f2->write(arg);
783 return m_f1->write(g);
784}
785
786 Func1& Composite1::duplicate() const {
787 warn_deprecated("Composite1::duplicate",
788 "To be removed after Cantera 3.0; no longer needed.");
789 Func1& f1d = m_f1->duplicate();
790 Func1& f2d = m_f2->duplicate();
791 return newCompositeFunction(f1d, f2d);
792}
793
794 Func1& Composite1::derivative() const {
795 warn_deprecated("Composite1::derivative",
796 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
797 Func1* d1 = &m_f1->derivative();
798 Func1* d3 = &newCompositeFunction(*d1, m_f2->duplicate());
799 Func1* d2 = &m_f2->derivative();
800 Func1* p = &newProdFunction(*d3, *d2);
801 return *p;
802}
803
804shared_ptr<Func1> Composite1::derivative3() const {
805 auto d1 = m_f1_shared->derivative3();
806 auto d2 = m_f2_shared->derivative3();
807 auto d3 = newCompositeFunction(d1, m_f2_shared);
808 return newProdFunction(d3, d2);
809}
810
811 string TimesConstant1::write(const string& arg) const
812{
813 string s = m_f1->write(arg);
814 if (m_f1->order() < order()) {
815 s = "\\left(" + s + "\\right)";
816 }
817 if (m_c == 1.0) {
818 return s;
819 }
820 if (m_c == -1.0) {
821 return "-"+s;
822 }
823 char n = s[0];
824 if (n >= '0' && n <= '9') {
825 s = "\\left(" + s + "\\right)";
826 }
827 return fmt::format("{}{}", m_c, s);
828}
829
830 Func1& TimesConstant1::duplicate() const {
831 warn_deprecated("TimesConstant1::duplicate",
832 "To be removed after Cantera 3.0; no longer needed.");
833 Func1& f1 = m_f1->duplicate();
834 Func1* dup = new TimesConstant1(f1, m_c);
835 return *dup;
836}
837
838 Func1& TimesConstant1::derivative() const {
839 warn_deprecated("TimesConstant1::derivative",
840 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
841 Func1& f1d = m_f1->derivative();
842 Func1* d = &newTimesConstFunction(f1d, m_c);
843 return *d;
844}
845
846 string PlusConstant1::write(const string& arg) const
847{
848 if (m_c == 0.0) {
849 return m_f1->write(arg);
850 }
851 return fmt::format("{} + {}", m_f1->write(arg), m_c);
852}
853
854 Func1& PlusConstant1::duplicate() const {
855 warn_deprecated("PlusConstant1::duplicate",
856 "To be removed after Cantera 3.0; no longer needed.");
857 Func1& f1 = m_f1->duplicate();
858 Func1* dup = new PlusConstant1(f1, m_c);
859 return *dup;
860}
861
862 Func1& PlusConstant1::derivative() const {
863 warn_deprecated("PlusConstant1::derivative",
864 "To be changed after Cantera 3.0; for new behavior, see 'derivative3'.");
865 return m_f1->derivative();
866}
867
868
869 double Func1::isProportional(TimesConstant1& other)
870{
871 if (isIdentical(other.func1())) {
872 return other.c();
873 }
874 return 0.0;
875}
876 double Func1::isProportional(Func1& other)
877{
878 if (isIdentical(other)) {
879 return 1.0;
880 } else {
881 return 0.0;
882 }
883}
884
885 namespace { // restrict scope of helper functions to local translation unit
886
887 static bool isConstant(Func1& f)
888{
889 if (f.type() == "constant") {
890 return true;
891 } else {
892 return false;
893 }
894}
895
896 bool isConstant(const shared_ptr<Func1>& f)
897{
898 return f->type() == "constant";
899}
900
901 static bool isZero(Func1& f)
902{
903 if (f.type() == "constant" && f.c() == 0.0) {
904 return true;
905 } else {
906 return false;
907 }
908}
909
910 bool isZero(const shared_ptr<Func1>& f)
911{
912 return f->type() == "constant" && f->c() == 0.0;
913}
914
915 static bool isOne(Func1& f)
916{
917 if (f.type() == "constant" && f.c() == 1.0) {
918 return true;
919 } else {
920 return false;
921 }
922}
923
924 bool isOne(const shared_ptr<Func1>& f)
925{
926 return f->type() == "constant" && f->c() == 1.0;
927}
928
929 static bool isTimesConst(Func1& f)
930{
931 if (f.type() == "times-constant") {
932 return true;
933 } else {
934 return false;
935 }
936}
937
938 bool isTimesConst(const shared_ptr<Func1>& f)
939{
940 return f->type() == "times-constant";
941}
942
943 static bool isExp(Func1& f)
944{
945 if (f.type() == "exp") {
946 return true;
947 } else {
948 return false;
949 }
950}
951
952 bool isExp(const shared_ptr<Func1>& f)
953{
954 return f->type() == "exp";
955}
956
957 static bool isPow(Func1& f)
958{
959 if (f.type() == "pow") {
960 return true;
961 } else {
962 return false;
963 }
964}
965
966 bool isPow(const shared_ptr<Func1>& f)
967{
968 return f->type() == "pow";
969}
970
971} // end unnamed namespace
972
973Func1& newSumFunction(Func1& f1, Func1& f2)
974{
975 warn_deprecated("newSumFunction(Func1&, Func1&)",
976 "To be removed after Cantera 3.0; replaced by shared pointer version.");
977
978 if (f1.isIdentical(f2)) {
979 return newTimesConstFunction(f1, 2.0);
980 }
981 if (isZero(f1)) {
982 delete &f1;
983 return f2;
984 }
985 if (isZero(f2)) {
986 delete &f2;
987 return f1;
988 }
989 double c = f1.isProportional(f2);
990 if (c != 0) {
991 if (c == -1.0) {
992 return *(new Const1(0.0));
993 } else {
994 return newTimesConstFunction(f1, c + 1.0);
995 }
996 }
997 return *(new Sum1(f1, f2));
998}
999
1000shared_ptr<Func1> newSumFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
1001{
1002 if (f1->isIdentical(*f2)) {
1003 return newTimesConstFunction(f1, 2.);
1004 }
1005 if (isZero(f1)) {
1006 return f2;
1007 }
1008 if (isZero(f2)) {
1009 return f1;
1010 }
1011 double c = f1->isProportional(*f2);
1012 if (c != 0.) {
1013 if (c == -1.) {
1014 return make_shared<Const1>(0.);
1015 }
1016 return newTimesConstFunction(f1, c + 1.);
1017 }
1018 return make_shared<Sum1>(f1, f2);
1019}
1020
1021Func1& newDiffFunction(Func1& f1, Func1& f2)
1022{
1023 warn_deprecated("newDiffFunction(Func1&, Func1&)",
1024 "To be removed after Cantera 3.0; replaced by shared pointer version.");
1025
1026 if (isZero(f2)) {
1027 delete &f2;
1028 return f1;
1029 }
1030 if (f1.isIdentical(f2)) {
1031 delete &f1;
1032 delete &f2;
1033 return *(new Const1(0.0));
1034 }
1035 double c = f1.isProportional(f2);
1036 if (c != 0.0) {
1037 if (c == 1.0) {
1038 return *(new Const1(0.0));
1039 } else {
1040 return newTimesConstFunction(f1, 1.0 - c);
1041 }
1042 }
1043 return *(new Diff1(f1, f2));
1044}
1045
1046shared_ptr<Func1> newDiffFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
1047{
1048 if (isZero(f2)) {
1049 return f1;
1050 }
1051 if (isZero(f1)) {
1052 return newTimesConstFunction(f2, -1.);
1053 }
1054
1055 if (f1->isIdentical(*f2)) {
1056 return make_shared<Const1>(0.);
1057 }
1058 double c = f1->isProportional(*f2);
1059 if (c != 0.) {
1060 if (c == 1.0) {
1061 return make_shared<Const1>(0.);
1062 } else {
1063 return newTimesConstFunction(f1, 1. - c);
1064 }
1065 }
1066 return make_shared<Diff1>(f1, f2);
1067}
1068
1069Func1& newProdFunction(Func1& f1, Func1& f2)
1070{
1071 warn_deprecated("newProdFunction(Func1&, Func1&)",
1072 "To be removed after Cantera 3.0; replaced by shared pointer version.");
1073
1074 if (isOne(f1)) {
1075 delete &f1;
1076 return f2;
1077 }
1078 if (isOne(f2)) {
1079 delete &f2;
1080 return f1;
1081 }
1082 if (isZero(f1) || isZero(f2)) {
1083 delete &f1;
1084 delete &f2;
1085 return *(new Const1(0.0));
1086 }
1087 if (isConstant(f1) && isConstant(f2)) {
1088 double c1c2 = f1.c() * f2.c();
1089 delete &f1;
1090 delete &f2;
1091 return *(new Const1(c1c2));
1092 }
1093 if (isConstant(f1)) {
1094 double c = f1.c();
1095 delete &f1;
1096 return newTimesConstFunction(f2, c);
1097 }
1098 if (isConstant(f2)) {
1099 double c = f2.c();
1100 delete &f2;
1101 return newTimesConstFunction(f1, c);
1102 }
1103
1104 if (isPow(f1) && isPow(f2)) {
1105 Func1& p = *(new Pow1(f1.c() + f2.c()));
1106 delete &f1;
1107 delete &f2;
1108 return p;
1109 }
1110
1111 if (isExp(f1) && isExp(f2)) {
1112 Func1& p = *(new Exp1(f1.c() + f2.c()));
1113 delete &f1;
1114 delete &f2;
1115 return p;
1116 }
1117
1118 bool tc1 = isTimesConst(f1);
1119 bool tc2 = isTimesConst(f2);
1120
1121 if (tc1 || tc2) {
1122 double c1 = 1.0, c2 = 1.0;
1123 Func1* ff1 = 0, *ff2 = 0;
1124 if (tc1) {
1125 c1 = f1.c();
1126 ff1 = &f1.func1_dup();
1127 delete &f1;
1128 } else {
1129 ff1 = &f1;
1130 }
1131 if (tc2) {
1132 c2 = f2.c();
1133 ff2 = &f2.func1_dup();
1134 delete &f2;
1135 } else {
1136 ff2 = &f2;
1137 }
1138 Func1& p = newProdFunction(*ff1, *ff2);
1139
1140 if (c1* c2 != 1.0) {
1141 return newTimesConstFunction(p, c1*c2);
1142 } else {
1143 return p;
1144 }
1145 } else {
1146 return *(new Product1(f1, f2));
1147 }
1148}
1149
1150shared_ptr<Func1> newProdFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
1151{
1152 if (isOne(f1)) {
1153 return f2;
1154 }
1155 if (isOne(f2)) {
1156 return f1;
1157 }
1158 if (isZero(f1) || isZero(f2)) {
1159 return make_shared<Const1>(0.);
1160 }
1161 if (isConstant(f1) && isConstant(f2)) {
1162 return make_shared<Const1>(f1->c() * f2->c());
1163 }
1164 if (isConstant(f1)) {
1165 return newTimesConstFunction(f2, f1->c());
1166 }
1167 if (isConstant(f2)) {
1168 return newTimesConstFunction(f1, f2->c());
1169 }
1170 if (isPow(f1) && isPow(f2)) {
1171 return make_shared<Pow1>(f1->c() + f2->c());
1172 }
1173 if (isExp(f1) && isExp(f2)) {
1174 return make_shared<Exp1>(f1->c() + f2->c());
1175 }
1176
1177 bool tc1 = isTimesConst(f1);
1178 bool tc2 = isTimesConst(f2);
1179
1180 if (tc1 || tc2) {
1181 double c1 = 1.0;
1182 auto ff1 = f1;
1183 if (tc1) {
1184 c1 = f1->c();
1185 ff1 = f1->func1_shared();
1186 }
1187 double c2 = 1.0;
1188 auto ff2 = f2;
1189 if (tc2) {
1190 c2 = f2->c();
1191 ff2 = f2->func1_shared();
1192 }
1193 auto p = newProdFunction(ff1, ff2);
1194
1195 if (c1 * c2 != 1.0) {
1196 return newTimesConstFunction(p, c1 * c2);
1197 }
1198 return p;
1199 }
1200 return make_shared<Product1>(f1, f2);
1201}
1202
1203Func1& newRatioFunction(Func1& f1, Func1& f2)
1204{
1205 warn_deprecated("newRatioFunction(Func1&, Func1&)",
1206 "To be removed after Cantera 3.0; replaced by shared pointer version.");
1207
1208 if (isOne(f2)) {
1209 return f1;
1210 }
1211 if (isZero(f1)) {
1212 return *(new Const1(0.0));
1213 }
1214 if (f1.isIdentical(f2)) {
1215 delete &f1;
1216 delete &f2;
1217 return *(new Const1(1.0));
1218 }
1219 if (f1.ID() == PowFuncType && f2.ID() == PowFuncType) {
1220 return *(new Pow1(f1.c() - f2.c()));
1221 }
1222 if (f1.ID() == ExpFuncType && f2.ID() == ExpFuncType) {
1223 return *(new Exp1(f1.c() - f2.c()));
1224 }
1225 return *(new Ratio1(f1, f2));
1226}
1227
1228shared_ptr<Func1> newRatioFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
1229{
1230 if (isOne(f2)) {
1231 return f1;
1232 }
1233 if (isZero(f1)) {
1234 return make_shared<Const1>(0.);
1235 }
1236 if (f1->isIdentical(*f2)) {
1237 return make_shared<Const1>(1.);
1238 }
1239 if (isPow(f1) && isPow(f2)) {
1240 return make_shared<Pow1>(f1->c() - f2->c());
1241 }
1242 if (isExp(f1) && isExp(f2)) {
1243 return make_shared<Exp1>(f1->c() - f2->c());
1244 }
1245 return make_shared<Ratio1>(f1, f2);
1246}
1247
1248Func1& newCompositeFunction(Func1& f1, Func1& f2)
1249{
1250 warn_deprecated("newCompositeFunction(Func1&, Func1&)",
1251 "To be removed after Cantera 3.0; replaced by shared pointer version.");
1252
1253 if (isZero(f1)) {
1254 delete &f1;
1255 delete &f2;
1256 return *(new Const1(0.0));
1257 }
1258 if (isConstant(f1)) {
1259 delete &f2;
1260 return f1;
1261 }
1262 if (isPow(f1) && f1.c() == 1.0) {
1263 delete &f1;
1264 return f2;
1265 }
1266 if (isPow(f1) && f1.c() == 0.0) {
1267 delete &f1;
1268 delete &f2;
1269 return *(new Const1(1.0));
1270 }
1271 if (isPow(f1) && isPow(f2)) {
1272 double c1c2 = f1.c() * f2.c();
1273 delete &f1;
1274 delete &f2;
1275 return *(new Pow1(c1c2));
1276 }
1277 return *(new Composite1(f1, f2));
1278}
1279
1280shared_ptr<Func1> newCompositeFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
1281{
1282 if (isZero(f1)) {
1283 return make_shared<Const1>(0.0);
1284 }
1285 if (isConstant(f1)) {
1286 return f1;
1287 }
1288 if (isPow(f1) && f1->c() == 1.0) {
1289 return f2;
1290 }
1291 if (isPow(f1) && f1->c() == 0.0) {
1292 return make_shared<Const1>(1.);
1293 }
1294 if (isPow(f1) && isPow(f2)) {
1295 return make_shared<Pow1>(f1->c() * f2->c());
1296 }
1297 return make_shared<Composite1>(f1, f2);
1298}
1299
1300Func1& newTimesConstFunction(Func1& f, double c)
1301{
1302 warn_deprecated("newTimesConstFunction(Func1&, double)",
1303 "To be removed after Cantera 3.0; replaced by shared pointer version.");
1304
1305 if (c == 0.0) {
1306 delete &f;
1307 return *(new Const1(0.0));
1308 }
1309 if (c == 1.0) {
1310 return f;
1311 }
1312 if (f.type() == "times-constant") {
1313 f.setC(f.c() * c);
1314 return f;
1315 }
1316 return *(new TimesConstant1(f, c));
1317}
1318
1319shared_ptr<Func1> newTimesConstFunction(shared_ptr<Func1> f, double c)
1320{
1321 if (c == 0.0) {
1322 return make_shared<Const1>(0.0);
1323 }
1324 if (c == 1.0) {
1325 return f;
1326 }
1327 if (f->type() == "times-constant") {
1328 return make_shared<TimesConstant1>(f->func1_shared(), f->c() * c);
1329 }
1330 return make_shared<TimesConstant1>(f, c);
1331}
1332
1333Func1& newPlusConstFunction(Func1& f, double c)
1334{
1335 warn_deprecated("newPlusConstFunction(Func1&, double)",
1336 "To be removed after Cantera 3.0; replaced by shared pointer version.");
1337
1338 if (c == 0.0) {
1339 return f;
1340 }
1341 if (isConstant(f)) {
1342 double cc = f.c() + c;
1343 delete &f;
1344 return *(new Const1(cc));
1345 }
1346 if (f.type() == "plus-constant") {
1347 f.setC(f.c() + c);
1348 return f;
1349 }
1350 return *(new PlusConstant1(f, c));
1351}
1352
1353shared_ptr<Func1> newPlusConstFunction(shared_ptr<Func1> f, double c)
1354{
1355 if (c == 0.0) {
1356 return f;
1357 }
1358 if (isConstant(f)) {
1359 return make_shared<Const1>(f->c() + c);
1360 }
1361 if (f->type() == "plus-constant") {
1362 return make_shared<PlusConstant1>(f->func1_shared(), f->c() + c);
1363 }
1364 return make_shared<PlusConstant1>(f, c);
1365}
1366
1367}
Func1.h
Cantera::Arrhenius1
Implements a sum of Arrhenius terms.
Definition Func1.h:1291
Cantera::Arrhenius1::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:604
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition ctexceptions.h:66
Cantera::Composite1::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:794
Cantera::Composite1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:780
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::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:643
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::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:228
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::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:774
Cantera::Diff1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:755
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::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:275
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::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_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::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::Gaussian
A Gaussian.
Definition Func1.h:1152
Cantera::Gaussian::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:583
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::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition ctexceptions.h:195
Cantera::Periodic1
Implements a periodic function.
Definition Func1.h:1352
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::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:846
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::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::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:623
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::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:714
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::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::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:675
Cantera::Ratio1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:661
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::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:164
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::derivative
Func1 & derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:747
Cantera::Sum1::write
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:728
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::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::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::Tabulated1
Tabulated1(size_t n, const double *tvals, const double *fvals, const string &method="linear")
Constructor.
Definition Func1.cpp:429
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::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::duplicate
Func1 & duplicate() const override
Duplicate the current function.
Definition Func1.cpp:830
ctexceptions.h
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
global.h
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Cantera::demangle
string demangle(const std::type_info &type)
Convert a type name to a human readable string, using boost::core::demangle if available.
Definition global.cpp:213
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::warn_deprecated
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926
stringUtils.h
Contains declarations for string manipulation functions within Cantera.