@@ -386,7 +386,7 @@ function assemble_jumps(rs; combinatoric_ratelaws = true, physical_scales = noth
386
386
error (" Must have at least one reaction that will be represented as a jump when constructing a JumpSystem." )
387
387
388
388
# note isvrjvec indicates which reactions are not constant rate jumps
389
- # it may be that a given jump has isvrjvec[i] = true but has a physical
389
+ # it may be that a given jump has isvrjvec[i] = true but has a physical
390
390
isvrjvec = classify_vrjs (rs, physcales)
391
391
392
392
rxvars = []
@@ -505,9 +505,16 @@ COMPLETENESS_ERROR = "A ReactionSystem must be complete before it can be convert
505
505
506
506
# ## System Conversions ###
507
507
508
+ abstract type SystemType end
509
+
510
+ struct ReactionRateSystem <: SystemType end
511
+ struct ChemicalLangevinSystem <: SystemType end
512
+ struct StochasticChemicalKineticSystem <: SystemType end
513
+ struct NonlinearSystem <: SystemType end
514
+
508
515
"""
509
516
```julia
510
- Base.convert(::Type{<:ODESystem },rs::ReactionSystem)
517
+ Base.convert(::Type{<:System },rs::ReactionSystem)
511
518
```
512
519
Convert a [`ReactionSystem`](@ref) to an `ModelingToolkit.ODESystem`.
513
520
@@ -524,7 +531,7 @@ Keyword args and default values:
524
531
with their rational function representation when converting to another system type. Set to
525
532
`false`` to disable.
526
533
"""
527
- function Base. convert (:: Type{<:ODESystem } , rs:: ReactionSystem ; name = nameof (rs),
534
+ function Base. convert (:: Type{<:ReactionRateSystem } , rs:: ReactionSystem ; name = nameof (rs),
528
535
combinatoric_ratelaws = get_combinatoric_ratelaws (rs),
529
536
include_zero_odes = true , remove_conserved = false , checks = false ,
530
537
default_u0 = Dict (), default_p = Dict (),
@@ -541,7 +548,7 @@ function Base.convert(::Type{<:ODESystem}, rs::ReactionSystem; name = nameof(rs)
541
548
include_zero_odes, expand_catalyst_funs)
542
549
eqs, us, ps, obs, defs = addconstraints! (eqs, fullrs, ists, ispcs; remove_conserved)
543
550
544
- ODESystem (eqs, get_iv (fullrs), us, ps;
551
+ System (eqs, get_iv (fullrs), us, ps;
545
552
observed = obs,
546
553
name,
547
554
defaults = _merge (defaults, defs),
@@ -622,7 +629,7 @@ function Base.convert(::Type{<:NonlinearSystem}, rs::ReactionSystem; name = name
622
629
all_differentials_permitted || nonlinear_convert_differentials_check (rs)
623
630
eqs = [remove_diffs (eq. lhs) ~ remove_diffs (eq. rhs) for eq in eqs]
624
631
625
- NonlinearSystem (eqs, us, ps;
632
+ System (eqs, us, ps;
626
633
name,
627
634
observed = obs, initialization_eqs = initeqs,
628
635
defaults = _merge (defaults, defs),
@@ -679,7 +686,7 @@ Notes:
679
686
with their rational function representation when converting to another system type. Set to
680
687
`false`` to disable.
681
688
"""
682
- function Base. convert (:: Type{<:SDESystem } , rs:: ReactionSystem ;
689
+ function Base. convert (:: Type{<:ChemicalLangevinSystem } , rs:: ReactionSystem ;
683
690
name = nameof (rs), combinatoric_ratelaws = get_combinatoric_ratelaws (rs),
684
691
include_zero_odes = true , checks = false , remove_conserved = false ,
685
692
default_u0 = Dict (), default_p = Dict (),
@@ -704,7 +711,7 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
704
711
@info " Boundary condition species detected. As constraint equations are not currently supported when converting to SDESystems, the resulting system will be undetermined. Consider using constant species instead."
705
712
end
706
713
707
- SDESystem ( eqs, noiseeqs, get_iv (flatrs), us, ps;
714
+ System ([ eqs; noiseeqs] , get_iv (flatrs), us, ps;
708
715
observed = obs,
709
716
name,
710
717
defaults = _merge (defaults, defs),
@@ -728,7 +735,7 @@ Merge physical scales for a set of reactions.
728
735
function merge_physical_scales (rxs, physical_scales, default)
729
736
scales = get_physical_scale .(rxs)
730
737
731
- # override metadata attached scales
738
+ # override metadata attached scales
732
739
if physical_scales != = nothing
733
740
for (key, scale) in physical_scales
734
741
scales[key] = scale
@@ -769,13 +776,13 @@ Notes:
769
776
`VariableRateJump` to save the solution before and/or after the jump occurs. Defaults to
770
777
true for both.
771
778
"""
772
- function Base. convert (:: Type{<:JumpSystem } , rs:: ReactionSystem ; name = nameof (rs),
779
+ function Base. convert (:: Type{<:StochasticChemicalKineticSystem } , rs:: ReactionSystem ; name = nameof (rs),
773
780
combinatoric_ratelaws = get_combinatoric_ratelaws (rs),
774
781
remove_conserved = nothing , checks = false , default_u0 = Dict (), default_p = Dict (),
775
782
defaults = _merge (Dict (default_u0), Dict (default_p)), expand_catalyst_funs = true ,
776
783
save_positions = (true , true ), physical_scales = nothing , kwargs... )
777
784
iscomplete (rs) || error (COMPLETENESS_ERROR)
778
- spatial_convert_err (rs:: ReactionSystem , JumpSystem )
785
+ spatial_convert_err (rs:: ReactionSystem , StochasticChemicalKineticSystem )
779
786
(remove_conserved != = nothing ) &&
780
787
throw (ArgumentError (" Catalyst does not support removing conserved species when converting to JumpSystems." ))
781
788
@@ -794,7 +801,7 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
794
801
physical_scales, save_positions)
795
802
ists, ispcs = get_indep_sts (flatrs)
796
803
797
- # handle coupled ODEs and BC species
804
+ # handle coupled ODEs and BC species
798
805
if (PhysicalScale. ODE in unique_scales) || has_nonreactions (flatrs)
799
806
odeeqs = assemble_drift (flatrs, ispcs; combinatoric_ratelaws,
800
807
remove_conserved = false , physical_scales, include_zero_odes = true )
@@ -811,7 +818,7 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
811
818
defs = MT. defaults (flatrs)
812
819
end
813
820
814
- JumpSystem (eqs, get_iv (flatrs), us, ps;
821
+ System (eqs, get_iv (flatrs), us, ps;
815
822
observed = obs,
816
823
name,
817
824
defaults = _merge (defaults, defs),
850
857
DiffEqBase.NonlinearProblem(rs::ReactionSystem, u0,
851
858
p = DiffEqBase.NullParameters(), args...;
852
859
name = nameof(rs), combinatoric_ratelaws = get_combinatoric_ratelaws(rs),
853
- remove_conserved = false, checks = false, check_length = false,
854
- structural_simplify = remove_conserved, all_differentials_permitted = false,
860
+ remove_conserved = false, checks = false, check_length = false,
861
+ structural_simplify = remove_conserved, all_differentials_permitted = false,
855
862
kwargs...)
856
863
```
857
864
@@ -923,7 +930,7 @@ Inputs for a JumpProblem from a given `ReactionSystem`.
923
930
# Fields
924
931
$(FIELDS)
925
932
"""
926
- struct JumpInputs{S <: MT.JumpSystem , T <: SciMLBase.AbstractODEProblem }
933
+ struct JumpInputs{S <: MT.System , T <: SciMLBase.AbstractODEProblem }
927
934
""" The `JumpSystem` to define the problem over"""
928
935
sys:: S
929
936
""" The problem the JumpProblem should be defined over, for example DiscreteProblem"""
@@ -936,8 +943,8 @@ JumpInputs(rs::ReactionSystem, u0, tspan,
936
943
p = DiffEqBase.NullParameters;
937
944
name = nameof(rs),
938
945
combinatoric_ratelaws = get_combinatoric_ratelaws(rs),
939
- checks = false, physical_scales = nothing,
940
- expand_catalyst_funs = true,
946
+ checks = false, physical_scales = nothing,
947
+ expand_catalyst_funs = true,
941
948
save_positions = (true, true),
942
949
remake_warn = true, kwargs...)
943
950
```
@@ -988,7 +995,7 @@ function JumpInputs(rs::ReactionSystem, u0, tspan, p = DiffEqBase.NullParameters
988
995
name = nameof (rs), combinatoric_ratelaws = get_combinatoric_ratelaws (rs),
989
996
checks = false , physical_scales = nothing , expand_catalyst_funs = true ,
990
997
save_positions = (true , true ), remake_warn = true , kwargs... )
991
- jsys = complete (convert (JumpSystem , rs; name, combinatoric_ratelaws, checks,
998
+ jsys = complete (convert (StochasticChemicalKineticSystem , rs; name, combinatoric_ratelaws, checks,
992
999
physical_scales, expand_catalyst_funs, save_positions))
993
1000
994
1001
if MT. has_variableratejumps (jsys) || MT. has_equations (jsys) ||
@@ -1025,7 +1032,7 @@ function DiffEqBase.DiscreteProblem(rs::ReactionSystem, u0, tspan::Tuple,
1025
1032
Base. depwarn (" DiscreteProblem(rn::ReactionSystem, ...) is deprecated and will be \
1026
1033
removed in Catalyst 16. Use JumpInputs(rn, ...) instead." ,
1027
1034
:DiscreteProblem )
1028
- jsys = convert (JumpSystem , rs; name, combinatoric_ratelaws, checks,
1035
+ jsys = convert (StochasticChemicalKineticSystem , rs; name, combinatoric_ratelaws, checks,
1029
1036
expand_catalyst_funs)
1030
1037
jsys = complete (jsys)
1031
1038
return DiscreteProblem (jsys, u0, tspan, p, args... ; kwargs... )
@@ -1040,7 +1047,7 @@ function JumpProcesses.JumpProblem(rs::ReactionSystem, prob::SciMLBase.AbstractD
1040
1047
Base. depwarn (" JumpProblem(rn::ReactionSystem, prob, ...) is \
1041
1048
deprecated and will be removed in Catalyst 16. Use \
1042
1049
JumpProblem(JumpInputs(rn, ...), ...) instead." , :JumpProblem )
1043
- jsys = convert (JumpSystem , rs; name, combinatoric_ratelaws,
1050
+ jsys = convert (StochasticChemicalKineticSystem , rs; name, combinatoric_ratelaws,
1044
1051
expand_catalyst_funs, checks)
1045
1052
jsys = complete (jsys)
1046
1053
return JumpProblem (jsys, prob, aggregator; kwargs... )
0 commit comments