diff --git a/src/problems/analytical_problems.jl b/src/problems/analytical_problems.jl index 7dabf9807..d6b744885 100644 --- a/src/problems/analytical_problems.jl +++ b/src/problems/analytical_problems.jl @@ -10,11 +10,12 @@ struct AnalyticalProblem{uType, tType, isinplace, P, F, K} <: kwargs::K @add_kwonly function AnalyticalProblem{iip}(f, u0, tspan, p = NullParameters(); kwargs...) where {iip} + _u0 = prepare_initial_state(u0) _tspan = promote_tspan(tspan) warn_paramtype(p) - new{typeof(u0), typeof(_tspan), iip, typeof(p), + new{typeof(_u0), typeof(_tspan), iip, typeof(p), typeof(f), typeof(kwargs)}(f, - u0, + _u0, _tspan, p, kwargs) diff --git a/src/problems/bvp_problems.jl b/src/problems/bvp_problems.jl index 2e9f1feab..3baf71215 100644 --- a/src/problems/bvp_problems.jl +++ b/src/problems/bvp_problems.jl @@ -110,6 +110,7 @@ struct BVProblem{uType, tType, isinplace, P, F, BF, PT, K} <: @add_kwonly function BVProblem{iip}(f::AbstractBVPFunction{iip, TP}, bc, u0, tspan, p = NullParameters(); problem_type=nothing, kwargs...) where {iip, TP} + _u0 = prepare_initial_state(u0) _tspan = promote_tspan(tspan) warn_paramtype(p) prob_type = TP ? TwoPointBVProblem() : StandardBVProblem() @@ -119,8 +120,8 @@ struct BVProblem{uType, tType, isinplace, P, F, BF, PT, K} <: else @assert prob_type === problem_type "This indicates incorrect problem type specification! Users should never pass in `problem_type` kwarg, this exists exclusively for internal use." end - return new{typeof(u0), typeof(_tspan), iip, typeof(p), typeof(f), typeof(bc), - typeof(problem_type), typeof(kwargs)}(f, bc, u0, _tspan, p, problem_type, + return new{typeof(_u0), typeof(_tspan), iip, typeof(p), typeof(f), typeof(bc), + typeof(problem_type), typeof(kwargs)}(f, bc, _u0, _tspan, p, problem_type, kwargs) end diff --git a/src/problems/dae_problems.jl b/src/problems/dae_problems.jl index 5d729cd8d..e5e532aac 100644 --- a/src/problems/dae_problems.jl +++ b/src/problems/dae_problems.jl @@ -80,21 +80,23 @@ struct DAEProblem{uType, duType, tType, isinplace, P, F, K, D} <: du0, u0, tspan, p = NullParameters(); differential_vars = nothing, kwargs...) where {iip} - if !isnothing(u0) + _u0 = prepare_initial_state(u0) + _du0 = prepare_initial_state(du0) + if !isnothing(_u0) # Defend against external solvers like Sundials breaking on non-uniform input dimensions. - size(du0) == size(u0) || + size(_du0) == size(_u0) || throw(ArgumentError("Sizes of u0 and du0 must be the same.")) if !isnothing(differential_vars) - size(u0) == size(differential_vars) || + size(_u0) == size(differential_vars) || throw(ArgumentError("Sizes of u0 and differential_vars must be the same.")) end end _tspan = promote_tspan(tspan) warn_paramtype(p) - new{typeof(u0), typeof(du0), typeof(_tspan), + new{typeof(_u0), typeof(_du0), typeof(_tspan), isinplace(f), typeof(p), typeof(f), typeof(kwargs), - typeof(differential_vars)}(f, du0, u0, _tspan, p, + typeof(differential_vars)}(f, _du0, _u0, _tspan, p, kwargs, differential_vars) end diff --git a/src/problems/dde_problems.jl b/src/problems/dde_problems.jl index 3bf2df8f2..98dfc4a0c 100644 --- a/src/problems/dde_problems.jl +++ b/src/problems/dde_problems.jl @@ -224,11 +224,13 @@ struct DDEProblem{uType, tType, lType, lType2, isinplace, P, F, H, K, PT} <: order_discontinuity_t0 = 0, problem_type = StandardDDEProblem(), kwargs...) where {iip} + _u0 = prepare_initial_state(u0) _tspan = promote_tspan(tspan) warn_paramtype(p) - new{typeof(u0), typeof(_tspan), typeof(constant_lags), typeof(dependent_lags), + new{typeof(_u0), typeof(_tspan), typeof(constant_lags), typeof(dependent_lags), isinplace(f), - typeof(p), typeof(f), typeof(h), typeof(kwargs), typeof(problem_type)}(f, u0, h, + typeof(p), typeof(f), typeof(h), typeof(kwargs), typeof(problem_type)}(f, _u0, + h, _tspan, p, constant_lags, diff --git a/src/problems/discrete_problems.jl b/src/problems/discrete_problems.jl index 9d6f643e9..b2f2a362c 100644 --- a/src/problems/discrete_problems.jl +++ b/src/problems/discrete_problems.jl @@ -90,12 +90,13 @@ struct DiscreteProblem{uType, tType, isinplace, P, F, K} <: @add_kwonly function DiscreteProblem{iip}(f::AbstractDiscreteFunction{iip}, u0, tspan::Tuple, p = NullParameters(); kwargs...) where {iip} + _u0 = prepare_initial_state(u0) _tspan = promote_tspan(tspan) warn_paramtype(p) - new{typeof(u0), typeof(_tspan), isinplace(f, 4), + new{typeof(_u0), typeof(_tspan), isinplace(f, 4), typeof(p), typeof(f), typeof(kwargs)}(f, - u0, + _u0, _tspan, p, kwargs) diff --git a/src/problems/implicit_discrete_problems.jl b/src/problems/implicit_discrete_problems.jl index 063a96d2e..b6463fa6b 100644 --- a/src/problems/implicit_discrete_problems.jl +++ b/src/problems/implicit_discrete_problems.jl @@ -86,12 +86,13 @@ struct ImplicitDiscreteProblem{uType, tType, isinplace, P, F, K} <: u0, tspan::Tuple, p = NullParameters(); kwargs...) where {iip} + _u0 = prepare_initial_state(u0) _tspan = promote_tspan(tspan) warn_paramtype(p) - new{typeof(u0), typeof(_tspan), isinplace(f, 6), + new{typeof(_u0), typeof(_tspan), isinplace(f, 6), typeof(p), typeof(f), typeof(kwargs)}(f, - u0, + _u0, _tspan, p, kwargs) diff --git a/src/problems/rode_problems.jl b/src/problems/rode_problems.jl index d5c04e21b..18c7a587e 100644 --- a/src/problems/rode_problems.jl +++ b/src/problems/rode_problems.jl @@ -69,12 +69,13 @@ mutable struct RODEProblem{uType, tType, isinplace, P, NP, F, K, ND} <: rand_prototype = nothing, noise = nothing, seed = UInt64(0), kwargs...) where {iip} + _u0 = prepare_initial_state(u0) _tspan = promote_tspan(tspan) warn_paramtype(p) - new{typeof(u0), typeof(_tspan), + new{typeof(_u0), typeof(_tspan), isinplace(f), typeof(p), typeof(noise), typeof(f), typeof(kwargs), - typeof(rand_prototype)}(f, u0, _tspan, p, noise, kwargs, + typeof(rand_prototype)}(f, _u0, _tspan, p, noise, kwargs, rand_prototype, seed) end function RODEProblem{iip}(f, u0, tspan, p = NullParameters(); kwargs...) where {iip} diff --git a/src/problems/sdde_problems.jl b/src/problems/sdde_problems.jl index 12cafe9d7..76d4b8dc4 100644 --- a/src/problems/sdde_problems.jl +++ b/src/problems/sdde_problems.jl @@ -126,12 +126,13 @@ struct SDDEProblem{uType, tType, lType, lType2, isinplace, P, NP, F, G, H, K, ND det(f.mass_matrix) != 1, order_discontinuity_t0 = 0 // 1, kwargs...) where {iip} + _u0 = prepare_initial_state(u0) _tspan = promote_tspan(tspan) warn_paramtype(p) - new{typeof(u0), typeof(_tspan), typeof(constant_lags), typeof(dependent_lags), + new{typeof(_u0), typeof(_tspan), typeof(constant_lags), typeof(dependent_lags), isinplace(f), typeof(p), typeof(noise), typeof(f), typeof(g), typeof(h), typeof(kwargs), - typeof(noise_rate_prototype)}(f, g, u0, h, _tspan, p, noise, constant_lags, + typeof(noise_rate_prototype)}(f, g, _u0, h, _tspan, p, noise, constant_lags, dependent_lags, kwargs, noise_rate_prototype, seed, neutral, order_discontinuity_t0) end diff --git a/src/problems/steady_state_problems.jl b/src/problems/steady_state_problems.jl index 5a01410b9..ed4fd3a05 100644 --- a/src/problems/steady_state_problems.jl +++ b/src/problems/steady_state_problems.jl @@ -83,8 +83,9 @@ struct SteadyStateProblem{uType, isinplace, P, F, K} <: @add_kwonly function SteadyStateProblem{iip}(f::AbstractODEFunction{iip}, u0, p = NullParameters(); kwargs...) where {iip} + _u0 = prepare_initial_state(u0) warn_paramtype(p) - new{typeof(u0), isinplace(f), typeof(p), typeof(f), typeof(kwargs)}(f, u0, p, + new{typeof(_u0), isinplace(f), typeof(p), typeof(f), typeof(kwargs)}(f, _u0, p, kwargs) end