Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Muhammad Hasan

PROJECT (20K-0479)
BCS-1A

Applied Physics (EE-117)


Simple pendulum in VPython

Problem Statement:
Simulate simple pendulum with small and large angles, keeping same lengths. Plot the
amplitude as a function of time for different angles and explain if any difference occurs.

Solution:
A simple pendulum system is set up using a bob attached with a rod clamped to a roof. The only
constant force acting on sphere will be gravity (g). The experiment will be done in ideal
conditions with no external forces such as air resistance. The simulation will show an oscillation
with the real time corresponding graph (time t against position theta)

PROCEDURE:
For simulation, the online platform Glowscript 3.0 VPython is used on trinket.io. Further
elements and properties of the simulation are described below.

➢ ANIMATION
For animation we will use a while loop that ends once the time limit is reached.
For all the angles the time taken is 20 seconds.

➢ OBJECTS IN SIMULATION:
1) A sphere: named bob, colored green, positioned (5,2,0), radius 0.5 2)
Cylinder: used as a massless rod attached with bob and roof.
3) Box: used as a roof, to which rod is attached

➢ ESSENTIAL VARIABLES
Time, angular velocity, angle with vertical direction (theta), position of bob
(displacement), acceleration (magnitude and vector), velocity

➢ INTIAL VALUES
SMALL ANGLES (theta):

1) 6.8 degrees / 0.12 radians


2) 12 degrees / 0.209
LARGE ANGLES (theta):

1) 30 degrees / 0.524 radians


2) 45 degrees / 0.785

➢ FINAL VALUES
The final values of velocity, acceleration and time period will be used to
evaluate the nature of motion on different angles (small and large)

➢ CODE BLOCK
Since, it was not possible to plot multiple curves on single graph, the code is
executed 5 times with different values of theta. The code is as follows.
NOTE: The code below works for theta = 6.8 degrees or 0.12 radians. Other
results are obtained by changing the value of theta with the test values
mentioned above. Therefore, the code is executed 5 times.

# ------------ Background and axes


display(width=700,height=700,center=vector(0,12,0),backgroun
d=color.yellow) g=9.8 # acceleration due to gravity

# ------------- objects
bob=sphere(pos=vector(5,2,0),radius=0.5,color=color.green)
pivot=vector(0,20,0)
roof=box(pos=pivot,size=vector(10,0.5,10),color=color.white)
rod=cylinder(pos=pivot,axis=bob.pospivot,radius
=0.1,color=color.blue)

# length of pendulum l=mag(bob.pos-pivot)

# Time period
TP = (2*3.142)*((l/g)**0.5)

#------------- variables

# time

t=0

# time interval dt=0.00001

# calculation of cos(theta) cs=(pivot.y-bob.pos.y)/l

# angle with vertical direction theta=(0.12)

# angular velocity(initial)
vel=0.0 newtime = 0
noofwaves = 0
#-------graph
gd=graph(title ="Oscillations with theta smaller than 15 degrees
",xtitle="Time [s]", ytitle="Position [rad]")
graph1 = series(color=color.red) print("length of
pendum ",l)
#-------------- iteration(for 20 seconds) while
(t<=20):

rate(100000000)

# updating of angular acceleration acc=-


g/l*sin(theta)
# updating of angular position
theta=theta+vel*dt
# updating of angular velocity vel=vel+acc*dt #
calculating position bob.pos=vector(l*sin(theta),pivot.y-
l*cos(theta),0) # updating other end of rod of pendulum
rod.axis=bob.pos-rod.pos # updating time
t=t+dt graph1.plot(t,theta)
print("___For theta = 6.8
degrees / 0.12 radians___")
print("Final velocity
",vel,"m/s") print("Final
acceleration ",acc,"m/s/s")
print("Final angle
",theta,"rad")

Let us now look at the results of simulation with different values of


theta:

Results:
CONCLUSION:-
➢ For the results in experiment (a) (b) (c), it can be seen that the periods for all
three oscillations remain about the same. The relation a=-w^2x where x is the
displacement from mean position, works for angles in a, and c as they have
same angular velocities omega (w) Experimental acceleration in (a) is -9.2e3ms-
2 and from the SIMPLE HARMONIC EQUATION acceleration is also equivalent.
Subsequently for (b) and (c) the relation is valid too as the periods are equal.
For angles below 15 degrees the approximation “sin*theta = theta” remains
valid!

➢ In contrast, the angles above 15 degrees in (d) and (e) tend to produce
oscillations with different time periods, i.e. the relation a=-w^2x no longer
remain valid since omega changes as time period changes.
From theory, below is the proof for validity of SHM equation for smaller angles.

Weight’s x-component provides


. the necessary restoring force
(resultant force)

For small angles, the


displacement x is a straight line,
whilst for larger angles it is a
curve, for which it would not be
possible to obtain the
proportionalitybetween
acceleration and displacement

If theta is large it is not possible


to reach this result

You might also like