Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop scalarizing #1052

Merged
merged 14 commits into from
Sep 21, 2024
2 changes: 1 addition & 1 deletion docs/src/model_creation/dsl_advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Sometimes, one wishes to declare a large number of similar parameters or species
using Catalyst # hide
two_state_model = @reaction_network begin
@parameters k[1:2]
@species X(t)[1:2]
@species (X(t))[1:2]
(k[1],k[2]), X[1] <--> X[2]
end
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ t = default_t()
@parameters τ
function generate_lp(n)
# Creates a vector `X` with n+1 species.
@species X(t)[1:n+1]
@species (X(t))[1:n+1]
@species Xend(t)

# Generate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ for n = 1:nr
[1, 1], [1]))
end
end
@named rs = ReactionSystem(rx, t, collect(X), collect(k))
@named rs = ReactionSystem(rx, t, collect(X), [k])
rs = complete(rs)
```
We now convert the [`ReactionSystem`](@ref) into a `ModelingToolkit.JumpSystem`, and solve it using Gillespie's direct method. For details on other possible solvers (SSAs), see the [DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/types/jump_types/) documentation
Expand Down
4 changes: 2 additions & 2 deletions src/reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ function make_ReactionSystem_internal(rxs_and_eqs::Vector, iv, us_in, ps_in;

# Initialises the new unknowns and parameter vectors.
# Preallocates the `vars` set, which is used by `findvars!`
us = OrderedSet{eltype(us_in)}(us_in)
ps = OrderedSet{eltype(ps_in)}(ps_in)
us = OrderedSet{Any}(us_in)
ps = OrderedSet{Any}(ps_in)
vars = OrderedSet()

# Extracts the reactions and equations from the combined reactions + equations input vector.
Expand Down
17 changes: 15 additions & 2 deletions test/dsl/dsl_advanced_model_construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,23 @@ let
k[1]*a+k[2], X[1] + V[1]*X[2] --> V[2]*W*Y + B*C
end

@parameters k[1:3] a B
TorkelE marked this conversation as resolved.
Show resolved Hide resolved
@parameters k[1:2] a B
@variables (V(t))[1:2] W(t)
@species (X(t))[1:2] Y(t) C(t)
rx = Reaction(k[1]*a+k[2], [X[1], X[2]], [Y, C], [1, V[1]], [V[2] * W, B])
@named arrtest = ReactionSystem([rx], t)
arrtest == rn
TorkelE marked this conversation as resolved.
Show resolved Hide resolved
@test arrtest == rn

rn = @reaction_network twostate begin
@parameters k[1:2]
@species (X(t))[1:2]
(k[1],k[2]), X[1] <--> X[2]
end

@parameters k[1:2]
@species (X(t))[1:2]
rx1 = Reaction(k[1], [X[1]], [X[2]])
rx2 = Reaction(k[2], [X[2]], [X[1]])
@named twostate = ReactionSystem([rx1, rx2], t)
@test twostate == rn
end
2 changes: 1 addition & 1 deletion test/network_analysis/conservation_laws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ end
let
# Prepares the model.
t = default_t()
@species X(t)[1:2]
@species (X(t))[1:2]
@parameters k[1:2]
rxs = [
Reaction(k[1], [X[1]], [X[2]]),
Expand Down
2 changes: 1 addition & 1 deletion test/reactionsystem_core/reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ end
# Needs fix for https://github.com/JuliaSymbolics/Symbolics.jl/issues/842.
let
@parameters a
@species A(t) B(t) C(t)[1:2]
@species A(t) B(t) (C(t))[1:2]
rx1 = Reaction(a, [A, C[1]], [C[2], B], [1, 2], [2, 3])
io = IOBuffer()
show(io, rx1)
Expand Down
2 changes: 1 addition & 1 deletion test/upstream/mtk_problem_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ end
begin
# Declares the model (with vector species/parameters, with/without default values, and observables).
t = default_t()
@species X(t)[1:2] Y(t)[1:2] = [10.0, 20.0] XY(t)[1:2]
@species (X(t))[1:2] (Y(t))[1:2] = [10.0, 20.0] (XY(t))[1:2]
@parameters p[1:2] d[1:2] = [0.2, 0.5]
rxs = [
Reaction(p[1], [], [X[1]]),
Expand Down
Loading