Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
TruncatedStacktraces = "781d530d-4396-4725-bb49-402e4bee1e77"

[compat]
Expand Down Expand Up @@ -84,6 +85,7 @@ SparseArrays = "1.9"
SparseDiffTools = "2.3"
StaticArrayInterface = "1.2"
StaticArrays = "1.0"
SymbolicIndexingInterface = "0.3.16"
TruncatedStacktraces = "1.2"
julia = "1.10"

Expand Down
2 changes: 2 additions & 0 deletions src/OrdinaryDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ using ExponentialUtilities

using NonlinearSolve

using SymbolicIndexingInterface

# Required by temporary fix in not in-place methods with 12+ broadcasts
# `MVector` is used by Nordsieck forms
import StaticArrays: SArray, MVector, SVector, @SVector, StaticArray, MMatrix, SA
Expand Down
11 changes: 10 additions & 1 deletion src/initialize_dae.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,16 @@ end
function _initialize_dae!(integrator, prob::Union{ODEProblem, DAEProblem},
alg::OverrideInit, isinplace::Union{Val{true}, Val{false}})
initializeprob = prob.f.initializeprob

if initializeprob.f.sys !== nothing && prob.f.sys !== nothing
initu0vars = variable_symbols(initializeprob)
initu0order = variable_index.((initializeprob,), initu0vars)
# Variable symbols are not guaranteed to be in order
invpermute!(initu0vars, initu0order)
initu0 = getu(prob.f.initializeprob, initu0vars)(prob)
initp = remake_buffer(initializeprob, parameter_values(initializeprob),
Dict(sym => getu(prob, sym)(prob) for sym in parameter_symbols(initializeprob)))
initializeprob = remake(initializeprob; u0 = initu0, p = initp)
Comment on lines +137 to +145
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this all makes sense. First of all, it shouldn't come from prob since you can have callback reinitialization, so it should come from integrator.u. But also, this is just very heavy and dynamic: can't we just add a initializeprobsetu in the ODEFunction which sets up the initalizeprob based on integrator.u, and then also have one for p that updates based on any p updates (and also this should update t, which is a psuedo-parameter of the initialization)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Since this involves SciMLBase changes (changing ODEFunction and DAEFunction fields) I'll merge this PR with #2228 since that depends on this PR and modifies those structs anyway.

end
# If it doesn't have autodiff, assume it comes from symbolic system like ModelingToolkit
# Since then it's the case of not a DAE but has initializeprob
# In which case, it should be differentiable
Expand Down