V-Pythonfor computer modeling

COMPILATION: V-Pythonfor computer modeling

Date: Mon, 25 Apr 2005

From: Matt Greenwolfe <>

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. a brief description from the VPython website.

Students in introductory physics courses have been using VPython to docomputer modeling. VPython lets students focus on the physicscomputations without having to write explicit graphics statements yetobtain 3D visualization. Students can do true vector computations, whichimproves their understanding of the utility of vectors and vectornotation.

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

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

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

their interactions (elastic collisions with each other and the boxwalls) and determine their motionusing conservation of momentum,energy, dynamics and kinematics. They can then compute averagequantities 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 <>

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

Another way I use it is when we talk about gravitation, I have the studentswrite a program to calculate a minimal energy orbit for a spacecrafttaking off from earth and landing on the moon. The students have to takeinto account the gravitational effects of the earth, moon and sun. Vpythonmakes it very easy to have a visual representation of the orbit.

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

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

------

From: Gregg Swackhamer

VPython is pretty easy to learn if you have ever written even a simpleprogram. By learn, I do not mean that I am a proficient programmer. I amnot. 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 controlthe 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 <>

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 <>

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

Use something like:

scene.autoscale=0

scene.range=10

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

1