What is VPython and Where Do I Get It?
VPython is a free, open-source module for the equally free and open source programming language Python. VPython makes it relatively easy to set up 3D scenes and by default permits the viewer to move around and zoom in / out. For information about VPython, visit the VPython homepage. There you will find out why it exists, what it can do, more examples, and how to install it on your computer and use it.
My Simulations
These simulations vary in how good their internal documentation is and how complex they are. In all cases though, it should be instructive to examine the core physics in the code that produces the simulations in addition to using the simulations themselves.
Air Resistance
One Dimensional Motion
One ball
Add air resistance to the basic bounce.py simulation.
air drag on a bouncing ball - vpython sourceMany balls
Let a lot of balls fall and bounce with air resistance.
air drag on bouncing balls - vpython sourceWater drops
I really wanted to think in terms of rain drops rather than balls. So instead of bouncing, I want things to go splat. The splat is, however, utterly artificial and doesn't capture any of the real behavior of a drop of liquid hitting a solid.
air resistance plus going splatSeparation
If you run a few of the last two simulations, you will see things behaving more like soap bubbles than any ball or rain drop I ever saw. That is fixed here.
force drops to separate - vpython sourceDeformation
click for larger image |
Rain drops aren't really spherical. They get flattened by the air resistance. Again, the flattening is a crude approximation rather than a true simulation of the interactive deformation of the drops by the air. Note that the drops become flattened by the air because in the middle of the drop the force from the air is straight upward, but as the air diverts around the drop, the force is no longer perpendicular to the surface. Rain drops are not tear-drop shaped.
deforming drops falling through air - vpython sourceProjectile Motion
click for larger image | click for larger image |
This simulation requires the controls.py and controls.pyc file to be in the same folder as projectile-air.py. This is a slightly modified version of the standard controls. (The controls.pyc file should be automatically generated from controls.py the first time projectile-air.py is run.)
This simulation lets the user make a lot of choices including what form the air resistance takes, the launch angle, and the launch velocity. The simulation is designed to encourage comparison between cases with different kinds of air resistance. Graphs of velocity and acceleration encourage correlation of graph shape with trajectory shape. It is possible to display velocity and acceleration arrows on any of the projectiles.
There is a lot of non-physics in the code for this simulation. Search for the word "physics" in the code to find the few lines that implement air resistance (or lack of it).
The graph windows can be expanded to see more detail.
My thanks to Bruce Sherwood for his help on this project.
projectile motion with air resistance - vpython source modified controls module for this simulationNewton's Cannon
click for larger image |
The basic premise of Newton's cannon is that a cannon at the top of the highest mountain on a spherical Earth is fired horizontally. At the right velocity, the cannon will make one complete (very low!) orbit. One day one of our students came by and asked how to figure out when the cannon ball lands if the velocity is too small. After starting several times to suggest a method of figuring out the answer, I realized a numerical simulation would probably be faster to do than an analytical calculation.
Newton's cannon - vpython sourceCurrent loop in a magnetic field
click for larger image; more images here |
current loop in magnetic field - vpython source You will also need povexport in the same folder as loopTorque.py or in your path (maybe - I've only done the former).