1- using ModelingToolkit, DiffEqGPU, OrdinaryDiffEq, LinearAlgebra, Test
1+ using ModelingToolkit, DiffEqGPU, OrdinaryDiffEq, LinearAlgebra, StaticArrays, Test
22using 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
2527tspan = (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