GeneralAstrodynamics.jl icon indicating copy to clipboard operation
GeneralAstrodynamics.jl copied to clipboard

Bounds Error in `AttitudeFunction`

Open cadojo opened this issue 1 month ago • 5 comments

The Attitude Model Calculations unit test is failing due to a bounds checking error. Using Debugger.jl, and looking at the error message, it appears that the issue is that the parameter vector (which has not really been a vector for the last couple of major ModelingToolkit.jl versions, but to my knowledge vectors are the only way to call ODEFunction instances) is being indexed by another vector.

The issue only occurs when Julia is initialized with --check-bounds yes.

vectorfield = AttitudeFunction()

q = [0, 0, 0, 1]
ω = [0.1, 0.1, 0.1]
x = vcat(q, ω)

J = diagm([0.1, 0.2, 0.3])
L = [0, 0, 0]
f = [0, 0, 0]
p = vcat(vec(J), L, f)

cadojo avatar Oct 12 '25 23:10 cadojo

Thanks, Joey! I was also able to reproduce this on just the SciML side with this stripped back example I think:

using ModelingToolkit

import SciMLBase

@independent_variables t

@variables (q(t))[1:2]

@parameters L

δ = Differential(t)

eqs = [
    δ(q[1]) ~ 0,
    δ(q[2]) ~ L,
]

sys = complete(System(eqs, t; name = :Test); split = false)

AF = ODEFunction{true, SciMLBase.FullSpecialize}(sys; jac = true)

AF([1.0, 2.0], [3.0], NaN)

# Also same error with combined state / params
# AF([1.0, 2.0], [1.0, 2.0, 3.0], NaN)

icweaver avatar Oct 12 '25 23:10 icweaver

@icweaver have you filed a ticket to ModelingToolkit? I was planning to myself, but ya beat me to the MWE! I think if you posted this, that would be helpful. If you do, maybe link this issue?

cadojo avatar Oct 13 '25 01:10 cadojo

haha, for sure, sorry for the delay, just opened https://github.com/SciML/ModelingToolkit.jl/issues/3965

icweaver avatar Oct 14 '25 20:10 icweaver

Oh geez, I was playing around with our project tools and didn't realize it would spam notifications like this. Sorry for the noise

icweaver avatar Oct 31 '25 06:10 icweaver

All good, I don't mind! If you find some solid project management tools lmk, I'd love to get more organized here.

cadojo avatar Oct 31 '25 13:10 cadojo