Question about putting variable outside @animation

I think you need to annotate the following two variables as global inside the macro @animate:

global v += u * Δt
global q += v * Δt

NB: Δt is not defined in your MWE. Consider also the fps argument to gif()