From 8ee3a3925f0ab9ea7ff069247d8f71440e4ee257 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 30 Jul 2024 10:24:51 -0400 Subject: [PATCH] Default to using fully_determined when possible in initialization This should give better error messages --- src/systems/diffeqs/abstractodesystem.jl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/systems/diffeqs/abstractodesystem.jl b/src/systems/diffeqs/abstractodesystem.jl index 5f69266f7e..f61423e61d 100644 --- a/src/systems/diffeqs/abstractodesystem.jl +++ b/src/systems/diffeqs/abstractodesystem.jl @@ -762,7 +762,7 @@ function process_DEProblem(constructor, sys::AbstractODESystem, u0map, parammap; warn_initialize_determined = true, build_initializeprob = true, initialization_eqs = [], - fully_determined = false, + fully_determined = nothing, kwargs...) eqs = equations(sys) dvs = unknowns(sys) @@ -1467,7 +1467,7 @@ InitializationProblem{iip}(sys::AbstractODESystem, u0map, tspan, simplify = false, linenumbers = true, parallel = SerialForm(), initialization_eqs = [], - fully_determined = false, + fully_determined = nothing, kwargs...) where {iip} ``` @@ -1517,7 +1517,7 @@ function InitializationProblem{iip, specialize}(sys::AbstractODESystem, check_length = true, warn_initialize_determined = true, initialization_eqs = [], - fully_determined = false, + fully_determined = nothing, kwargs...) where {iip, specialize} if !iscomplete(sys) error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating an `ODEProblem`") @@ -1525,11 +1525,13 @@ function InitializationProblem{iip, specialize}(sys::AbstractODESystem, if isempty(u0map) && get_initializesystem(sys) !== nothing isys = get_initializesystem(sys; initialization_eqs) elseif isempty(u0map) && get_initializesystem(sys) === nothing - isys = structural_simplify( - generate_initializesystem(sys; initialization_eqs); fully_determined) + isys = generate_initializesystem(sys; initialization_eqs) + _fully_determined = fully_determined === nothing ? length(equations(isys)) == length(unknowns(isys)) + isys = structural_simplify(isys ; _fully_determined) else - isys = structural_simplify( - generate_initializesystem(sys; u0map, initialization_eqs); fully_determined) + isys = generate_initializesystem(sys; u0map, initialization_eqs) + _fully_determined = fully_determined === nothing ? length(equations(isys)) == length(unknowns(isys)) + isys = structural_simplify(isys; _fully_determined) end uninit = setdiff(unknowns(sys), [unknowns(isys); getfield.(observed(isys), :lhs)])