Skip to content

Commit 3ae7b69

Browse files
Update initialization.jl
1 parent 8636420 commit 3ae7b69

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/initialization.jl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,27 @@ function get_initial_values end
5555
struct CheckInitFailureError <: Exception
5656
normresid::Any
5757
abstol::Any
58+
isdae::Bool
5859
end
5960

6061
function Base.showerror(io::IO, e::CheckInitFailureError)
6162
print(io,
6263
"DAE initialization failed: your u0 did not satisfy the initialization requirements,
63-
normresid = $(e.normresid) > abstol = $(e.abstol). If you wish for the system to
64-
automatically change the algebraic variables to satisfy the algebraic constraints,
65-
please pass `initializealg = BrownBasicInit()` to solve (this option will require
66-
`using OrdinaryDiffEqNonlinearSolve`). If you wish to perform an initialization on the
67-
complete u0, please pass initializealg = ShampineCollocationInit() to solve. Note that
68-
initialization can be a very difficult process for DAEs and in many cases can be
69-
numerically intractable without symbolic manipulation of the system. For an automated
70-
system that will generate numerically stable initializations, see ModelingToolkit.jl
71-
structural simplification for more details."
64+
normresid = $(e.normresid) > abstol = $(e.abstol)."
7265
)
66+
67+
if isdae
68+
print(io, " If you wish for the system to
69+
automatically change the algebraic variables to satisfy the algebraic constraints,
70+
please pass `initializealg = BrownBasicInit()` to solve (this option will require
71+
`using OrdinaryDiffEqNonlinearSolve`). If you wish to perform an initialization on the
72+
complete u0, please pass initializealg = ShampineCollocationInit() to solve. Note that
73+
initialization can be a very difficult process for DAEs and in many cases can be
74+
numerically intractable without symbolic manipulation of the system. For an automated
75+
system that will generate numerically stable initializations, see ModelingToolkit.jl
76+
structural simplification for more details."
77+
)
78+
end
7379
end
7480

7581
struct OverrideInitMissingAlgorithm <: Exception end
@@ -144,7 +150,7 @@ function get_initial_values(
144150
normresid = isdefined(integrator.opts, :internalnorm) ?
145151
integrator.opts.internalnorm(tmp, t) : norm(tmp)
146152
if normresid > abstol
147-
throw(CheckInitFailureError(normresid, abstol))
153+
throw(CheckInitFailureError(normresid, abstol, true))
148154
end
149155
return u0, p, true
150156
end
@@ -161,7 +167,7 @@ function get_initial_values(
161167
integrator.opts.internalnorm(resid, t) : norm(resid)
162168

163169
if normresid > abstol
164-
throw(CheckInitFailureError(normresid, abstol))
170+
throw(CheckInitFailureError(normresid, abstol, false))
165171
end
166172
return u0, p, true
167173
end

0 commit comments

Comments
 (0)