Cantera 2.6.0
Custom.h
Go to the documentation of this file.
1/**
2 * @file Custom.h
3 *
4 * @warning This file is an experimental part of the %Cantera API and
5 * may be changed or removed without notice.
6 */
7
8// This file is part of Cantera. See License.txt in the top-level directory or
9// at https://cantera.org/license.txt for license and copyright information.
10
11#ifndef CT_CUSTOM_H
12#define CT_CUSTOM_H
13
15#include "cantera/base/Units.h"
17#include "ReactionRate.h"
18#include "MultiRate.h"
19
20namespace Cantera
21{
22
23class AnyValue;
24class AnyMap;
25class Func1;
26
27
28//! Custom reaction rate depending only on temperature
29/**
30 * The rate expression is provided by a Func1 object taking a single
31 * argument (temperature) and does not use a formalized parameterization.
32 *
33 * @warning This class is an experimental part of the %Cantera API and
34 * may be changed or removed without notice.
35 */
36class CustomFunc1Rate final : public ReactionRate
37{
38public:
40 CustomFunc1Rate(const AnyMap& node, const UnitStack& rate_units)
42 {
43 setParameters(node, rate_units);
44 }
45
46 unique_ptr<MultiRateBase> newMultiRate() const override {
47 return unique_ptr<MultiRateBase>(new MultiRate<CustomFunc1Rate, ArrheniusData>);
48 }
49
50 const std::string type() const override { return "custom-rate-function"; }
51
52 void getParameters(AnyMap& rateNode, const Units& rate_units=Units(0.)) const;
54
55 virtual void validate(const std::string& equation, const Kinetics& kin) override;
56
57 //! Update information specific to reaction
58 /*!
59 * @param shared_data data shared by all reactions of a given type
60 */
61 double evalFromStruct(const ArrheniusData& shared_data) const;
62
63 //! Set custom rate
64 /**
65 * The call to the Func1 object takes a single argument (temperature) and
66 * does not depend on parameters handled in C++.
67 */
68 void setRateFunction(shared_ptr<Func1> f);
69
70protected:
71 shared_ptr<Func1> m_ratefunc;
72};
73
74
75}
76
77#endif
Header for reaction rates that involve Arrhenius-type kinetics.
Header for unit conversion utilities, which are used to translate user input from input files (See In...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Custom reaction rate depending only on temperature.
Definition: Custom.h:37
unique_ptr< MultiRateBase > newMultiRate() const override
Create a rate evaluator for reactions of a particular derived type.
Definition: Custom.h:46
const std::string type() const override
String identifying reaction rate specialization.
Definition: Custom.h:50
virtual void validate(const std::string &equation, const Kinetics &kin) override
Validate the reaction rate expression.
Definition: Custom.cpp:22
double evalFromStruct(const ArrheniusData &shared_data) const
Update information specific to reaction.
Definition: Custom.cpp:30
void setRateFunction(shared_ptr< Func1 > f)
Set custom rate.
Definition: Custom.cpp:17
Public interface for kinetics managers.
Definition: Kinetics.h:114
A class template handling ReactionRate specializations.
Definition: MultiRate.h:21
Abstract base class for reaction rate definitions; this base class is used by user-facing APIs to acc...
Definition: ReactionRate.h:45
virtual void setParameters(const AnyMap &node, const UnitStack &units)
Set parameters.
Definition: ReactionRate.h:88
virtual void getParameters(AnyMap &node) const
Get parameters.
Definition: ReactionRate.h:172
A representation of the units associated with a dimensional quantity.
Definition: Units.h:30
This file contains definitions of constants, types and terms that are used in internal routines and a...
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
Data container holding shared data specific to ArrheniusRate.
Definition: Arrhenius.h:30
Unit aggregation utility.
Definition: Units.h:99