diff --git a/src/structural_transformation/utils.jl b/src/structural_transformation/utils.jl index 405a3ebed3..bd24a1d017 100644 --- a/src/structural_transformation/utils.jl +++ b/src/structural_transformation/utils.jl @@ -123,16 +123,15 @@ function check_consistency(state::TransformationState, orig_inputs; nothrow = fa unassigned_var = singular_check(state) if !isempty(unassigned_var) || !is_balanced + if nothrow + return false + end io = IOBuffer() Base.print_array(io, unassigned_var) unassigned_var_str = String(take!(io)) errmsg = "The system is structurally singular! " * "Here are the problematic variables: \n" * unassigned_var_str - if nothrow - @warn errmsg - return false - end throw(InvalidSystemException(errmsg)) end diff --git a/src/systems/diffeqs/abstractodesystem.jl b/src/systems/diffeqs/abstractodesystem.jl index 4019a868d8..8f70f6710d 100644 --- a/src/systems/diffeqs/abstractodesystem.jl +++ b/src/systems/diffeqs/abstractodesystem.jl @@ -1313,8 +1313,15 @@ function InitializationProblem{iip, specialize}(sys::AbstractODESystem, sys; u0map, initialization_eqs, check_units, pmap = parammap); fully_determined) end - if !isempty(StructuralTransformations.singular_check(get_tearing_state(isys))) - @warn "Since the initialization system is singular, the guess values may significantly affect the initial values of the ODE" + ts = get_tearing_state(isys) + if warn_initialize_determined && (unassigned_vars = StructuralTransformations.singular_check(ts); !isempty(unassigned_vars)) + errmsg = """ + The initialization system is singular. Guess values may significantly affect \ + the initial values of the ODE. The problematic variables are $unassigned_vars. + + Note that the identification of problematic variables is a best-effort heuristic. + """ + @warn errmsg end uninit = setdiff(unknowns(sys), [unknowns(isys); getfield.(observed(isys), :lhs)])