Skip to content

Commit 8ef587c

Browse files
feat: add u0_eltype kwarg to problems, only use tofloat for parameter vector
1 parent c1e4dfd commit 8ef587c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/systems/problem_utils.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,10 @@ Keyword arguments:
12011201
- `fully_determined`: Override whether the initialization system is fully determined.
12021202
- `check_initialization_units`: Enable or disable unit checks when constructing the
12031203
initialization problem.
1204-
- `tofloat`, `is_initializeprob`: Passed to [`better_varmap_to_vars`](@ref) for building `u0` (and possibly `p`).
1204+
- `tofloat`: Passed to [`better_varmap_to_vars`](@ref) when building the parameter vector of
1205+
a non-split system.
1206+
- `u0_eltype`: The `eltype` of the `u0` vector. If `nothing`, finds the promoted floating point
1207+
type from `op`.
12051208
- `u0_constructor`: A function to apply to the `u0` value returned from `better_varmap_to_vars`
12061209
to construct the final `u0` value.
12071210
- `p_constructor`: A function to apply to each array buffer created when constructing the parameter object.
@@ -1232,7 +1235,7 @@ function process_SciMLProblem(
12321235
implicit_dae = false, t = nothing, guesses = AnyDict(),
12331236
warn_initialize_determined = true, initialization_eqs = [],
12341237
eval_expression = false, eval_module = @__MODULE__, fully_determined = nothing,
1235-
check_initialization_units = false, tofloat = true,
1238+
check_initialization_units = false, u0_eltype = nothing, tofloat = true,
12361239
u0_constructor = identity, p_constructor = identity,
12371240
check_length = true, symbolic_u0 = false, warn_cyclic_dependency = false,
12381241
circular_dependency_max_cycle_length = length(all_symbols(sys)),
@@ -1275,6 +1278,8 @@ function process_SciMLProblem(
12751278
floatT = float_type_from_varmap(op, floatT)
12761279
end
12771280

1281+
u0_eltype = something(u0_eltype, floatT)
1282+
12781283
if !is_time_dependent(sys) || is_initializesystem(sys)
12791284
add_observed_equations!(u0map, obs)
12801285
end
@@ -1324,7 +1329,7 @@ function process_SciMLProblem(
13241329
evaluate_varmap!(op, dvs; limit = substitution_limit)
13251330

13261331
u0 = better_varmap_to_vars(
1327-
op, dvs; tofloat, floatT,
1332+
op, dvs; buffer_eltype = u0_eltype,
13281333
container_type = u0Type, allow_symbolic = symbolic_u0, is_initializeprob)
13291334

13301335
if u0 !== nothing

0 commit comments

Comments
 (0)