-
-
Notifications
You must be signed in to change notification settings - Fork 243
Closed
Description
Using Julia 1.5.3 and DifferentialEquations v6.15.0, the solver gets stuck at a time value and won't progress anymore. I'm using a VectorContinuousCallback to determine events that are root findable, defined in the condition function. There are additional boolean conditions that need to be met for the events to actually occur. I put these conditions in the affect function. To reproduce that error, you can use the following code snippet:
const torque = 1.0
const Ic = 10.0
const Iv = 0.15
const r_c = 1.0
const r_v = 0.3
const αc = 24.0 * pi/180
const e_r = 0.05
const nteeth = round(Int, 2pi/αc)
const Mv = Iv/r_v^2
const Mc = Ic/r_c^2
const Gc = Mv*(1 + e_r)/r_c/(Mv + Mc)
const Gv = Mc*(1 + e_r)/r_v/(Mv + Mc)
const αv = Gv*r_c/(1-e_r)*αc/2
p = (torque, Ic)
function f(du,u,p,t)
du[1] = u[3]
du[2] = u[4]
du[3] = p[1]/p[2] # p =(torque, crown inertia)
du[4] = 0.0
@show t
end
#out = vector of length 2nteeth
function condition(out,u,t,integrator)
for m in 1:nteeth
out[m] = r_c*sin(u[1] - (m-1)*αc) - r_v*tan(u[2] + αv/2)#upper
out[m + nteeth] = r_c*sin((m-1)*αc - u[1]) - r_v*tan(-u[2] + αv/2) #lower
end
end
function affect!(integrator, m)
c_up = r_c*integrator.u[3] - r_v*integrator.u[4] > 0.0 && ( (m-1)*αc <= mod(integrator.u[1] + αc/2, 2π) <= m*αc)#upper
c_dn = r_c*integrator.u[3] + r_v*integrator.u[4] > 0.0 && ( (m-1)*αc <= mod(integrator.u[1] + αc/2 + π, 2π) <= m*αc ) #lower
if m <= nteeth && c_up
integrator.u[3] = -r_c*Gc*integrator.u[3] + r_v*Gc*integrator.u[4]
integrator.u[4] = + r_c*Gv*integrator.u[3] - r_v*Gv*integrator.u[4]
elseif m > nteeth && c_dn
integrator.u[3] = -r_c*Gc*integrator.u[3] - r_v*Gc*integrator.u[4]
integrator.u[4] = -r_c*Gv*integrator.u[3] - r_v*Gv*integrator.u[4]
end
end
cb = VectorContinuousCallback(condition,affect!,2nteeth)
u0 = [0, 0.0, 0.0, 3.0]
prob = ODEProblem(f,u0,(0.0,2.0),p)
sol = solve(prob, callback=cb, abstol=1e-3, reltol=1e-3, dt = 1e-1, adaptive=false) #
plot(sol,layout=(4,1))
Note that I would get an "Event repeated at same time" error when using v6.12.0. If this is of any help, I'm trying to reproduce results published in Roup et al.
Metadata
Metadata
Assignees
Labels
No labels