From b5b1a8a1665c9ccdb2f2d7e12cf49735d1c51e63 Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Sun, 20 Oct 2024 18:49:02 +0200 Subject: [PATCH] Dispatch on ODESystem to print initialization equation count --- src/systems/diffeqs/odesystem.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/systems/diffeqs/odesystem.jl b/src/systems/diffeqs/odesystem.jl index b901275121..7055da3ac9 100644 --- a/src/systems/diffeqs/odesystem.jl +++ b/src/systems/diffeqs/odesystem.jl @@ -704,3 +704,15 @@ function add_accumulations(sys::ODESystem, vars::Vector{<:Pair}) @set! sys.unknowns = [get_unknowns(sys); avars] @set! sys.defaults = merge(get_defaults(sys), Dict(a => 0.0 for a in avars)) end + +function Base.show(io::IO, mime::MIME"text/plain", sys::ODESystem; hint = true, bold = true) + # Print general AbstractSystem information + invoke(Base.show, Tuple{typeof(io), typeof(mime), AbstractSystem}, io, mime, sys; hint, bold) + + # Print initialization equations (unique to ODESystems) + nini = length(initialization_equations(sys)) + nini > 0 && printstyled(io, "\nInitialization equations ($nini):"; bold) + nini > 0 && hint && print(io, " see initialization_equations(sys)") + + return nothing +end