Home > Uncategorized > Introduction to collisions

## Introduction to collisions

Here is the code that I showed in class: https://gist.github.com/rhettallain/10657928.  Download it and run it on your own computer.  Let me just point out a few important things.

This is just the set up.  Load the visual module and the graphing module.  The last three lines here set up three different functions to plot.

Here I just make two cars and then set up some constants.  In particular, you want to look at k.  This is the force constant. You will see this below, but I have a repulsive force between the two cars that has the following magnitude:

$F=\frac{k}{r^3}$

The value of k tells how strong this force can be.  You might want to try changing this to see what happens.

This last part uses the momentum principle to model the motion of both carts.  The last three lines make a plot of momentum (x-component) for each cart and the total.

Things to try:

• Is momentum conserved?  How do you know?
• What happens if you make dt smaller or bigger?  Is momentum still conserved?
• What happens if you change the interacting force to some other function?
• Is kinetic energy conserved?  Can you make a plot of KE vs. time?
• What if you change the masses of one or both carts?
• What if both carts are initially moving?
• How would you change this code to make a 2-d (or 3-d) collision?  Would momentum still be conserved?
• Can you think of some way to make an interacting force so that the kinetic energy is not conserved in the collision?