Passing userdata to solver

Hi there,

I’m using DifferentialEquations.jl to simulate collisions between particles. When one particle leaves a defined volume I want to reseed it randomly until a certain number of collisions is reached. My code from last autumn used the solution recommended here, i.e. to pass the number of collisions in the userdata dictionary and update it. This is what my callback function, that is called everytime one particle leaves the volume, looks like:

    function affect!(integrator)
        integrator.opts.userdata[:n_coll] += 1
        if integrator.opts.userdata[:n_coll] == integrator.opts.userdata[:n_coll_max]
            terminate!(integrator)
        else
            rᵢₙᵢₜ, vᵢₙᵢₜ = seed_atom_T(integrator.opts.userdata[:r_init_sphere])
            integrator.u[10:12] .= rᵢₙᵢₜ
            integrator.u[4:6] .= vᵢₙᵢₜ
        end
    end

Revisiting the code I realized that userdata is deprecated since a while. What is the recommended way to solve this now? I’m not very familiar with julia so far so there might be an obvious solution I’m missing.

Thanks!

Just make it be the parameters.