Skip to content

Commit 3fd29cc

Browse files
committed
test updates
1 parent ceadf0b commit 3fd29cc

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

ext/CatalystBifurcationKitExtension/bifurcation_kit_extension.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
### Dispatch for BifurcationKit BifurcationProblems ###
22

33
# Creates a BifurcationProblem, using a ReactionSystem as an input.
4-
function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...; plot_var=nothing, record_from_solution=BK.record_sol_default, jac=true, u0=[], kwargs...)
5-
4+
function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...; plot_var=nothing, record_from_solution=BK.record_sol_default, jac=true, u0=[], kwargs...)
65
# Converts symbols to symbolics.
76
(bif_par isa Symbol) && (bif_par = rs.var_to_name[bif_par])
87
(plot_var isa Symbol) && (plot_var = rs.var_to_name[plot_var])
@@ -11,7 +10,7 @@ function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...;
1110
(u0 isa Vector{Pair{Symbol, Float64}}) && (u0 = symmap_to_varmap(rs, u0))
1211

1312
# Creates NonlinearSystem.
14-
conservationlaw_errorcheck(rs, vcat(ps, u0))
13+
Catalyst.conservationlaw_errorcheck(rs, vcat(ps, u0))
1514
nsys = convert(NonlinearSystem, rs; remove_conserved=true, defaults=Dict(u0))
1615

1716
# Makes BifurcationProblem.

ext/CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function steady_state_polynomial(rs::ReactionSystem, ps, u0)
4747
rs = Catalyst.expand_registered_functions(rs)
4848
ns = convert(NonlinearSystem, rs; remove_conserved = true)
4949
pre_varmap = [symmap_to_varmap(rs,u0)..., symmap_to_varmap(rs,ps)...]
50-
conservationlaw_errorcheck(rs, pre_varmap)
50+
Catalyst.conservationlaw_errorcheck(rs, pre_varmap)
5151
p_vals = ModelingToolkit.varmap_to_vars(pre_varmap, parameters(ns); defaults = ModelingToolkit.defaults(ns))
5252
p_dict = Dict(parameters(ns) .=> p_vals)
5353
eqs_pars_funcs = vcat(equations(ns), conservedequations(rs))

src/Catalyst.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ export @compound
106106
export components, iscompound, coefficients
107107
export balance_reaction
108108

109+
# for functions I am unsure where to best place them.
110+
include("miscellaneous.jl")
111+
109112
### Extensions ###
110113

111114
# HomotopyContinuation

test/extensions/bifurcation_kit.jl

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### Fetch Packages ###
2-
using Bifurcationkit, Catalyst, Test
2+
using BifurcationKit, Catalyst, Test
33

44
# Sets rnd number.
55
using StableRNGs
@@ -15,7 +15,7 @@ rng = StableRNG(12345)
1515
# Checks that bifurcation diagrams can be computed for systems with non-constant rate.
1616
# Checks that not providing conserved species throws and appropriate error.
1717
let
18-
# Create model
18+
# Create model.
1919
extended_brusselator = @reaction_network begin
2020
@species W(t) = 2.0
2121
@parameters k2 = 0.5
@@ -25,19 +25,15 @@ let
2525
1, X
2626
(k1*Y, k2), V <--> W
2727
end
28-
@unpack A, B, k1
28+
@unpack A, B, k1 = extended_brusselator
2929
u0_guess = [:X => 1.0, :Y => 1.0, :V => 0.0, :W => 0.0]
3030
p_start = [A => 1.0, B => 4.0, k1 => 0.1]
3131

3232
# 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])
3434
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)
4137

4238
# Checks computed V values are correct (Formula: V = k2*(V0+W0)/(k1*Y+k2), where Y=2*B.)
4339
B_vals = getfield.(bif_dia.γ.branch, :param)
@@ -63,10 +59,10 @@ let
6359
0.1 + hill(X,v,K,n), 0 --> X
6460
d, X --> 0
6561
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]
6864
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)
7066

7167
# Creates BifurcationProblem via BifurcationKit.
7268
function bistable_switch_BK(u, p)
@@ -84,4 +80,4 @@ let
8480
p = rand(rng, 4)
8581
@test bprob_BK.VF.F(u0, p) == bprob.VF.F(u0, p)
8682
end
87-
end
83+
end

0 commit comments

Comments
 (0)