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:
The value of k tells how strong this force can be. You might want to try changing this to see what happens.
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?