19 vector<InterfaceKinetics*> k,
double rtol,
double atol,
20 double maxStepSize,
size_t maxSteps,
21 size_t maxErrTestFails) :
24 m_maxstep(maxStepSize),
26 m_maxErrTestFails(maxErrTestFails)
29 size_t kinSpIndex = 0;
31 for (
size_t n = 0; n < k.size(); n++) {
35 if (surf ==
nullptr) {
37 "kinetics manager contains no surface phase");
40 size_t nsp =
m_surf.back()->nSpecies();
43 size_t nt = k[n]->nTotalSpecies();
44 ntmax = std::max(nt, ntmax);
45 m_specStartIndex.push_back(kinSpIndex);
47 size_t nPhases = kinPtr->
nPhases();
48 vector<int> pLocTmp(nPhases);
51 for (
size_t ip = 1; ip < nPhases; ip++) {
56 m_numTotalBulkSpecies += nsp;
59 pLocTmp[ip] = int(imatch);
61 pLocVec.push_back(pLocTmp);
63 m_numTotalSpecies =
m_nv + m_numTotalBulkSpecies;
65 m_concSpeciesSave.resize(m_numTotalSpecies, 0.0);
72 m_integ->setLinearSolverType(
"DENSE");
76 int ImplicitSurfChem::checkMatch(vector<ThermoPhase*> m_vec,
ThermoPhase* thPtr)
79 for (
int i = 0; i < (int) m_vec.size(); i++) {
91 for (
size_t n = 0; n <
m_surf.size(); n++) {
92 m_surf[n]->getCoverages(c + loc);
109 m_integ->setTolerances(m_rtol, m_atol);
130 m_integ->initialize(t0, *
this);
138 m_integ->setMaxStepSize(t1 - t0);
153 for (
size_t n = 0; n <
m_surf.size(); n++) {
154 m_surf[n]->setCoverages(c + loc);
163 for (
size_t n = 0; n <
m_surf.size(); n++) {
164 double rs0 = 1.0/
m_surf[n]->siteDensity();
167 for (
size_t k = 1; k <
m_nsp[n]; k++) {
168 ydot[k + loc] = m_work[k] * rs0 *
m_surf[n]->size(k);
177 double timeScaleOverride)
183 double time_scale = timeScaleOverride;
193 if (ifuncOverride >= 0) {
194 ifunc = ifuncOverride;
215 double reltol = 1.0E-6;
216 double atol = 1.0E-20;
221 for (
size_t k = 0; k <
m_nv; k++) {
236 int retn =
m_surfSolver->solveSurfProb(ifunc, time_scale, TKelvin, PGas,
243 retn =
m_surfSolver->solveSurfProb(ifunc, time_scale, TKelvin, PGas,
246 throw CanteraError(
"ImplicitSurfChem::solvePseudoSteadyStateProblem",
247 "solveSP return an error condition!");
255 for (
size_t ip = 0; ip <
m_surf.size(); ip++) {
257 kstart = m_specStartIndex[ip];
271 for (
size_t ip = 0; ip <
m_surf.size(); ip++) {
273 kstart = m_specStartIndex[ip];
286 for (
size_t ip = 0; ip <
m_surf.size(); ip++) {
Declarations for the implicit integration of surface site density equations (see Kinetics Managers an...
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Base class for exceptions thrown by Cantera classes.
vector< ThermoPhase * > m_bulkPhases
Vector of pointers to bulk phases.
void eval(double t, double *y, double *ydot, double *p) override
Evaluate the value of ydot[k] at the current conditions.
void setConcSpecies(const double *const vecConcSpecies)
Sets the concentrations within phases that are unknowns in the surface problem.
void setCommonState_TP(double TKelvin, double PresPa)
Sets the state variable in all thermodynamic phases (surface and surrounding bulk phases) to the inpu...
size_t m_nv
Total number of surface species in all surface phases.
int m_ioFlag
Controls the amount of printing from this routine and underlying routines.
void initialize(double t0=0.0)
Must be called before calling method 'advance'.
void integrate(double t0, double t1)
Integrate from t0 to t1. The integrator is reinitialized first.
void getConcSpecies(double *const vecConcSpecies) const
Get the specifications for the problem from the values in the ThermoPhase objects for all phases.
vector< SurfPhase * > m_surf
vector of pointers to surface phases.
vector< InterfaceKinetics * > m_vecKinPtrs
vector of pointers to InterfaceKinetics objects
unique_ptr< solveSP > m_surfSolver
Pointer to the helper method, Placid, which solves the surface problem.
double m_maxstep
max step size
bool m_commonTempPressForPhases
If true, a common temperature and pressure for all surface and bulk phases associated with the surfac...
void setTolerances(double rtol=1.e-7, double atol=1.e-14)
Set the relative and absolute integration tolerances.
vector< size_t > m_nsp
Vector of number of species in each Surface Phase.
void setMaxStepSize(double maxstep=0.0)
Set the maximum integration step-size.
vector< double > m_concSpecies
Temporary vector - length num species in the Kinetics object.
void setMaxSteps(size_t maxsteps=20000)
Set the maximum number of CVODES integration steps.
void updateState(double *y)
Set the mixture to a state consistent with solution vector y.
void getState(double *y) override
Get the current state of the solution vector.
size_t m_maxErrTestFails
maximum number of error test failures allowed
unique_ptr< Integrator > m_integ
Pointer to the CVODE integrator.
void integrate0(double t0, double t1)
Integrate from t0 to t1 without reinitializing the integrator.
void solvePseudoSteadyStateProblem(int ifuncOverride=-1, double timeScaleOverride=1.0)
Solve for the pseudo steady-state of the surface problem.
ImplicitSurfChem(vector< InterfaceKinetics * > k, double rtol=1.e-7, double atol=1.e-14, double maxStepSize=0, size_t maxSteps=20000, size_t maxErrTestFails=7)
Constructor for multiple surfaces.
void setMaxErrTestFails(size_t maxErrTestFails=7)
Set the maximum number of CVODES error test failures.
size_t m_nmax
maximum number of steps allowed
A kinetics manager for heterogeneous reaction mechanisms.
size_t nPhases() const
The number of phases participating in the reaction mechanism.
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
virtual void getConcentrations(double *const c) const
Get the species concentrations (kmol/m^3).
size_t nSpecies() const
Returns the number of species in the phase.
double temperature() const
Temperature (K).
virtual void setConcentrations(const double *const conc)
Set the concentrations to the specified values within the phase.
virtual double pressure() const
Return the thermodynamic pressure (Pa).
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Base class for a phase with thermodynamic properties.
virtual void setState_TP(double t, double p)
Set the temperature (K) and pressure (Pa)
Integrator * newIntegrator(const string &itype)
Create new Integrator object.
const int BULK_ETCH
Etching of a bulk phase is to be expected.
const int SFLUX_RESIDUAL
Need to solve the surface problem in order to calculate the surface fluxes of gas-phase species.
const int SFLUX_INITIALIZE
This assumes that the initial guess supplied to the routine is far from the correct one.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
@ BDF_Method
Backward Differentiation.
Header file for implicit surface problem solver (see Chemical Kinetics and class solveSP).