Skip to content

Commit 7a1f784

Browse files
committed
isconsistent -> check_consistency
1 parent a1c1d13 commit 7a1f784

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/structural_transformation/StructuralTransformations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using SparseArrays
3131

3232
using NonlinearSolve
3333

34-
export tearing, dae_index_lowering, isconsistent
34+
export tearing, dae_index_lowering, check_consistency
3535
export build_torn_function, build_observed_function, ODAEProblem
3636
export sorted_incidence_matrix
3737

src/structural_transformation/utils.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,17 @@ end
5050
###
5151
### Structural check
5252
###
53-
function isconsistent(s::SystemStructure; verbose=true)
53+
function check_consistency(s::SystemStructure)
5454
@unpack varmask, graph, varassoc, fullvars = s
5555
n_highest_vars = count(varmask)
5656
neqs = nsrcs(graph)
5757
is_balanced = n_highest_vars == neqs
5858

59-
(neqs > 0 && !is_balanced) && throw(ArgumentError("The system is unbalanced. "
59+
(neqs > 0 && !is_balanced) && throw(InvalidSystemException(
60+
"The system is unbalanced. "
6061
* "There are $n_highest_vars highest order derivative variables "
61-
* "and $neqs equations."))
62+
* "and $neqs equations."
63+
))
6264

6365
# This is defined to check if Pantelides algorithm terminates. For more
6466
# details, check the equation (15) of the original paper.
@@ -73,11 +75,11 @@ function isconsistent(s::SystemStructure; verbose=true)
7375
end
7476

7577
if !isempty(unassigned_var) || !is_balanced
76-
verbose && @error "The system is structurally singular! Here are the unmatched variables:" unassigned_var
77-
return false
78+
@error "The system is structurally singular! Here are the unmatched variables:" unassigned_var
79+
throw(InvalidSystemException(""))
7880
end
7981

80-
return true
82+
return nothing
8183
end
8284

8385
function pantelides_extended_graph(varassoc)

src/systems/abstractsystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ $(SIGNATURES)
521521
Structurally simplify algebraic equations in a system and compute the
522522
topological sort of the observed equations.
523523
"""
524-
function structural_simplify(sys::AbstractSystem; verbose=true)
524+
function structural_simplify(sys::AbstractSystem)
525525
sys = initialize_system_structure(alias_elimination(sys))
526-
isconsistent(structure(sys); verbose=verbose) || return sys
526+
check_consistency(structure(sys))
527527
if sys isa ODESystem
528528
sys = dae_index_lowering(sys)
529529
end

0 commit comments

Comments
 (0)