I am given an initial x and y position and initial velocity and I was asked to graph the trajectory in 1 second intervals.
This is what I have so far:
If x0=1,v0x=70,y0=0,v0y=80,ax=0,ay=−9.8, and time will be 0,1,2,3... and so on.
Using these equations on every second you can find the plot will be a bell shaped with the highest point being ~ 325 m at about 600 seconds:
x=x0+(v0x)t+1/2((ax)t2)
Usually in physics, we are taught in perfect condition with no air resistance. But what if there was air resistance? How would it affect this problem? How can i add it to my calculations and see what the difference is?
Answer
With drag force −α|˙r|˙r and gravitational force −mgˆy, the equations of motion are (see my answer to this question) ¨x=−β˙x√˙x2+˙y2¨y=−g−β˙y√˙x2+˙y2
I've never seen the above equations solved analytically. Here's some Python code that plots the solution with and without air resistance. To run, copy into a text file myFile.py and run
python myFile.py
from the command line.
from pylab import *
import math
# Physical constants
g = 9.8
m = 1.0
rho = 1.0
Cd = 1.0
A = math.pi * pow(0.01,2.0)
alpha = rho * Cd * A / 2.0
beta = alpha / m
# Initial conditions
X0 = 1.0
Y0 = 0.0
Vx0 = 70.0
Vy0 = 80.0
# Time steps
steps = 1000
t_HIT = 2.0*Vy0/g
dt = t_HIT / steps
# No drag
X_ND = list()
Y_ND = list()
for i in xrange(steps+1):
X_ND.append(X0 + Vx0 * dt * i)
Y_ND.append(Y0 + Vy0 * dt * i - 0.5 * g * pow(dt * i,2.0))
# With drag
X_WD = list()
Y_WD = list()
Vx_WD = list()
Vy_WD = list()
for i in xrange(steps+1):
X_ND.append(X0 + Vx0 * dt * i)
Y_ND.append(Y0 + Vy0 * dt * i - 0.5 * g * pow(dt * i,2.0))
# With drag
X_WD = list()
Y_WD = list()
Vx_WD = list()
Vy_WD = list()
X_WD.append(X0)
Y_WD.append(Y0)
Vx_WD.append(Vx0)
Vy_WD.append(Vy0)
stop = 0
for i in range(1,steps+1):
if stop != 1:
speed = pow(pow(Vx_WD[i-1],2.0)+pow(Vy_WD[i-1],2.0),0.5)
# First calculate velocity
Vx_WD.append(Vx_WD[i-1] * (1.0 - beta * speed * dt))
Vy_WD.append(Vy_WD[i-1] + ( - g - beta * Vy_WD[i-1] * speed) * dt)
# Now calculate position
X_WD.append(X_WD[i-1] + Vx_WD[i-1] * dt)
Y_WD.append(Y_WD[i-1] + Vy_WD[i-1] * dt)
# Stop if hits ground
if Y_WD[i] <= 0.0:
stop = 1
# Plot results
plot(X_ND, Y_ND)
plot(X_WD, Y_WD)
show()
No comments:
Post a Comment