<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Homework 6 - The T-Shirt Cannon
The MSU Science Festival has decided that its existing marketing efforts are not effective enough at attracting peoples' attention, and has decided to enter a new era of high-velocity publicity.  You have been commissioned to build a t-shirt cannon to distribute Science Festival t-shirts in MSU's large lecture halls to raise public awareness for the festival.  Your deliverables for this highly lucrative contract are (1) a fully functioning t-shirt cannon and (2) a program that calculates ranges as a function of the t-shirt cannon's launch speed and launch angle, and some informative graphs so that the t-shirt cannon's operator can precisely target their long-distance PR efforts. You have already constructed your t-shirt cannon; now you need to make predictions about how far you can launch a t-shirt, taking into account the challenges inherent to the nascent, but potentially highly lucrative, field of indoor high-velocity garment distribution.  As part of your contract, you have agreed to provide software, tables, and graphs that model the behavior of the t-shirt cannon.  Once you do this, you will take your place in t-shirt cannon history, beside such innovators as the San Antonio Coyote (also known as the Tesla of T-Shirt Cannons).
In the paragraphs below, we provide you with some background knowledge that you will need for this model as well as detailed instructions for the assignment itself.  Happy simulating!  And remember... you're securing your place in history with this project.
Note
Step1:  Section 2 - some questions and plots
Note
Step2:  Question 2
Step3:  Put your answer here!
Question 4
Step4:  Put your answer here!
Question 5
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import math 
def calc_accel(velocity, use_resistance=True):
    '''
    This function calculates and returns the acceleration vector 
    from a launched t-shirt, given an input velocity.  Optionally,
    you can turn on and off air resistance for comparison purposes with
    resistance=True or False.  
    
    Note 1: inputs and outputs are in SI units - meters per second for 
    velocity and meters per second^2 for acceleration. 
    
    Note 2: both input velocity and returned acceleration are 2-element
    numpy arrays, with the horizontal (x) direction in the first element 
    and vertical (y) direction in the second element of the array.
    '''
    
    C = 2.0  # t-shirt
    rho_air = 1.225     # kg/m^3
    rho_tshirt = 500.0  # kg/m^3
    mass_obj = 1.0  # kg
    rad_obj = ((3.0*mass_obj)/(4.0*rho_tshirt*math.pi))**(1.0/3.0)  # assume sphere for simplicity; slight approx.
    
    # speed = magnitude of velocity vector
    speed = (velocity[0]**2 + velocity[1]**2)**0.5
    if speed > 75.0:
        print("WARNING! At speeds > 75 m/s, your t-shirt cannon will explode!")
    
    accel_vector = np.zeros(2)
    
    # if we have air resistance turned on, compute the force due to air 
    # resistance and add it to the acceleration.
    if use_resistance==True:
        '''
        Calculates acceleration due to air resistance
        |F_air| = 0.5 * C * rho * A * v^2
        C = constant based on shape
        rho = density of air
        A = cross-sectional area
        v = speed (magnitude of velocity)
        Note that we calculate the magnitude in the first step and turn it into a vector in the second step.
        '''
        accel_air_resist = -0.5 * (C/mass_obj) * rho_air * math.pi * rad_obj**2 * speed**2
        # turn this into a vector quantity - velocity[0]/speed gives x-component of velocity unit vector
        # and velocity[1]/speed gives y-component of velocity unit vector
        accel_vector[0] += accel_air_resist*velocity[0]/speed
        accel_vector[1] += accel_air_resist*velocity[1]/speed
    # we always have gravity, which always points downward.
    accel_vector[1] -= 9.81
    
    return accel_vector
# Put your code here!  Add additional cells as necessary.
def calc_pos_vel(speed,angle,dt = 0.05, use_resistance=True):
    position = np.array([0.0,0.0])
    velocity = np.array([speed*math.cos(math.radians(angle)),speed*math.sin(math.radians(angle))])
    this_time = 0.0
    pos = [[],[]]
    vel = [[],[]]
    time = []
    while(position[1]>=0.0):
        accel = calc_accel(velocity, use_resistance=use_resistance)
        
        velocity += accel*dt
        position += velocity*dt
        this_time += dt
        pos[0].append(position[0])
        pos[1].append(position[1])
        vel[0].append(velocity[0])
        vel[1].append(velocity[1])
        time.append(this_time)
    
    return pos, vel, time
Explanation: Homework 6 - The T-Shirt Cannon
The MSU Science Festival has decided that its existing marketing efforts are not effective enough at attracting peoples' attention, and has decided to enter a new era of high-velocity publicity.  You have been commissioned to build a t-shirt cannon to distribute Science Festival t-shirts in MSU's large lecture halls to raise public awareness for the festival.  Your deliverables for this highly lucrative contract are (1) a fully functioning t-shirt cannon and (2) a program that calculates ranges as a function of the t-shirt cannon's launch speed and launch angle, and some informative graphs so that the t-shirt cannon's operator can precisely target their long-distance PR efforts. You have already constructed your t-shirt cannon; now you need to make predictions about how far you can launch a t-shirt, taking into account the challenges inherent to the nascent, but potentially highly lucrative, field of indoor high-velocity garment distribution.  As part of your contract, you have agreed to provide software, tables, and graphs that model the behavior of the t-shirt cannon.  Once you do this, you will take your place in t-shirt cannon history, beside such innovators as the San Antonio Coyote (also known as the Tesla of T-Shirt Cannons).
In the paragraphs below, we provide you with some background knowledge that you will need for this model as well as detailed instructions for the assignment itself.  Happy simulating!  And remember... you're securing your place in history with this project.
Note: While it's fine to talk with others about this homework - and in fact we strongly encourage you to do so - you need to write your own code and turn in your own homework assignment!  
<img src="https://static01.nyt.com/images/2013/06/23/magazine/23wmt1/mag-23WMT-t_CA0-master675.jpg" width=500>
Your name
// put your name here!
Some background knowledge that we need for this model
Position, velocity, and acceleration
In this homework assignment, we are going to model a relatively simple system - namely, the launching of a t-shirt.  An object's position ($\vec{x}$) and velocity ($\vec{v}$) evolve according to a straightforward set of mathematical rules:
$\vec{x} = \vec{x}_0 + \int_0^t \vec{v} dt$
$\vec{v} = \vec{v}_0 + \int_0^t \vec{a} dt$
$\vec{a} = \frac{d\vec{v}}{dt} = \frac{1}{m}\sum \vec{F}$
Note that $\vec{a}$ is the acceleration and m is the mass of the t-shirt.  $\vec{x}_0$ and $\vec{v}_0$ are the position and velocity at $t=0$, respectively.  The little arrows on top of letters indicate vector quantities - i.e., quantities that have direction as well as magnitude.  With vector quantities, you can separate the components and solve them independently - for example, you only need to know the x-velocity to calculate the x-position (though ultimately you may need some quantities that need information from both - you need the speed, which includes x- and y-velocity, to calculate the acceleration due to air resistance).  In the last term of the third equation, the sum is over all forces acting on the object (i.e., the t-shirt).  
The forces acting on the object are gravity, which points downward with a magnitude of $g=9.81$m s$^{-2}$, and air resistance, which can be written as:
$\vec{F}_{air} = -\frac{1}{2} C \rho A v^2 \hat{v}$
Where C is a constant corresponding to the shape of the object ($C=0.47$ for a sphere, $C=2.0$ for an Industry Standard T-Shirt, or IST), $\rho$ is the density of the atmosphere, 1.2 kg/m$^3$, A is the cross-sectional area of the object, v is the magnitude of the velocity, and $\hat{v}$ is the unit vector of the velocity.  Note the minus sign - this means that the force of air resistance always opposes the motion of the object, regardless of its direction.
Section 1 - The Model
Your task is to create a code that implements the equations presented above to model the position and velocity of the t-shirt cannon as a function of time.  You have been provided a function that calculates the acceleration on the t-shirt due to both air resistance and gravity; you need to write a function that takes in a speed (the magnitude of velocity) and a launch angle (i.e., the angle above horizontal that you are launching the t-shirt) and returns lists of horizontal and vertical positions and velocities, as well as times.
Note that you will be graded both on the correctness of your solution and the quality of your code.  Use functions when possible, and make sure that your code is clearly written and has comments explaining what everything does.  Also make sure that all plots are clearly marked with axis labels and a title!
End of explanation
# Put your code here!
speeds = [15, 30, 45, 60, 75]
angles = [15, 30, 45, 60, 75]
pos, vel, time = calc_pos_vel(45,45,use_resistance=False)
plt.plot(pos[0],pos[1],'k--')
for speed in speeds:
    for angle in angles:
        pos, vel, time = calc_pos_vel(speed,angle,use_resistance=True)
        plt.plot(pos[0],pos[1])
        
plt.title("trajectories")
plt.xlabel("horizontal distance")
plt.ylabel("vertical distance")
plt.ylim(-5,60)
Explanation: Section 2 - some questions and plots
Note: make sure that all plots have appropriate x- and y-limits, as well as figure titles and axis labels.  The questions may require both code and a written answer, so please make sure to do both!
Question 1: Create a plot that shows trajectories (lines showing the x- and y-position of the t-shirt, without showing the time) for a grid of speeds (ranging from 15 to 75 m/s in steps of 15 m/s) and angles above the horizontal (from 15 to 75 degrees in steps of 15 degrees).  For one of the values (45 degrees and 45 m/s) also plot the trajectory when you turn off air resistance (with the argument resistance=False in the calc_accel() function).  Note that your t-shirt cannon can only launch t-shirts at speeds of up to 75 m/s - at any higher speeds, you risk the cannon exploding or the t-shirt disintegrating in flight!
End of explanation
# Put your code here!
Explanation: Question 2: Qualitatively, how important is the effect of air resistance in this calculation?
Put your answer here!
Question 3: When air resistance is included, what combination of angle and speed gives you the longest "hang time"?  In other words, if you want the t-shirt to be in the air for as long as possible, what values do you choose?  (Note: this doesn't have to be the angles and speeds chosen above, but your cannon can only launch t-shirts at speeds of up to 75 m/s.)
End of explanation
# Put your code here!
Explanation: Put your answer here!
Question 4: When air resistance is included, what combination of angle and speed lets you send a t-shirt the farthest horizontal distance?
End of explanation
# Put your code here!
Explanation: Put your answer here!
Question 5: You are asked to distribute t-shirts in a lecture hall that has 12 meter high ceilings.  What is the farthest horizontal distance that you can send a t-shirt in that case, and how long does it take to get there?  (Ignore the fact that most lecture halls have stadium-type ceiling; imagine the floor is flat.)
End of explanation
<END_TASK>