The program has to versions for this lab. The first version of the program is a one dimensional motion that consist of a block with an initial velocity and a constant net force applied in the opposite direction. The force applied over time causes an impulse which in turn changes the momentum. Th cart eventually returns back to the position it started at with the same initial velocity magnitude in the opposite direction.
Code from first version of the program:
#Physics 4A Lab: Fancart Momentum Lab
#April 9th 2012
#Chris Cosio
#This is a program to simulate a fancart that changes momentum over time.
from __future__ import division
from visual import*
mcart=0.80 #mass in kilograms
pcart=mcart*vector(0.5) #momentum of cart
t=0 #initial time
deltat=0.01 #change in time in seconds
F_external=vector(0.0526)
print('cart momentum=',pcart)
track=box(pos=vector(0,-0.025,0), size=(2.0,0.05,0.10), color=color.white)
cart=box(pos=vector(0.95,0.027,0),size=(0.1,0.04,0.06), color=color.magenta)
while t<=15.2:#This loop will change time, momentum, and position incrementally.
rate(100)
pcart=pcart-F_external*deltat
cart.pos=cart.pos-(pcart/mcart)*deltat
t=t+deltat
print('end of program')
Video of program being executed:
The second version of the program is a two dimensional motion that consist of a block with an initial 2-D velocity with a 2-D constant net force applied in the opposite direction. The force being applied causes an impuse which in turn changes the momentum. The goal of this program was to create a loop that updated the momentum with an impulse that would return the block back to its original position.
Code from the second version of the program:
#Physics 4A Lab: Fancart Momentum Lab
#April 9th 2012
#Chris Cosio
#This is a program to simulate a fancart that changes momentum over time.
from __future__ import division
from visual import*
mcart=0.80 #mass in kilograms
pcart=mcart*vector(0.5,0,0.15) #momentum of cart
t=0 #initial time
deltat=0.01 #change in time in seconds
F_external=vector(0.0526,0,0.016)#External force acting upon the cart
print('cart momentum=',pcart)
track=box(pos=vector(0,-0.025,0), size=(2.0,0.05,1.75), color=color.white)
cart=box(pos=vector(0.95,0.027,0),size=(0.1,0.04,0.06), color=color.magenta)
while t<=15.2:#This loop will change time, momentum, and position incrementally.
rate(100)
pcart=pcart-F_external*deltat
cart.pos=cart.pos-(pcart/mcart)*deltat
t=t+deltat
print('end of program')
Video of program being executed:
This lab explored the concepts of loops, momentum and impulse. The loops inside of a program are useful to repeat calculations until a statement is true. This can consist of a value that eventually violates a less than or equal statement. This will cause the program to exit the loop. Both programs utilized two physics principles:
momentum
impulse
No comments:
Post a Comment