Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
Loading...
Searching...
No Matches
ReactionData.h
Go to the documentation of this file.
1
/**
2
* @file ReactionData.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_REACTIONDATA_H
9
#define CT_REACTIONDATA_H
10
11
#include "
cantera/base/ct_defs.h
"
12
#include "
cantera/base/ctexceptions.h
"
13
14
namespace
Cantera
15
{
16
17
class
ThermoPhase
;
18
class
Kinetics
;
19
20
21
//! Data container holding shared data used for ReactionRate calculation
22
/**
23
* The base class defines variables and methods used by all specializations.
24
* @ingroup reactionGroup
25
*/
26
struct
ReactionData
27
{
28
ReactionData() =
default
;
29
30
virtual
~ReactionData() =
default
;
31
32
//! Update data container based on temperature *T*
33
/**
34
* Only used in conjunction with MultiRateBase::evalSingle / ReactionRate::eval.
35
* This method allows for testing of a reaction rate expression outside of
36
* Kinetics reaction rate evaluators.
37
*/
38
virtual
void
update
(
double
T) {
39
temperature
= T;
40
logT
= std::log(T);
41
recipT
= 1./T;
42
}
43
44
//! Update data container based on temperature *T* and an *extra* parameter
45
/**
46
* Only used in conjunction with MultiRateBase::evalSingle / ReactionRate::eval.
47
* This method allows for testing of a reaction rate expression outside of
48
* Kinetics reaction rate evaluators.
49
*/
50
virtual
void
update
(
double
T,
double
extra) {
51
throw
NotImplementedError
(
"ReactionData::update"
,
52
"ReactionData type does not use extra scalar argument."
);
53
}
54
55
//! Update data container based on temperature *T* and a vector parameter *extra*
56
/**
57
* Only used in conjunction with MultiRateBase::evalSingle / ReactionRate::eval.
58
* This method allows for testing of a reaction rate expression outside of
59
* Kinetics reaction rate evaluators.
60
*
61
* @warning This method is an experimental part of the %Cantera API and
62
* may be changed or removed without notice.
63
*/
64
virtual
void
update
(
double
T, span<const double> extra) {
65
throw
NotImplementedError
(
"ReactionData::update"
,
66
"ReactionData type does not use extra vector argument."
);
67
}
68
69
//! Update data container based on thermodynamic phase state
70
/**
71
* This update mechanism is used by Kinetics reaction rate evaluators.
72
* @returns A boolean element indicating whether the `evalFromStruct` method
73
* needs to be called (assuming previously-calculated values were cached)
74
*/
75
virtual
bool
update
(
const
ThermoPhase
& phase,
const
Kinetics
& kin) = 0;
76
77
//! Perturb temperature of data container
78
/**
79
* The method is used for the evaluation of numerical derivatives.
80
* @param deltaT relative temperature perturbation
81
*/
82
void
perturbTemperature
(
double
deltaT) {
83
if
(
m_temperature_buf
> 0.) {
84
throw
CanteraError
(
"ReactionData::perturbTemperature"
,
85
"Cannot apply another perturbation as state is already perturbed."
);
86
}
87
m_temperature_buf
=
temperature
;
88
ReactionData::update
(
temperature
* (1. + deltaT));
89
}
90
91
//! Restore data container after a perturbation
92
virtual
void
restore
() {
93
// only restore if there is a valid buffered value
94
if
(
m_temperature_buf
< 0.) {
95
return
;
96
}
97
ReactionData::update
(
m_temperature_buf
);
98
m_temperature_buf
= -1.;
99
}
100
101
//! Update array sizes that depend on number of species, reactions and phases
102
virtual
void
resize
(
Kinetics
& kin) {}
103
104
//! Force shared data and reaction rates to be updated next time. This is called by
105
//! functions that change quantities affecting rate calculations that are normally
106
//! assumed to be constant, like the reaction rate parameters or the number of
107
//! reactions.
108
virtual
void
invalidateCache
() {
109
temperature
= NAN;
110
}
111
112
double
temperature
= 1.0;
//!< temperature
113
double
logT
= 0.0;
//!< logarithm of temperature
114
double
recipT
= 1.0;
//!< inverse of temperature
115
116
protected
:
117
double
m_temperature_buf
= -1.0;
//!< buffered temperature
118
};
119
120
}
121
122
#endif
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition
ctexceptions.h:66
Cantera::Kinetics
Public interface for kinetics managers.
Definition
Kinetics.h:124
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition
ctexceptions.h:209
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition
ThermoPhase.h:391
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:595
Cantera::ReactionData::update
virtual void update(double T, span< const double > extra)
Update data container based on temperature T and a vector parameter extra.
Definition
ReactionData.h:64
Cantera::ReactionData::recipT
double recipT
inverse of temperature
Definition
ReactionData.h:114
Cantera::ReactionData::m_temperature_buf
double m_temperature_buf
buffered temperature
Definition
ReactionData.h:117
Cantera::ReactionData::update
virtual void update(double T, double extra)
Update data container based on temperature T and an extra parameter.
Definition
ReactionData.h:50
Cantera::ReactionData::update
virtual bool update(const ThermoPhase &phase, const Kinetics &kin)=0
Update data container based on thermodynamic phase state.
Cantera::ReactionData::perturbTemperature
void perturbTemperature(double deltaT)
Perturb temperature of data container.
Definition
ReactionData.h:82
Cantera::ReactionData::update
virtual void update(double T)
Update data container based on temperature T.
Definition
ReactionData.h:38
Cantera::ReactionData::temperature
double temperature
temperature
Definition
ReactionData.h:112
Cantera::ReactionData::logT
double logT
logarithm of temperature
Definition
ReactionData.h:113
Cantera::ReactionData::restore
virtual void restore()
Restore data container after a perturbation.
Definition
ReactionData.h:92
Cantera::ReactionData::invalidateCache
virtual void invalidateCache()
Force shared data and reaction rates to be updated next time.
Definition
ReactionData.h:108
Cantera::ReactionData::resize
virtual void resize(Kinetics &kin)
Update array sizes that depend on number of species, reactions and phases.
Definition
ReactionData.h:102
include
cantera
kinetics
ReactionData.h
Generated by
1.17.0