185
185
"""
186
186
oderatelaw(rx; combinatoric_ratelaw=true)
187
187
188
- Given a [`Reaction`](@ref), return the reaction rate law [`Operation`](@ref) used in
188
+ Given a [`Reaction`](@ref), return the symbolic reaction rate law used in
189
189
generated ODEs for the reaction. Note, for a reaction defined by
190
190
191
191
`k*X*Y, X+Z --> 2X + Y`
@@ -195,7 +195,7 @@ of the form
195
195
196
196
`k, 2X+3Y --> Z`
197
197
198
- the `Operation` that is returned will be `k * (X(t)^2/2) * (Y(t)^3/6)`.
198
+ the expression that is returned will be `k * (X(t)^2/2) * (Y(t)^3/6)`.
199
199
200
200
Notes:
201
201
- Allocates
@@ -240,13 +240,13 @@ function assemble_oderhs(rs; combinatoric_ratelaws=true)
240
240
rhsvec
241
241
end
242
242
243
- function assemble_drift (rs; combinatoric_ratelaws= true , as_odes= true )
243
+ function assemble_drift (rs; combinatoric_ratelaws= true , as_odes= true , include_zero_odes = true )
244
244
rhsvec = assemble_oderhs (rs; combinatoric_ratelaws= combinatoric_ratelaws)
245
245
if as_odes
246
246
D = Differential (get_iv (rs))
247
- eqs = [Equation (D (x),rhs) for (x,rhs) in zip (get_states (rs),rhsvec) if (! _iszero (rhs))]
247
+ eqs = [Equation (D (x),rhs) for (x,rhs) in zip (get_states (rs),rhsvec) if (include_zero_odes || ( ! _iszero (rhs) ))]
248
248
else
249
- eqs = [Equation (0 ,rhs) for rhs in rhsvec if (! _iszero (rhs))]
249
+ eqs = [Equation (0 ,rhs) for rhs in rhsvec if (include_zero_odes || ( ! _iszero (rhs) ))]
250
250
end
251
251
eqs
252
252
end
272
272
"""
273
273
jumpratelaw(rx; rxvars=get_variables(rx.rate), combinatoric_ratelaw=true)
274
274
275
- Given a [`Reaction`](@ref), return the reaction rate law [`Operation`](@ref) used in
275
+ Given a [`Reaction`](@ref), return the symbolic reaction rate law used in
276
276
generated stochastic chemical kinetics model SSAs for the reaction. Note,
277
277
for a reaction defined by
278
278
@@ -283,7 +283,7 @@ the form
283
283
284
284
`k, 2X+3Y --> Z`
285
285
286
- the `Operation` that is returned will be `k * binomial(X,2) *
286
+ the expression that is returned will be `k * binomial(X,2) *
287
287
binomial(Y,3)`.
288
288
289
289
Notes:
@@ -411,8 +411,8 @@ law, i.e. for `2S -> 0` at rate `k` the ratelaw would be `k*S^2/2!`. If
411
411
ignored.
412
412
"""
413
413
function Base. convert (:: Type{<:ODESystem} , rs:: ReactionSystem ;
414
- name= nameof (rs), combinatoric_ratelaws= true , kwargs... )
415
- eqs = assemble_drift (rs; combinatoric_ratelaws= combinatoric_ratelaws)
414
+ name= nameof (rs), combinatoric_ratelaws= true , include_zero_odes = true , kwargs... )
415
+ eqs = assemble_drift (rs; combinatoric_ratelaws= combinatoric_ratelaws, include_zero_odes = include_zero_odes )
416
416
systems = map (sys -> (sys isa ODESystem) ? sys : convert (ODESystem, sys), get_systems (rs))
417
417
ODESystem (eqs, get_iv (rs), get_states (rs), get_ps (rs); name= name, systems= systems, kwargs... )
418
418
end
@@ -431,8 +431,8 @@ law, i.e. for `2S -> 0` at rate `k` the ratelaw would be `k*S^2/2!`. If
431
431
ignored.
432
432
"""
433
433
function Base. convert (:: Type{<:NonlinearSystem} ,rs:: ReactionSystem ;
434
- name= nameof (rs), combinatoric_ratelaws= true , kwargs... )
435
- eqs = assemble_drift (rs; combinatoric_ratelaws= combinatoric_ratelaws, as_odes= false )
434
+ name= nameof (rs), combinatoric_ratelaws= true , include_zero_odes = true , kwargs... )
435
+ eqs = assemble_drift (rs; combinatoric_ratelaws= combinatoric_ratelaws, as_odes= false , include_zero_odes = include_zero_odes )
436
436
systems = convert .(NonlinearSystem, get_systems (rs))
437
437
NonlinearSystem (eqs, get_states (rs), get_ps (rs); name= name, systems= systems, kwargs... )
438
438
end
@@ -449,17 +449,18 @@ Notes:
449
449
law, i.e. for `2S -> 0` at rate `k` the ratelaw would be `k*S^2/2!`. If
450
450
`combinatoric_ratelaws=false` then the ratelaw is `k*S^2`, i.e. the scaling factor is
451
451
ignored.
452
- - `noise_scaling=nothing::Union{Vector{Operation},Operation ,Nothing}` allows for linear
452
+ - `noise_scaling=nothing::Union{Vector{Num},Num ,Nothing}` allows for linear
453
453
scaling of the noise in the chemical Langevin equations. If `nothing` is given, the default
454
- value as in Gillespie 2000 is used. Alternatively, an `Operation ` can be given, this is
454
+ value as in Gillespie 2000 is used. Alternatively, a `Num ` can be given, this is
455
455
added as a parameter to the system (at the end of the parameter array). All noise terms
456
456
are linearly scaled with this value. The parameter may be one already declared in the `ReactionSystem`.
457
- Finally, a `Vector{Operation }` can be provided (the length must be equal to the number of reactions).
457
+ Finally, a `Vector{Num }` can be provided (the length must be equal to the number of reactions).
458
458
Here the noise for each reaction is scaled by the corresponding parameter in the input vector.
459
459
This input may contain repeat parameters.
460
460
"""
461
461
function Base. convert (:: Type{<:SDESystem} , rs:: ReactionSystem ;
462
- noise_scaling= nothing , name= nameof (rs), combinatoric_ratelaws= true , kwargs... )
462
+ noise_scaling= nothing , name= nameof (rs), combinatoric_ratelaws= true ,
463
+ include_zero_odes= true , kwargs... )
463
464
464
465
if noise_scaling isa Vector
465
466
(length (noise_scaling)!= length (equations (rs))) &&
@@ -470,7 +471,8 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
470
471
noise_scaling = fill (value (noise_scaling),length (equations (rs)))
471
472
end
472
473
473
- eqs = assemble_drift (rs; combinatoric_ratelaws= combinatoric_ratelaws)
474
+ eqs = assemble_drift (rs; combinatoric_ratelaws= combinatoric_ratelaws,
475
+ include_zero_odes= include_zero_odes)
474
476
noiseeqs = assemble_diffusion (rs,noise_scaling;
475
477
combinatoric_ratelaws= combinatoric_ratelaws)
476
478
systems = convert .(SDESystem, get_systems (rs))
0 commit comments