diff --git a/src/initialization.jl b/src/initialization.jl index 3cfb99aa..ae9a5739 100644 --- a/src/initialization.jl +++ b/src/initialization.jl @@ -199,16 +199,17 @@ function initialize_component!(cf; verbose=true, kwargs...) @warn "Initialization for componend stalled with residual $(res)" elseif !SciMLBase.successful_retcode(sol.retcode) throw(ArgumentError("Initialization failed. Solver returned $(sol.retcode)")) + else + verbose && @info "Initialization successful with residual $(LinearAlgebra.norm(sol.resid))" end set_init!.(Ref(cf), SII.variable_symbols(sol), sol.u) resid = sol.resid else resid = init_residual(cf; recalc=true) + verbose && @info "No free variables! Residual $(LinearAlgebra.norm(resid))" end set_metadata!(cf, :init_residual, resid) - - verbose && @info "Initialization successful with residual $(LinearAlgebra.norm(sol.resid))" cf end diff --git a/test/initialization_test.jl b/test/initialization_test.jl index e1041841..04a20124 100644 --- a/test/initialization_test.jl +++ b/test/initialization_test.jl @@ -65,7 +65,14 @@ end @test vf.symmetadata[:i_r][:default] == 1 @test vf.symmetadata[:i_i][:default] == 0.1 - NetworkDynamics.initialize_component!(vf) + NetworkDynamics.initialize_component!(vf; verbose=true) @test NetworkDynamics.init_residual(vf) < 1e-8 @test init_residual(vf) ≈ init_residual(vf; recalc=true) + + # make empty problem + set_default!(vf, :Pm, get_init(vf, :Pm)) + set_default!(vf, :θ, get_init(vf, :θ)) + set_default!(vf, :ω, get_init(vf, :ω)) + + NetworkDynamics.initialize_component!(vf; verbose=true) end