Skip to content

Commit 68465d8

Browse files
committed
update
1 parent 4c85f2c commit 68465d8

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/reaction_network.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,14 @@ function make_reaction_system(ex::Expr; name = :(gensym(:ReactionSystem)))
410410
pexprs = get_pexpr(parameters_extracted, options)
411411
ns_ps, ns_pssym = scalarize_macro(haskey(options, :noise_scaling_parameters), noise_scaling_pexpr, "ns_ps")
412412
ps, pssym = scalarize_macro(!isempty(parameters), pexprs, "ps")
413+
rs_p_syms = haskey(options, :noise_scaling_parameters) ? :(union($pssym, $ns_pssym)) : pssym
413414
vars, varssym = scalarize_macro(!isempty(variables), vexprs, "vars")
414415
sps, spssym = scalarize_macro(!isempty(species), sexprs, "specs")
415416
comps, compssym = scalarize_macro(!isempty(compound_species), compound_expr, "comps")
416417
rxexprs = :(Catalyst.CatalystEqType[])
417418
for reaction in reactions
418419
push!(rxexprs.args, get_rxexprs(reaction))
419420
end
420-
421421
# Returns the rephrased expression.
422422
quote
423423
$ps

src/reactionsystem.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ Notes:
15001500
differential equations.
15011501
"""
15021502
function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
1503-
noise_scaling = get_noise_scaling(rs), name = nameof(rs),
1503+
noise_scaling = nothing, name = nameof(rs),
15041504
combinatoric_ratelaws = get_combinatoric_ratelaws(rs),
15051505
include_zero_odes = true, checks = false, remove_conserved = false,
15061506
default_u0 = Dict(), default_p = Dict(), defaults = _merge(Dict(default_u0), Dict(default_p)),
@@ -1510,7 +1510,13 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
15101510
flatrs = Catalyst.flatten(rs)
15111511
error_if_constraints(SDESystem, flatrs)
15121512

1513-
isnothing(noise_scaling) && (noise_scaling = get_noise_scaling(rs)) # Required until passing nosie into SDEProblem can be depricated.
1513+
# Required until passing nosie into SDEProblem can be depricated. When properly deprecated, change the kwarg to noise_scaling = get_noise_scaling(rs).
1514+
if !isnothing(noise_scaling)
1515+
!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.")
1516+
@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."
1517+
end
1518+
isnothing(noise_scaling) && (noise_scaling = get_noise_scaling(flatrs))
1519+
15141520
if noise_scaling isa AbstractArray
15151521
(length(noise_scaling) != numreactions(flatrs)) &&
15161522
error("The number of elements in 'noise_scaling' must be equal " *
@@ -1551,7 +1557,7 @@ function get_noise_scaling(rs::ReactionSystem)
15511557
if isempty(ns_params)
15521558
return nothing
15531559
elseif length(ns_params) == 1
1554-
return Num(ns_params[1])
1560+
return ns_params[1]
15551561
elseif length(ns_params) == length(reactions(rs))
15561562
return ns_params
15571563
else
@@ -1648,11 +1654,6 @@ function DiffEqBase.SDEProblem(rs::ReactionSystem, u0, tspan,
16481654
check_length = false,
16491655
remove_conserved = false, kwargs...)
16501656

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-
16561657
u0map = symmap_to_varmap(rs, u0)
16571658
pmap = symmap_to_varmap(rs, p)
16581659
sde_sys = convert(SDESystem, rs; noise_scaling, name, combinatoric_ratelaws,

0 commit comments

Comments
 (0)