19 ImplicitSurfChem::ImplicitSurfChem(vector<InterfaceKinetics*> k) :
24 m_numTotalBulkSpecies(0),
30 m_mediumSpeciesStart(-1),
31 m_bulkSpeciesStart(-1),
32 m_surfSpeciesStart(-1),
34 m_commonTempPressForPhases(true),
40 size_t kinSpIndex = 0;
42 for (
size_t n = 0; n <
m_nsurf; n++) {
45 ns = k[n]->surfacePhaseIndex();
48 "kinetics manager contains no surface phase");
51 nsp =
m_surf.back()->nSpecies();
54 nt = k[n]->nTotalSpecies();
58 m_specStartIndex.push_back(kinSpIndex);
61 size_t nPhases = kinPtr->
nPhases();
64 for (
size_t ip = 0; ip < nPhases; ip++) {
71 m_nspBulkPhases.push_back(nsp);
72 m_numTotalBulkSpecies += nsp;
75 pLocTmp[ip] = int(imatch);
77 pLocTmp[ip] = -int(n);
80 pLocVec.push_back(pLocTmp);
83 m_numTotalSpecies =
m_nv + m_numTotalBulkSpecies;
85 m_concSpeciesSave.resize(m_numTotalSpecies, 0.0);
87 m_integ = newIntegrator(
"CVODE");
100 int ImplicitSurfChem::checkMatch(std::vector<ThermoPhase*> m_vec,
ThermoPhase* thPtr)
103 for (
int i = 0; i < (int) m_vec.size(); i++) {
131 for (
size_t n = 0; n <
m_nsurf; n++) {
132 m_surf[n]->getCoverages(c + loc);
181 for (
size_t n = 0; n <
m_nsurf; n++) {
182 m_surf[n]->setCoverages(c + loc);
191 doublereal* ydot, doublereal* p)
196 for (
size_t n = 0; n <
m_nsurf; n++) {
197 rs0 = 1.0/
m_surf[n]->siteDensity();
202 for (
size_t k = 1; k <
m_nsp[n]; k++) {
203 ydot[k + loc] = m_work[kstart + k] * rs0 *
m_surf[n]->size(k);
221 doublereal timeScaleOverride)
229 int bulkFunc = BULK_ETCH;
233 doublereal time_scale = timeScaleOverride;
241 ifunc = SFLUX_RESIDUAL;
245 if (ifuncOverride >= 0) {
246 ifunc = ifuncOverride;
271 doublereal reltol = 1.0E-6;
272 doublereal atol = 1.0E-20;
280 for (
size_t k = 0; k <
m_nv; k++) {
300 copy(m_concSpeciesSave.begin(), m_concSpeciesSave.end(),
m_concSpecies.begin());
307 throw CanteraError(
"ImplicitSurfChem::solvePseudoSteadyStateProblem",
308 "solveSP return an error condition!");
324 void ImplicitSurfChem::getConcSpecies(doublereal*
const vecConcSpecies)
const
327 for (
size_t ip = 0; ip <
m_nsurf; ip++) {
329 kstart = m_specStartIndex[ip];
333 for (
size_t ip = 0; ip < m_numBulkPhases; ip++) {
335 TP_ptr->getConcentrations(vecConcSpecies + kstart);
336 kstart += TP_ptr->nSpecies();
352 for (
size_t ip = 0; ip <
m_nsurf; ip++) {
354 kstart = m_specStartIndex[ip];
358 for (
size_t ip = 0; ip < m_numBulkPhases; ip++) {
377 for (
size_t ip = 0; ip <
m_nsurf; ip++) {
381 for (
size_t ip = 0; ip < m_numBulkPhases; ip++) {