# Sticky Collision

Activity Information

Learning Goals

• Apply principles of momentum conservation in a given system (HS-PS2-2)
• Modify a computational model to represent an inelastic collision

Prior Knowledge Required

• Constant velocity motion
• Momentum
• Vector and scalar quantities

Code Manipulation

• Interpreting existing code
• Interpreting if/else statements
• Using while loops
• Modifying existing code
• Creating new code from mathematical equations

Activity

Handout – Sticky Collision

In this activity you will model a simple linear inelastic collision.

There are 3 objects: 2 carts and a track. The track is positioned slightly below the center of the screen so your view corresponds to the scene above. The “carts” are positioned on opposite ends of the track.

Consider the track to be frictionless. Assign a larger mass to the cart on the left end of the track. Specify initial velocities for each cart. Give the cart on the left end an initial velocity to the right and an initial leftward velocity of the cart on the right end of the track. Make the magnitude of the velocity of the cart on the left end greater.

Your code should produce a simulation of the carts approaching each other at constant but different speeds. Once they collide, they should stick together and move toward the right of the track at a realistic velocity.

Write your condition statements such that the block combination stops at the right end of the track without extending beyond the track.

Code

``````GlowScript 2.7 VPython

#Set up windows
scene = canvas(width=1024, height=768, center=vector(65,-30,0), background=color.white)

track = box(pos=vector(0,-46,0), size=vector(400,20,20), color=color.red, opacity=1.0)
cart1 = box(pos=vector(-190,-31,0), size=vector(20,13,10), color=color.yellow, opacity=1.0)
cart2 = box(pos=vector(190,-31,0), size=vector(20,10,10), color=color.green, opacity=1.0)

c1m = 5
c2m = 3
c1v = vector(10,0,0)
c2v = vector(-6,0,0)
c1p = c1m*c1v
c2p = c2m*c2v
t = 0
dt = 0.05

while t >= 0:
rate(240)
if cart2.pos.x-cart1.pos.x > 20:
cart1.pos = cart1.pos + c1v*dt
cart2.pos = cart2.pos + c2v*dt
t = t + dt
if cart1.pos.x < -190:
break
if cart2.pos.x > 190:
break
else:
cart1.pos = cart1.pos + c1v*dt
cart2.pos = cart2.pos + c2v*dt
t = t + dt
if cart1.pos.x < -190:
break
if cart2.pos.x > 190:
break

``````

Handout

Considering the system to be the two carts, the momentum of the system is conserved, such that:

`Pi = Pf   =>  P1 + P1 = Pf`

Now that we know how the momenta relate to each other, we can use the general momentum equation: P = mv, to rewrite the above equation to find the final velocity of both carts after the collision:

`m1v1 + m2v2 = vf(m1 + m2)  =>  vf = (m1v1 + m2v2)/(m1 + m2)`

The given code already calculates both initial momenta, so the line of code that solves for the velocity after the crash looks like:

``vf = (c1p +c2p)/(c1m+c2m)``

Code

``````GlowScript 2.7 VPython

#Set up windows
scene = canvas(width=1024, height=768, center=vector(65,-30,0), background=color.white)

track = box(pos=vector(0,-46,0), size=vector(400,20,20), color=color.red, opacity=1.0)
cart1 = box(pos=vector(-190,-31,0), size=vector(20,13,10), color=color.yellow, opacity=1.0)
cart2 = box(pos=vector(190,-31,0), size=vector(20,10,10), color=color.green, opacity=1.0)

c1m = 5
c2m = 3
c1v = vector(10,0,0)
c2v = vector(-6,0,0)
c1p = c1m*c1v
c2p = c2m*c2v
vf = (c1p +c2p)/(c1m+c2m)
t = 0
dt = 0.05

while t >= 0:
rate(240)
if cart2.pos.x-cart1.pos.x > 20:
cart1.pos = cart1.pos + c1v*dt
cart2.pos = cart2.pos + c2v*dt
t = t + dt
if cart1.pos.x < -190:
break
if cart2.pos.x > 190:
break
else:
cart1.pos = cart1.pos + vf*dt
cart2.pos = cart2.pos + vf*dt
t = t + dt
if cart1.pos.x < -190:
break
if cart2.pos.x > 190:
break

``````