In: Physics
use python to graph the projectile motion of an object under quadratic drag
As you have not specified the mass of the particle, the angle, it's inital velocity, angle of projection, etc., here is a general python program which you can use accordingly.
import numpy as np
import matplotlib.pyplot as plt
% matplotlib inline
# Model parameters
M = (put some value) # Mass of projectile in kg
g = 9.8 # Acceleration due to gravity (m/s^2)
V = () # Initial velocity in m/s
ang = () # Angle of initial velocity in degrees
Cd = () # Drag coefficient
dt = () # time step in s
t = [0]
vx = [V*np.cos(ang/180*np.pi)]
vy = [V*np.sin(ang/180*np.pi)]
x = [0]
y = [0]
drag=Cd*V**2
ax = [-(drag*np.cos(ang/180*np.pi))/M ]
ay = [-g-(drag*np.sin(ang/180*np.pi)/M) ]
counter = 0
while (y[counter] >= 0):
t.append(t[counter]+dt)
vx.append(vx[counter]+dt*ax[counter])
vy.append(vy[counter]+dt*ay[counter])
x.append(x[counter]+dt*vx[counter])
y.append(y[counter]+dt*vy[counter])
vel = np.sqrt(vx[counter+1]**2 + vy[counter+1]**2)
drag = Cd*vel**2
ax.append(-(drag*np.cos(ang/180*np.pi))/M)
ay.append(-g-(drag*np.sin(ang/180*np.pi)/M))
counter = counter +1
plt.plot(x,y,'ro')
plt.ylabel("y (m)")
plt.xlabel("x (m)")
print "Range of projectile is {:3.1f} m".format(x[counter])