Question
STARTER CODE: # 0. Place your necessary imports here. You may find it useful to be able to plot when debugging and visualizing your result.
STARTER CODE:
# 0. Place your necessary imports here. You may find it useful to be able to plot when debugging and visualizing your result. import numpy as np
# 1. Create a 1D vector named `t` and 2D arrays named `vx`, `vy`, `x`, and `y` to hold the state variables, of size 90 x 1001. t = ???
# 2. Store the angles from 1 to 90 degrees as radians in a variable called `radians`. Use this to initialize the state variables for `vx` and `vy`. m = 90 # angles to fire at angles = ??? radians = angles * 2*np.pi/360
# 3. Define properties like gravity, Callista's surface area, and Callista's mass, and any other parameters you may need as they come up. A = 0.8 # m^2 g = 9.8 # m/s^2 # etc. Note that I expect an `initial_height` and `initial_velocity` below.
# 4. At this point, you should have defined `t`, `x`, `y`, `vx`, `vy`, `radians`, and the properties you need. Now, initialize the starting condition in each array: for i in range(m): y[ i,0 ] = initial_height vx[ i,0 ] = initial_velocity * np.cos( radians[ i ] ) vy[ i,0 ] = ??? # (see "Angles" above)
# 5. Now you are ready to begin the simulation proper. You will need two loops, one over every angle, and one over every time step for that angle's launch. for i in ???: # loop over each angle for j in ???: # loop over each time step # check that the location isn't below the ground; if so, adjust as specified above # calculate the acceleration including drag (for both x and y, x shown) v = np.sqrt( vx[ i,j-1 ]**2 + vy[ i,j-1 ]**2 ) ax = -( 0.5*rho*C*A/mass ) * v**2 * ( vx[ i,j-1 ] / v ) # calculate the change in position at time `ts` using the current velocities (`vx[ i,j ]`) and the previous positions (`x[ i,j-1 ]`). This is slightly different from the previous example you solved in an earlier homework.
# 6. The purpose of these calculations was to show which angle yielded the farthest distance. Find this out and store the result in a variable named `best_angle`.
Callista "Cherry Bomb" Davidson is a world-famous stunt woman, and she is trying to achieve the long distance world record human cannonball. She needs your help, though, because she has no idea what angle is best to aim her cannon. You will need to simulate firing the cannon at all integer angles from 1 to 98 inclusive. LIFE Her cannon will shoot her at a velocity of 70 at a starting height of 5m. We will assume an acceleration of gravity g = -9.8 . We will simulate her trajectory for 10 seconds in 1,000 steps (so 1,001 states including the initial state.) Angles We will simulate 90 different angles from 1 90. You will need to find the horizontal a and vertical y components of her initial velocity at each angle to simulate in two dimensions. Vz0 = vocos(0) Vy0 = vosin(0). (Note that you will need to convert from degrees to radians before using the numpy sin and cos functions.)
Step by Step Solution
3.42 Rating (171 Votes )
There are 3 Steps involved in it
Step: 1
AnswerCode in pycharm import time importing time moduleimport math importing math modulepi mathpi de...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started