Skip to content

Commit 980e61b

Browse files
Merge pull request #1371 from baggepinnen/discrete_structure
Add structure to DiscreteSystem
2 parents 06474b5 + d9ca383 commit 980e61b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/systems/diffeqs/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct ODESystem <: AbstractODESystem
9292
"""
9393
preface::Any
9494
"""
95-
events: A `Vector{SymbolicContinuousCallback}` that model events.
95+
continuous_events: A `Vector{SymbolicContinuousCallback}` that model events.
9696
The integrator will use root finding to guarantee that it steps at each zero crossing.
9797
"""
9898
continuous_events::Vector{SymbolicContinuousCallback}

src/systems/discrete_system/discrete_system.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,20 @@ struct DiscreteSystem <: AbstractTimeDependentSystem
5252
"""
5353
defaults::Dict
5454
"""
55+
structure: structural information of the system
56+
"""
57+
structure::Any
58+
"""
5559
type: type of the system
5660
"""
5761
connector_type::Any
58-
function DiscreteSystem(discreteEqs, iv, dvs, ps, var_to_name, ctrls, observed, name, systems, defaults, connector_type; checks::Bool = true)
62+
function DiscreteSystem(discreteEqs, iv, dvs, ps, var_to_name, ctrls, observed, name, systems, defaults, structure, connector_type; checks::Bool = true)
5963
if checks
6064
check_variables(dvs, iv)
6165
check_parameters(ps, iv)
62-
all_dimensionless([dvs;ps;iv;ctrls]) ||check_units(discreteEqs)
66+
all_dimensionless([dvs;ps;iv;ctrls]) || check_units(discreteEqs)
6367
end
64-
new(discreteEqs, iv, dvs, ps, var_to_name, ctrls, observed, name, systems, defaults, connector_type)
68+
new(discreteEqs, iv, dvs, ps, var_to_name, ctrls, observed, name, systems, defaults, structure, connector_type)
6569
end
6670
end
6771

@@ -104,7 +108,7 @@ function DiscreteSystem(
104108
if length(unique(sysnames)) != length(sysnames)
105109
throw(ArgumentError("System names must be unique."))
106110
end
107-
DiscreteSystem(eqs, iv′, dvs′, ps′, var_to_name, ctrl′, observed, name, systems, defaults, connector_type, kwargs...)
111+
DiscreteSystem(eqs, iv′, dvs′, ps′, var_to_name, ctrl′, observed, name, systems, defaults, nothing, connector_type, kwargs...)
108112
end
109113

110114

test/discretesystem.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ eqs = [D(S) ~ S-infection,
2424

2525
# System
2626
@named sys = DiscreteSystem(eqs,t,[S,I,R],[c,nsteps,δt,β,γ]; controls = [β, γ])
27+
syss = structural_simplify(sys)
28+
@test syss == syss
2729

2830
# Problem
2931
u0 = [S => 990.0, I => 10.0, R => 0.0]

0 commit comments

Comments
 (0)