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
This problem seems to regard several parts of the DifferentialEquations.jl ecosystem, so I hope this is the right place to post it!
An error is thrown when an EnsembleProblem is created using a JumpProblem which includes aVariableRateJump and the saveat keyword is specified. Here is a minimum working example (using the base problem from the documentation here:
using DifferentialEquations
functionf!(du, u, p, t)
du[4] = u[2] * u[3] /100000- u[1]*u[4]/100000nothingend
u0 = [999.0, 10.0, 0.0, 100.0]
p = (.1/1000, .01)
tspan = (0.0, 250)
save_times =range(tspan...; step =1)
variable_rate(u, p, t) =1e-2*u[4]
functionvariable_affect!(integrator)
integrator.u[2] +=1nothingend
jump =VariableRateJump(variable_rate, variable_affect!)
#breaks if saveat is specified and interpolation is required
prob =ODEProblem(f!, u0, tspan, p, saveat = save_times)
jump_prob =JumpProblem(prob, Direct(), jump)
ensemble_prob =EnsembleProblem(jump_prob)
sol =solve(ensemble_prob, Tsit5(); trajectories =2)
The issue appears to be that JumpProcesses keeps up with the variable rate by appending the rates to the existing solution to create an ExtendedJumpArray. The problem only appears when saveat is specified because the integrator tried to interpolate to time in between the timesteps, and the interpolate method returns the ExtendedJumpArray and attempts to save it alongside the raw solution in an output array. I was able to implement a hack-ish fix by manually type checking and replacing the copyat_or_push! method here:
I am new to Julia, so please let me know if I can provide more info!
The text was updated successfully, but these errors were encountered:
benmcdonough20
changed the title
Type conversion error when adding a VariableRateJump to an EnsembleProblem and specifying savåçeat
Type conversion error when adding a VariableRateJump to an EnsembleProblem and specifying saveatJun 20, 2023
I'm going to move this to JumpProcesses since it appears to be another issue with the ExtendedJumpArray interface needing custom dispatches (as we also see in #321).
If you think you have a fix via adding a custom dispatch for ExtendedJumpArrays, a PR that adds it to JumpProcesses in
This problem seems to regard several parts of the
DifferentialEquations.jl
ecosystem, so I hope this is the right place to post it!An error is thrown when an
EnsembleProblem
is created using aJumpProblem
which includes aVariableRateJump
and thesaveat
keyword is specified. Here is a minimum working example (using the base problem from the documentation here:Here is the stack trace: (pastebin)
The issue appears to be that
JumpProcesses
keeps up with the variable rate by appending the rates to the existing solution to create anExtendedJumpArray
. The problem only appears whensaveat
is specified because the integrator tried to interpolate to time in between the timesteps, and theinterpolate
method returns theExtendedJumpArray
and attempts to save it alongside the raw solution in an output array. I was able to implement a hack-ish fix by manually type checking and replacing thecopyat_or_push!
method here:https://github.com/SciML/OrdinaryDiffEq.jl/blob/f56981814afbc058a95471d2f1b8ac7abdb8ff41/src/integrators/integrator_utils.jl#LL69C9-L75C84
I am new to Julia, so please let me know if I can provide more info!
The text was updated successfully, but these errors were encountered: