Cantera  3.1.0b1
Loading...
Searching...
No Matches
ReactorSurface.cpp
Go to the documentation of this file.
1//! @file ReactorSurface.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
11
12namespace Cantera
13{
14
15bool ReactorSurface::setDefaultName(map<string, int>& counts)
16{
17 if (m_defaultNameSet) {
18 return false;
19 }
20 m_defaultNameSet = true;
21 if (m_name == "(none)" || m_name == "") {
22 m_name = fmt::format("{}_{}", type(), counts[type()]);
23 }
24 counts[type()]++;
25 return true;
26}
27
29{
30 return m_area;
31}
32
34{
35 m_area = a;
36}
37
39 m_kinetics = kin;
40 if (kin == nullptr) {
41 m_thermo = nullptr;
42 return;
43 }
44
45 m_thermo = dynamic_cast<SurfPhase*>(&kin->thermo(0));
46 if (m_thermo == nullptr) {
47 throw CanteraError("ReactorSurface::setKinetics",
48 "Specified kinetics manager does not represent a surface "
49 "kinetics mechanism.");
50 }
51 m_cov.resize(m_thermo->nSpecies());
52 m_thermo->getCoverages(m_cov.data());
53}
54
56{
57 m_reactor = reactor;
58}
59
60void ReactorSurface::setCoverages(const double* cov)
61{
62 copy(cov, cov + m_cov.size(), m_cov.begin());
63}
64
66{
67 m_thermo->setCoveragesByName(cov);
68 m_thermo->getCoverages(m_cov.data());
69}
70
71void ReactorSurface::setCoverages(const string& cov)
72{
73 m_thermo->setCoveragesByName(cov);
74 m_thermo->getCoverages(m_cov.data());
75}
76
77void ReactorSurface::getCoverages(double* cov) const
78{
79 copy(m_cov.begin(), m_cov.end(), cov);
80}
81
83{
84 m_thermo->setTemperature(m_reactor->temperature());
85 m_thermo->setCoveragesNoNorm(m_cov.data());
86}
87
89{
90 if (i >= m_kinetics->nReactions()) {
91 throw CanteraError("ReactorSurface::addSensitivityReaction",
92 "Reaction number out of range ({})", i);
93 }
94 size_t p = m_reactor->network().registerSensitivityParameter(
95 m_kinetics->reaction(i)->equation(), 1.0, 1.0);
96 m_params.emplace_back(
97 SensitivityParameter{i, p, 1.0, SensParameterType::reaction});
98}
99
101{
102 for (auto& p : m_params) {
103 p.value = m_kinetics->multiplier(p.local);
104 m_kinetics->setMultiplier(p.local, p.value*params[p.global]);
105 }
106}
107
109{
110 for (auto& p : m_params) {
111 m_kinetics->setMultiplier(p.local, p.value);
112 }
113}
114
115}
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Header file for class ReactorSurface.
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Base class for exceptions thrown by Cantera classes.
Public interface for kinetics managers.
Definition Kinetics.h:125
double multiplier(size_t i) const
The current value of the multiplier for reaction i.
Definition Kinetics.h:1369
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
Definition Kinetics.h:242
shared_ptr< Reaction > reaction(size_t i)
Return the Reaction object for reaction i.
Definition Kinetics.cpp:740
size_t nReactions() const
Number of reactions in the reaction mechanism.
Definition Kinetics.h:152
virtual void setMultiplier(size_t i, double f)
Set the multiplier for reaction i to f.
Definition Kinetics.h:1378
size_t nSpecies() const
Returns the number of species in the phase.
Definition Phase.h:231
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
Definition Phase.h:623
Base class for stirred reactors.
Definition ReactorBase.h:49
double temperature() const
Returns the current temperature (K) of the reactor's contents.
ReactorNet & network()
The ReactorNet that this reactor belongs to.
size_t registerSensitivityParameter(const string &name, double value, double scale)
Used by Reactor and Wall objects to register the addition of sensitivity parameters so that the React...
bool m_defaultNameSet
true if default name has been previously set.
double area() const
Returns the surface area [m^2].
void setReactor(ReactorBase *reactor)
Set the reactor that this Surface interacts with.
void setSensitivityParameters(const double *params)
Set reaction rate multipliers.
virtual string type() const
String indicating the wall model implemented.
bool setDefaultName(map< string, int > &counts)
Set the default name of a wall. Returns false if it was previously set.
void getCoverages(double *cov) const
Get the surface coverages.
void setArea(double a)
Set the surface area [m^2].
void resetSensitivityParameters()
Set reaction rate multipliers back to their initial values.
void syncState()
Set the coverages and temperature in the surface phase object to the values for this surface.
string m_name
Reactor surface name.
void setCoverages(const double *cov)
Set the surface coverages.
void setKinetics(Kinetics *kin)
Set the InterfaceKinetics object for this surface.
void addSensitivityReaction(size_t i)
Enable calculation of sensitivities with respect to the rate constant for reaction i.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition SurfPhase.h:98
void setCoveragesNoNorm(const double *theta)
Set the surface site fractions to a specified state.
void getCoverages(double *theta) const
Return a vector of surface coverages.
void setCoveragesByName(const string &cov)
Set the coverages from a string of colon-separated name:value pairs.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
map< string, double > Composition
Map from string names to doubles.
Definition ct_defs.h:177