diff --git a/docs/src/model_creation/chemistry_related_functionality.md b/docs/src/model_creation/chemistry_related_functionality.md index f87402d91c..c1f279a55d 100644 --- a/docs/src/model_creation/chemistry_related_functionality.md +++ b/docs/src/model_creation/chemistry_related_functionality.md @@ -103,7 +103,7 @@ In all of these cases, the left-hand side must be enclosed within `()`. While we generally do not need to specify independent variables for compound, if the components (together) have more than one independent variable, this *must be done*: ```@example chem1 t = default_t() -@variables s +@parameters s @species N(s) O(t) @compound NO2(t,s) ~ N + 2O ``` diff --git a/docs/unpublished/pdes.md b/docs/unpublished/pdes.md index f4443f9834..eb4fe09495 100644 --- a/docs/unpublished/pdes.md +++ b/docs/unpublished/pdes.md @@ -43,7 +43,7 @@ end We now define the reaction model ```julia t = default_t() -@variables x y +@parameters x y @species U(x,y,t) V(x,y,t) W(x,y,t) rxs = [Reaction(k[1], [U, W], [V, W]), Reaction(k[2], [V], [W], [2], [1]), diff --git a/test/dsl/dsl_options.jl b/test/dsl/dsl_options.jl index 819a887427..791bdca75f 100644 --- a/test/dsl/dsl_options.jl +++ b/test/dsl/dsl_options.jl @@ -436,7 +436,8 @@ let end @parameters k k2 - @variables s x D(x) E(s) F(s,x) + @parameters s x + @variables D(x) E(s) F(s,x) @species A(s,x) B(s) C(x) C2(s,x) rx = Reaction(k*k2*D, [A, B], [C, C2], [E, 1], [F, 1]) @named ivstest = ReactionSystem([rx], s; spatial_ivs = [x]) diff --git a/test/miscellaneous_tests/compound_macro.jl b/test/miscellaneous_tests/compound_macro.jl index eafc9e124d..a65d809973 100644 --- a/test/miscellaneous_tests/compound_macro.jl +++ b/test/miscellaneous_tests/compound_macro.jl @@ -103,7 +103,7 @@ end # Test using different independent variable combinations. let - @variables x y z + @parameters x y z @species C(t) H(x) N(x) O(t) P(t,x) S(x,y) # Checks that wrong (or absent) independent variable produces errors. diff --git a/test/miscellaneous_tests/reactionsystem_serialisation.jl b/test/miscellaneous_tests/reactionsystem_serialisation.jl index 2488b9b318..61a4637485 100644 --- a/test/miscellaneous_tests/reactionsystem_serialisation.jl +++ b/test/miscellaneous_tests/reactionsystem_serialisation.jl @@ -213,7 +213,7 @@ end # Checks for system with non-default independent variable. let # Prepares parameters/variables/species with complicated dependencies. - @variables τ + @parameters τ @parameters begin b = 3.0 c diff --git a/test/reactionsystem_core/coupled_equation_crn_systems.jl b/test/reactionsystem_core/coupled_equation_crn_systems.jl index 0db49c8964..db7e14b887 100644 --- a/test/reactionsystem_core/coupled_equation_crn_systems.jl +++ b/test/reactionsystem_core/coupled_equation_crn_systems.jl @@ -182,7 +182,8 @@ end # The system is mostly made up to be non-trivial, but reliably solvable. let @parameters p d a b c - @variables τ A(τ) B(τ) C(τ) + @parameters τ + @variables A(τ) B(τ) C(τ) @species X(τ) Δ = Differential(τ) eqs = [ @@ -265,7 +266,8 @@ end # Checks that non-default iv is inferred correctly from reactions/equations. let # Create coupled model. - @variables τ A(τ) B(τ) + @parameters τ + @variables A(τ) B(τ) @species X(τ) X2(τ) @parameters k1 k2 k b1 b2 D = Differential(τ) @@ -607,7 +609,8 @@ let # Declares the model in a messy fashion, and simulates it. osol_messy = let - @variables τ M(τ) H(τ)=h_max + @parameters τ + @variables M(τ) H(τ)=h_max @species S(τ) I(τ) R(τ) Δ = Differential(τ) eqs_messy = [ @@ -972,7 +975,8 @@ end # Checks that various erroneous coupled system declarations yield errors. let @parameters p1 p2 - @variables τ U1(τ) V1(t) + @parameters τ + @variables U1(τ) V1(t) @species R1(τ) R2(τ) S1(t) S2(t) E = Differential(τ) @@ -989,7 +993,7 @@ let # Equation with variable using non-declared independent variable. @test_throws Exception ReactionSystem([ Reaction(p1, [S1], [S2]), - U1 ~ S1 + p2 + E(U1) ~ S1 + p2 ], t; name = :rs) # Differential with respect to non-declared independent variable. diff --git a/test/reactionsystem_core/custom_crn_functions.jl b/test/reactionsystem_core/custom_crn_functions.jl index c4f115d7c3..2cfe60ae65 100644 --- a/test/reactionsystem_core/custom_crn_functions.jl +++ b/test/reactionsystem_core/custom_crn_functions.jl @@ -141,7 +141,8 @@ end # Tests `Equation`s. # Tests using non-default independent variable. let - @variables T X(T) Y(T) + @parameters T + @variables X(T) Y(T) @parameters K V N eq1 = 0 ~ mm(X, V, K) diff --git a/test/reactionsystem_core/reactionsystem.jl b/test/reactionsystem_core/reactionsystem.jl index 77ee4e0954..1ba9142bf1 100644 --- a/test/reactionsystem_core/reactionsystem.jl +++ b/test/reactionsystem_core/reactionsystem.jl @@ -628,6 +628,30 @@ let @test_throws Exception convert(NonlinearSystem, nc) end +# Checks that the same name cannot be used for two different of parameters/species/variables. +let + # Stores a parameter, a species, and a variable (with identical names) in different variables. + x_p = let + only(@parameters x) + end + x_sp = let + only(@species x(t)) + end + x_v = let + only(@variables x(t)) + end + + # Checks that creating systems with different in combination produces errors. + # Currently broken on MTK, potentially fix in Catalyst once sorted out there (https://github.com/SciML/ModelingToolkit.jl/issues/2883). + @parameters d + @species X(t) + rx = Reaction(d, [X], []) + @test_broken false # (not sure how to mark a `@test_throws` as broken) + # @test_throws rs1 = ReactionSystem([rx], t, [X, x_sp,], [d, x_p]; name = :rs) + # @test_throws rs2 = ReactionSystem([rx], t, [X, X, x_v], [d, x_p]; name = :rs) + # @test_throws rs2 = ReactionSystem([rx], t, [X, x_sp, x_v], [d]; name = :rs) +end + ### Other Tests ### # Test for https://github.com/SciML/ModelingToolkit.jl/issues/436. diff --git a/test/spatial_modelling/simulate_PDEs.jl b/test/spatial_modelling/simulate_PDEs.jl index b7edcee73c..f0051e69fd 100644 --- a/test/spatial_modelling/simulate_PDEs.jl +++ b/test/spatial_modelling/simulate_PDEs.jl @@ -19,7 +19,7 @@ end let t = default_t() @parameters k[1:7] D[1:3] n0[1:3] A - @variables x y + @parameters x y @species U(x, y, t) V(x, y, t) W(x, y, t) rxs = [Reaction(k[1], [U, W], [V, W]), Reaction(k[2], [V], [W], [2], [1]),