Skip to content

Commit c15f84e

Browse files
committed
start noise scaling remake
1 parent 7b8c789 commit c15f84e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/reactionsystem.jl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ end
5454
# variables
5555
drop_dynamics(s) = isconstant(s) || isbc(s) || (!isspecies(s))
5656

57+
### Other Metadata Fields ###
58+
59+
# Denotes that a parameter controls the scaling of noise in the CLE.
60+
struct NoiseScalingParameter end
61+
Symbolics.option_to_metadata_type(::Val{:isnoisescalingparameter}) = NoiseScalingParameter
62+
63+
isnoisescalingparameter(s::Num) = isnoisescalingparameter(MT.value(s))
64+
function isnoisescalingparameter(s)
65+
MT.getmetadata(s, NoiseScalingParameter, false)
66+
end
67+
5768
"""
5869
$(TYPEDEF)
5970
@@ -1489,7 +1500,7 @@ Notes:
14891500
differential equations.
14901501
"""
14911502
function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
1492-
noise_scaling = nothing, name = nameof(rs),
1503+
noise_scaling = get_noise_scaling(rs), name = nameof(rs),
14931504
combinatoric_ratelaws = get_combinatoric_ratelaws(rs),
14941505
include_zero_odes = true, checks = false, remove_conserved = false,
14951506
default_u0 = Dict(), default_p = Dict(), defaults = _merge(Dict(default_u0), Dict(default_p)),
@@ -1533,6 +1544,11 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
15331544
kwargs...)
15341545
end
15351546

1547+
# Extracts any noise scaling parameters from a reaction system.
1548+
function get_noise_scaling(rs::ReactionSystem)
1549+
return nothing
1550+
end
1551+
15361552
"""
15371553
```julia
15381554
Base.convert(::Type{<:JumpSystem},rs::ReactionSystem; combinatoric_ratelaws=true)
@@ -1616,7 +1632,7 @@ end
16161632
# SDEProblem from AbstractReactionNetwork
16171633
function DiffEqBase.SDEProblem(rs::ReactionSystem, u0, tspan,
16181634
p = DiffEqBase.NullParameters(), args...;
1619-
noise_scaling = nothing, name = nameof(rs),
1635+
noise_scaling = get_noise_scaling(rs), name = nameof(rs),
16201636
combinatoric_ratelaws = get_combinatoric_ratelaws(rs),
16211637
include_zero_odes = true, checks = false,
16221638
check_length = false,

0 commit comments

Comments
 (0)