====== Project 14: Part B: Showdown at boar tiger corral ====== After the epic showdown, the leaders of the boar tiger defense team decide to commission the development of an arcade game simulating the battle. The head of the development team, Boris Grishenko (Борис Грищенко), recently resigned. He leaves for you a partially completed section of code which aims to show the paths that the cannonball and block trace out in time. Pick up where he left off. {{183_projects:F15_P13_splash.png}} To make things more exciting, the defense team requests that: * the cannonball can be shot with a muzzle velocity of $v=1600\,{\rm m/s}$ * the mass of the cannonball be increased to $m_{\rm ball}=400\,{\rm kg}$ * the mass of the block be fixed at $m_{\rm block}=1700\,{\rm kg}$ having corresponding moment of inertia $I_{\rm block}=33\,{\rm kg\cdot m^{2}}$ about its rotation axis * the cannonball can only strike the block perpendicularly While you are at it, generate a plot of the total energy before and after the collision. This plot will help to determine how many points are gained/lost in the arcade game. https://www.glowscript.org/#/user/pcubed/folder/incompleteprograms/program/Showdown ====== Project 14 Solution: Part B: Showdown at boar tiger corral ====== The first thing that can be done is to change the junk initial conditions to reflect the actual values: #Parameters and Initial Conditions mball = 400 mblock = 1700 vball = vector(0,1600,0) #Calculation Loop Iblock = 33 Notice that there is an intentional error in the MWP (in the angular momentum calculation). The students will need to recognize and fix this in the angular momentum calculation: #Parameters and Initial Conditions Lball = cross(ball.pos,pball) Now, after the collision occurs, we need to add in the translation of the block and the rotation of the ball: #Calculation Loop block.pos = block.pos + (ptot/mtot)*dt ball.rotate(angle=(mag(Ltot)/Itot)*dt,axis=Ltot/mag(Ltot),origin=block.pos) In adding the graph, the group should use the [[https://github.com/perlatmsu/python-physutil/wiki/PhysGraph-Class|PhysGraph bookmark]] in Safari to figure out how to plot. #MotionMap/Graph energyGraph = PhysGraph(numPlots=1) #Calculation Loop energyGraph.plot(t,(mag(pball)**2)/(2*mball)) energyGraph.plot(t,(1/2)*Itot*((mag(Ltot)/Itot)**2) + (mag(ptot)**2)/(2*mtot)) ==Tutor Questions:== * **Question:** Add in a plot for the translational and rotational kinetic energies. * **Expected Answer:** ... * **Question:** Which of these quantities -- position, rotation, linear momentum, and/or angular momentum -- change and need to be updated in the calculation loop? Why? * **Expected Answer:** The position and rotation of the ball and block "continuously" change with time given that they have a velocity and angular velocity, respectively. That is why they must "update" inside the calculation loop. * **Question:** While the collision is occurring, which object feels a larger overall force? * **Expected Answer:** Both objects feel equal and opposite forces. * **Question:** What causes the angular momentum of the block to change? * **Expected Answer:** The ball exerts a torque on the block. Although the angular momentum of the entire system is conserved, that of the block alone is not. * **Question:** How did you calculate the total kinetic energies before and after the collision? * **Expected Answer:** Before, there is only translational kinetic energy due to the ball: $K_{i}=K_{\rm ball}$. After the collision, there is a translational kinetic energy due to the center of mass motion and a rotational energy relative to that center of mass: $K_{f}=K_{\rm trans,cm}+K_{\rm rot,rel}$. * **Question:** How much energy is lost/gained during the collision? Where does it go/come from? * **Expected Answer:** * If we gain energy, this happens because the mass of the cannonball is too heavy and the approximation that the center of mass remains at the geometric center of the block is violated. Notice that as we move the cannonball closer to the center of mass of the block, the approximation becomes more valid and we begin to lose energy (as we should for an inelastic collision). * If we lose energy, this happens because of the inelastic nature of the collision. The cannonball and block may heat up or deform, sapping some energy. * **Question:** What does the if-else statement do? * **Expected Answer:** The first if tests to see if the cannonball has **NOT** yet collided with the block, and runs the according updates. The else statement handles the updates once the collision has occurred. * **Question:** Draw a graph of the magnitude of the angular momentum of the block vs time before and after the collision. * **Expected Answer:** Should look like a step function. * **Question:** How are the cannonball and block being rotated in the code? Each iteration of the loop, how much are they being rotated? * **Expected Answer:** The rotate function does this. Each iteration of the loop, the objects are rotated by an amount $(L/I)dt = \omega dt=d\theta$. You might push them to consider how this resembles the position update $(p/m)dt=v dt=dr$ ==Common Difficulties:== * Determining the moment of inertia of the ball with respect to the center of the block is challenging. Prompt the students to consider what the location of the ball is with respect to the axis of rotation (center of the block). * Note that your $x$-position of the ball must be non-zero. A zero value gives an error. * Take note of the intentional error in the angular momentum calculation. * There is a possibility to generate a scenario where total energy increases after the collision. Push them to consider if this is possible, and why it happens (the assumption that the center of mass being located at the geometric center of the block is violated). ==Main Points:== * Students should recognize that they need to take advantage of the fact that linear and angular momentum are conserved. * Students should recognize that the collision is inelastic, and thus cannot take advantage of energy conservation. * Students should understanding what quantities are being used (angular momentum, linear momentum) to differentially increment other quantities (rotation, translation). Solution Link: https://www.glowscript.org/#/user/pcubed/folder/solutions/program/ShowdownSolution from __future__ import division from visual import * from physutil import * from visual.graph import * #Window setup scene.center = (0,0,0) scene.range = 5 #Objects block = box(pos=(0,0,0), length=5, width=1, height=1, color=color.green,make_trail=True) ball = sphere(pos=vector(-1,-10,0), radius=0.15, color=color.red,make_trail=True) #Parameters and Initial Conditions mball = 400 mblock = 1700 mtot = mball + mblock vball = vector(0,1600,0) pball = mball*vball ptot = pball Lball = cross(ball.pos,pball) Ltot = Lball #Time and time step t = 0 tf = 1000 dt = 0.00001 #MotionMap/Graph energyGraph = PhysGraph(numPlots=1) #Calculation Loop while t2.5 or abs(ball.pos.z)>0.5: ball.pos = ball.pos + (pball/mball)*dt energyGraph.plot(t,(mag(pball)**2)/(2*mball)) else: ball.pos = ball.pos + (ptot/mtot)*dt block.pos = block.pos + (ptot/mtot)*dt Iball = mball*mag(ball.pos-block.pos)**2 Iblock = 33 Itot = Iball+Iblock ball.rotate(angle=(mag(Ltot)/Itot)*dt, axis=Ltot/mag(Ltot), origin=block.pos) block.rotate(angle=(mag(Ltot)/Itot)*dt, axis=Ltot/mag(Ltot), origin=block.pos) energyGraph.plot(t,(1/2)*Itot*((mag(Ltot)/Itot)**2) + (mag(ptot)**2)/(2*mtot)) t = t + dt