Skip to content

Commit 99724d1

Browse files
committed
Fix display error and some typos
1 parent 99acf1e commit 99724d1

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

src/structural_transformation/StructuralTransformations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ using NonlinearSolve
3939

4040
export tearing, partial_state_selection, dae_index_lowering, check_consistency
4141
export build_torn_function, build_observed_function, ODAEProblem
42-
export sorted_incidence_matrix, pantelides!, tearing_reassemble
42+
export sorted_incidence_matrix, pantelides!, tearing_reassemble, find_solvables!
4343

4444
include("utils.jl")
4545
include("pantelides.jl")

src/structural_transformation/symbolics_tearing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching; simplify=false
151151
end
152152

153153
function tearing(state::TearingState)
154-
find_solvables!(state)
154+
state.structure.solvable_graph === nothing && find_solvables!(state)
155155
complete!(state.structure)
156156
@unpack graph, solvable_graph = state.structure
157157
algvars = BitSet(findall(v->isalgvar(state.structure, v), 1:ndsts(graph)))

src/systems/abstractsystem.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,11 @@ function Base.show(io::IO, ::MIME"text/plain", sys::AbstractSystem)
715715
if has_torn_matching(sys)
716716
# If the system can take a torn matching, then we can initialize a tearing
717717
# state on it. Do so and get show the structure.
718-
state = TearingState(sys)
719-
Base.printstyled(io, "\nIncidence matrix:"; color=:magenta)
720-
show(io, incidence_matrix(state.structure.graph, Num(Sym{Real}(:×))))
718+
state = TearingState(sys; check=false)
719+
if state !== nothing
720+
Base.printstyled(io, "\nIncidence matrix:"; color=:magenta)
721+
show(io, incidence_matrix(state.structure.graph, Num(Sym{Real}(:×))))
722+
end
721723
end
722724
return nothing
723725
end

src/systems/systemstructure.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function Base.push!(ev::EquationsView, eq)
196196
push!(ev.ts.extra_eqs, eq)
197197
end
198198

199-
function TearingState(sys; quick_cancel=false)
199+
function TearingState(sys; quick_cancel=false, check=true)
200200
sys = flatten(sys)
201201
ivs = independent_variables(sys)
202202
eqs = copy(equations(sys))
@@ -218,6 +218,9 @@ function TearingState(sys; quick_cancel=false)
218218

219219
vars = OrderedSet()
220220
for (i, eq′) in enumerate(eqs)
221+
if eq′.lhs isa Connection
222+
check ? error("$(nameof(sys)) has unexpanded `connect` statements") : return nothing
223+
end
221224
if _iszero(eq′.lhs)
222225
rhs = quick_cancel ? quick_cancel_expr(eq′.rhs) : eq′.rhs
223226
eq = eq′
@@ -296,9 +299,9 @@ function TearingState(sys; quick_cancel=false)
296299
# it could be that a variable appeared in the states, but never appeared
297300
# in the equations.
298301
algvaridx = get(var2idx, algvar, 0)
299-
algvaridx == 0 && throw(InvalidSystemException("The system is missing "
300-
* "an equation for $algvar."
301-
))
302+
if algvaridx == 0
303+
check ? throw(InvalidSystemException("The system is missing an equation for $algvar.")) : return nothing
304+
end
302305
vartype[algvaridx] = ALGEBRAIC_VARIABLE
303306
end
304307

0 commit comments

Comments
 (0)