22 InterfaceKineticsData::InterfaceKineticsData() :
31 InterfaceKineticsData:: InterfaceKineticsData(
const InterfaceKineticsData& right) :
41 InterfaceKineticsData::~InterfaceKineticsData()
50 m_logp0 = right.m_logp0;
51 m_logc0 = right.m_logc0;
52 m_ropf = right.m_ropf;
53 m_ropr = right.m_ropr;
54 m_ropnet = right.m_ropnet;
55 m_ROP_ok = right.m_ROP_ok;
59 m_rkcn = right.m_rkcn;
71 InterfaceKinetics::InterfaceKinetics(
thermo_t* thermo) :
83 m_ProdStanConcReac(0),
85 m_has_coverage_dependence(false),
86 m_has_electrochem_rxns(false),
87 m_has_exchange_current_density_formulation(false),
88 m_phaseExistsCheck(false),
91 m_rxnPhaseIsReactant(0),
92 m_rxnPhaseIsProduct(0),
111 for (
size_t i = 0; i <
m_ii; i++) {
134 m_ProdStanConcReac(0),
136 m_has_coverage_dependence(false),
137 m_has_electrochem_rxns(false),
138 m_has_exchange_current_density_formulation(false),
139 m_phaseExistsCheck(false),
142 m_rxnPhaseIsReactant(0),
143 m_rxnPhaseIsProduct(0),
167 if (
this == &right) {
171 for (
size_t i = 0; i <
m_ii; i++) {
181 m_redo_rates = right.m_redo_rates;
199 m_beta = right.m_beta;
202 m_StandardConc = right.m_StandardConc;
203 m_deltaG0 = right.m_deltaG0;
204 m_ProdStanConcReac = right.m_ProdStanConcReac;
216 for (
size_t i = 0; i <
m_ii; i++) {
219 for (
size_t p = 0; p < np; p++) {
225 m_ioFlag = right.m_ioFlag;
233 return cInterfaceKinetics;
238 return cInterfaceKinetics;
303 m_redo_rates =
false;
309 for (
size_t n = 0; n <
nPhases(); n++) {
328 for (
size_t n = 0; n <
nPhases(); n++) {
363 fill(m_rkc.begin(), m_rkc.end(), 0.0);
370 doublereal rrt = 1.0 / rt;
372 for (
size_t n = 0; n < np; n++) {
375 for (
size_t k = 0; k < nsp; k++) {
386 for (
size_t i = 0; i <
m_nrev; i++) {
390 "illegal value: irxn = "+
int2str(irxn));
392 m_rkc[irxn] = exp(m_rkc[irxn]*rrt);
394 for (
size_t i = 0; i !=
m_nirrev; ++i) {
403 void InterfaceKinetics::checkPartialEquil()
417 for (
size_t n = 0; n <
nPhases(); n++) {
420 for (
size_t k = 0; k < nsp; k++) {
433 for (
size_t i = 0; i <
m_nrev; i++) {
436 <<
" " << rmu[irxn]/rt << endl;
437 printf(
"%12.6e %12.6e %12.6e %12.6e \n",
438 frop[irxn], rrop[irxn], netrop[irxn],
439 netrop[irxn]/(frop[irxn] + rrop[irxn]));
453 doublereal rrt = 1.0/rt;
454 for (
size_t n = 0; n <
nPhases(); n++) {
457 for (
size_t k = 0; k < nsp; k++) {
464 fill(kc, kc +
m_ii, 0.0);
468 for (
size_t i = 0; i <
m_ii; i++) {
469 kc[i] = exp(-kc[i]*rrt);
473 void InterfaceKinetics::getExchangeCurrentQuantities()
483 for (
size_t n = 0; n <
nPhases(); n++) {
486 for (
size_t k = 0; k < nsp; k++) {
494 for (
size_t i = 0; i <
m_ii; i++) {
495 m_ProdStanConcReac[i] = 1.0;
566 for (
size_t n = 0; n <
nPhases(); n++) {
568 for (
size_t k = 0; k < nsp; k++) {
590 #ifdef DEBUG_KIN_MODE
593 for (
size_t i = 0; i < m_beta.size(); i++) {
595 eamod = m_beta[i]*
m_rwork[irxn];
598 #ifdef DEBUG_KIN_MODE
600 if (eamod + ea < 0.0) {
601 writelog(
"Warning: act energy mod too large!\n");
605 for (n = 0; n < np; n++) {
612 doublereal rrt = 1.0/rt;
613 kf[irxn] *= exp(-eamod*rrt);
620 getExchangeCurrentQuantities();
622 doublereal rrt = 1.0/rt;
623 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
626 if (iECDFormulation) {
627 double tmp = exp(- m_beta[i] * m_deltaG0[irxn] * rrt);
628 double tmp2 = m_ProdStanConcReac[irxn];
629 tmp *= 1.0 / tmp2 / Faraday;
649 copy(rf.begin(), rf.end(), kfwd);
664 if (doIrreversible) {
667 for (
size_t i = 0; i <
m_ii; i++) {
679 copy(
m_E.begin(),
m_E.end(), E);
703 copy(rf.begin(), rf.end(), ropf.begin());
709 copy(ropf.begin(), ropf.end(), ropr.begin());
729 for (
size_t j = 0; j !=
m_ii; ++j) {
730 ropnet[j] = ropf[j] - ropr[j];
740 for (
size_t j = 0; j !=
m_ii; ++j) {
741 if ((ropr[j] > ropf[j]) && (ropr[j] > 0.0)) {
742 for (
size_t p = 0; p <
nPhases(); p++) {
748 for (
size_t rp = 0; rp <
nPhases(); rp++) {
752 ropr[j] = ropf[j] = 0.0;
766 }
else if ((ropf[j] > ropr[j]) && (ropf[j] > 0.0)) {
767 for (
size_t p = 0; p <
nPhases(); p++) {
773 for (
size_t rp = 0; rp <
nPhases(); rp++) {
777 ropf[j] = ropr[j] = 0.0;
798 #ifdef KINETICS_WITH_INTERMEDIATE_ZEROED_PHASES
800 InterfaceKinetics::adjustRatesForIntermediatePhases()
802 doublereal sFac = 1.0;
808 getCreatingRates(
DATA_PTR(m_speciestmpP));
811 for (iphase = 0; iphase < nphases; iphase++) {
812 if (m_intermediatePhases(iphase)) {
813 for (isp = 0; isp < nspecies; isp++) {
847 for (
size_t n = 0; n <
nPhases(); n++) {
878 for (
size_t n = 0; n < np; n++) {
905 for (
size_t n = 0; n <
nPhases(); n++) {
934 for (
size_t n = 0; n <
nPhases(); n++) {
963 for (
size_t n = 0; n <
nPhases(); n++) {
992 for (
size_t n = 0; n <
nPhases(); n++) {
996 for (
size_t k = 0; k <
m_kk; k++) {
1024 for (
size_t n = 0; n <
nPhases(); n++) {
1028 for (
size_t k = 0; k <
m_kk; k++) {
1059 addElementaryReaction(r);
1083 size_t i = m_ii - 1;
1087 for (
size_t p = 0; p < np; p++) {
1092 const std::vector<size_t>& vr =
reactants(i);
1093 for (
size_t ik = 0; ik < vr.size(); ik++) {
1098 const std::vector<size_t>& vp =
products(i);
1099 for (
size_t ik = 0; ik < vp.size(); ik++) {
1106 void InterfaceKinetics::addElementaryReaction(ReactionData& r)
1110 size_t ncov = r.cov.size();
1114 for (
size_t m = 0; m < ncov; m++) {
1115 rp.push_back(r.cov[m]);
1122 int reactionRateCoeffType_orig = r.rateCoeffType;
1123 if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) {
1124 r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE;
1126 if (r.rateCoeffType == ARRHENIUS_REACTION_RATECOEFF_TYPE) {
1127 r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE;
1137 r.rateCoeffType = reactionRateCoeffType_orig;
1140 m_E.push_back(r.rateCoeffParameters[2]);
1144 m_beta.push_back(r.beta);
1145 m_ctrxn.push_back(reactionNumber());
1146 if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) {
1155 m_kdata->m_rfn.push_back(r.rateCoeffParameters[0]);
1160 void InterfaceKinetics::setIOFlag(
int ioFlag)
1196 void InterfaceKinetics::installReagents(
const ReactionData& r)
1204 m_kdata->m_ropf.push_back(0.0);
1205 m_kdata->m_ropr.push_back(0.0);
1206 m_kdata->m_ropnet.push_back(0.0);
1207 m_kdata->m_rkcn.push_back(0.0);
1213 size_t rnum = reactionNumber();
1222 std::vector<size_t> rk;
1223 size_t nr = r.reactants.size();
1224 for (n = 0; n < nr; n++) {
1225 nsFlt = r.rstoich[n];
1226 ns = (size_t) nsFlt;
1227 if ((doublereal) ns != nsFlt) {
1238 m_rrxn[r.reactants[n]][rnum] = nsFlt;
1239 for (m = 0; m < ns; m++) {
1240 rk.push_back(r.reactants[n]);
1249 std::vector<size_t> pk;
1250 size_t np = r.products.size();
1251 for (n = 0; n < np; n++) {
1252 nsFlt = r.pstoich[n];
1253 ns = (size_t) nsFlt;
1254 if ((doublereal) ns != nsFlt) {
1265 m_prxn[r.products[n]][rnum] = nsFlt;
1266 for (m = 0; m < ns; m++) {
1267 pk.push_back(r.products[n]);
1289 m_irrev.push_back(reactionNumber());
1312 for (
size_t n = 0; n <
nPhases(); n++) {
1335 size_t safe_reaction_size = std::max<size_t>(
nReactions(), 1);
1336 m_rwork.resize(safe_reaction_size);
1339 "no surface phase is present.");
1343 "expected interface dimension = 2, but got dimension = "
1346 m_StandardConc.resize(
m_kk, 0.0);
1347 m_deltaG0.resize(safe_reaction_size, 0.0);
1348 m_ProdStanConcReac.resize(safe_reaction_size, 0.0);
1351 throw CanteraError(
"InterfaceKinetics::finalize",
"internal error");
1365 for (
size_t i = 0; i <
m_ctrxn.size(); i++) {
1387 vector<InterfaceKinetics*> k;
1414 vector<InterfaceKinetics*> k;
1430 throw CanteraError(
"InterfaceKinetics:setPhaseExistence",
"out of bounds");
1456 if (iphase < 0 || iphase >= (
int)
m_thermo.size()) {
1457 throw CanteraError(
"InterfaceKinetics:phaseExistence()",
"out of bounds");
1473 if (iphase < 0 || iphase >= (
int)
m_thermo.size()) {
1474 throw CanteraError(
"InterfaceKinetics:phaseStability()",
"out of bounds");
1482 if (iphase < 0 || iphase >= (
int)
m_thermo.size()) {
1483 throw CanteraError(
"InterfaceKinetics:setPhaseStability",
"out of bounds");
1498 "no edge phase is present.");
1502 "expected interface dimension = 1, but got dimension = "