Cantera  3.1.0a1
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
10
11using namespace std;
12
13namespace Cantera
14{
15
16string Func1::typeName() const
17{
18 return demangle(typeid(*this));
19}
20
21// Calls method eval to evaluate the function
22double Func1::operator()(double t) const
23{
24 return eval(t);
25}
26
27// Evaluate the function.
28double Func1::eval(double t) const
29{
30 return 0.0;
31}
32
33shared_ptr<Func1> Func1::derivative() const
34{
35 throw CanteraError("Func1::derivative",
36 "Needs to be overloaded by Func1 specialization.");
37}
38
39bool Func1::isIdentical(Func1& other) const
40{
41 if (type() != other.type() || m_c != other.m_c) {
42 return false;
43 }
44 if (m_f1) {
45 if (!other.m_f1) {
46 return false;
47 }
48 if (!m_f1->isIdentical(*other.m_f1)) {
49 return false;
50 }
51 }
52 if (m_f2) {
53 if (!other.m_f2) {
54 return false;
55 }
56 if (!m_f2->isIdentical(*other.m_f2)) {
57 return false;
58 }
59 }
60 return true;
61}
62
63//! accessor function for the returned constant
64double Func1::c() const
65{
66 return m_c;
67}
68
69int Func1::order() const
70{
71 return 3;
72}
73
74/*****************************************************************************/
75
76Sin1::Sin1(const vector<double>& params)
77{
78 if (params.size() != 1) {
79 throw CanteraError("Sin1::Sin1",
80 "Constructor needs exactly one parameter (frequency).");
81 }
82 m_c = params[0];
83}
84
85string Sin1::write(const string& arg) const
86{
87 if (m_c == 1.0) {
88 return fmt::format("\\sin({})", arg);
89 } else {
90 return fmt::format("\\sin({}{})", m_c, arg);
91 }
92}
93
94shared_ptr<Func1> Sin1::derivative() const
95{
96 auto c = make_shared<Cos1>(m_c);
97 return newTimesConstFunction(c, m_c);
98}
99
100/*****************************************************************************/
101
102Cos1::Cos1(const vector<double>& params)
103{
104 if (params.size() != 1) {
105 throw CanteraError("Cos1::Cos1",
106 "Constructor needs exactly one parameter (frequency).");
107 }
108 m_c = params[0];
109}
110
111shared_ptr<Func1> Cos1::derivative() const
112{
113 auto s = make_shared<Sin1>(m_c);
114 return newTimesConstFunction(s, -m_c);
115}
116
117string Cos1::write(const string& arg) const
118{
119 if (m_c == 1.0) {
120 return fmt::format("\\cos({})", arg);
121 } else {
122 return fmt::format("\\cos({}{})", m_c, arg);
123 }
124}
125
126/**************************************************************************/
127
128Exp1::Exp1(const vector<double>& params)
129{
130 if (params.size() != 1) {
131 throw CanteraError("Exp1::Exp1",
132 "Constructor needs exactly one parameter (exponent factor).");
133 }
134 m_c = params[0];
135}
136
137shared_ptr<Func1> Exp1::derivative() const
138{
139 auto f = make_shared<Exp1>(m_c);
140 if (m_c != 1.0) {
141 return newTimesConstFunction(f, m_c);
142 }
143 return f;
144}
145
146string Exp1::write(const string& arg) const
147{
148 if (m_c == 1.0) {
149 return fmt::format("\\exp({})", arg);
150 } else {
151 return fmt::format("\\exp({}{})", m_c, arg);
152 }
153}
154
155Log1::Log1(const vector<double>& params)
156{
157 if (params.size() != 1) {
158 throw CanteraError("Log1::Log1",
159 "Constructor needs exactly one parameter (factor).");
160 }
161 m_c = params[0];
162}
163
164shared_ptr<Func1> Log1::derivative() const
165{
166 auto f = make_shared<Pow1>(-1.);
167 if (m_c != 1.0) {
168 return newTimesConstFunction(f, m_c);
169 }
170 return f;
171}
172
173string Log1::write(const string& arg) const
174{
175 if (m_c == 1.0) {
176 return fmt::format("\\log({})", arg);
177 }
178 return fmt::format("\\log({}{})", m_c, arg);
179}
180
181/******************************************************************************/
182
183Pow1::Pow1(const vector<double>& params)
184{
185 if (params.size() != 1) {
186 throw CanteraError("Pow1::Pow1",
187 "Constructor needs exactly one parameter (exponent).");
188 }
189 m_c = params[0];
190}
191
192shared_ptr<Func1> Pow1::derivative() const
193{
194 if (m_c == 0.0) {
195 return make_shared<Const1>(0.0);
196 }
197 if (m_c == 1.0) {
198 return make_shared<Const1>(1.0);
199 }
200 auto f = make_shared<Pow1>(m_c - 1.);
201 return newTimesConstFunction(f, m_c);
202}
203
204/******************************************************************************/
205
206Const1::Const1(const vector<double>& params)
207{
208 if (params.size() != 1) {
209 throw CanteraError("Const1::Const1",
210 "Constructor needs exactly one parameter (constant).");
211 }
212 m_c = params[0];
213}
214
215Poly1::Poly1(const vector<double>& params)
216{
217 if (params.size() == 0) {
218 throw CanteraError("Poly1::Poly1",
219 "Constructor needs an array that is not empty.");
220 }
221 size_t n = params.size() - 1;
222 m_cpoly.resize(n + 1);
223 copy(params.data(), params.data() + m_cpoly.size(), m_cpoly.begin());
224}
225
226Fourier1::Fourier1(const vector<double>& params)
227{
228 if (params.size() < 4) {
229 throw CanteraError("Fourier1::Fourier1",
230 "Constructor needs an array with at least 4 entries.");
231 }
232 if (params.size() % 2 != 0) {
233 throw CanteraError("Fourier1::Fourier1",
234 "Constructor needs an array with an even number of entries.");
235 }
236 size_t n = params.size() / 2 - 1;
237 m_omega = params[n + 1];
238 m_a0_2 = 0.5 * params[0];
239 m_ccos.resize(n);
240 m_csin.resize(n);
241 copy(params.data() + 1, params.data() + n + 1, m_ccos.begin());
242 copy(params.data() + n + 2, params.data() + 2 * n + 2, m_csin.begin());
243}
244
245Gaussian1::Gaussian1(const vector<double>& params)
246{
247 if (params.size() != 3) {
248 throw CanteraError("Gaussian1::Gaussian1",
249 "Constructor needs exactly 3 parameters (amplitude, center, width).");
250 }
251 m_A = params[0];
252 m_t0 = params[1];
253 m_tau = params[2] / (2. * sqrt(log(2.)));
254}
255
256Arrhenius1::Arrhenius1(const vector<double>& params)
257{
258 if (params.size() < 3) {
259 throw CanteraError("Arrhenius1::Arrhenius1",
260 "Constructor needs an array with at least 3 entries.");
261 }
262 if (params.size() % 3 != 0) {
263 throw CanteraError("Arrhenius1::Arrhenius1",
264 "Constructor needs an array with multiples of 3 entries.");
265 }
266 size_t n = params.size() / 3;
267 m_A.resize(n);
268 m_b.resize(n);
269 m_E.resize(n);
270 for (size_t i = 0; i < n; i++) {
271 size_t loc = 3 * i;
272 m_A[i] = params[loc];
273 m_b[i] = params[loc + 1];
274 m_E[i] = params[loc + 2];
275 }
276}
277
278Tabulated1::Tabulated1(size_t n, const double* tvals, const double* fvals,
279 const string& method)
280{
281 m_tvec.resize(n);
282 std::copy(tvals, tvals + n, m_tvec.begin());
283 for (auto it = std::begin(m_tvec) + 1; it != std::end(m_tvec); it++) {
284 if (*(it - 1) > *it) {
285 throw CanteraError("Tabulated1::Tabulated1",
286 "time values are not increasing monotonically.");
287 }
288 }
289 m_fvec.resize(n);
290 std::copy(fvals, fvals + n, m_fvec.begin());
291 setMethod(method);
292}
293
294Tabulated1::Tabulated1(const vector<double>& params) : m_isLinear(true)
295{
296 if (params.size() < 4) {
297 throw CanteraError("Tabulated1::Tabulated1",
298 "Constructor needs an array with at least 4 entries.");
299 }
300 if (params.size() % 2 != 0) {
301 throw CanteraError("Tabulated1::Tabulated1",
302 "Constructor needs an array with an even number of entries.");
303 }
304 size_t n = params.size() / 2;
305 m_tvec.resize(n);
306 copy(params.data(), params.data() + n, m_tvec.begin());
307 for (auto it = std::begin(m_tvec) + 1; it != std::end(m_tvec); it++) {
308 if (*(it - 1) > *it) {
309 throw CanteraError("Tabulated1::Tabulated1",
310 "Time values are not monotonically increasing.");
311 }
312 }
313 m_fvec.resize(n);
314 copy(params.data() + n, params.data() + 2 * n, m_fvec.begin());
315}
316
317void Tabulated1::setMethod(const string& method)
318{
319 if (method == "linear") {
320 m_isLinear = true;
321 } else if (method == "previous") {
322 m_isLinear = false;
323 } else {
324 throw NotImplementedError("Tabulated1::setMethod",
325 "Interpolation method '{}' is not implemented.", method);
326 }
327}
328
329double Tabulated1::eval(double t) const {
330 size_t siz = m_tvec.size();
331 // constructor ensures that siz > 0
332 if (t <= m_tvec[0]) {
333 return m_fvec[0];
334 } else if (t >= m_tvec[siz-1]) {
335 return m_fvec[siz-1];
336 } else {
337 size_t ix = 0;
338 while (t > m_tvec[ix+1]) {
339 ix++;
340 }
341 if (m_isLinear) {
342 double df = m_fvec[ix+1] - m_fvec[ix];
343 df /= m_tvec[ix+1] - m_tvec[ix];
344 df *= t - m_tvec[ix];
345 return m_fvec[ix] + df;
346 } else {
347 return m_fvec[ix];
348 }
349 }
350}
351
352shared_ptr<Func1> Tabulated1::derivative() const {
353 vector<double> tvec;
354 vector<double> dvec;
355 size_t siz = m_tvec.size();
356 if (m_isLinear) {
357 // piece-wise continuous derivative
358 if (siz>1) {
359 for (size_t i=1; i<siz; i++) {
360 double d = (m_fvec[i] - m_fvec[i-1]) /
361 (m_tvec[i] - m_tvec[i-1]);
362 tvec.push_back(m_tvec[i-1]);
363 dvec.push_back(d);
364 }
365 }
366 tvec.push_back(m_tvec[siz-1]);
367 dvec.push_back(0.);
368 } else {
369 // derivative is zero (ignoring discontinuities)
370 tvec.push_back(m_tvec[0]);
371 tvec.push_back(m_tvec[siz-1]);
372 dvec.push_back(0.);
373 dvec.push_back(0.);
374 }
375 return make_shared<Tabulated1>(tvec.size(), &tvec[0], &dvec[0], "previous");
376}
377
378/******************************************************************************/
379
380string Func1::write(const string& arg) const
381{
382 return fmt::format("\\mathrm{{{}}}({})", type(), arg);
383}
384
385string Pow1::write(const string& arg) const
386{
387 if (m_c == 0.5) {
388 return "\\sqrt{" + arg + "}";
389 }
390 if (m_c == -0.5) {
391 return "\\frac{1}{\\sqrt{" + arg + "}}";
392 }
393 if (m_c != 1.0) {
394 return fmt::format("\\left({}\\right)^{{{}}}", arg, m_c);
395 } else {
396 return arg;
397 }
398}
399
400string Tabulated1::write(const string& arg) const
401{
402 return fmt::format("\\mathrm{{Tabulated}}({})", arg);
403}
404
405string Const1::write(const string& arg) const
406{
407 return fmt::format("{}", m_c);
408}
409
410string Ratio1::write(const string& arg) const
411{
412 return "\\frac{" + m_f1->write(arg) + "}{"
413 + m_f2->write(arg) + "}";
414}
415
416shared_ptr<Func1> Ratio1::derivative() const {
417 auto a1 = newProdFunction(m_f1_shared->derivative(), m_f2_shared);
418 auto a2 = newProdFunction(m_f1_shared, m_f2_shared->derivative());
419 auto s = newDiffFunction(a1, a2);
420 auto p = newProdFunction(m_f2_shared, m_f2_shared);
421 return newRatioFunction(s, p);
422}
423
424string Product1::write(const string& arg) const
425{
426 string s = m_f1->write(arg);
427 if (m_f1->order() < order()) {
428 s = "\\left(" + s + "\\right)";
429 }
430 string s2 = m_f2->write(arg);
431 if (m_f2->order() < order()) {
432 s2 = "\\left(" + s2 + "\\right)";
433 }
434 return s + " " + s2;
435}
436
437shared_ptr<Func1> Product1::derivative() const {
438 auto a1 = newProdFunction(m_f1_shared, m_f2_shared->derivative());
439 auto a2 = newProdFunction(m_f2_shared, m_f1_shared->derivative());
440 return newSumFunction(a1, a2);
441}
442
443string Sum1::write(const string& arg) const
444{
445 string s1 = m_f1->write(arg);
446 string s2 = m_f2->write(arg);
447 if (s2[0] == '-') {
448 return s1 + " - " + s2.substr(1,s2.size());
449 } else {
450 return s1 + " + " + s2;
451 }
452}
453
454string Diff1::write(const string& arg) const
455{
456 string s1 = m_f1->write(arg);
457 string s2 = m_f2->write(arg);
458 if (s2[0] == '-') {
459 return s1 + " + " + s2.substr(1,s2.size());
460 } else {
461 return s1 + " - " + s2;
462 }
463}
464
465string Composite1::write(const string& arg) const
466{
467 string g = m_f2->write(arg);
468 return m_f1->write(g);
469}
470
471shared_ptr<Func1> Composite1::derivative() const {
472 auto d1 = m_f1_shared->derivative();
473 auto d2 = m_f2_shared->derivative();
474 auto d3 = newCompositeFunction(d1, m_f2_shared);
475 return newProdFunction(d3, d2);
476}
477
478string TimesConstant1::write(const string& arg) const
479{
480 string s = m_f1->write(arg);
481 if (m_f1->order() < order()) {
482 s = "\\left(" + s + "\\right)";
483 }
484 if (m_c == 1.0) {
485 return s;
486 }
487 if (m_c == -1.0) {
488 return "-"+s;
489 }
490 char n = s[0];
491 if (n >= '0' && n <= '9') {
492 s = "\\left(" + s + "\\right)";
493 }
494 return fmt::format("{}{}", m_c, s);
495}
496
497string PlusConstant1::write(const string& arg) const
498{
499 if (m_c == 0.0) {
500 return m_f1->write(arg);
501 }
502 return fmt::format("{} + {}", m_f1->write(arg), m_c);
503}
504
505
506double Func1::isProportional(TimesConstant1& other)
507{
508 if (isIdentical(*other.func1_shared())) {
509 return other.c();
510 }
511 return 0.0;
512}
513double Func1::isProportional(Func1& other)
514{
515 if (isIdentical(other)) {
516 return 1.0;
517 } else {
518 return 0.0;
519 }
520}
521
522namespace { // restrict scope of helper functions to local translation unit
523
524bool isConstant(const shared_ptr<Func1>& f)
525{
526 return f->type() == "constant";
527}
528
529bool isZero(const shared_ptr<Func1>& f)
530{
531 return f->type() == "constant" && f->c() == 0.0;
532}
533
534bool isOne(const shared_ptr<Func1>& f)
535{
536 return f->type() == "constant" && f->c() == 1.0;
537}
538
539bool isTimesConst(const shared_ptr<Func1>& f)
540{
541 return f->type() == "times-constant";
542}
543
544bool isExp(const shared_ptr<Func1>& f)
545{
546 return f->type() == "exp";
547}
548
549bool isPow(const shared_ptr<Func1>& f)
550{
551 return f->type() == "pow";
552}
553
554} // end unnamed namespace
555
556shared_ptr<Func1> newSumFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
557{
558 if (f1->isIdentical(*f2)) {
559 return newTimesConstFunction(f1, 2.);
560 }
561 if (isZero(f1)) {
562 return f2;
563 }
564 if (isZero(f2)) {
565 return f1;
566 }
567 double c = f1->isProportional(*f2);
568 if (c != 0.) {
569 if (c == -1.) {
570 return make_shared<Const1>(0.);
571 }
572 return newTimesConstFunction(f1, c + 1.);
573 }
574 return make_shared<Sum1>(f1, f2);
575}
576
577shared_ptr<Func1> newDiffFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
578{
579 if (isZero(f2)) {
580 return f1;
581 }
582 if (isZero(f1)) {
583 return newTimesConstFunction(f2, -1.);
584 }
585
586 if (f1->isIdentical(*f2)) {
587 return make_shared<Const1>(0.);
588 }
589 double c = f1->isProportional(*f2);
590 if (c != 0.) {
591 if (c == 1.0) {
592 return make_shared<Const1>(0.);
593 } else {
594 return newTimesConstFunction(f1, 1. - c);
595 }
596 }
597 return make_shared<Diff1>(f1, f2);
598}
599
600shared_ptr<Func1> newProdFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
601{
602 if (isOne(f1)) {
603 return f2;
604 }
605 if (isOne(f2)) {
606 return f1;
607 }
608 if (isZero(f1) || isZero(f2)) {
609 return make_shared<Const1>(0.);
610 }
611 if (isConstant(f1) && isConstant(f2)) {
612 return make_shared<Const1>(f1->c() * f2->c());
613 }
614 if (isConstant(f1)) {
615 return newTimesConstFunction(f2, f1->c());
616 }
617 if (isConstant(f2)) {
618 return newTimesConstFunction(f1, f2->c());
619 }
620 if (isPow(f1) && isPow(f2)) {
621 return make_shared<Pow1>(f1->c() + f2->c());
622 }
623 if (isExp(f1) && isExp(f2)) {
624 return make_shared<Exp1>(f1->c() + f2->c());
625 }
626
627 bool tc1 = isTimesConst(f1);
628 bool tc2 = isTimesConst(f2);
629
630 if (tc1 || tc2) {
631 double c1 = 1.0;
632 auto ff1 = f1;
633 if (tc1) {
634 c1 = f1->c();
635 ff1 = f1->func1_shared();
636 }
637 double c2 = 1.0;
638 auto ff2 = f2;
639 if (tc2) {
640 c2 = f2->c();
641 ff2 = f2->func1_shared();
642 }
643 auto p = newProdFunction(ff1, ff2);
644
645 if (c1 * c2 != 1.0) {
646 return newTimesConstFunction(p, c1 * c2);
647 }
648 return p;
649 }
650 return make_shared<Product1>(f1, f2);
651}
652
653shared_ptr<Func1> newRatioFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
654{
655 if (isOne(f2)) {
656 return f1;
657 }
658 if (isZero(f1)) {
659 return make_shared<Const1>(0.);
660 }
661 if (f1->isIdentical(*f2)) {
662 return make_shared<Const1>(1.);
663 }
664 if (isPow(f1) && isPow(f2)) {
665 return make_shared<Pow1>(f1->c() - f2->c());
666 }
667 if (isExp(f1) && isExp(f2)) {
668 return make_shared<Exp1>(f1->c() - f2->c());
669 }
670 return make_shared<Ratio1>(f1, f2);
671}
672
673shared_ptr<Func1> newCompositeFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
674{
675 if (isZero(f1)) {
676 return make_shared<Const1>(0.0);
677 }
678 if (isConstant(f1)) {
679 return f1;
680 }
681 if (isPow(f1) && f1->c() == 1.0) {
682 return f2;
683 }
684 if (isPow(f1) && f1->c() == 0.0) {
685 return make_shared<Const1>(1.);
686 }
687 if (isPow(f1) && isPow(f2)) {
688 return make_shared<Pow1>(f1->c() * f2->c());
689 }
690 return make_shared<Composite1>(f1, f2);
691}
692
693shared_ptr<Func1> newTimesConstFunction(shared_ptr<Func1> f, double c)
694{
695 if (c == 0.0) {
696 return make_shared<Const1>(0.0);
697 }
698 if (c == 1.0) {
699 return f;
700 }
701 if (f->type() == "times-constant") {
702 return make_shared<TimesConstant1>(f->func1_shared(), f->c() * c);
703 }
704 return make_shared<TimesConstant1>(f, c);
705}
706
707shared_ptr<Func1> newPlusConstFunction(shared_ptr<Func1> f, double c)
708{
709 if (c == 0.0) {
710 return f;
711 }
712 if (isConstant(f)) {
713 return make_shared<Const1>(f->c() + c);
714 }
715 if (f->type() == "plus-constant") {
716 return make_shared<PlusConstant1>(f->func1_shared(), f->c() + c);
717 }
718 return make_shared<PlusConstant1>(f, c);
719}
720
721}
Base class for exceptions thrown by Cantera classes.
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:471
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:465
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:405
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:111
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:117
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:454
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:137
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:146
Base class for 'functor' classes that evaluate a function of one variable.
Definition Func1.h:75
string typeName() const
Returns a string with the class name of the functor.
Definition Func1.cpp:16
virtual shared_ptr< Func1 > derivative() const
Creates a derivative to the current function.
Definition Func1.cpp:33
virtual string type() const
Returns a string describing the type of the function.
Definition Func1.h:97
virtual double eval(double t) const
Evaluate the function.
Definition Func1.cpp:28
shared_ptr< Func1 > func1_shared() const
Accessor function for m_f1_shared.
Definition Func1.h:146
virtual string write(const string &arg) const
Write LaTeX string describing function.
Definition Func1.cpp:380
double operator()(double t) const
Calls method eval to evaluate the function.
Definition Func1.cpp:22
virtual int order() const
Return the order of the function, if it makes sense.
Definition Func1.cpp:69
bool isIdentical(Func1 &other) const
Routine to determine if two functions are the same.
Definition Func1.cpp:39
double c() const
Accessor function for the stored constant.
Definition Func1.cpp:64
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:164
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:173
An error indicating that an unimplemented function has been called.
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:497
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:192
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:385
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:437
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:557
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:424
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:416
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:410
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:94
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:85
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:443
double eval(double t) const override
Evaluate the function.
Definition Func1.cpp:329
shared_ptr< Func1 > derivative() const override
Creates a derivative to the current function.
Definition Func1.cpp:352
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:400
void setMethod(const string &method)
Set the interpolation method.
Definition Func1.cpp:317
vector< double > m_tvec
Vector of time values.
Definition Func1.h:391
bool m_isLinear
Boolean indicating interpolation method.
Definition Func1.h:393
vector< double > m_fvec
Vector of function values.
Definition Func1.h:392
Tabulated1(size_t n, const double *tvals, const double *fvals, const string &method="linear")
Constructor.
Definition Func1.cpp:278
Implements the product of a function and a constant.
Definition Func1.h:570
int order() const override
Return the order of the function, if it makes sense.
Definition Func1.h:615
string write(const string &arg) const override
Write LaTeX string describing function.
Definition Func1.cpp:478
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
shared_ptr< Func1 > newCompositeFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Composite of two functions.
Definition Func1.cpp:673
shared_ptr< Func1 > newProdFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Product of two functions.
Definition Func1.cpp:600
shared_ptr< Func1 > newDiffFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Difference of two functions.
Definition Func1.cpp:577
shared_ptr< Func1 > newTimesConstFunction(shared_ptr< Func1 > f, double c)
Product of function and constant.
Definition Func1.cpp:693
shared_ptr< Func1 > newSumFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Sum of two functions.
Definition Func1.cpp:556
shared_ptr< Func1 > newRatioFunction(shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
Ratio of two functions.
Definition Func1.cpp:653
shared_ptr< Func1 > newPlusConstFunction(shared_ptr< Func1 > f, double c)
Sum of function and constant.
Definition Func1.cpp:707
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
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Contains declarations for string manipulation functions within Cantera.