[VPYTHON] I have a project for physics that involves coding. It involves project
ID: 3911808 • Letter: #
Question
[VPYTHON] I have a project for physics that involves coding. It involves projectile motion with air drag. I can't seem to get the air drag part right. Any tips? My code is copied below:
GlowScript 2.7 VPython
scene.width=600
scene.height=600
scene.center=vec(120,5,0)
scene.range=150
velocity_person = 15
degrees = 45
angle=radians(degrees)
mass_hammer = 7.26
velocity_hammer = 45
Lx = velocity_hammer*cos(angle)
Ly = velocity_hammer*sin(angle)
''' Air drag variables'''
rho = 1.2
c = .47
A = pi*1**2
F_drag= .5*c*rho*A*velocity_hammer**2
floor = box(pos=vec(0,-1,0), size=vec(500,0.1,50), color=color.yellow)
body = box(pos=vec(-20,3.5,0), size=vec(1,7,1), color=color.blue)
head = sphere(pos=vector(-20,7,0), radius=1.5)
hammer = sphere(pos=vector(-15,3.5,0), radius=1, color=color.red, make_trail=True)
head.velocity = vector(velocity_person,0,0)
body.velocity = vector(velocity_person,0,0)
dt = 0.01
while head.pos.x< -10:
rate(50)
head.pos=head.pos+head.velocity*dt
body.pos=body.pos+head.velocity*dt
hammer.rotate(angle=.01, axis = vector(-15,3.5,0))
hammer.velocity=vector(Lx,Ly,0)
hammer.acceleration=vector(0,-9.8,0)
'''Here's where I need help. I need to include air drag in the 'while' loop'''
while hammer.pos.y>= 0:
rate(300)
hammer.acceleration = hammer.acceleration - '''air drag: what do I put here?'''
hammer.pos= hammer.pos + hammer.velocity*dt + .5*hammer.acceleration*dt**2
hammer.velocity= hammer.velocity + hammer.acceleration*dt
Explanation / Answer
First of all, If we calculate the projectile motion of hammer without using air drag (also called air resistance or simply called drag), then only gravity effect will include in acceleration component. The acceleration component in x and y direction are:
Ax = 0 (in x-direction), and Ay = -g (in y-direction)
But if we calculate the projectile motion with air drag, the effects of both gravity and air drag will include in the acceleration component. The acceleration components in x and y direction are:
Ax = -(D/m)*v*Vx (in x direction), and Ay = -g-(D/m)*v*Vy (in y direction)
where D is a constant needed for the drag calculation, m is mass of object, v is velocity of pbject, g is acceleration with gravity effect, Vx is velocity in horizonatl direction and Vy is velocity in vertical direction.
So, you need to include the effects of both gravity and air drag in acceleration component to calculate the projectilemotion with air drag.
Simply you can write below code in while loop to include air drag,
hammer.accelration = hammer.acceleration - (F_drag/mass_hammer)*Velocity_hameer*Ly
Where F_drag is a constant needed to calucalate the air drag, mass_hammer is mass of object, Velocity is velocity of object, Ly is Velocity in y direction and hammer.acceleration is the acceleration with gravity effect.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.