lec16_ODE3 - # #Example 1: Projectile with air drag (2D) #...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
############### #Example 1: Projectile with air drag (2D) ################ ########################## # Projectile motion of a ball with air drag. # Uses euler and euler-cromer methods and plots results with theory (no drag) ########################## #from pylab import * # #def euler(rc,vc,acc,tau): # v_new = vc + dt* acc # #r_new = rc+tau*vc # r_new = rc+dt*v_new # return r_new,v_new # # #close('all') # ##Initial conditions #yi=0. #xi=0. #speed=15. #theta=65. #vx=speed*cos(theta*pi/180.) #vy=speed*sin(theta*pi/180.) # ##Simulation parameters #T=20 #n=2000 #dt=T/float(n) # # ##Create container 2-D arrays for position, velocity and theory position #r=zeros((n,2)) #v=zeros((n,2)) #r_nodrag=zeros((n,2)) # #times=zeros(n) #r[0,0]=xi #r[0,1]=yi #v[0,0]=vx #v[0,1]=vy # ##Some air drag physics #Cd=0.35 #area=9.3E-3 #g=9.81 #m=0.045 # ##density of air in Kg/m^3 ##rho= 1.2 #rho =0. # ##Calculate this once (outside the loop) #drag=-0.5*Cd*rho*area/m #
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#for step in range(n-1): # vc=v[step] # rc=r[step]
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/05/2010 for the course PHYS phy503 taught by Professor Gladden during the Spring '09 term at Ole Miss.

Page1 / 4

lec16_ODE3 - # #Example 1: Projectile with air drag (2D) #...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online