Cantera  2.1.2
InterfaceKinetics.cpp
Go to the documentation of this file.
1 /**
2  * @file InterfaceKinetics.cpp
3  */
4 
5 // Copyright 2002 California Institute of Technology
6 
13 
14 #include <cstdio>
15 
16 using namespace std;
17 
18 namespace Cantera
19 {
20 InterfaceKinetics::InterfaceKinetics(thermo_t* thermo) :
21  Kinetics(),
22  m_redo_rates(false),
23  m_nirrev(0),
24  m_nrev(0),
25  m_surf(0),
26  m_integrator(0),
27  m_beta(0),
28  m_ctrxn(0),
29  m_ctrxn_ecdf(0),
30  m_StandardConc(0),
31  m_deltaG0(0),
32  m_ProdStanConcReac(0),
33  m_logp0(0.0),
34  m_logc0(0.0),
35  m_ROP_ok(false),
36  m_temp(0.0),
37  m_logtemp(0.0),
38  m_finalized(false),
39  m_has_coverage_dependence(false),
40  m_has_electrochem_rxns(false),
41  m_has_exchange_current_density_formulation(false),
42  m_phaseExistsCheck(false),
43  m_phaseExists(0),
44  m_phaseIsStable(0),
45  m_rxnPhaseIsReactant(0),
46  m_rxnPhaseIsProduct(0),
47  m_ioFlag(0)
48 {
49  if (thermo != 0) {
50  addPhase(*thermo);
51  }
52 }
53 
55 {
56  delete m_integrator;
57 }
58 
60  Kinetics(),
61  m_redo_rates(false),
62  m_nirrev(0),
63  m_nrev(0),
64  m_surf(0),
65  m_integrator(0),
66  m_beta(0),
67  m_ctrxn(0),
68  m_ctrxn_ecdf(0),
69  m_StandardConc(0),
70  m_deltaG0(0),
71  m_ProdStanConcReac(0),
72  m_logp0(0.0),
73  m_logc0(0.0),
74  m_ROP_ok(false),
75  m_temp(0.0),
76  m_logtemp(0.0),
77  m_finalized(false),
78  m_has_coverage_dependence(false),
79  m_has_electrochem_rxns(false),
80  m_has_exchange_current_density_formulation(false),
81  m_phaseExistsCheck(false),
82  m_phaseExists(0),
83  m_phaseIsStable(0),
84  m_rxnPhaseIsReactant(0),
85  m_rxnPhaseIsProduct(0),
86  m_ioFlag(0)
87 {
88  /*
89  * Call the assignment operator
90  */
91  *this = operator=(right);
92 }
93 
96 {
97  /*
98  * Check for self assignment.
99  */
100  if (this == &right) {
101  return *this;
102  }
103 
104  Kinetics::operator=(right);
105 
106  m_grt = right.m_grt;
107  m_revindex = right.m_revindex;
108  m_rates = right.m_rates;
109  m_redo_rates = right.m_redo_rates;
110  m_index = right.m_index;
111  m_irrev = right.m_irrev;
112  m_rxnstoich = right.m_rxnstoich;
113  m_nirrev = right.m_nirrev;
114  m_nrev = right.m_nrev;
115  m_rrxn = right.m_rrxn;
116  m_prxn = right.m_prxn;
117  m_rxneqn = right.m_rxneqn;
118  m_conc = right.m_conc;
119  m_mu0 = right.m_mu0;
120  m_phi = right.m_phi;
121  m_pot = right.m_pot;
122  m_rwork = right.m_rwork;
123  m_E = right.m_E;
124  m_surf = right.m_surf; //DANGER - shallow copy
125  m_integrator = right.m_integrator; //DANGER - shallow copy
126  m_beta = right.m_beta;
127  m_ctrxn = right.m_ctrxn;
128  m_ctrxn_ecdf = right.m_ctrxn_ecdf;
129  m_StandardConc = right.m_StandardConc;
130  m_deltaG0 = right.m_deltaG0;
131  m_ProdStanConcReac = right.m_ProdStanConcReac;
132  m_logp0 = right.m_logp0;
133  m_logc0 = right.m_logc0;
134  m_ropf = right.m_ropf;
135  m_ropr = right.m_ropr;
136  m_ropnet = right.m_ropnet;
137  m_ROP_ok = right.m_ROP_ok;
138  m_temp = right.m_temp;
139  m_logtemp = right.m_logtemp;
140  m_rfn = right.m_rfn;
141  m_rkcn = right.m_rkcn;
142  m_finalized = right.m_finalized;
151  m_ioFlag = right.m_ioFlag;
152 
153  return *this;
154 }
155 
157 {
158  return cInterfaceKinetics;
159 }
160 
161 Kinetics* InterfaceKinetics::duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const
162 {
163  InterfaceKinetics* iK = new InterfaceKinetics(*this);
164  iK->assignShallowPointers(tpVector);
165  return iK;
166 }
167 
169 {
171  m_redo_rates = true;
172 }
173 
175 {
179  m_rates.update_C(DATA_PTR(m_conc));
180  m_redo_rates = true;
181  }
182  doublereal T = thermo(surfacePhaseIndex()).temperature();
183  m_redo_rates = true;
184  if (T != m_temp || m_redo_rates) {
185  m_logtemp = log(T);
186  m_rates.update(T, m_logtemp, DATA_PTR(m_rfn));
189  }
192  }
193  m_temp = T;
194  updateKc();
195  m_ROP_ok = false;
196  m_redo_rates = false;
197  }
198 }
199 
201 {
202  for (size_t n = 0; n < nPhases(); n++) {
203  if (thermo(n).electricPotential() != m_phi[n]) {
204  m_phi[n] = thermo(n).electricPotential();
205  m_redo_rates = true;
206  }
207  }
208 }
209 
211 {
212  for (size_t n = 0; n < nPhases(); n++) {
213  /*
214  * We call the getActivityConcentrations function of each
215  * ThermoPhase class that makes up this kinetics object to
216  * obtain the generalized concentrations for species within that
217  * class. This is collected in the vector m_conc. m_start[]
218  * are integer indices for that vector denoting the start of the
219  * species for each phase.
220  */
222  }
223  m_ROP_ok = false;
224 }
225 
227 {
228  _update_rates_C();
229  copy(m_conc.begin(), m_conc.end(), conc);
230 }
231 
233 {
234  fill(m_rkcn.begin(), m_rkcn.end(), 0.0);
235 
236  //static vector_fp mu(nTotalSpecies());
237  if (m_nrev > 0) {
238  /*
239  * Get the vector of standard state electrochemical potentials for species in the Interfacial
240  * kinetics object and store it in m_mu0[]
241  */
242  size_t nsp, ik = 0;
243  doublereal rt = GasConstant*thermo(0).temperature();
244  doublereal rrt = 1.0 / rt;
245  size_t np = nPhases();
246  for (size_t n = 0; n < np; n++) {
248  nsp = thermo(n).nSpecies();
249  for (size_t k = 0; k < nsp; k++) {
250  m_mu0[ik] -= rt * thermo(n).logStandardConc(k);
251  m_mu0[ik] += Faraday * m_phi[n] * thermo(n).charge(k);
252  ik++;
253  }
254  }
255 
256  // compute Delta mu^0 for all reversible reactions
258 
259  for (size_t i = 0; i < m_nrev; i++) {
260  size_t irxn = m_revindex[i];
261  if (irxn == npos || irxn >= nReactions()) {
262  throw CanteraError("InterfaceKinetics",
263  "illegal value: irxn = "+int2str(irxn));
264  }
265  // WARNING this may overflow HKM
266  m_rkcn[irxn] = exp(m_rkcn[irxn]*rrt);
267  }
268  for (size_t i = 0; i != m_nirrev; ++i) {
269  m_rkcn[ m_irrev[i] ] = 0.0;
270  }
271  }
272 }
273 
274 void InterfaceKinetics::checkPartialEquil()
275 {
276  vector_fp dmu(nTotalSpecies(), 0.0);
277  vector_fp rmu(std::max<size_t>(nReactions(), 1), 0.0);
278  if (m_nrev > 0) {
279  doublereal rt = GasConstant*thermo(0).temperature();
280  cout << "T = " << thermo(0).temperature() << " " << rt << endl;
281  size_t nsp, ik=0;
282  //doublereal rt = GasConstant*thermo(0).temperature();
283  // doublereal rrt = 1.0/rt;
284  doublereal delta;
285  for (size_t n = 0; n < nPhases(); n++) {
287  nsp = thermo(n).nSpecies();
288  for (size_t k = 0; k < nsp; k++) {
289  delta = Faraday * m_phi[n] * thermo(n).charge(k);
290  //cout << thermo(n).speciesName(k) << " " << (delta+dmu[ik])/rt << " " << dmu[ik]/rt << endl;
291  dmu[ik] += delta;
292  ik++;
293  }
294  }
295 
296  // compute Delta mu^ for all reversible reactions
298  updateROP();
299  for (size_t i = 0; i < m_nrev; i++) {
300  size_t irxn = m_revindex[i];
301  cout << "Reaction " << reactionString(irxn)
302  << " " << rmu[irxn]/rt << endl;
303  printf("%12.6e %12.6e %12.6e %12.6e \n",
304  m_ropf[irxn], m_ropr[irxn], m_ropnet[irxn],
305  m_ropnet[irxn]/(m_ropf[irxn] + m_ropr[irxn]));
306  }
307  }
308 }
309 
311 {
312  updateROP();
313  std::copy(m_ropf.begin(), m_ropf.end(), fwdROP);
314 }
315 
317 {
318  updateROP();
319  std::copy(m_ropr.begin(), m_ropr.end(), revROP);
320 }
321 
323 {
324  updateROP();
325  std::copy(m_ropnet.begin(), m_ropnet.end(), netROP);
326 }
327 
329 {
330  size_t ik=0;
331  doublereal rt = GasConstant*thermo(0).temperature();
332  doublereal rrt = 1.0/rt;
333  for (size_t n = 0; n < nPhases(); n++) {
335  size_t nsp = thermo(n).nSpecies();
336  for (size_t k = 0; k < nsp; k++) {
337  m_mu0[ik] -= rt*thermo(n).logStandardConc(k);
338  m_mu0[ik] += Faraday * m_phi[n] * thermo(n).charge(k);
339  ik++;
340  }
341  }
342 
343  fill(kc, kc + m_ii, 0.0);
344 
346 
347  for (size_t i = 0; i < m_ii; i++) {
348  kc[i] = exp(-kc[i]*rrt);
349  }
350 }
351 
352 void InterfaceKinetics::getExchangeCurrentQuantities()
353 {
354  /*
355  * First collect vectors of the standard Gibbs free energies of the
356  * species and the standard concentrations
357  * - m_mu0
358  * - m_logStandardConc
359  */
360  size_t ik = 0;
361 
362  for (size_t n = 0; n < nPhases(); n++) {
364  size_t nsp = thermo(n).nSpecies();
365  for (size_t k = 0; k < nsp; k++) {
366  m_StandardConc[ik] = thermo(n).standardConcentration(k);
367  ik++;
368  }
369  }
370 
372 
373  for (size_t i = 0; i < m_ii; i++) {
374  m_ProdStanConcReac[i] = 1.0;
375  }
376 
377  m_rxnstoich.multiplyReactants(DATA_PTR(m_StandardConc), DATA_PTR(m_ProdStanConcReac));
378 
379 }
380 
382 {
383  updateROP();
384  m_rxnstoich.getCreationRates(m_kk, &m_ropf[0], &m_ropr[0], cdot);
385 }
386 
388 {
389  updateROP();
390  m_rxnstoich.getDestructionRates(m_kk, &m_ropf[0], &m_ropr[0], ddot);
391 }
392 
394 {
395  updateROP();
396  m_rxnstoich.getNetProductionRates(m_kk, &m_ropnet[0], net);
397 }
398 
400 {
401  // compute the electrical potential energy of each species
402  size_t ik = 0;
403  for (size_t n = 0; n < nPhases(); n++) {
404  size_t nsp = thermo(n).nSpecies();
405  for (size_t k = 0; k < nsp; k++) {
406  m_pot[ik] = Faraday*thermo(n).charge(k)*m_phi[n];
407  ik++;
408  }
409  }
410 
411  // Compute the change in electrical potential energy for each
412  // reaction. This will only be non-zero if a potential
413  // difference is present.
415 
416  // Modify the reaction rates. Only modify those with a
417  // non-zero activation energy. Below we decrease the
418  // activation energy below zero but in some debug modes
419  // we print out a warning message about this.
420  /*
421  * NOTE, there is some discussion about this point.
422  * Should we decrease the activation energy below zero?
423  * I don't think this has been decided in any definitive way.
424  * The treatment below is numerically more stable, however.
425  */
426  doublereal eamod;
427 #ifdef DEBUG_KIN_MODE
428  doublereal ea;
429 #endif
430  for (size_t i = 0; i < m_beta.size(); i++) {
431  size_t irxn = m_ctrxn[i];
432  eamod = m_beta[i]*m_rwork[irxn];
433  // if (eamod != 0.0 && m_E[irxn] != 0.0) {
434  if (eamod != 0.0) {
435 #ifdef DEBUG_KIN_MODE
436  ea = GasConstant * m_E[irxn];
437  if (eamod + ea < 0.0) {
438  writelog("Warning: act energy mod too large!\n");
439  writelog(" Delta phi = "+fp2str(m_rwork[irxn]/Faraday)+"\n");
440  writelog(" Delta Ea = "+fp2str(eamod)+"\n");
441  writelog(" Ea = "+fp2str(ea)+"\n");
442  for (n = 0; n < np; n++) {
443  writelog("Phase "+int2str(n)+": phi = "
444  +fp2str(m_phi[n])+"\n");
445  }
446  }
447 #endif
448  doublereal rt = GasConstant*thermo(0).temperature();
449  doublereal rrt = 1.0/rt;
450  kf[irxn] *= exp(-eamod*rrt);
451  }
452  }
453 }
454 
456 {
457  getExchangeCurrentQuantities();
458  doublereal rt = GasConstant*thermo(0).temperature();
459  doublereal rrt = 1.0/rt;
460  for (size_t i = 0; i < m_ctrxn.size(); i++) {
461  size_t irxn = m_ctrxn[i];
462  int iECDFormulation = m_ctrxn_ecdf[i];
463  if (iECDFormulation) {
464  double tmp = exp(- m_beta[i] * m_deltaG0[irxn] * rrt);
465  double tmp2 = m_ProdStanConcReac[irxn];
466  tmp *= 1.0 / tmp2 / Faraday;
467  kfwd[irxn] *= tmp;
468  }
469  }
470 }
471 
473 {
474 
475  updateROP();
476 
477  // copy rate coefficients into kfwd
478  copy(m_rfn.begin(), m_rfn.end(), kfwd);
479 
480  // multiply by perturbation factor
481  multiply_each(kfwd, kfwd + nReactions(), m_perturb.begin());
482 
483 }
484 
485 void InterfaceKinetics::getRevRateConstants(doublereal* krev, bool doIrreversible)
486 {
487  getFwdRateConstants(krev);
488  if (doIrreversible) {
489  getEquilibriumConstants(&m_ropnet[0]);
490  for (size_t i = 0; i < m_ii; i++) {
491  krev[i] /= m_ropnet[i];
492  }
493  } else {
494  multiply_each(krev, krev + nReactions(), m_rkcn.begin());
495  }
496 }
497 
499 {
500  warn_deprecated("Kinetics::getActivationEnergies",
501  "To be removed in Cantera 2.2.");
502  copy(m_E.begin(), m_E.end(), E);
503 }
504 
506 {
507  _update_rates_T();
508  _update_rates_C();
509 
510  if (m_ROP_ok) {
511  return;
512  }
513 
514  // copy rate coefficients into ropf
515  copy(m_rfn.begin(), m_rfn.end(), m_ropf.begin());
516 
517  // multiply by perturbation factor
518  multiply_each(m_ropf.begin(), m_ropf.end(), m_perturb.begin());
519 
520  // copy the forward rates to the reverse rates
521  copy(m_ropf.begin(), m_ropf.end(), m_ropr.begin());
522 
523  // for reverse rates computed from thermochemistry, multiply
524  // the forward rates copied into m_ropr by the reciprocals of
525  // the equilibrium constants
526  multiply_each(m_ropr.begin(), m_ropr.end(), m_rkcn.begin());
527 
528  // multiply ropf by concentration products
530  //m_reactantStoich.multiply(m_conc.begin(), ropf.begin());
531 
532  // for reversible reactions, multiply ropr by concentration
533  // products
535  DATA_PTR(m_ropr));
536  //m_revProductStoich.multiply(m_conc.begin(), ropr.begin());
537 
538  // do global reactions
539  //m_globalReactantStoich.power(m_conc.begin(), ropf.begin());
540 
541  for (size_t j = 0; j != m_ii; ++j) {
542  m_ropnet[j] = m_ropf[j] - m_ropr[j];
543  }
544 
545  /*
546  * For reactions involving multiple phases, we must check that the phase
547  * being consumed actually exists. This is particularly important for
548  * phases that are stoichiometric phases containing one species with a unity activity
549  */
550  if (m_phaseExistsCheck) {
551  for (size_t j = 0; j != m_ii; ++j) {
552  if ((m_ropr[j] > m_ropf[j]) && (m_ropr[j] > 0.0)) {
553  for (size_t p = 0; p < nPhases(); p++) {
554  if (m_rxnPhaseIsProduct[j][p]) {
555  if (! m_phaseExists[p]) {
556  m_ropnet[j] = 0.0;
557  m_ropr[j] = m_ropf[j];
558  if (m_ropf[j] > 0.0) {
559  for (size_t rp = 0; rp < nPhases(); rp++) {
560  if (m_rxnPhaseIsReactant[j][rp]) {
561  if (! m_phaseExists[rp]) {
562  m_ropnet[j] = 0.0;
563  m_ropr[j] = m_ropf[j] = 0.0;
564  }
565  }
566  }
567  }
568  }
569  }
570  if (m_rxnPhaseIsReactant[j][p]) {
571  if (! m_phaseIsStable[p]) {
572  m_ropnet[j] = 0.0;
573  m_ropr[j] = m_ropf[j];
574  }
575  }
576  }
577  } else if ((m_ropf[j] > m_ropr[j]) && (m_ropf[j] > 0.0)) {
578  for (size_t p = 0; p < nPhases(); p++) {
579  if (m_rxnPhaseIsReactant[j][p]) {
580  if (! m_phaseExists[p]) {
581  m_ropnet[j] = 0.0;
582  m_ropf[j] = m_ropr[j];
583  if (m_ropf[j] > 0.0) {
584  for (size_t rp = 0; rp < nPhases(); rp++) {
585  if (m_rxnPhaseIsProduct[j][rp]) {
586  if (! m_phaseExists[rp]) {
587  m_ropnet[j] = 0.0;
588  m_ropf[j] = m_ropr[j] = 0.0;
589  }
590  }
591  }
592  }
593  }
594  }
595  if (m_rxnPhaseIsProduct[j][p]) {
596  if (! m_phaseIsStable[p]) {
597  m_ropnet[j] = 0.0;
598  m_ropf[j] = m_ropr[j];
599  }
600  }
601  }
602  }
603  }
604  }
605 
606  m_ROP_ok = true;
607 }
608 
609 void InterfaceKinetics::getDeltaGibbs(doublereal* deltaG)
610 {
611  /*
612  * Get the chemical potentials of the species in the
613  * ideal gas solution.
614  */
615  for (size_t n = 0; n < nPhases(); n++) {
617  }
618  //for (n = 0; n < m_grt.size(); n++) {
619  // cout << n << "G_RT = " << m_grt[n] << endl;
620  //}
621 
622  /*
623  * Use the stoichiometric manager to find deltaG for each
624  * reaction.
625  */
626  m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_grt), deltaG);
627 }
628 
630 {
631  /*
632  * Get the chemical potentials of the species in the
633  * ideal gas solution.
634  */
635  size_t np = nPhases();
636  for (size_t n = 0; n < np; n++) {
638  }
639  /*
640  * Use the stoichiometric manager to find deltaG for each
641  * reaction.
642  */
643  m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_grt), deltaM);
644 }
645 
646 void InterfaceKinetics::getDeltaEnthalpy(doublereal* deltaH)
647 {
648  /*
649  * Get the partial molar enthalpy of all species in the
650  * ideal gas.
651  */
652  for (size_t n = 0; n < nPhases(); n++) {
654  }
655  /*
656  * Use the stoichiometric manager to find deltaG for each
657  * reaction.
658  */
659  m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_grt), deltaH);
660 }
661 
662 void InterfaceKinetics::getDeltaEntropy(doublereal* deltaS)
663 {
664  /*
665  * Get the partial molar entropy of all species in all of
666  * the phases
667  */
668  for (size_t n = 0; n < nPhases(); n++) {
670  }
671  /*
672  * Use the stoichiometric manager to find deltaS for each
673  * reaction.
674  */
675  m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_grt), deltaS);
676 }
677 
678 void InterfaceKinetics::getDeltaSSGibbs(doublereal* deltaG)
679 {
680  /*
681  * Get the standard state chemical potentials of the species.
682  * This is the array of chemical potentials at unit activity
683  * We define these here as the chemical potentials of the pure
684  * species at the temperature and pressure of the solution.
685  */
686  for (size_t n = 0; n < nPhases(); n++) {
688  }
689  /*
690  * Use the stoichiometric manager to find deltaG for each
691  * reaction.
692  */
693  m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_grt), deltaG);
694 }
695 
697 {
698  /*
699  * Get the standard state enthalpies of the species.
700  * This is the array of chemical potentials at unit activity
701  * We define these here as the enthalpies of the pure
702  * species at the temperature and pressure of the solution.
703  */
704  for (size_t n = 0; n < nPhases(); n++) {
706  }
707  doublereal RT = thermo().temperature() * GasConstant;
708  for (size_t k = 0; k < m_kk; k++) {
709  m_grt[k] *= RT;
710  }
711  /*
712  * Use the stoichiometric manager to find deltaG for each
713  * reaction.
714  */
715  m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_grt), deltaH);
716 }
717 
718 void InterfaceKinetics::getDeltaSSEntropy(doublereal* deltaS)
719 {
720  /*
721  * Get the standard state entropy of the species.
722  * We define these here as the entropies of the pure
723  * species at the temperature and pressure of the solution.
724  */
725  for (size_t n = 0; n < nPhases(); n++) {
727  }
728  doublereal R = GasConstant;
729  for (size_t k = 0; k < m_kk; k++) {
730  m_grt[k] *= R;
731  }
732  /*
733  * Use the stoichiometric manager to find deltaS for each
734  * reaction.
735  */
736  m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_grt), deltaS);
737 }
738 
740 {
741  /*
742  * Install the rate coefficient for the current reaction
743  * in the appropriate data structure.
744  */
745  addElementaryReaction(r);
746  /*
747  * Add the reactants and products for m_ropnet;the current reaction
748  * to the various stoichiometric coefficient arrays.
749  */
750  installReagents(r);
751  /*
752  * Save the reaction and product groups, which are
753  * part of the ReactionData class, in this class.
754  * They aren't used for anything but reaction path
755  * analysis.
756  */
757  //installGroups(reactionNumber(), r.rgroups, r.pgroups);
758  /*
759  * Increase the internal number of reactions, m_ii, by one.
760  * increase the size of m_perturb by one as well.
761  */
763  m_rxneqn.push_back(r.equation);
764 
765  m_rxnPhaseIsReactant.push_back(std::vector<bool>(nPhases(), false));
766  m_rxnPhaseIsProduct.push_back(std::vector<bool>(nPhases(), false));
767 
768  size_t i = m_ii - 1;
769  const std::vector<size_t>& vr = reactants(i);
770  for (size_t ik = 0; ik < vr.size(); ik++) {
771  size_t k = vr[ik];
772  size_t p = speciesPhaseIndex(k);
773  m_rxnPhaseIsReactant[i][p] = true;
774  }
775  const std::vector<size_t>& vp = products(i);
776  for (size_t ik = 0; ik < vp.size(); ik++) {
777  size_t k = vp[ik];
778  size_t p = speciesPhaseIndex(k);
779  m_rxnPhaseIsProduct[i][p] = true;
780  }
781 }
782 
783 void InterfaceKinetics::addElementaryReaction(ReactionData& r)
784 {
785  // install rate coeff calculator
787  size_t ncov = r.cov.size();
788  if (ncov > 3) {
790  }
791  for (size_t m = 0; m < ncov; m++) {
792  rp.push_back(r.cov[m]);
793  }
794 
795  /*
796  * Temporarily change the reaction rate coefficient type to surface arrhenius.
797  * This is what is expected. We'll handle exchange current types below by hand.
798  */
799  int reactionRateCoeffType_orig = r.rateCoeffType;
800  if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) {
801  r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE;
802  }
803  if (r.rateCoeffType == ARRHENIUS_REACTION_RATECOEFF_TYPE) {
804  r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE;
805  }
806  /*
807  * Install the reaction rate into the vector of reactions handled by this class
808  */
809  size_t iloc = m_rates.install(reactionNumber(), r);
810 
811  /*
812  * Change the reaction rate coefficient type back to its original value
813  */
814  r.rateCoeffType = reactionRateCoeffType_orig;
815 
816  // store activation energy
817  m_E.push_back(r.rateCoeffParameters[2]);
818 
819  if (r.beta > 0.0) {
820  m_has_electrochem_rxns = true;
821  m_beta.push_back(r.beta);
822  m_ctrxn.push_back(reactionNumber());
823  if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) {
825  m_ctrxn_ecdf.push_back(1);
826  } else {
827  m_ctrxn_ecdf.push_back(0);
828  }
829  }
830 
831  // add constant term to rate coeff value vector
832  m_rfn.push_back(r.rateCoeffParameters[0]);
833  registerReaction(reactionNumber(), ELEMENTARY_RXN, iloc);
834 }
835 
836 void InterfaceKinetics::setIOFlag(int ioFlag)
837 {
838  m_ioFlag = ioFlag;
839  if (m_integrator) {
840  m_integrator->setIOFlag(ioFlag);
841  }
842 }
843 
844 // void InterfaceKinetics::
845 // addGlobalReaction(const ReactionData& r) {
846 
847 // int iloc;
848 // // install rate coeff calculator
849 // vector_fp rp = r.rateCoeffParameters;
850 // int ncov = r.cov.size();
851 // for (int m = 0; m < ncov; m++) rp.push_back(r.cov[m]);
852 // iloc = m_rates.install( reactionNumber(),
853 // r.rateCoeffType, rp.size(),
854 // rp.begin() );
855 // // store activation energy
856 // m_E.push_back(r.rateCoeffParameters[2]);
857 // // add constant term to rate coeff value vector
858 // m_rfn.push_back(r.rateCoeffParameters[0]);
859 
860 // int nr = r.order.size();
861 // vector_fp ordr(nr);
862 // for (int n = 0; n < nr; n++) {
863 // ordr[n] = r.order[n] - r.rstoich[n];
864 // }
865 // m_globalReactantStoich.add( reactionNumber(),
866 // r.reactants, ordr);
867 
868 // registerReaction( reactionNumber(), GLOBAL_RXN, iloc);
869 // }
870 
871 void InterfaceKinetics::installReagents(const ReactionData& r)
872 {
873 
874  size_t n, ns, m;
875  doublereal nsFlt;
876  /*
877  * extend temporary storage by one for this rxn.
878  */
879  m_ropf.push_back(0.0);
880  m_ropr.push_back(0.0);
881  m_ropnet.push_back(0.0);
882  m_rkcn.push_back(0.0);
883 
884  /*
885  * Obtain the current reaction index for the reaction that we
886  * are adding. The first reaction is labeled 0.
887  */
888  size_t rnum = reactionNumber();
889 
890  // vectors rk and pk are lists of species numbers, with
891  // repeated entries for species with stoichiometric
892  // coefficients > 1. This allows the reaction to be defined
893  // with unity reaction order for each reactant, and so the
894  // faster method 'multiply' can be used to compute the rate of
895  // progress instead of 'power'.
896 
897  std::vector<size_t> rk;
898  size_t nr = r.reactants.size();
899  for (n = 0; n < nr; n++) {
900  nsFlt = r.rstoich[n];
901  ns = (size_t) nsFlt;
902  if ((doublereal) ns != nsFlt) {
903  if (ns < 1) {
904  ns = 1;
905  }
906  }
907  /*
908  * Add to m_rrxn. m_rrxn is a vector of maps. m_rrxn has a length
909  * equal to the total number of species for each species, there
910  * exists a map, with the reaction number being the key, and the
911  * reactant stoichiometric coefficient being the value.
912  */
913  m_rrxn[r.reactants[n]][rnum] = nsFlt;
914  for (m = 0; m < ns; m++) {
915  rk.push_back(r.reactants[n]);
916  }
917  }
918  /*
919  * Now that we have rk[], we add it into the vector<vector_int> m_reactants
920  * in the rnum index spot. Thus m_reactants[rnum] yields a vector
921  * of reactants for the rnum'th reaction
922  */
923  m_reactants.push_back(rk);
924  std::vector<size_t> pk;
925  size_t np = r.products.size();
926  for (n = 0; n < np; n++) {
927  nsFlt = r.pstoich[n];
928  ns = (size_t) nsFlt;
929  if ((doublereal) ns != nsFlt) {
930  if (ns < 1) {
931  ns = 1;
932  }
933  }
934  /*
935  * Add to m_prxn. m_prxn is a vector of maps. m_prxn has a length
936  * equal to the total number of species for each species, there
937  * exists a map, with the reaction number being the key, and the
938  * product stoichiometric coefficient being the value.
939  */
940  m_prxn[r.products[n]][rnum] = nsFlt;
941  for (m = 0; m < ns; m++) {
942  pk.push_back(r.products[n]);
943  }
944  }
945  /*
946  * Now that we have pk[], we add it into the vector<vector_int> m_products
947  * in the rnum index spot. Thus m_products[rnum] yields a vector
948  * of products for the rnum'th reaction
949  */
950  m_products.push_back(pk);
951  /*
952  * Add this reaction to the stoichiometric coefficient manager. This
953  * calculates rates of species production from reaction rates of
954  * progress.
955  */
956  m_rxnstoich.add(reactionNumber(), r);
957  /*
958  * register reaction in lists of reversible and irreversible rxns.
959  */
960  if (r.reversible) {
961  m_revindex.push_back(reactionNumber());
962  m_nrev++;
963  } else {
964  m_irrev.push_back(reactionNumber());
965  m_nirrev++;
966  }
967 }
968 
970 {
971  Kinetics::addPhase(thermo);
972  m_phaseExists.push_back(true);
973  m_phaseIsStable.push_back(true);
974 }
975 
977 {
978  m_kk = 0;
979  for (size_t n = 0; n < nPhases(); n++) {
980  m_kk += thermo(n).nSpecies();
981  }
982  m_rrxn.resize(m_kk);
983  m_prxn.resize(m_kk);
984  m_conc.resize(m_kk);
985  m_mu0.resize(m_kk);
986  m_grt.resize(m_kk);
987  m_pot.resize(m_kk, 0.0);
988  m_phi.resize(nPhases(), 0.0);
989 }
990 
992 {
994  size_t safe_reaction_size = std::max<size_t>(nReactions(), 1);
995  m_rwork.resize(safe_reaction_size);
996  size_t ks = reactionPhaseIndex();
997  if (ks == npos) throw CanteraError("InterfaceKinetics::finalize",
998  "no surface phase is present.");
999  m_surf = (SurfPhase*)&thermo(ks);
1000  if (m_surf->nDim() != 2)
1001  throw CanteraError("InterfaceKinetics::finalize",
1002  "expected interface dimension = 2, but got dimension = "
1003  +int2str(m_surf->nDim()));
1004 
1005  m_StandardConc.resize(m_kk, 0.0);
1006  m_deltaG0.resize(safe_reaction_size, 0.0);
1007  m_ProdStanConcReac.resize(safe_reaction_size, 0.0);
1008 
1009  if (m_thermo.size() != m_phaseExists.size()) {
1010  throw CanteraError("InterfaceKinetics::finalize", "internal error");
1011  }
1012 
1013  // Guarantee that these arrays can be converted to double* even in the
1014  // special case where there are no reactions defined.
1015  if (!m_ii) {
1016  m_perturb.resize(1, 1.0);
1017  m_ropf.resize(1, 0.0);
1018  m_ropr.resize(1, 0.0);
1019  m_ropnet.resize(1, 0.0);
1020  m_rkcn.resize(1, 0.0);
1021  }
1022 
1023  m_finalized = true;
1024 }
1025 
1026 doublereal InterfaceKinetics::electrochem_beta(size_t irxn) const
1027 {
1028  for (size_t i = 0; i < m_ctrxn.size(); i++) {
1029  if (m_ctrxn[i] == irxn) {
1030  return m_beta[i];
1031  }
1032  }
1033  return 0.0;
1034 }
1035 
1037 {
1038  return m_finalized;
1039 }
1040 
1042 advanceCoverages(doublereal tstep)
1043 {
1044  if (m_integrator == 0) {
1045  vector<InterfaceKinetics*> k;
1046  k.push_back(this);
1047  m_integrator = new ImplicitSurfChem(k);
1049  }
1050  m_integrator->integrate(0.0, tstep);
1051  delete m_integrator;
1052  m_integrator = 0;
1053 }
1054 
1056 solvePseudoSteadyStateProblem(int ifuncOverride, doublereal timeScaleOverride)
1057 {
1058  // create our own solver object
1059  if (m_integrator == 0) {
1060  vector<InterfaceKinetics*> k;
1061  k.push_back(this);
1062  m_integrator = new ImplicitSurfChem(k);
1064  }
1065  m_integrator->setIOFlag(m_ioFlag);
1066  /*
1067  * New direct method to go here
1068  */
1069  m_integrator->solvePseudoSteadyStateProblem(ifuncOverride, timeScaleOverride);
1070 }
1071 
1072 void InterfaceKinetics::setPhaseExistence(const size_t iphase, const int exists)
1073 {
1074  if (iphase >= m_thermo.size()) {
1075  throw CanteraError("InterfaceKinetics:setPhaseExistence", "out of bounds");
1076  }
1077  if (exists) {
1078  if (!m_phaseExists[iphase]) {
1080  if (m_phaseExistsCheck < 0) {
1081  m_phaseExistsCheck = 0;
1082  }
1083  m_phaseExists[iphase] = true;
1084  }
1085  m_phaseIsStable[iphase] = true;
1086  } else {
1087  if (m_phaseExists[iphase]) {
1089  m_phaseExists[iphase] = false;
1090  }
1091  m_phaseIsStable[iphase] = false;
1092  }
1093 
1094 }
1095 
1096 int InterfaceKinetics::phaseExistence(const size_t iphase) const
1097 {
1098  if (iphase >= m_thermo.size()) {
1099  throw CanteraError("InterfaceKinetics:phaseExistence()", "out of bounds");
1100  }
1101  return m_phaseExists[iphase];
1102 }
1103 
1104 int InterfaceKinetics::phaseStability(const size_t iphase) const
1105 {
1106  if (iphase >= m_thermo.size()) {
1107  throw CanteraError("InterfaceKinetics:phaseStability()", "out of bounds");
1108  }
1109  return m_phaseIsStable[iphase];
1110 }
1111 
1112 void InterfaceKinetics::setPhaseStability(const size_t iphase, const int isStable)
1113 {
1114  if (iphase >= m_thermo.size()) {
1115  throw CanteraError("InterfaceKinetics:setPhaseStability", "out of bounds");
1116  }
1117  if (isStable) {
1118  m_phaseIsStable[iphase] = true;
1119  } else {
1120  m_phaseIsStable[iphase] = false;
1121  }
1122 }
1123 
1125 {
1126  m_rwork.resize(std::max<size_t>(nReactions(), 1));
1127  size_t ks = reactionPhaseIndex();
1128  if (ks == npos) throw CanteraError("EdgeKinetics::finalize",
1129  "no edge phase is present.");
1130  m_surf = (SurfPhase*)&thermo(ks);
1131  if (m_surf->nDim() != 1)
1132  throw CanteraError("EdgeKinetics::finalize",
1133  "expected interface dimension = 1, but got dimension = "
1134  +int2str(m_surf->nDim()));
1135 
1136  // Guarantee that these arrays can be converted to double* even in the
1137  // special case where there are no reactions defined.
1138  if (!m_ii) {
1139  m_perturb.resize(1, 1.0);
1140  m_ropf.resize(1, 0.0);
1141  m_ropr.resize(1, 0.0);
1142  m_ropnet.resize(1, 0.0);
1143  m_rkcn.resize(1, 0.0);
1144  }
1145 
1146  m_finalized = true;
1147 }
1148 
1149 }
virtual void getActivationEnergies(doublereal *E)
Return the activation energies in Kelvin.
virtual void getNetProductionRates(size_t nsp, const doublereal *ropnet, doublereal *w)
Species net production rates.
void setElectricPotential(int n, doublereal V)
Set the electric potential in the nth phase.
int phaseStability(const size_t iphase) const
Gets the phase stability int for the ith phase.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:40
std::vector< thermo_t * > m_thermo
m_thermo is a vector of pointers to ThermoPhase objects that are involved with this kinetics operator...
Definition: Kinetics.h:938
virtual void getCreationRates(doublereal *cdot)
Species creation rates [kmol/m^3/s or kmol/m^2/s].
doublereal electricPotential() const
Returns the electric potential of this phase (V).
Definition: ThermoPhase.h:391
void incrementRxnCount()
Increment the number of reactions in the mechanism by one.
Definition: Kinetics.h:859
virtual bool ready() const
Returns true if the kinetics manager has been properly initialized and finalized. ...
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
std::vector< std::vector< size_t > > m_reactants
This is a vector of vectors containing the reactants for each reaction.
Definition: Kinetics.h:908
doublereal m_logtemp
Current log of the temperature.
virtual void getDeltaEnthalpy(doublereal *deltaH)
Return the vector of values for the reactions change in enthalpy.
virtual void getDestructionRates(size_t nSpecies, const doublereal *fwdRatesOfProgress, const doublereal *revRatesOfProgress, doublereal *destructionRates)
Species destruction rates.
virtual void assignShallowPointers(const std::vector< thermo_t * > &tpVector)
Reassign the pointers within the Kinetics object.
Definition: Kinetics.cpp:144
virtual void getNetProductionRates(doublereal *net)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
doublereal electrochem_beta(size_t irxn) const
Return the charge transfer rxn Beta parameter for the ith reaction.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
Definition: ThermoPhase.h:721
thermo_t & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism...
Definition: Kinetics.h:288
void setElectricPotential(doublereal v)
Set the electric potential of this phase (V).
Definition: ThermoPhase.h:383
void solvePseudoSteadyStateProblem(int ifuncOverride=-1, doublereal timeScaleOverride=1.0)
Solve for the pseudo steady-state of the surface problem.
virtual void getCreationRates(size_t nSpecies, const doublereal *fwdRatesOfProgress, const doublereal *revRatesOfProgress, doublereal *creationRates)
Species creation rates.
size_t m_kk
The number of species in all of the phases that participate in this kinetics mechanism.
Definition: Kinetics.h:891
SurfPhase * m_surf
Pointer to the single surface phase.
int phaseExistence(const size_t iphase) const
Gets the phase existence int for the ith phase.
virtual void getRevReactionDelta(size_t nr, const doublereal *g, doublereal *dg)
Given an array of species properties 'g', return in array 'dg' the change in this quantity in the rev...
std::vector< size_t > m_start
m_start is a vector of integers specifying the beginning position for the species vector for the n'th...
Definition: Kinetics.h:945
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:173
vector_fp m_phi
Vector of phase electric potentials.
void advanceCoverages(doublereal tstep)
Advance the surface coverages in time.
vector_fp cov
Adjustments to the Arrhenius rate expression dependent on surface species coverages.
Definition: ReactionData.h:119
doublereal beta
for electrochemical reactions
Definition: ReactionData.h:133
void applyButlerVolmerCorrection(doublereal *const kf)
Apply corrections for interfacial charge transfer reactions.
virtual const std::vector< size_t > & products(size_t i) const
Returns a read-only reference to the vector of product index numbers for reaction i...
Definition: Kinetics.h:683
virtual void getReactionDelta(size_t nReactions, const doublereal *g, doublereal *dg)
Calculates the change of a molar species property in a reaction.
virtual void getDeltaEntropy(doublereal *deltaS)
Return the vector of values for the reactions change in entropy.
virtual ~InterfaceKinetics()
Destructor.
virtual void getDeltaSSEntropy(doublereal *deltaS)
Return the vector of values for the change in the standard state entropies for each reaction...
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
Definition: Kinetics.h:300
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:76
virtual void getEquilibriumConstants(doublereal *kc)
Return a vector of Equilibrium constants.
std::vector< std::vector< bool > > m_rxnPhaseIsProduct
Vector of vector of booleans indicating whether a phase participates in a reaction as a product...
void registerReaction(size_t rxnNumber, int type, size_t loc)
Write values into m_index.
virtual std::string reactionString(size_t i) const
Return a string representing the reaction.
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Definition: ThermoPhase.h:711
virtual void addReaction(ReactionData &r)
Add a single reaction to the mechanism.
size_t reactionPhaseIndex()
Phase where the reactions occur.
Definition: Kinetics.h:275
virtual void getFwdRatesOfProgress(doublereal *fwdROP)
Return the forward rates of progress of the reactions.
size_t m_nrev
Number of reversible reactions in the mechanism.
std::vector< std::map< size_t, doublereal > > m_prxn
m_prxn is a vector of maps, containing the reactant stoichiometric coefficient information ...
bool m_has_electrochem_rxns
Boolean flag indicating whether any reaction in the mechanism has a beta electrochemical parameter...
std::vector< std::string > m_rxneqn
String expression for each rxn.
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:318
void multiply_each(OutputIter x_begin, OutputIter x_end, InputIter y_begin)
Multiply each entry in x by the corresponding entry in y.
Definition: utilities.h:227
int m_phaseExistsCheck
Int flag to indicate that some phases in the kinetics mechanism are non-existent. ...
virtual void finalize()
Finish adding reactions and prepare for use.
vector_fp rateCoeffParameters
Vector of rate coefficient parameters.
Definition: ReactionData.h:91
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: ThermoPhase.h:487
virtual void getDestructionRates(doublereal *ddot)
Species destruction rates [kmol/m^3/s or kmol/m^2/s].
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
void updateKc()
Update the equilibrium constants in molar units for all reversible reactions.
std::string equation
The reaction equation. Used only for display purposes.
Definition: ReactionData.h:109
doublereal m_temp
Current temperature of the data.
std::vector< std::map< size_t, doublereal > > m_rrxn
m_rrxn is a vector of maps, containing the reactant stoichiometric coefficient information ...
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
size_t surfacePhaseIndex()
This returns the integer index of the phase which has ThermoPhase type cSurf.
Definition: Kinetics.h:263
bool m_has_coverage_dependence
Boolean flag indicating whether any reaction in the mechanism has a coverage dependent forward reacti...
virtual void multiplyReactants(const doublereal *C, doublereal *R)
Given an array of concentrations C, multiply the entries in array R by the concentration products for...
vector_int m_ctrxn_ecdf
Vector of booleans indicating whether the charge transfer reaction may be described by an exchange cu...
virtual void getDeltaGibbs(doublereal *deltaG)
Return the vector of values for the reaction gibbs free energy change.
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
vector_fp m_E
Vector of raw activation energies for the reactions.
size_t nPhases() const
The number of phases participating in the reaction mechanism.
Definition: Kinetics.h:228
A kinetics manager for heterogeneous reaction mechanisms.
virtual void getNetRatesOfProgress(doublereal *netROP)
Net rates of progress.
vector_fp m_conc
an array of generalized concentrations for each species
void solvePseudoSteadyStateProblem(int ifuncOverride=-1, doublereal timeScaleOverride=1.0)
Solve for the pseudo steady-state of the surface problem.
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:29
virtual int type() const
Identifies the kinetics manager type.
std::vector< bool > m_phaseExists
Vector of booleans indicating whether phases exist or not.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: ThermoPhase.h:595
void _update_rates_T()
Update properties that depend on temperature.
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
Definition: Kinetics.h:895
Public interface for kinetics managers.
Definition: Kinetics.h:131
virtual void getActivityConcentrations(doublereal *const conc)
Get the vector of activity concentrations used in the kinetics object.
void _update_rates_C()
Update properties that depend on the species mole fractions and/or concentration,.
vector_fp m_pot
Vector of potential energies due to Voltages.
Intermediate class which stores data about a reaction and its rate parameterization before adding the...
Definition: ReactionData.h:16
size_t m_nirrev
Number of irreversible reactions in the mechanism.
void setPhaseStability(const size_t iphase, const int isStable)
Set the stability of a phase in the reaction object.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: ThermoPhase.h:638
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
bool m_has_exchange_current_density_formulation
Boolean flag indicating whether any reaction in the mechanism is described by an exchange current den...
Declarations for the implicit integration of surface site density equations (see Kinetics Managers an...
std::vector< std::vector< bool > > m_rxnPhaseIsReactant
Vector of vector of booleans indicating whether a phase participates in a reaction as a reactant...
Kinetics & operator=(const Kinetics &right)
Assignment operator.
Definition: Kinetics.cpp:62
virtual void getRevRatesOfProgress(doublereal *revROP)
Return the Reverse rates of progress of the reactions.
std::vector< size_t > m_revindex
List of reactions numbers which are reversible reactions.
virtual const std::vector< size_t > & reactants(size_t i) const
Returns a read-only reference to the vector of reactant index numbers for reaction i...
Definition: Kinetics.h:673
virtual void getRevRateConstants(doublereal *krev, bool doIrreversible=false)
Return the reverse rate constants.
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:252
int rateCoeffType
Type of the rate coefficient for the forward rate constant.
Definition: ReactionData.h:86
void _update_rates_phi()
Update properties that depend on the electric potential.
virtual void init()
Prepare the class for the addition of reactions.
std::vector< size_t > m_irrev
Vector of irreversible reaction numbers.
Advances the surface coverages of the associated set of SurfacePhase objects in time.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
Definition: ThermoPhase.h:731
doublereal temperature() const
Temperature (K).
Definition: Phase.h:528
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
Definition: Phase.h:512
InterfaceKinetics(thermo_t *thermo=0)
Constructor.
virtual Kinetics * duplMyselfAsKinetics(const std::vector< thermo_t * > &tpVector) const
Duplication routine for objects which inherit from Kinetics.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Definition: ThermoPhase.h:465
void applyExchangeCurrentDensityFormulation(doublereal *const kfwd)
When an electrode reaction rate is optionally specified in terms of its exchange current density...
virtual void initialize(doublereal t0=0.0)
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
void updateROP()
Internal routine that updates the Rates of Progress of the reactions.
size_t speciesPhaseIndex(size_t k)
This function takes as an argument the kineticsSpecies index (i.e., the list index in the list of spe...
Definition: Kinetics.cpp:244
std::vector< std::vector< size_t > > m_products
This is a vector of vectors containing the products for each reaction.
Definition: Kinetics.h:921
std::vector< int > m_phaseIsStable
Vector of int indicating whether phases are stable or not.
Rate1< SurfaceArrhenius > m_rates
Templated class containing the vector of reactions for this interface.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:66
vector_fp m_rwork
Vector temporary.
size_t m_ii
Number of reactions in the mechanism.
Definition: Kinetics.h:887
const int ELEMENTARY_RXN
A reaction with a rate coefficient that depends only on temperature.
Definition: reaction_defs.h:26
std::vector< size_t > m_ctrxn
Vector of reaction indexes specifying the id of the current transfer reactions in the mechanism...
virtual void multiplyRevProducts(const doublereal *c, doublereal *r)
Given an array of concentrations C, multiply the entries in array R by the concentration products for...
size_t nReactions() const
Number of reactions in the reaction mechanism.
Definition: Kinetics.h:196
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
Definition: ct_defs.h:36
void setPhaseExistence(const size_t iphase, const int exists)
Set the existence of a phase in the reaction object.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: ThermoPhase.h:628
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
void writelog(const std::string &msg)
Write a message to the screen.
Definition: global.cpp:43
std::map< size_t, std::pair< int, size_t > > m_index
Vector of information about reactions in the mechanism.
virtual void getDeltaSSGibbs(doublereal *deltaG)
Return the vector of values for the reaction standard state gibbs free energy change.
virtual void getDeltaElectrochemPotentials(doublereal *deltaM)
Return the vector of values for the reaction electrochemical free energy change.
ReactionStoichMgr m_rxnstoich
Stoichiometric manager for the reaction mechanism.
virtual void finalize()
Finish adding reactions and prepare for use.
Definition: Kinetics.cpp:290
vector_fp m_mu0
Vector of standard state chemical potentials.
vector_fp m_grt
Temporary work vector of length m_kk.
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
Definition: Kinetics.cpp:255
virtual void getDeltaSSEnthalpy(doublereal *deltaH)
Return the vector of values for the change in the standard state enthalpies of reaction.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
Definition: ThermoPhase.h:614
ImplicitSurfChem * m_integrator
Pointer to the Implicit surface chemistry object.
void integrate(doublereal t0, doublereal t1)
Integrate from t0 to t1. The integrator is reinitialized first.
InterfaceKinetics & operator=(const InterfaceKinetics &right)
Assignment operator.
bool m_finalized
boolean indicating whether mechanism has been finalized
virtual void finalize()
Finish adding reactions and prepare for use.
virtual void add(size_t rxn, const std::vector< size_t > &reactants, const std::vector< size_t > &products, bool reversible)
Add a reaction with mass-action kinetics.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
Definition: Phase.h:504