Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
394 views
ubuntu2204
Kernel: Python 3 (system-wide)

Prelab 02: Computational Kinematics

Name: Hannah Black

Part One: Position Update Equation with Constant Velocity

Suppose a particle moves in the y^-\hat{y} direction starting at y=100 my=100\ \text{m} with a velocity vy=10 m/sv_y = -10\ \text{m/s}.

Prelab Problem 2.1: With the initial conditions y=100 my=100\ \text{m} and vy=10 m/sv_y = -10\ \text{m/s}, how long will it take for the particle to reach y=0y=0?

#Using the kinematic equation y(f) = y(0) + v(t(f) - t(0)) and solving for the change in t, delta t = (y(f) - y(0))/(v) = (0 - 100)/(-10) = 10 s

#Using the kinematic equation y(f) = y(0) + v(t(f) - t(0)) and solving for the change in t, delta t = (y(f) - y(0))/(v) = (0 - 100)/(-10) = 10 s

Let us confirm your answer to problem 2.1 numerically. To do so, we will use the position update equation rnew=rold+vΔt\vec{r}_\text{new} = \vec{r}_\text{old} + \vec{v}\cdot \Delta t which simply states that the position at a time tnewt_\textrm{new} is equal to the old position at time toldt_\textrm{old} plus the change in position due to the velocity. This equation is essentially one step in the summation of an integral, we must perform it multiple times to do the entire integral. To to the full integral, we will use a while loop. In this case, we are starting at y0=100y_0 = 100 and taking time steps of 1 s1 \ \text{s}. We also have a constant velocity of 10 m/s-10 \ \text{m/s} in the y^\hat{y} direction.

Prelab Code Task 2.1: Input the initial conditions for the y position and y velocity. Then, run the cell to define the initial conditions.

#import numpy package import numpy as np #define initial conditions #individual positions x0 = 0 #meters ##### Begin Editing ##### y0 = 100 # meters ##### End Editing ##### z0 = 0 #meters #position vector r0 = np.array([x0,y0,z0]) #indivitual velocities vx0 = 0 #m/s ##### Begin Editing ##### vy0 = -10 #m/s ##### End Editing ##### vz0 = 0 #m/s #velocity vector v0 = np.array([vx0,vy0,vz0])

Next we will set up the while loop to perform the integration.

Prelab Code Task 2.2: Read code below then run the cell below, without editing, to perform the integration.

t = 0 r = r0 y = r[1] deltat = 1 while t <= 11: #position update r = r + v0 * deltat #update time and position for conditional t += deltat y = r[1] if y <= 0: break print('Particle reached y={} after t={} seconds.'.format(y,t))
Particle reached y=0 after t=10 seconds.

Part Two: Characteristic Time

The characteristic time of a physical process is not fixed, but rather an estimate based on the physical properties of the problem. For example, if we consider the earth's orbit, it takes one year to complete an orbit therefore a good characteristic time would be 1 year. Another way to arrive at 1 year for an earth orbit would be to use the values of the problem's parameters in a combination that has units of time.

In a very similar manner, we can estimate the characteristic time for the process in part one under the influence of earth's gravity near the surface. Near the earth's surface a=g=9.81 m/s2a = g = 9.81\ \text{m}/\text{s}^2, and in the problem above y0=100 my_0 = 100\ \text{m}.

Prelab Problem 2.2 Using the values of gg and y0y_0 above, estimate the characteristic time for an object falling 100 m100\ \text{m} near the earth's surface where g=9.81 m/s2g = 9.81\ \text{m}/\text{s}^2. Hint: what combination of gg and y0y_0 has units of seconds?

square root of (y(0) (m) / (g (m/s^2)) gives units of only seconds, as the m^(1/2) cancels out and the s^2 becomes seconds


Part Three: Combining Velocity Update and Position Update Equations

Finally, we will include the influence of gravity on the object by using the acceleration due to gravity to update the velocity as the object falls. The velocity update equation is vnew=vold+aΔt\vec{v}_\text{new} = \vec{v}_\text{old} + \vec{a}\cdot \Delta t. The acceleration due to gravity is ag=(0,g,0)a_g = (0,-g,0) where gg is the magnitude of the gravitational acceleration. In this case the acceleration is simple and uniform, but in the future we will use the force with newton's second law to determine the acceleration for the velocity update, as a=F/ma = F/m.

To include velocity updates, we will modify our previous code.

Prelab Code Task 2.3: Fill in the gaps in the code below to perform the computation of an object falling 100m100 \text{m} under the influence of gravity. Note: You will need the numpy square root function np.sqrt

t = 0 r = r0 v = v0 y = r[1] g = 9.81 a = np.array([0,-g,0]) ##### Begin Editing ##### tc = np.sqrt(y0/g) ##### End Editing ##### Ncycles = 10000 deltat = tc/Ncycles while t < 1.2 * tc: #position update r = r + v * deltat ##### Begin Editing ##### #Edit what's below to include the velocity update equation #velocity update v = v + a * deltat ##### End Editing ##### #update time and position for conditional t += deltat y = r[1] if y <= 0: break print('Particle reached y={} after t={} seconds.'.format(y,t))
Particle reached y=-0.004444935689719787 after t=3.6097279935697855 seconds.
You should find that the particle reaches $y=0$ after about $3.6$ seconds.

You're done! Submit your pre-lab per the following instructions

* Save an html version of this file with the pre-lab number and your uniqname to submit to canvas, e.g. `prelab02_bhipsley.html`. You can do this by opening the `File` tab on the top left corner of Jupyter, then select `Download as > HTML (.html)`. * If you are working in CoCalc, open the **lowest** `File` button in the top left corner and scroll through the menu until you see `Download as` grayed out. In the tabbed over list, select `Download as > HTML (.html)`. In the pop-up window, wait until the blue link for the file pops up. Then select the `Files` button above the previously selected `File` button and download the newly appeared .html file (click the Download icon button on the right side of the screen and rename it using the appropriate naming format explained above. Also download and rename the .ipynb file to your computer. * Submit <ins>**both**</ins> the .ipynb and .html files to canvas under the `Pre-Lab 2: Computation of Kinematics` assignment.