Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ModelingToolkitTearing/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ModelingToolkitTearing"
uuid = "6bb917b9-1269-42b9-9f7c-b0dca72083ab"
version = "1.20.6"
version = "1.21.0"
authors = ["Aayush Sabharwal <aayush.sabharwal@juliahub.com>"]

[deps]
Expand Down
18 changes: 18 additions & 0 deletions lib/ModelingToolkitTearing/src/clock_inference/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function substitute_sample_time(ci::ClockInference{TearingState}, ts::TearingSta
else
subrules[st] = dt
neweq = substitute(eq, subrules)
dirty_array_group!(ts, i, "the sample time was substituted into the row")
end
eqs[i] = neweq
end
Expand All @@ -73,6 +74,23 @@ function system_subset(ts::TearingState, ieqs::Vector{Int}, iieqs::Vector{Int},
if !isempty(ts.eqs_source)
@set! ts.eqs_source = ts.eqs_source[ieqs]
end
# Array blocks are only tracked once the equations are scalarized (after clock
# inference), so the subset only carries scalar rows. Any groups that exist (eagerly
# scalarized state) that are split across partitions are broken.
array_groups = map(ts.array_groups) do g
ArrayEquationGroup(g.eq, g.lhs_vars, g.dirty, g.dirty_reason, g.dirty_elem)
end
row_group = ts.row_group[ieqs]
row_elem = ts.row_elem[ieqs]
old_counts = count_group_rows(length(array_groups), ts.row_group)
new_counts = count_group_rows(length(array_groups), row_group)
for g in eachindex(array_groups)
old_counts[g] == new_counts[g] ||
dirty_array_group!(array_groups[g], 0, "the rows were split across clock partitions")
end
@set! ts.array_groups = array_groups
@set! ts.row_group = row_group
@set! ts.row_elem = row_elem
if all(eq -> eq.rhs isa StateMachineOperator, MTKBase.get_eqs(ts.sys))
names = Symbol[]
for eq in MTKBase.get_eqs(ts.sys)
Expand Down
Loading