|
535 | 535 |
|
536 | 536 | export calcbranchingnumbers
|
537 | 537 |
|
| 538 | +""" |
| 539 | +Calculate the ratio of net consumption/termination of core radicals contributed by each edge reaction compared to all core reactions |
| 540 | +""" |
| 541 | +function calcradconstermratios(sim,reactantinds,productinds,corespcsinds,corerxninds,edgerxninds,edgereactionrates,corespeciesnetconsumptionrates,coreradicalnetterminationrates) |
| 542 | + radconstermratios = zeros(length(edgereactionrates)) |
| 543 | + for ind in 1:length(edgereactionrates) |
| 544 | + chain_termination = false |
| 545 | + chain_transfer = false |
| 546 | + |
| 547 | + index = edgerxninds[ind] |
| 548 | + reactionrate = edgereactionrates[ind] |
| 549 | + |
| 550 | + if reactionrate > 0 |
| 551 | + reactantside = reactantinds[:,index] |
| 552 | + productside = productinds[:,index] |
| 553 | + else |
| 554 | + reactantside = productinds[:,index] |
| 555 | + productside = reactantinds[:,index] |
| 556 | + end |
| 557 | + |
| 558 | + productrade = [sim.species[i].radicalelectrons for i in productside if i != 0] |
| 559 | + reactantrade = [sim.species[i].radicalelectrons for i in reactantside if i != 0] |
| 560 | + |
| 561 | + if length(productrade) == 1 && length(reactantrade) == 2 |
| 562 | + if productrade[1] == 0 && reactantrade[1] == 1 && reactantrade[2] == 1 |
| 563 | + chain_termination = true |
| 564 | + end |
| 565 | + elseif length(reactantrade) == length(productrade) && length(productrade) == 2 |
| 566 | + if (0 in reactantrade && 1 in reactantrade) && (0 in productrade && 1 in productrade) |
| 567 | + chain_transfer = true |
| 568 | + end |
| 569 | + end |
| 570 | + |
| 571 | + if !(chain_transfer || chain_termination) |
| 572 | + continue |
| 573 | + end |
| 574 | + |
| 575 | + for spcindex in reactantside |
| 576 | + if spcindex == 0 |
| 577 | + continue |
| 578 | + elseif spcindex in corespcsinds |
| 579 | + if sim.species[spcindex].radicalelectrons != 1 |
| 580 | + continue |
| 581 | + end |
| 582 | + |
| 583 | + if chain_transfer |
| 584 | + consumption = corespeciesnetconsumptionrates[spcindex] |
| 585 | + consumption = max(consumption, 1e-40) # avoid divide by zeros |
| 586 | + radconstermratio = abs(reactionrate) / consumption |
| 587 | + end |
| 588 | + |
| 589 | + if chain_termination |
| 590 | + termination = coreradicalnetterminationrates[spcindex] |
| 591 | + termination = max(termination, 1e-40) # avoid divide by zeros |
| 592 | + radconstermratio = abs(reactionrate) / termination |
| 593 | + end |
| 594 | + |
| 595 | + if radconstermratio > radconstermratios[ind] |
| 596 | + radconstermratios[ind] = radconstermratio |
| 597 | + end |
| 598 | + end |
| 599 | + end |
| 600 | + end |
| 601 | + return radconstermratios |
| 602 | +end |
| 603 | + |
| 604 | +export calcradconstermratios |
| 605 | + |
538 | 606 | """
|
539 | 607 | determine species pairings that are concentrated enough that they should be reacted
|
540 | 608 | """
|
|
0 commit comments