17 const vector<shared_ptr<ReactorBase>>& reactors,
23 vector<shared_ptr<Solution>> adjacent;
24 for (
auto R : reactors) {
25 adjacent.push_back(R->contents4());
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);
59 if (!std::dynamic_pointer_cast<SurfPhase>(sol->thermo())) {
61 "Solution object must have a SurfPhase object as the thermo manager.");
64 if (!sol->kinetics() ) {
66 "Solution object must have kinetics manager.");
67 }
else if (!std::dynamic_pointer_cast<InterfaceKinetics>(sol->kinetics())) {
69 "Kinetics manager must be an InterfaceKinetics object.");
74 m_surf =
dynamic_cast<SurfPhase*
>(m_thermo);
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.");
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());
155 copy(m_cov.begin(), m_cov.end(), cov);
160 if (m_reactors.empty()) {
165 "Surface is not installed on any Reactor");
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().");
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) {
195 m_kinetics->
setMultiplier(p.local, p.value*params[p.global]);
201 for (
auto& p : m_sensParams) {
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.
double multiplier(size_t i) const
The current value of the multiplier for reaction i.
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
shared_ptr< Reaction > reaction(size_t i)
Return the Reaction object for reaction i.
size_t nReactions() const
Number of reactions in the reaction mechanism.
virtual void setMultiplier(size_t i, double f)
Set the multiplier for reaction i to f.
size_t nSpecies() const
Returns the number of species in the phase.
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
Base class for reactor objects.
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
double temperature() const
Returns the current temperature (K) of the reactor's contents.
A surface where reactions can occur that is in contact with the bulk fluid of a Reactor.
void restoreState() override
Set the coverages and temperature in the surface phase object to the values for this surface.
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.
ReactorSurface(shared_ptr< Solution > soln, const vector< shared_ptr< ReactorBase > > &reactors, bool clone, const string &name="(none)")
Create a new ReactorSurface.
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 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 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.
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.