Skip to content

Commit e9ee923

Browse files
committed
handle multiplication by neg one
1 parent 9e7d373 commit e9ee923

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/systems/reaction/reactionsystem.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ function assemble_drift(rs)
7979
for (spec,stoich) in rx.netstoich
8080
i = species_to_idx[spec]
8181
if iszero(eqs[i].rhs)
82-
rhs = isone(stoich) ? rl : stoich * rl
82+
signedrl = (stoich > zero(stoich)) ? rl : -rl
83+
rhs = isone(abs(stoich)) ? signedrl : stoich * rl
8384
else
8485
Δspec = isone(abs(stoich)) ? rl : abs(stoich) * rl
8586
rhs = (stoich > zero(stoich)) ? (eqs[i].rhs + Δspec) : (eqs[i].rhs - Δspec)
@@ -97,8 +98,9 @@ function assemble_diffusion(rs)
9798
for (j,rx) in enumerate(rs.eqs)
9899
rlsqrt = sqrt(oderatelaw(rx))
99100
for (spec,stoich) in rx.netstoich
100-
i = species_to_idx[spec]
101-
eqs[i,j] = isone(stoich) ? rlsqrt : stoich * rlsqrt
101+
i = species_to_idx[spec]
102+
signedrlsqrt = (stoich > zero(stoich)) ? rlsqrt : -rlsqrt
103+
eqs[i,j] = isone(abs(stoich)) ? signedrlsqrt : stoich * rlsqrt
102104
end
103105
end
104106
eqs

0 commit comments

Comments
 (0)