|
3 | 3 | # stochiometric coefficient. |
4 | 4 | ############################################################################### |
5 | 5 |
|
6 | | -@inline function evalrxrate(speciesvec::AbstractVector{T}, rxidx::S, |
7 | | - majump::MassActionJump{U, V, W, X})::R where |
8 | | - {T, S, R, U <: AbstractVector{R}, V, W, X} |
| 6 | +@inline function evalrxrate(speciesvec::AbstractVector{T}, rxidx, |
| 7 | + majump::MassActionJump{U})::R where {T <: Integer, R, U <: AbstractVector{R}} |
9 | 8 | val = one(T) |
10 | 9 | @inbounds for specstoch in majump.reactant_stoch[rxidx] |
11 | 10 | specpop = speciesvec[specstoch[1]] |
|
19 | 18 | @inbounds return val * majump.scaled_rates[rxidx] |
20 | 19 | end |
21 | 20 |
|
| 21 | +@inline function evalrxrate(speciesvec::AbstractVector{T}, rxidx, |
| 22 | + majump::MassActionJump{U})::R where {T <: Real, R, U <: AbstractVector{R}} |
| 23 | + val = one(T) |
| 24 | + @inbounds for specstoch in majump.reactant_stoch[rxidx] |
| 25 | + specpop = speciesvec[specstoch[1]] |
| 26 | + val *= specpop |
| 27 | + @inbounds for k in 2:specstoch[2] |
| 28 | + specpop -= one(specpop) |
| 29 | + val *= specpop |
| 30 | + end |
| 31 | + # we need to check the smallest rate law term is positive |
| 32 | + # i.e. for an order k reaction: x - k + 1 > 0 |
| 33 | + (specpop <= 0) && return zero(R) |
| 34 | + end |
| 35 | + |
| 36 | + @inbounds return val * majump.scaled_rates[rxidx] |
| 37 | +end |
| 38 | + |
| 39 | + |
22 | 40 | @inline function executerx!(speciesvec::AbstractVector{T}, rxidx::S, |
23 | 41 | majump::M) where {T, S, M <: AbstractMassActionJump} |
24 | 42 | @inbounds net_stoch = majump.net_stoch[rxidx] |
|
0 commit comments