| 382 | } |
| 383 | |
| 384 | bool InterfaceKinetics::addReaction(shared_ptr<Reaction> r_base, bool resize) |
| 385 | { |
| 386 | if (!m_surf) { |
| 387 | init(); |
| 388 | } |
| 389 | |
| 390 | size_t i = nReactions(); |
| 391 | shared_ptr<ReactionRate> rate = r_base->rate(); |
| 392 | if (rate) { |
| 393 | rate->setContext(*r_base, *this); |
| 394 | } |
| 395 | |
| 396 | bool added = Kinetics::addReaction(r_base, resize); |
| 397 | if (!added) { |
| 398 | return false; |
| 399 | } |
| 400 | |
| 401 | m_rxnPhaseIsReactant.emplace_back(nPhases(), false); |
| 402 | m_rxnPhaseIsProduct.emplace_back(nPhases(), false); |
| 403 | |
| 404 | for (const auto& [name, stoich] : r_base->reactants) { |
| 405 | size_t k = kineticsSpeciesIndex(name); |
| 406 | size_t p = speciesPhaseIndex(k); |
| 407 | m_rxnPhaseIsReactant[i][p] = true; |
| 408 | } |
| 409 | for (const auto& [name, stoich] : r_base->products) { |
| 410 | size_t k = kineticsSpeciesIndex(name); |
| 411 | size_t p = speciesPhaseIndex(k); |
| 412 | m_rxnPhaseIsProduct[i][p] = true; |
| 413 | } |
| 414 | |
| 415 | // Set index of rate to number of reaction within kinetics |
| 416 | rate->setRateIndex(nReactions() - 1); |
| 417 | |
| 418 | string rtype = rate->subType(); |
| 419 | if (rtype == "") { |
| 420 | rtype = rate->type(); |
| 421 | } |
| 422 | |
| 423 | // If necessary, add new interface MultiRate evaluator |
| 424 | if (m_rateTypes.find(rtype) == m_rateTypes.end()) { |
| 425 | m_rateTypes[rtype] = m_rateHandlers.size(); |
| 426 | m_rateHandlers.push_back(rate->newMultiRate()); |
| 427 | m_rateHandlers.back()->resize(m_kk, nReactions(), nPhases()); |
| 428 | } |
| 429 | |
| 430 | // Add reaction rate to evaluator |
| 431 | size_t index = m_rateTypes[rtype]; |
| 432 | m_rateHandlers[index]->add(nReactions() - 1, *rate); |
| 433 | |
| 434 | // Set flag for coverage dependence to true |
| 435 | if (rate->compositionDependent()) { |
| 436 | m_has_coverage_dependence = true; |
| 437 | } |
| 438 | |
| 439 | // Set flag for electrochemistry to true |
| 440 | if (r_base->usesElectrochemistry(*this)) { |
| 441 | m_has_electrochemistry = true; |
nothing calls this directly
no test coverage detected