| Cantera 3.0.0

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
6#include "cantera/zeroD/ReactorSurface.h"
7#include "cantera/zeroD/ReactorNet.h"
8#include "cantera/thermo/SurfPhase.h"
9#include "cantera/kinetics/Kinetics.h"
10#include "cantera/kinetics/Reaction.h"
11
12 namespace Cantera
13{
14
15 double ReactorSurface::area() const
16{
17 return m_area;
18}
19
20 void ReactorSurface::setArea(double a)
21{
22 m_area = a;
23}
24
25 void ReactorSurface::setKinetics(Kinetics* kin) {
26 m_kinetics = kin;
27 if (kin == nullptr) {
28 m_thermo = nullptr;
29 return;
30 }
31
32 m_thermo = dynamic_cast<SurfPhase*>(&kin->thermo(kin->reactionPhaseIndex()));
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
42 void ReactorSurface::setReactor(ReactorBase* reactor)
43{
44 m_reactor = reactor;
45}
46
47 void ReactorSurface::setCoverages(const double* cov)
48{
49 copy(cov, cov + m_cov.size(), m_cov.begin());
50}
51
52 void ReactorSurface::setCoverages(const Composition& cov)
53{
54 m_thermo->setCoveragesByName(cov);
55 m_thermo->getCoverages(m_cov.data());
56}
57
58 void ReactorSurface::setCoverages(const string& cov)
59{
60 m_thermo->setCoveragesByName(cov);
61 m_thermo->getCoverages(m_cov.data());
62}
63
64 void ReactorSurface::getCoverages(double* cov) const
65{
66 copy(m_cov.begin(), m_cov.end(), cov);
67}
68
69 void ReactorSurface::syncState()
70{
71 m_thermo->setTemperature(m_reactor->temperature());
72 m_thermo->setCoveragesNoNorm(m_cov.data());
73}
74
75 void ReactorSurface::addSensitivityReaction(size_t i)
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
87 void ReactorSurface::setSensitivityParameters(const double* params)
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
95 void ReactorSurface::resetSensitivityParameters()
96{
97 for (auto& p : m_params) {
98 m_kinetics->setMultiplier(p.local, p.value);
99 }
100}
101
102}
Kinetics.h
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Reaction.h
ReactorNet.h
ReactorSurface.h
Header file for class ReactorSurface.
SurfPhase.h
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition ctexceptions.h:66
Cantera::Kinetics
Public interface for kinetics managers.
Definition Kinetics.h:126
Cantera::Kinetics::reactionPhaseIndex
size_t reactionPhaseIndex() const
Phase where the reactions occur.
Definition Kinetics.h:235
Cantera::Kinetics::multiplier
double multiplier(size_t i) const
The current value of the multiplier for reaction i.
Definition Kinetics.h:1434
Cantera::Kinetics::thermo
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
Definition Kinetics.h:254
Cantera::Kinetics::reaction
shared_ptr< Reaction > reaction(size_t i)
Return the Reaction object for reaction i.
Definition Kinetics.cpp:784
Cantera::Kinetics::nReactions
size_t nReactions() const
Number of reactions in the reaction mechanism.
Definition Kinetics.h:153
Cantera::Kinetics::setMultiplier
virtual void setMultiplier(size_t i, double f)
Set the multiplier for reaction i to f.
Definition Kinetics.h:1443
Cantera::Phase::nSpecies
size_t nSpecies() const
Returns the number of species in the phase.
Definition Phase.h:245
Cantera::Phase::setTemperature
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
Definition Phase.h:728
Cantera::ReactorBase
Base class for stirred reactors.
Definition ReactorBase.h:50
Cantera::ReactorBase::temperature
double temperature() const
Returns the current temperature (K) of the reactor's contents.
Definition ReactorBase.h:209
Cantera::ReactorBase::network
ReactorNet & network()
The ReactorNet that this reactor belongs to.
Definition ReactorBase.cpp:86
Cantera::ReactorNet::registerSensitivityParameter
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...
Definition ReactorNet.cpp:479
Cantera::ReactorSurface::area
double area() const
Returns the surface area [m^2].
Definition ReactorSurface.cpp:15
Cantera::ReactorSurface::setReactor
void setReactor(ReactorBase *reactor)
Set the reactor that this Surface interacts with.
Definition ReactorSurface.cpp:42
Cantera::ReactorSurface::setSensitivityParameters
void setSensitivityParameters(const double *params)
Set reaction rate multipliers.
Definition ReactorSurface.cpp:87
Cantera::ReactorSurface::getCoverages
void getCoverages(double *cov) const
Get the surface coverages.
Definition ReactorSurface.cpp:64
Cantera::ReactorSurface::setArea
void setArea(double a)
Set the surface area [m^2].
Definition ReactorSurface.cpp:20
Cantera::ReactorSurface::resetSensitivityParameters
void resetSensitivityParameters()
Set reaction rate multipliers back to their initial values.
Definition ReactorSurface.cpp:95
Cantera::ReactorSurface::syncState
void syncState()
Set the coverages and temperature in the surface phase object to the values for this surface.
Definition ReactorSurface.cpp:69
Cantera::ReactorSurface::setCoverages
void setCoverages(const double *cov)
Set the surface coverages.
Definition ReactorSurface.cpp:47
Cantera::ReactorSurface::setKinetics
void setKinetics(Kinetics *kin)
Set the InterfaceKinetics object for this surface.
Definition ReactorSurface.cpp:25
Cantera::ReactorSurface::addSensitivityReaction
void addSensitivityReaction(size_t i)
Enable calculation of sensitivities with respect to the rate constant for reaction i.
Definition ReactorSurface.cpp:75
Cantera::SurfPhase
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition SurfPhase.h:98
Cantera::SurfPhase::setCoveragesNoNorm
void setCoveragesNoNorm(const double *theta)
Set the surface site fractions to a specified state.
Definition SurfPhase.cpp:239
Cantera::SurfPhase::getCoverages
void getCoverages(double *theta) const
Return a vector of surface coverages.
Definition SurfPhase.cpp:257
Cantera::SurfPhase::setCoveragesByName
void setCoveragesByName(const string &cov)
Set the coverages from a string of colon-separated name:value pairs.
Definition SurfPhase.cpp:271
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::Composition
map< string, double > Composition
Map from string names to doubles.
Definition ct_defs.h:184