@@ -171,6 +171,9 @@ Keyword arguments:
171171 provided to the `OverrideInit` constructor takes priority over this keyword argument.
172172 If the former is `nothing`, this keyword argument will be used. If it is also not provided,
173173 an error will be thrown.
174+
175+ In case the initialization problem is trivial, `nlsolve_alg`, `abstol` and `reltol` are
176+ not required.
174177"""
175178function get_initial_values (prob, valp, f, alg:: OverrideInit ,
176179 iip:: Union{Val{true}, Val{false}} ; nlsolve_alg = nothing , abstol = nothing , reltol = nothing , kwargs... )
@@ -193,26 +196,32 @@ function get_initial_values(prob, valp, f, alg::OverrideInit,
193196 initdata. update_initializeprob! (initprob, valp)
194197 end
195198
196- if alg. abstol != = nothing
197- _abstol = alg. abstol
198- elseif abstol != = nothing
199- _abstol = abstol
200- else
201- throw (OverrideInitNoTolerance (:abstol ))
202- end
203- if alg. reltol != = nothing
204- _reltol = alg. reltol
205- elseif reltol != = nothing
206- _reltol = reltol
199+ if state_values (initprob) === nothing
200+ nlsol = initprob
201+ success = true
207202 else
208- throw (OverrideInitNoTolerance (:reltol ))
203+ if alg. abstol != = nothing
204+ _abstol = alg. abstol
205+ elseif abstol != = nothing
206+ _abstol = abstol
207+ else
208+ throw (OverrideInitNoTolerance (:abstol ))
209+ end
210+ if alg. reltol != = nothing
211+ _reltol = alg. reltol
212+ elseif reltol != = nothing
213+ _reltol = reltol
214+ else
215+ throw (OverrideInitNoTolerance (:reltol ))
216+ end
217+ nlsol = solve (initprob, nlsolve_alg; abstol = _abstol, reltol = _reltol)
218+ success = SciMLBase. successful_retcode (nlsol)
209219 end
210- nlsol = solve (initprob, nlsolve_alg; abstol = _abstol, reltol = _reltol)
211220
212221 u0 = initdata. initializeprobmap (nlsol)
213222 if initdata. initializeprobpmap != = nothing
214223 p = initdata. initializeprobpmap (valp, nlsol)
215224 end
216225
217- return u0, p, SciMLBase . successful_retcode (nlsol)
226+ return u0, p, success
218227end
0 commit comments