From 4d1019bc79729d810395f0a836fb22eb7796f247 Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Thu, 3 Oct 2024 16:01:26 +0200 Subject: [PATCH] Remove unnecessary branch and just iterate over empty dictionary --- src/systems/nonlinear/initializesystem.jl | 30 +++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/systems/nonlinear/initializesystem.jl b/src/systems/nonlinear/initializesystem.jl index 3cca51b1e9..2097e2955e 100644 --- a/src/systems/nonlinear/initializesystem.jl +++ b/src/systems/nonlinear/initializesystem.jl @@ -36,22 +36,20 @@ function generate_initializesystem(sys::ODESystem; # set dummy derivatives to default_dd_guess unless specified push!(defs, x[1] => get(guesses, x[1], default_dd_guess)) end - if !isnothing(u0map) - for (y, x) in u0map - y = get(schedule.dummy_sub, y, y) - y = fixpoint_sub(y, diffmap) - if y ∈ vars_set - # variables specified in u0 overrides defaults - push!(defs, y => x) - elseif y isa Symbolics.Arr - # TODO: don't scalarize arrays - merge!(defs, Dict(scalarize(y .=> x))) - elseif y isa Symbolics.BasicSymbolic - # y is a derivative expression expanded; add it to the initialization equations - push!(eqs_ics, y ~ x) - else - error("Initialization expression $y is currently not supported. If its a higher order derivative expression, then only the dummy derivative expressions are supported.") - end + for (y, x) in u0map + y = get(schedule.dummy_sub, y, y) + y = fixpoint_sub(y, diffmap) + if y ∈ vars_set + # variables specified in u0 overrides defaults + push!(defs, y => x) + elseif y isa Symbolics.Arr + # TODO: don't scalarize arrays + merge!(defs, Dict(scalarize(y .=> x))) + elseif y isa Symbolics.BasicSymbolic + # y is a derivative expression expanded; add it to the initialization equations + push!(eqs_ics, y ~ x) + else + error("Initialization expression $y is currently not supported. If its a higher order derivative expression, then only the dummy derivative expressions are supported.") end end end