Skip to content

Commit e8e21ad

Browse files
Update gpu_ode_modelingtoolkit_dae.jl
1 parent aab9aa5 commit e8e21ad

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/gpu_kernel_de/stiff_ode/gpu_ode_modelingtoolkit_dae.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using ModelingToolkit, DiffEqGPU, OrdinaryDiffEq, LinearAlgebra, Test
1+
using ModelingToolkit, DiffEqGPU, OrdinaryDiffEq, LinearAlgebra, StaticArrays, Test
22
using ModelingToolkit: t_nounits as t, D_nounits as D
33

4+
include("../../utils.jl")
5+
46
# Define the cartesian pendulum DAE system
57
@parameters g = 9.81 L = 1.0
68
@variables x(t) y(t) [state_priority = 10] λ(t)
@@ -16,16 +18,16 @@ eqs = [D(D(x)) ~ λ * x / L
1618
@named pendulum = ODESystem(eqs, t, [x, y, λ], [g, L])
1719

1820
# Perform structural simplification with index reduction
19-
pendulum_sys = structural_simplify(dae_index_lowering(pendulum))
21+
pendulum_sys = mtkcompile(pendulum)
2022

2123
# Initial conditions: pendulum starts at bottom right position
22-
u0 = [x => 1.0, y => 0.0, λ => -g] # λ initial guess for tension
24+
u0 = SA[x => 1.0, y => 0.0, λ => -g] # λ initial guess for tension
2325

2426
# Time span
2527
tspan = (0.0f0, 1.0f0)
2628

2729
# Create the ODE problem
28-
prob = ODEProblem(pendulum_sys, u0, tspan, Float32[])
30+
prob = ODEProblem(pendulum_sys, u0, tspan)
2931

3032
# Verify DAE properties
3133
@test SciMLBase.has_initialization_data(prob.f) == true
@@ -54,4 +56,4 @@ sol2 = solve(monteprob, GPURodas4(), EnsembleGPUKernel(backend),
5456
dt = 0.01f0,
5557
adaptive = false)
5658

57-
@test length(sol2.u) == 2
59+
@test length(sol2.u) == 2

0 commit comments

Comments
 (0)