Skip to content

Commit c6b2653

Browse files
committed
- Added another few test reactions (to enable proper testing of Constant and Variable RateJump's.
1 parent 4239be9 commit c6b2653

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/reactionsystem.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using ModelingToolkit, LinearAlgebra, Test
22

3-
@parameters t k[1:15]
3+
@parameters t k[1:20]
44
@variables A(t) B(t) C(t) D(t)
55
rxs = [Reaction(k[1], nothing, [A]), # 0 -> A
66
Reaction(k[2], [B], nothing), # B -> 0
@@ -16,7 +16,8 @@ rxs = [Reaction(k[1], nothing, [A]), # 0 -> A
1616
Reaction(k[12], [A,B,C], [C,D], [1,3,4], [2, 3]), # A+3B+4C -> 2C + 3D
1717
Reaction(k[13], [A,B], nothing, [3,1], nothing), # 3A+B -> 0
1818
Reaction(k[14], nothing, [A], nothing, [2]), # 0 -> 2A
19-
Reaction(k[15]*A/(2+A), [A], nothing; only_use_rate=true) # A -> 0 with custom rate
19+
Reaction(k[15]*A/(2+A), [A], nothing; only_use_rate=true), # A -> 0 with custom rate
20+
Reaction(k[16], [A], [B]; only_use_rate=true), # A -> B with custom rate.
2021
]
2122
rs = ReactionSystem(rxs,t,[A,B,C,D],k)
2223
odesys = convert(ODESystem,rs)
@@ -26,8 +27,8 @@ sdesys = convert(SDESystem,rs)
2627
function oderhs(u,k,t)
2728
A = u[1]; B = u[2]; C = u[3]; D = u[4];
2829
du = zeros(eltype(u),4)
29-
du[1] = k[1] - k[3]*A + k[4]*C + 2*k[5]*C - k[6]*A*B + k[7]*B^2/2 - k[9]*A*B - k[10]*A^2 - k[11]*A^2/2 - k[12]*A*B^3*C^4/144 - 3*k[13]*A^3*B/6 + 2*k[14] - k[15]*A/(2+A)
30-
du[2] = -k[2]*B + k[4]*C - k[6]*A*B - k[7]*B^2 - k[8]*A*B - k[9]*A*B + k[11]*A^2/2 - 3*k[12]*A*B^3*C^4/144 - k[13]*A^3*B/6
30+
du[1] = k[1] - k[3]*A + k[4]*C + 2*k[5]*C - k[6]*A*B + k[7]*B^2/2 - k[9]*A*B - k[10]*A^2 - k[11]*A^2/2 - k[12]*A*B^3*C^4/144 - 3*k[13]*A^3*B/6 + 2*k[14] - k[15]*A/(2+A) - k[16]
31+
du[2] = -k[2]*B + k[4]*C - k[6]*A*B - k[7]*B^2 - k[8]*A*B - k[9]*A*B + k[11]*A^2/2 - 3*k[12]*A*B^3*C^4/144 - k[13]*A^3*B/6 + k[16]
3132
du[3] = k[3]*A - k[4]*C - k[5]*C + k[6]*A*B + k[8]*A*B + k[9]*A*B + k[10]*A^2/2 - 2*k[12]*A*B^3*C^4/144
3233
du[4] = k[9]*A*B + k[10]*A^2/2 + 3*k[12]*A*B^3*C^4/144
3334
du

0 commit comments

Comments
 (0)