Skip to content

Commit 4c85f2c

Browse files
committed
fix error
1 parent 98a0511 commit 4c85f2c

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/reaction_network.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,6 @@ function make_reaction_system(ex::Expr; name = :(gensym(:ReactionSystem)))
418418
push!(rxexprs.args, get_rxexprs(reaction))
419419
end
420420

421-
println(ps)
422-
println(ns_ps)
423-
println(sps)
424-
425421
# Returns the rephrased expression.
426422
quote
427423
$ps
@@ -728,7 +724,7 @@ end
728724

729725
# macro, similar to @parameters, but all paraemters become noise scaling parameters.
730726
macro noise_scaling_parameters(ex...)
731-
vars = Symbolics._parse_vars(:parameters, Real, ex)
727+
vars = Symbolics._parse_vars(:parameters, Real, ex, toparam)
732728

733729
# Reads the observables options. Outputs an expression ofr creating the obervable variables, and a vector of observable equations.
734730
function read_observed_options(options, species_n_vars_declared, ivs_sorted)

src/reactionsystem.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,11 +1509,8 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
15091509

15101510
flatrs = Catalyst.flatten(rs)
15111511
error_if_constraints(SDESystem, flatrs)
1512-
if any(isnoisescalingparameter, get_ps(flatrs))
1513-
any(is_noise_scaling_parameter.(parameters(rs))) && error("You have declared some paraemters as noise scaling parameters, and also given a \"noise_scaling\" argument to SDEProblem. Please remove the \"noise_scaling\", as this way of scaling CLE noise is being depricated.")
1514-
@warn "Passing noise scaling input into SDEProblem will be deprecated. New standard is to declare one (or several) paraemter as noise scaling parameters when the ReactionSystem is created. Please read https://docs.sciml.ai/Catalyst/stable/catalyst_applications/advanced_simulations/#Scaling-the-noise-magnitude-in-the-chemical-Langevin-equations."
1515-
end
15161512

1513+
isnothing(noise_scaling) && (noise_scaling = get_noise_scaling(rs)) # Required until passing nosie into SDEProblem can be depricated.
15171514
if noise_scaling isa AbstractArray
15181515
(length(noise_scaling) != numreactions(flatrs)) &&
15191516
error("The number of elements in 'noise_scaling' must be equal " *
@@ -1650,6 +1647,12 @@ function DiffEqBase.SDEProblem(rs::ReactionSystem, u0, tspan,
16501647
include_zero_odes = true, checks = false,
16511648
check_length = false,
16521649
remove_conserved = false, kwargs...)
1650+
1651+
if !isnothing(noise_scaling)
1652+
!isnothing(get_noise_scaling(rs)) && error("You have declared some parameters as noise scaling parameters, and also given a \"noise_scaling\" argument to SDEProblem. Please remove the \"noise_scaling\", as this way of scaling CLE noise is being depricated.")
1653+
@warn "Passing noise scaling input into SDEProblem will be deprecated. New standard is to declare one (or several) paraemter as noise scaling parameters when the ReactionSystem is created. Please read https://docs.sciml.ai/Catalyst/stable/catalyst_applications/advanced_simulations/#Scaling-the-noise-magnitude-in-the-chemical-Langevin-equations."
1654+
end
1655+
16531656
u0map = symmap_to_varmap(rs, u0)
16541657
pmap = symmap_to_varmap(rs, p)
16551658
sde_sys = convert(SDESystem, rs; noise_scaling, name, combinatoric_ratelaws,

test/model_simulation/simulate_SDEs.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ let
119119
end
120120
end
121121

122+
### Checks Simulations Don't Error ###
123+
124+
#Tries to create a large number of problem, ensuring there are no errors (cannot solve as solution likely to go into negatives).
125+
let
126+
for reaction_network in reaction_networks_all
127+
for factor in [1e-2, 1e-1, 1e0, 1e1]
128+
u0 = factor * rand(rng, length(states(reaction_network)))
129+
p = factor * rand(rng, length(parameters(reaction_network)))
130+
prob = SDEProblem(reaction_network, u0, (0.0, 1.0), p)
131+
end
132+
end
133+
end
134+
122135
### Noise Scaling ###
123136

124137
# Tests with multiple noise scaling parameters directly in the macro.

0 commit comments

Comments
 (0)