Skip to content

Commit

Permalink
Default to using fully_determined when possible in initialization
Browse files Browse the repository at this point in the history
This should give better error messages
  • Loading branch information
ChrisRackauckas authored Jul 30, 2024
1 parent c2e6e4a commit 8ee3a39
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/systems/diffeqs/abstractodesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}
```
Expand Down Expand Up @@ -1517,19 +1517,21 @@ 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`")
end
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)])
Expand Down

0 comments on commit 8ee3a39

Please sign in to comment.