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
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
11 namespace 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
22 double ReactorSurface::area() const
23{
24 return m_area;
25}
26
27 void ReactorSurface::setArea(double a)
28{
29 m_area = a;
30}
31
32 void 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
50 void ReactorSurface::setReactor(ReactorBase* reactor)
51{
52 m_reactor = reactor;
53}
54
55 void ReactorSurface::setCoverages(const double* cov)
56{
57 copy(cov, cov + m_cov.size(), m_cov.begin());
58}
59
60 void ReactorSurface::setCoverages(const Composition& cov)
61{
62 m_thermo->setCoveragesByName(cov);
63 m_thermo->getCoverages(m_cov.data());
64}
65
66 void ReactorSurface::setCoverages(const std::string& cov)
67{
68 m_thermo->setCoveragesByName(cov);
69 m_thermo->getCoverages(m_cov.data());
70}
71
72 void ReactorSurface::getCoverages(double* cov) const
73{
74 copy(m_cov.begin(), m_cov.end(), cov);
75}
76
77 void 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
84 void ReactorSurface::syncState()
85{
86 m_thermo->setTemperature(m_reactor->temperature());
87 m_thermo->setCoveragesNoNorm(m_cov.data());
88}
89
90 void 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
102 void 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
110 void ReactorSurface::resetSensitivityParameters()
111{
112 for (auto& p : m_params) {
113 m_kinetics->setMultiplier(p.local, p.value);
114 }
115}
116
117}
Kinetics.h
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
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:61
Cantera::Kinetics
Public interface for kinetics managers.
Definition: Kinetics.h:114
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:231
Cantera::Kinetics::surfacePhaseIndex
size_t surfacePhaseIndex() const
This returns the integer index of the phase which has ThermoPhase type cSurf.
Definition: Kinetics.h:206
Cantera::ReactorBase
Base class for stirred reactors.
Definition: ReactorBase.h:49
Cantera::SurfPhase
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:125
Cantera::SurfPhase::getCoverages
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:277
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
Cantera::Composition
std::map< std::string, double > Composition
Map from string names to doubles.
Definition: ct_defs.h:180
Cantera::warn_deprecated
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