COMPILATION: V-Python for computer modeling


Date: Mon, 25 Apr 2005

From: Matt Greenwolfe <matt_greenwolfe@CARYACADEMY.ORG>

Subject: web links - VPython


Jane Jackson wrote:

>Last week I added these web links of interest to modelers. If an important web link isn't there, please reply.


I would suggest adding a link to VPython. Here's a brief description from the VPython website.

Students in introductory physics courses have been using VPython to do computer modeling. VPython lets students focus on the physics computations without having to write explicit graphics statements yet obtain 3D visualization. Students can do true vector computations, which improves their understanding of the utility of vectors and vector notation.


I've found this to be very useful and compatible with a modeling approach.  It allows students to build models of complex systems by using the basic laws of mechanics.  Then with no extra work, they can see a 3-D simulation of their own model.  The students are actually using the computer as a modeling tool, rather than just interacting with a model created by someone else. 

I've used this with pendulums, including the chaotic double pendulum, damped pendulum, and forced-damped pendulum, orbital motion, including parabolic and hyperbolic orbits and a mission to mars, and collisions and gas laws, as well as other areas.

The structure of the VPython program makes them think in a natural way about the basics of a model as spelled out in Hestenes original papers on modeling physics.  For example, to build a model of a gas, students must specify the properties of objects (solid spheres in a box) specify

their interactions (elastic collisions with each other and the box walls) and determine their motion using conservation of momentum, energy, dynamics and kinematics.  They can then compute average quantities such as the average force on the walls.

Is anyone else using VPython?  If so, what are you doing with it?



Date: Tue, 26 Apr 2005 1

From: Martin Mason <mmason@MTSAC.EDU>

I would like to second Matt's recommendation of Vpython. Vpython is a great way for students to create models of physical systems.  They also seem to internalize [the fact] that, by changing the assumptions of their model, the behavior of the physical system changes.  Yesterday I had the students work through a tutorial where they start with a constant velocity model of a ball in a box and then change the model to include constant acceleration, then add more and more levels of complexity and see how the behavior of the ball reflects these changes.

Another way I use it is when we talk about gravitation, I have the students write a program to calculate a minimal energy orbit for a spacecraft taking off from earth and landing on the moon.  The students have to take into account the gravitational effects of the earth, moon and sun. Vpython makes it very easy to have a visual representation of the orbit.

Another benefit of vpython is that students can tackle problems that don't lend themselves to analytic solutions.  If they pursue science, much of their problem solving may take the form of writing programs to arrive at numerical solutions.  I can get students (pre-engineering) up to speed in programming vpython in 3 hours even if they have never taken programming before. I used to teach a computational physics course, and using vpython lets me get a taste of that into my intro courses.

Bruce Sherwood and Ruth Chabay have lots of neat ideas for vpython projects in their matter and interactions texts.


From: Gregg Swackhamer

VPython is pretty easy to learn if you have ever written even a simple program. By learn, I do not mean that I am a proficient programmer. I am not. But I can write a VPython script that does what I want.

            Here is what I use VPython for in first year physics.  

Sun-Earth system to account for seasons (by L. Urbano)

interactive one-dimensional motion maps with -, 0, + initial velocities

interactive 2-D motion (uniform circular motion)

interactive Millikan experiment (with some simplifications)

visualization of electric fields

image formation by lenses and mirrors

            In AP:

For F=qv x B interactive mass spectrometer for alpha decay (you control the field strength)

beta-ray spectrometer (again, you control field strength)

visualizing E fields and B fields

visualizing induced B fields


Date:    Fri, 29 Apr 2005

From:    Aaron Titus <titus@MAILAPS.ORG>

I've posted various vpython scripts at

My favorites are the ferris wheel and the 09 programs.


Date:    Thu, 19 May 2005

From:    Jason Lonon

I downloaded the files and installed them, since we had discussed VPython last summer during our workshop. I liked the programming notation and functionality, but I was not impressed with the visual result on the screen. We created a simple object and gave it only one component of velocity, but when the simulation ran, the ball actually appeared to move in a radial manner. Starting at the left of the screen small, it moved constant at first, but increased in size, and then started to slow down and get smaller. The students and I thought that the spatial dimensions might not be those that we were used to, so we tried combinations of components - but could never get the ball to actually move at constant velocity straight across the screen. There did not seem to be anything in the manuals about this behavior, so we gave up.


Date:    Fri, 20 May 2005

From:    Aaron Titus <titus@MAILAPS.ORG>

The default behavior of VPython is to autoscale. That is, the"camera" zooms as needed in order to fill up the screen. Though this is helpful, perhaps, for a prototype, it is not useful for physics programs, in my opinion. As a result, we usually turn it off and then set the dimensions of the screen.

Use something like:



This turns autoscaling off (0 is off and 1 is on). It then sets the dimension of the screen (measured from center to edge as I recall) as 10 units.