Cantera  3.1.0a2
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
16{
17 return m_area;
18}
19
21{
22 m_area = a;
23}
24
26 m_kinetics = kin;
27 if (kin == nullptr) {
28 m_thermo = nullptr;
29 return;
30 }
31
32 m_thermo = dynamic_cast<SurfPhase*>(&kin->thermo(0));
33 if (m_thermo == nullptr) {
34 throw CanteraError("ReactorSurface::setKinetics",
35 "Specified kinetics manager does not represent a surface "
36 "kinetics mechanism.");
37 }
38 m_cov.resize(m_thermo->nSpecies());
39 m_thermo->getCoverages(m_cov.data());
40}
41
43{
44 m_reactor = reactor;
45}
46
47void ReactorSurface::setCoverages(const double* cov)
48{
49 copy(cov, cov + m_cov.size(), m_cov.begin());
50}
51
53{
54 m_thermo->setCoveragesByName(cov);
55 m_thermo->getCoverages(m_cov.data());
56}
57
58void ReactorSurface::setCoverages(const string& cov)
59{
60 m_thermo->setCoveragesByName(cov);
61 m_thermo->getCoverages(m_cov.data());
62}
63
64void ReactorSurface::getCoverages(double* cov) const
65{
66 copy(m_cov.begin(), m_cov.end(), cov);
67}
68
70{
71 m_thermo->setTemperature(m_reactor->temperature());
72 m_thermo->setCoveragesNoNorm(m_cov.data());
73}
74
76{
77 if (i >= m_kinetics->nReactions()) {
78 throw CanteraError("ReactorSurface::addSensitivityReaction",
79 "Reaction number out of range ({})", i);
80 }
81 size_t p = m_reactor->network().registerSensitivityParameter(
82 m_kinetics->reaction(i)->equation(), 1.0, 1.0);
83 m_params.emplace_back(
84 SensitivityParameter{i, p, 1.0, SensParameterType::reaction});
85}
86
88{
89 for (auto& p : m_params) {
90 p.value = m_kinetics->multiplier(p.local);
91 m_kinetics->setMultiplier(p.local, p.value*params[p.global]);
92 }
93}
94
96{
97 for (auto& p : m_params) {
98 m_kinetics->setMultiplier(p.local, p.value);
99 }
100}
101
102}
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:1360
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:684
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:1369
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:51
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...
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.
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.
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:564
map< string, double > Composition
Map from string names to doubles.
Definition ct_defs.h:177