VPython applications for Teaching Physics

Content from the original site https://web.archive.org/web/2001*/http://physics.syr.edu/~salgado/software/vpython/ is slowly being copied here.
Some links may be broken... but they will be fixed soon.

current academic homepage: Rob Salgado
up to: visualrelativity.com

last updated 10/31/2015 ( prev update 9/27/2011 )
created Dec 8, 2001 (at Syracuse)

Tinkering...

Rob Salgado's GlowScript programs
More about GlowScript
For Browsers that support GlowScript, view the GlowScript documentation

Soon

  • VPython-with-the-Wiimote files mentioned at AAPT09Sum-AnnArbor.
  • EXAMPLES ARE NOW AVAILABLE
  • Some reorganization of this page.
  • Some reogranization of URLs to other websites. (If you have a site to suggest, send me an email.)

What's Was New

  • (07/16/2008) - accelerometer example posted
    (06/20/2008) - IR-headtracking example posted
    VPython with real-time data - [Rob Salgado and Tav Hawkins]

    with the Wiimote, the Go!Motion, NeatTools-and-TNG-3B, ...

  • Most of these programs have been tested on Python 2.3.4 / VPython-Py2.3.4-2003-10-05b.exe I am trying to gradually update them to work with the newer versions. If you have made any upgrades, please share them with me.

How to run these Python programs

These python programs (pythlets?) are written in
Python with the "visual" module VPython, which provides real-time interactive visualization in 3D.

You can download the current version of VPython here and read about its development at the visualpython-users mailing list.

The older Python-2.4/VPython-3.2.9 version is here (local copy: python-2.4.1.msi and VPython-Win-Py2.4-3.2.9.exe).

Here is a local copy of the even older version (local copy: Python-2.3.4.exe and VPython-Py2.3.4-2003-10-05b.exe).



Waves

   wave_superposition.py tested with VPython23-2003-10-05

   doppler-wavefront.py tested with with Python-2.3.4.exe and VPython-2003-10-15.exe

Kinematics

   2D-kinematics-with-vectors.py tested with VPython23-2003-10-04
   2D-kinematics-with-vectors-circular.py tested with VPython23-2003-10-04
   2D-kinematics-with-vectors-circular-polar.py tested with VPython23-2003-10-04

1D-kinematics.py tested with VPython23-2003-09-04 1D-kinematics-with-vectors.py tested with VPython23-2003-10-04 1D-kinematics-with-vectors-alt.py tested with VPython23-2003-10-04


Electromagnetism


   EFieldBuilder-09990.py (v0.9990) tested with VPython-2003-10-05.exe
   EFieldBuilder-0997-22.py (v0.9972) requires VPython-2001-12-31.exe
   EFieldBuilder-0997.py (v0.997) requires VPython-2001-10-31.exe
   EFieldBuilder-0996.py requires VPython-2001-10-31.exe	
   EFieldBuilder-099.py	

   Maxwell-Gauss-Coulomb_v275.py tested with Python 2.3/VPython-2003-10-05.exe 
   Maxwell-Gauss-Magnetic_v275.py tested with Python 2.3/VPython-2003-10-05.exe 
   

   Maxwell-Ampere.py (v2.52) tested with VPython-2001-10-31.exe
   Maxwell-Ampere_v275.py tested with Python 2.3/VPython-2003-10-05.exe (includes change in color scheme) 
   Maxwell-Ampere_v276.py tested with Python 2.4/VPython-3.2.9 (includes change in color scheme) 


Maxwell-Faraday.py (v2.52) tested with VPython-2001-10-31.exe Maxwell-Faraday_v275.py tested with Python 2.3/VPython-2003-10-05.exe (includes change in color scheme) Maxwell-Faraday_v276.py tested with Python 2.4/VPython-3.2.9 (includes change in color scheme)

   EMWave-020110.py (v0.5) tested with VPython-2001-10-31.exe
   EMWave-030216.py (v0.51) tested with VPython-2001-10-31.exe
   EMWave.py (v1.00) tested with VPython-2003-10-05.exe
   EMWave-Maxwell.py (v2.51) tested with VPython-2003-10-05.exe
   
   EMWave-Maxwell_v275.py tested with Python 2.3/VPython-2003-10-05.exe (includes change in color scheme)
   EMWave-Maxwell_v277.py tested with Python 2.5/VPython-3.2.11 (Thanks to Martin Mason for changes needed for Python 2.4+.)
   EMWave-Maxwell_v280.py tested with Python 2.6/VPython-3.2.11 (fixed bug with scene.ambient [2015-10-31])


Under development: VPython projects (led by Rob)



Relativity

Visualizing Proper Time in Special Relativity




Tensor Calculus and Differential Forms

(under development)
This demonstrates the addition of two covectors (two "1-forms") via the "co-parallelogram rule".

Aa + Ba = Ca


(2008) VPython with Real-Time Data [with Tav Hawkins]
  • (06/20/2008) VPython with real-time Wiimote data (head tracking with the IR-camera)

    headtrack-Wiimotelib121-PY24.py
    tested with Python 2.4/VPython 3.2.9
    
    The inspiration for this project came from the efforts of Johnny Chung Lee - Projects - Wii.

    In order to read in the real-time data from the the Wiimote, we use the procedure presented by Nishio Hirokazu, which uses Brian Peek's (Windows-only) WiimoteLib v1.2.1 [a library for using a Nintendo Wii Remote (Wiimote) from .NET.] described in "Code4Fun - Managed Library for Nintendo's Wiimote (Brian Peek)". To use .NET with Python, we used Brian Lloyd's Python for .NET.

    Ideally, we would have liked to use the latest versions of the various software packages [which should be possible]. However, for now, the combination of versions that worked for us [with our program] is:

    I'm sure there is a platform-independent solution in which Python communicates directly with Bluetooth. Of course, one now needs to know details of the protocol for talking with the Wiimote.

    Note: This was just thrown together as a proof of concept. The code isn't the prettiest. The tracking and the visualization could certainly be improved.

    Some Hardware details: I bought two LED-flashlights (less than $5 each) and replaced the LEDs with IR-LEDs from DealExtreme. I mounted the flashlights onto a pair of safety goggles. (The first version is pictured here.) The Wiimote is sitting on top of my monitor, pointing toward me. [Note, I only use the Wiimote. I don't have a Wii console.]

    My current version uses IR-LEDs from Radio Shack [which seem to have a better viewing angle] and two MAGLITE Solitaire flashlights [found at Walmart] which feature replaceable LEDs. So, no soldering is needed! However, since my standard-size LEDs were too big, I had to leave off the moveable mirror/cover used to adjust the beam.

    If you don't have these IR parts available, you can try using a pair of standard (IR-based) remote controls. By the way, it's helpful to use your typical webcam or cameraphone to see the IR light to check that the LEDs are hooked-up correctly.

  • NEW! (07/15/2008) VPython with real-time Wiimote data (3-axis accelerometer)

    accelerometer-Wiimotelib121-PY24.py
    tested with Python 2.4/VPython 3.2.9
    

    After pairing your Wiimote with your computer's Bluetooth radio, your Wiimote's three-axis accelerometer readings are represented by an arrow.

    (Think of the accelerometer as "a small sphere suspended by identical springs attached to the corners of a cube".)

    When your Wiimote is sitting normally upright on your desk, it will read a_z=1. (The small sphere is displaced downwards, and the net force on the sphere due to the springs is upward.)

    When your Wiimote is in freefall (and not rotating), it will read zero. To show this, gently toss (without rotation) your Wiimote to someone. When the accelerometer value is small enough, the background color of the scene changes to white (since the corresponding small arrow is hard to see).

  • VPython with real-time Vernier Go!Motion data (ultrasonic ranger)

    (soon)

  • VPython with real-time data with NeatTools and Mindtel TNG-3B

    (soon)

VPython with the Wiimote

(based on our presentation at AAPT09Sum-AnnArbor)

(more information will be added to this section)

This is an update of our earlier version [for Python 2.4 / VPython 3.2.9 / WiimoteLib 1.2.1 / Python for .NET 1.0 ] from above.

For Windows XP and Vista... (checked with XP SP3 and Vista64)

[more to come!]

VPython applications (up)
Programming Notes
Using Python 2.3

Here's a registration-file for Windows 2000 and Windows XP that will fix that problem with the IDLE editor closing completely when terminating an animation you are working on. Python-File-new.reg It assumes that you installed Python in the C:\ drive. If so, you may just "Open" it. Otherwise, download [Right-click->Save Link to...] the appropriate pair to your desktop, then after reading the .reg files and making any desired changes, merge with your registry. Then, "Merge" it by double-clicking on it.

Python-File-new.reg

If you mess up, you can try to clean things up in Explorer via Tools->FolderOptions->FileTypes...->PY Python File->Advanced
..or else use regedit.
Use at your own risk! (Backup your registry before merging!)

Using Python 2.3 and Python 2.4

These registry hacks to allowed me to select which VPython version is used to execute a .py file. They may work for you.
Use at your own risk! (Backup your registry before merging!)
Download [Right-click->Save Link to...] the appropriate pair to your desktop, then after reading the .reg files and making any desired changes, merge with your registry.

My Python installations are on the F:\ drive:

Py23_HLM_driveF.reg - Py24_HLM_driveF.reg

If your installations are on the C:\ drive, use:

Py23_HLM_driveC.reg - Py24_HLM_driveC.reg

If you mess up, you can try to clean things up in Explorer via Tools->FolderOptions->FileTypes...->PY Python File->Advanced
..or else use regedit.
Use at your own risk! (Backup your registry before merging!)

This program demonstrates a subtlety in the copyobjects() function on http://www.vpython.org/webdoc/visual/options.html
copyobjects-subtlety.py tested with VPython23-2003-09-18

Working example of an improved copyobjects() and a new updatecopyobjects().
copyobjects-example.py tested with VPython23-2003-09-18


related sites:

VRML Gallery of Electromagnetism
The Light Cone

other VPython sites I have found


Google search for "from visual import"
Bing search for "from visual import"
Yahoo search for "from visual import"

VPython

VPython
Python Programming Language -- Official Website

recently added (to be sorted into the headings below)

Altankhuu Bayarsaikhan's Visual Python demos

Resources

Rob Salgado (Syracuse)
VPython projects at Dillard University (Salgado)
/~border/phys1905f02/
Matter & Interactions (Ruth Chabay and Bruce Sherwood, NCSU)
Matter & Interactions (Ruth Chabay and Bruce Sherwood, NCSU) [Wiley]
Vpython - AIMSWiki
VPython: 3D Interactive Scientific Graphics for Students (CISE)
Python Notes

Python Programming

Python_tutorial_uab.pdf
uselessPython
instantPython
Non-Programmers Tutorial For Python
Learning to program
Dive into Python
Python DevCenter
ASPN Cookbook
FAQts
Beazley's Python Slides (javascripted)
Python Tutorials
Python Short Course
Numerical Python
Numeric Python Tutorial
Minimal Python for Scientific Computing
Handbook of the Physics Computing Course (Python language)
Handbook of the Physics Computing Course (Python language)
An Incremental Introduction to Python (Noack) - large pdf
QuickRef
PyOpenGL
PythonApocrypha
Python Patterns - An Optimization Anecdote
Teaching with Python
Python Performance Tips
many Python links
pygsear ~~: Pygame Framework and Examples
PythonD 32bit Python for DOS and Windows
Explorer's Post 631 Learning Ideas
Python Eggs
Jython3D : Python and Java 3D
Movable Python - The Portable Programming Environment

Computational

Computational Biophysics (Drexel)
Computational Physics and the Open Source Physics Project (Gould, Clark U)
PHY 307/607 Codes
Konrad Hinsen's Python Page
Programming for Physical Sciences (Physics, Computer, Computing)
ScientificPython (Konrad Hinsen)
Tutorial in Computational Science using Visual Python (ANU)
Simulating a Gas (ANU)
Using Visual Python to Simulate a Bouncing Ball (ANU)
Introducci