Cantera 2.6.0
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
10
11namespace Cantera
12{
13
14ReactorSurface::ReactorSurface()
15 : m_area(1.0)
16 , m_thermo(nullptr)
17 , m_kinetics(nullptr)
18 , m_reactor(nullptr)
19{
20}
21
22double ReactorSurface::area() const
23{
24 return m_area;
25}
26
27void ReactorSurface::setArea(double a)
28{
29 m_area = a;
30}
31
32void ReactorSurface::setKinetics(Kinetics* kin) {
33 m_kinetics = kin;
34 if (kin == nullptr) {
35 m_thermo = nullptr;
36 return;
37 }
38
39 size_t i = kin->surfacePhaseIndex();
40 if (i == npos) {
41 throw CanteraError("ReactorSurface::setKinetics",
42 "Specified surface kinetics manager does not represent a surface "
43 "kinetics mechanism.");
44 }
45 m_thermo = dynamic_cast<SurfPhase*>(&kin->thermo(i));
46 m_cov.resize(m_thermo->nSpecies());
47 m_thermo->getCoverages(m_cov.data());
48}
49
50void ReactorSurface::setReactor(ReactorBase* reactor)
51{
52 m_reactor = reactor;
53}
54
55void ReactorSurface::setCoverages(const double* cov)
56{
57 copy(cov, cov + m_cov.size(), m_cov.begin());
58}
59
60void ReactorSurface::setCoverages(const Composition& cov)
61{
62 m_thermo->setCoveragesByName(cov);
63 m_thermo->getCoverages(m_cov.data());
64}
65
66void ReactorSurface::setCoverages(const std::string& cov)
67{
68 m_thermo->setCoveragesByName(cov);
69 m_thermo->getCoverages(m_cov.data());
70}
71
72void ReactorSurface::getCoverages(double* cov) const
73{
74 copy(m_cov.begin(), m_cov.end(), cov);
75}
76
77void ReactorSurface::syncCoverages()
78{
79 warn_deprecated("ReactorSurface::syncCoverages",
80 "To be removed after Cantera 2.6. Use syncState() instead.");
81 m_thermo->setCoveragesNoNorm(m_cov.data());
82}
83
84void ReactorSurface::syncState()
85{
86 m_thermo->setTemperature(m_reactor->temperature());
87 m_thermo->setCoveragesNoNorm(m_cov.data());
88}
89
90void ReactorSurface::addSensitivityReaction(size_t i)
91{
92 if (i >= m_kinetics->nReactions()) {
93 throw CanteraError("ReactorSurface::addSensitivityReaction",
94 "Reaction number out of range ({})", i);
95 }
96 size_t p = m_reactor->network().registerSensitivityParameter(
97 m_kinetics->reactionString(i), 1.0, 1.0);
98 m_params.emplace_back(
99 SensitivityParameter{i, p, 1.0, SensParameterType::reaction});
100}
101
102void ReactorSurface::setSensitivityParameters(const double* params)
103{
104 for (auto& p : m_params) {
105 p.value = m_kinetics->multiplier(p.local);
106 m_kinetics->setMultiplier(p.local, p.value*params[p.global]);
107 }
108}
109
110void ReactorSurface::resetSensitivityParameters()
111{
112 for (auto& p : m_params) {
113 m_kinetics->setMultiplier(p.local, p.value);
114 }
115}
116
117}
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.
Definition: ctexceptions.h:61
Public interface for kinetics managers.
Definition: Kinetics.h:114
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
Definition: Kinetics.h:231
size_t surfacePhaseIndex() const
This returns the integer index of the phase which has ThermoPhase type cSurf.
Definition: Kinetics.h:206
Base class for stirred reactors.
Definition: ReactorBase.h:49
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:125
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:277
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
std::map< std::string, double > Composition
Map from string names to doubles.
Definition: ct_defs.h:180
void warn_deprecated(const std::string &source, const AnyBase &node, const std::string &message)
A deprecation warning for syntax in an input file.
Definition: AnyMap.cpp:1901