[SciPy-User] odeint for pendulum with limits

Anne Archibald aarchiba at physics.mcgill.ca
Tue Jul 19 10:07:19 EDT 2011


Unfortunately this is a very tricky problem. The naive approach of
replacing the stop with an extremely large force runs into problems
because the integrator bogs down in tiny steps simulating the stop in
detail.

A better approach is to run the integrator with no limits but stopping
integration when the pendulum reaches its physical limit. Then you can
change the velocity any way you like and restart the integration.

In terms of scipy, I don't think any of the integrators support
stopping conditions (pydstool does) but I believe ours do support
backtracking within the last step, so you can implement this yourself.

The problem becomes really difficult if you can't compute forces
outside the valid domain, because all the good integrators I know
sometimes need to evaluate points outside the permitted region.

Anne

On 7/19/11, Gustavo Goretkin <gustavo.goretkin at gmail.com> wrote:
> I am trying to model a pendulum which has a limited range of motion. The
> state of the pendulum consists of its angular position and velocity. When
> the pendulum hits one of its stops, the velocity goes to zero.
>
> Can I model this with the integrators in SciPy? In the dX/dt = F(X), I can
> write F such that the position is clipped into some range, but I don't think
> I can make the velocity discontinuously drop to zero. I'd appreciate any
> suggestions, including removing the discontinuity and instead placing a
> sharp, but continuous stop.
>
> Thanks,
> Gustavo
>

-- 
Sent from my mobile device



More information about the SciPy-User mailing list