Skip to content

Commit 0a74983

Browse files
committed
u0 substitution in ODAEProblem
1 parent c1f2e70 commit 0a74983

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/structural_transformation/codegen.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,17 @@ function gen_nlsolve(eqs, vars, u0map::AbstractDict; checkbounds=true)
121121
params = setdiff(allvars, vars) # these are not the subject of the root finding
122122

123123
# splatting to tighten the type
124-
u0 = [map(var->get(u0map, var, 1e-3), vars)...]
124+
u0 = []
125+
for v in vars
126+
v in keys(u0map) || (push!(u0, 1e-3); continue)
127+
u = substitute(v, u0map)
128+
for i in 1:1000
129+
u = substitute(u, u0map)
130+
u isa Number && (push!(u0, u); continue)
131+
end
132+
u isa Number || error("$v doesn't have a default.")
133+
end
134+
u0 = [u0...]
125135
# specialize on the scalar case
126136
isscalar = length(u0) == 1
127137
u0 = isscalar ? u0[1] : SVector(u0...)

0 commit comments

Comments
 (0)