Skip to content

Commit e61a0f9

Browse files
use new ODE solver changes
1 parent 66c29ef commit e61a0f9

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Libdl = "1"
8989
LinearAlgebra = "1"
9090
MLStyle = "0.4.17"
9191
NaNMath = "0.3, 1"
92-
OrdinaryDiffEq = "6.72.0"
92+
OrdinaryDiffEq = "6.73.0"
9393
PrecompileTools = "1"
9494
RecursiveArrayTools = "2.3, 3"
9595
Reexport = "0.2, 1"

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,8 @@ function process_DEProblem(constructor, sys::AbstractODESystem, u0map, parammap;
862862
ps = full_parameters(sys)
863863
iv = get_iv(sys)
864864

865+
# TODO: Pass already computed information to varmap_to_vars call
866+
# in process_u0? That would just be a small optimization
865867
varmap = merge(defaults, todict(u0map))
866868
varlist = collect(map(unwrap, dvs))
867869
missingvars = setdiff(varlist, collect(keys(varmap)))

test/initializationsystem.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,28 @@ p = [σ => 28.0,
332332

333333
tspan = (0.0, 100.0)
334334
@test_throws ArgumentError prob=ODEProblem(sys, u0, tspan, p, jac = true)
335+
336+
# DAE Initialization on ODE with nonlinear system for initial conditions
337+
# https://github.com/SciML/ModelingToolkit.jl/issues/2508
338+
339+
using ModelingToolkit, OrdinaryDiffEq, Test
340+
using ModelingToolkit: t_nounits as t, D_nounits as D
341+
342+
function System(;name)
343+
vars = @variables begin
344+
dx(t), [guess=0]
345+
ddx(t), [guess=0]
346+
end
347+
eqs = [
348+
D(dx) ~ ddx
349+
0 ~ ddx + dx + 1
350+
]
351+
return ODESystem(eqs, t, vars, []; name)
352+
end
353+
354+
@mtkbuild sys = System()
355+
prob = ODEProblem(sys, [sys.dx => 1], (0,1)) # OK
356+
prob = ODEProblem(sys, [sys.ddx => -2], (0,1), guesses = [sys.dx => 1])
357+
sol = solve(prob, Tsit5())
358+
@test SciMLBase.successful_retcode(sol)
359+
@test sol[1] == [1.0]

0 commit comments

Comments
 (0)