Skip to content Skip to sidebar Skip to footer

How Do I Use Pylab To Plot A Phase Plane For Pendulum Motion?

I have code that will work for plotting the following predator prey model: dx/dt = x − xy, dy/dt = −y + xy from pylab import * xvalues, yvalues = meshgrid(arange(0, 3, 0.1),

Solution 1:

You do it the same way, first transform it into a first order system

thetadot = omega
omegadot = -g/L*sin(theta)

rename theta, omega to x,y for shortness and then proceed as before:

g,L = 1,1
xvalues, yvalues = meshgrid(arange(-8, 8, 0.1), arange(-3, 3, 0.1))
xdot = yvalues
ydot = -g/L*sin(xvalues)
streamplot(xvalues, yvalues, xdot, ydot)
grid(); show()

which gives the usual phase portrait

enter image description here

Post a Comment for "How Do I Use Pylab To Plot A Phase Plane For Pendulum Motion?"