1
1
# ## Fetch Packages ###
2
- using Bifurcationkit , Catalyst, Test
2
+ using BifurcationKit , Catalyst, Test
3
3
4
4
# Sets rnd number.
5
5
using StableRNGs
@@ -15,7 +15,7 @@ rng = StableRNG(12345)
15
15
# Checks that bifurcation diagrams can be computed for systems with non-constant rate.
16
16
# Checks that not providing conserved species throws and appropriate error.
17
17
let
18
- # Create model
18
+ # Create model.
19
19
extended_brusselator = @reaction_network begin
20
20
@species W (t) = 2.0
21
21
@parameters k2 = 0.5
25
25
1 , X → ∅
26
26
(k1* Y, k2), V <--> W
27
27
end
28
- @unpack A, B, k1
28
+ @unpack A, B, k1 = extended_brusselator
29
29
u0_guess = [:X => 1.0 , :Y => 1.0 , :V => 0.0 , :W => 0.0 ]
30
30
p_start = [A => 1.0 , B => 4.0 , k1 => 0.1 ]
31
31
32
32
# Computes bifurcation diagram.
33
- BifurcationProblem (extended_brusselator, u0_guess, p_start, :B ; plot_var= :V , u0 = [:V => 1.0 ])
33
+ BifurcationProblem (extended_brusselator, u0_guess, p_start, :B ; plot_var = :V , u0 = [:V => 1.0 ])
34
34
p_span = (0.1 , 6.0 )
35
- opt_newton = NewtonPar (tol = 1e-9 , max_iterations = 100 )
36
- opts_br = ContinuationPar (dsmin = 0.0001 , dsmax = 0.001 , ds = 0.0001 ,
37
- max_steps = 200000 , nev = 2 , newton_options = opt_newton,
38
- p_min = p_span[1 ], p_max = p_span[2 ],
39
- detect_bifurcation = 3 , n_inversion = 4 , tol_bisection_eigenvalue = 1e-8 , dsmin_bisection = 1e-9 )
40
- bif_dia = bifurcationdiagram (bprob, PALC (), 2 , (args... ) -> opts_br; bothside= true )
35
+ opts_br = ContinuationPar (dsmin = 0.0001 , dsmax = 0.001 , ds = 0.0001 , max_steps = 10000 , p_min = p_span[1 ], p_max = p_span[2 ], n_inversion = 4 )
36
+ bif_dia = bifurcationdiagram (bprob, PALC (), 2 , (args... ) -> opts_br; bothside = true )
41
37
42
38
# Checks computed V values are correct (Formula: V = k2*(V0+W0)/(k1*Y+k2), where Y=2*B.)
43
39
B_vals = getfield .(bif_dia. γ. branch, :param )
63
59
0.1 + hill (X,v,K,n), 0 --> X
64
60
d, X --> 0
65
61
end
66
- @unpack x , v, K, n, d = rn
67
- u0_guess = [x => 1.0 ]
62
+ @unpack X , v, K, n, d = bistable_switch
63
+ u0_guess = [X => 1.0 ]
68
64
p_start = [v => 5.0 , K => 2.5 , n => 3 , d => 1.0 ]
69
- bprob = BifurcationProblem (bistable_switch, u0_guess, p_start, K; jac= false ; plot_var= x )
65
+ bprob = BifurcationProblem (bistable_switch, u0_guess, p_start, K; jac= false , plot_var= X )
70
66
71
67
# Creates BifurcationProblem via BifurcationKit.
72
68
function bistable_switch_BK (u, p)
84
80
p = rand (rng, 4 )
85
81
@test bprob_BK. VF. F (u0, p) == bprob. VF. F (u0, p)
86
82
end
87
- end
83
+ end
0 commit comments