You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a component array for u, it is not possible to access its fields directly in a continuous callback when also using a variable rate jump.
Expected behavior
In the example below, I would expect to be able to access u.r in the callback condition.
This is indeed the not an issue when using ConstantRateJump instead of VariableRateJump.
I can access this field in condition by doing u.u.r, but it makes it painful to switch from constant to variable jump for more complex situations.
Minimal Reproducible Example 👇
using ComponentArrays
using DifferentialEquations
functionf!(du, u, p, t)
@static_unpack r, v = u
du.r = v
du.v =-r
end
u_0 =ComponentArray(r = [0.0, 0.0, 0.0], v = [1.0, 0.0, 0.0])
ode_prob =ODEProblem(f!, u_0, (0.0, 10))
rate(u, p, t) =1.0jump!(integrator) =nothing
jump_prob =JumpProblem(ode_prob, Direct(), VariableRateJump(rate, jump!))
condition(u, p, t) = u.r[1] -1.0functioncallback!(integrator)
integrator.u.r[1] =0.0reset_aggregated_jumps!(integrator)
endsolve(jump_prob, Tsit5(), callback =ContinuousCallback(condition, callback!))
When you use VariableRateJumps your input u is wrapped in an ExtendedJumpArray, hence why you need to use u.u. Unfortunately, while we've discussed changing this, it is fundamental to how the solvers for VariableRateJumps currently work, so isn't something that can be trivially fixed (i.e it would require a different method for integrating propensities of VariableRateJumps, and a breaking update to JumpProcesses). It will hopefully get changed in the future, but probably not until someone has time to work on it or we get a GSOC student interested in such changes.
Describe the bug 🐞
When using a component array for
u
, it is not possible to access its fields directly in a continuous callback when also using a variable rate jump.Expected behavior
In the example below, I would expect to be able to access
u.r
in the callbackcondition
.This is indeed the not an issue when using
ConstantRateJump
instead ofVariableRateJump
.I can access this field in
condition
by doingu.u.r
, but it makes it painful to switch from constant to variable jump for more complex situations.Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment:
Using Julia Version 1.11.3, DifferentialEquations v7.15.0, JumpProcesses v9.14.1, and ComponentArrays v0.15.23.
The text was updated successfully, but these errors were encountered: