@@ -171,7 +171,24 @@ function to_varmap(vals, varlist::Vector)
171
171
check_eqs_u0 (varlist, varlist, vals)
172
172
vals = vec (varlist) .=> vec (vals)
173
173
end
174
- return anydict (unwrap (k) => unwrap (v) for (k, v) in anydict (vals))
174
+ return recursive_unwrap (anydict (vals))
175
+ end
176
+
177
+ """
178
+ $(TYPEDSIGNATURES)
179
+
180
+ Recursively call `Symbolics.unwrap` on `x`. Useful when `x` is an array of (potentially)
181
+ symbolic values, all of which need to be unwrapped. Specializes when `x isa AbstractDict`
182
+ to unwrap keys and values, returning an `AnyDict`.
183
+ """
184
+ function recursive_unwrap (x:: AbstractArray )
185
+ symbolic_type (x) == ArraySymbolic () ? unwrap (x) : recursive_unwrap .(x)
186
+ end
187
+
188
+ recursive_unwrap (x) = unwrap (x)
189
+
190
+ function recursive_unwrap (x:: AbstractDict )
191
+ return anydict (unwrap (k) => recursive_unwrap (v) for (k, v) in x)
175
192
end
176
193
177
194
"""
@@ -262,7 +279,7 @@ function better_varmap_to_vars(varmap::AbstractDict, vars::Vector;
262
279
end
263
280
vals = map (x -> varmap[x], vars)
264
281
265
- if container_type <: Union{AbstractDict, Tuple, Nothing}
282
+ if container_type <: Union{AbstractDict, Tuple, Nothing, SciMLBase.NullParameters }
266
283
container_type = Array
267
284
end
268
285
@@ -410,7 +427,7 @@ function process_SciMLProblem(
410
427
u0map = to_varmap (u0map, dvs)
411
428
_pmap = pmap
412
429
pmap = to_varmap (pmap, ps)
413
- defs = add_toterms (defaults (sys))
430
+ defs = add_toterms (recursive_unwrap ( defaults (sys) ))
414
431
cmap, cs = get_cmap (sys)
415
432
kwargs = NamedTuple (kwargs)
416
433
@@ -433,9 +450,14 @@ function process_SciMLProblem(
433
450
solvablepars = [p
434
451
for p in parameters (sys)
435
452
if is_parameter_solvable (p, pmap, defs, guesses)]
453
+ has_dependent_unknowns = any (unknowns (sys)) do sym
454
+ val = get (op, sym, nothing )
455
+ val === nothing && return false
456
+ return symbolic_type (val) != NotSymbolic () || is_array_of_symbolics (val)
457
+ end
436
458
if build_initializeprob &&
437
459
(((implicit_dae || has_observed_u0s || ! isempty (missing_unknowns) ||
438
- ! isempty (solvablepars)) &&
460
+ ! isempty (solvablepars) || has_dependent_unknowns ) &&
439
461
get_tearing_state (sys) != = nothing ) ||
440
462
! isempty (initialization_equations (sys))) && t != = nothing
441
463
initializeprob = ModelingToolkit. InitializationProblem (
0 commit comments