

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Thursday 12 September - Due: Thursday 27 September
In this lab we will build a code to simulate a simple non-linear driven pen- dulum along the lines of the one we discussed in class. This will also serve as an introduction to the visual.graph module for 2D plots and also additional Vpython objects such as cylinder. We will be able to see chaotic behavior for some values of the driving force.
(a) Adding the initial lines of code after the import statement.
pic=gdisplay() angleplot=gcurve(gdisplay=pic)
(b) Also, add a new line directly after from visual import * which reads
from visual.graph import *
(c) Finally, add the following line of code (correctly indented!) at the end of the while loop
angleplot.plot(pos=(t,ball.angle)
if (ball.angle>math.pi): ball.angle=ball.angle-2math.pi if (ball.angle<-math.pi): ball.angle=ball.angle+2math.pi
string=cylinder(pos=(0,0,0),axis=ball.pos,color=color.green,radius=0.1)
This creates a cylinder object called string with one end at the origin of coordinates and with axis pointing towards the center of ball.
ball.pos=vector(....
You need to place this line of code after the initial creation of ball