Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ function timevaring_initsys_process_op!(
ikk = Initial(kk)
if SU.isconst(vv)
push!(eqs_ics, subkk ~ ikk)
write_possibly_indexed_array!(op, ikk, vv, COMMON_FALSE)
else
write_possibly_indexed_array!(guesses, kk, vv, COMMON_FALSE)
vv = fixpoint_sub(vv, derivative_rules; maxiters = get_maxiters(derivative_rules))
Expand Down
16 changes: 16 additions & 0 deletions lib/ModelingToolkitBase/test/initializationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1914,3 +1914,19 @@ end
@test_nowarn remake(oprob; p = SA[:p => 2.0, :d => 0.1])
@test_nowarn remake(oprob; p = (:p => 2.0, :d => 0.1))
end

@testset "Issue#4151: Partially symbolic initial conditions for array variable" begin
@variables x(t)[1:3] y(t)[1:1]
eqs = [
D(x)[1:2] ~ sin.(x[1:2]),
D(x)[3] ~ 0,
y[1] ~ x[1],
]
x0 = [1.3, 4.5]
ics = [x => [x0; y]]
@mtkcompile sys = System(eqs, t, [x, y], [], initial_conditions = ics)
prob = ODEProblem(sys, nothing, (0.0, 1.0))
@test prob.ps[Initial(x)][1:2] == x0
sol = solve(prob, Tsit5())
@test sol[x[1:2]][1] == x0
end
Loading