17 const vector<shared_ptr<ReactorBase>>& reactors,
23 vector<shared_ptr<Solution>> adjacent;
24 for (
auto R : reactors) {
25 adjacent.push_back(R->phase());
26 m_reactors.push_back(R.get());
30 m_solution = soln->clone(adjacent,
true,
false);
36 if (!std::dynamic_pointer_cast<SurfPhase>(soln->thermo())) {
38 "Solution object must have a SurfPhase object as the thermo manager.");
41 if (!soln->kinetics() ) {
43 "Solution object must have kinetics manager.");
44 }
else if (!std::dynamic_pointer_cast<InterfaceKinetics>(soln->kinetics())) {
46 "Kinetics manager must be an InterfaceKinetics object.");
51 m_surf =
dynamic_cast<SurfPhase*
>(m_thermo);
52 m_cov.resize(m_surf->nSpecies());
59 if (!std::dynamic_pointer_cast<SurfPhase>(sol->thermo())) {
60 throw CanteraError(
"ReactorSurface::ReactorSurface",
61 "Solution object must have a SurfPhase object as the thermo manager.");
64 if (!sol->kinetics() ) {
65 throw CanteraError(
"ReactorSurface::ReactorSurface",
66 "Solution object must have kinetics manager.");
67 }
else if (!std::dynamic_pointer_cast<InterfaceKinetics>(sol->kinetics())) {
68 throw CanteraError(
"ReactorSurface::ReactorSurface",
69 "Kinetics manager must be an InterfaceKinetics object.");
74 m_surf =
dynamic_cast<SurfPhase*
>(m_thermo);
75 m_cov.resize(m_surf->nSpecies());
84 throw CanteraError(
"ReactorSurface::ReactorSurface",
"Bad constructor arguments."
85 " When clone=true, list of adjacent reactors must be provided");
102 "To be removed after Cantera 3.2.");
104 if (kin ==
nullptr) {
110 if (m_surf ==
nullptr) {
112 "Specified kinetics manager does not represent a surface "
113 "kinetics mechanism.");
115 m_cov.resize(m_surf->nSpecies());
126 if (std::find(m_reactors.begin(), m_reactors.end(), reactor) != m_reactors.end()) {
130 warn_deprecated(
"ReactorSurface::setReactor",
"To be removed after Cantera 3.2. "
131 "Superseded by constructor taking a list of adjacent reactors.");
132 m_reactors.resize(1);
133 m_reactors[0] = reactor;
138 copy(cov, cov + m_cov.size(), m_cov.begin());
143 m_surf->setCoveragesByName(cov);
144 m_surf->getCoverages(m_cov.data());
149 m_surf->setCoveragesByName(cov);
150 m_surf->getCoverages(m_cov.data());
155 copy(m_cov.begin(), m_cov.end(), cov);
160 if (m_reactors.empty()) {
165 "Surface is not installed on any Reactor");
167 m_surf->setTemperature(m_reactors[0]->
temperature());
168 m_surf->setCoveragesNoNorm(m_cov.data());
173 warn_user(
"ReactorSurface::syncState",
"Behavior changed in Cantera 3.2 for "
174 "consistency with ReactorBase. To set SurfPhase state from ReactorSurface "
175 "object, use restoreState().");
176 m_surf->getCoverages(m_cov.data());
181 if (rxn >= m_kinetics->nReactions()) {
182 throw CanteraError(
"ReactorSurface::addSensitivityReaction",
183 "Reaction number out of range ({})", rxn);
185 size_t p = m_reactors[0]->network().registerSensitivityParameter(
186 m_kinetics->reaction(rxn)->equation(), 1.0, 1.0);
187 m_sensParams.emplace_back(
193 for (
auto& p : m_sensParams) {
194 p.value = m_kinetics->multiplier(p.local);
195 m_kinetics->setMultiplier(p.local, p.value*params[p.global]);
201 for (
auto& p : m_sensParams) {
202 m_kinetics->setMultiplier(p.local, p.value);
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.
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
ReactorBase(const string &name="(none)")
double temperature() const
Returns the current temperature (K) of the reactor's contents.
string name() const
Return the name of this reactor.
void restoreState() override
Set the coverages and temperature in the surface phase object to the values for this surface.
double area() const override
Returns the surface area [m²].
void setReactor(ReactorBase *reactor)
Set the reactor that this Surface interacts with.
void setSensitivityParameters(const double *params)
Set reaction rate multipliers.
ReactorSurface(shared_ptr< Solution > soln, const vector< shared_ptr< ReactorBase > > &reactors, bool clone, const string &name="(none)")
Create a new ReactorSurface.
void setArea(double a) override
Set the surface area [m²].
void getCoverages(double *cov) const
Get the surface coverages.
void resetSensitivityParameters()
Set reaction rate multipliers back to their initial values.
void addSensitivityReaction(size_t rxn) override
Add a sensitivity parameter associated with the reaction number rxn
void setThermo(ThermoPhase &thermo) override
Specify the mixture contained in the reactor.
void syncState() override
Set the coverages for this ReactorSurface based on the attached SurfPhase.
void setCoverages(const double *cov)
Set the surface coverages.
void setKinetics(Kinetics *kin)
Set the InterfaceKinetics object for this surface.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
void getCoverages(double *theta) const
Return a vector of surface coverages.
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Namespace for the Cantera kernel.
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
map< string, double > Composition
Map from string names to doubles.