VPython in Geoscience Education
From GeoMod
Title: Using VPython in Geoscience Education
The purpose of this page is to explain why VPython is a good choice for programming applications for Geoscience Education and for teaching computer modeling in the Earth Sciences.
I currently use VPython for two applications in the Geoscience Education.
- VPython models in introductory geoscience classes
- Using the VPython models for demonstrations in large lectures and smaller classes.
- Teaching introductory numerical methods using VPython
- The course called "Introduction to modeling in the Earth Sciences" uses VPython for its 3d visualization capabilities. I have created a new module (raster.py) to aid with geospatial problems.
Contents |
Introduction
The VPython module of the Python programming language provides an easily learned, object-oriented programming language that produces interactive, 3d visualizations. It was originally designed as an aid for undergraduate physics classes (Chabay and Sherwood, 2006). The physics textbooks "Matter and Interaction" (Chabay and Sherwood, 2007a,b) are designed around VPython programs that demonstrate mechanics, thermal physics, electricity and magnetism.
This paper discusses the use of VPython models in introductory Earth Science classes and in teaching numerical methods in upper level classes. In introductory undergraduate classes VPython models have been used by instructors in demonstrations in large lecture sections (eg. Urbano and Houghton, 2006) and by students for individual observation in smaller laboratory sections. For teaching numerical methods, VPython provides students the immediate gratification of 3d visualization and a free, portable interpreter that aids software programming.
The models described in this paper, as well as modules (classes) developed to facilitate the creation of distributed numerical models in the numerical methods class have been made available on the website http://lurbano-5.memphis.edu/GeoMod/.
What is VPython
VPython (http://www.vpython.org) is a high level language module created for the python programming language (http://www.python.org) that allows the creation of primitive 3D objects such as lines, spheres and boxes. These simple primitives can be easily combined to create complex, interactive and dynamic three dimensional models. VPython was originally developed for introductory undergraduate physics classes (Scherer et al., 2000) and undergraduate physics instruction remains its core purpose. This language however offers substantial advantages for instruction in the geosciences.
The python programming language is a free, open-source language with a large user base that includes programmers who create script extensions for ArcGIS. It is also a high-level, cross-platform (Windows, Linux and Mac) language with significant numerical capabilities into which low-level, computational efficient code can be incorporated. Without these additions, the high level of the language limits its application to research problems, however, this does not pose a significant problem for educational applications.
Advantages of VPython
- 3d
- Interactivity
- Dynamic
- Free, and open-source
- VPython is better than video. VPython programs being text scripts are trivially small compared to movie files so they are easy to transfer over the internet.
VPython models in introductory Earth Science classes
The models used in the introductory classes came from one of three sources. Some programs were adapted from the Chabay and Sherwood (2007a) text (eg. nebula collapse model). Others were created by the author to explain specific concepts, such as the coriolis effect (Urbano and Houghton, 2006), that were proving difficult to explain in large lecture sections. The third source of models were the term projects of students in the graduate level, numerical modeling class "Introduction to Modeling in the Earth Sciences" also described in this paper. These models were created as open-source projects and adapted for use by other faculty and students for undergraduate labs.
Principles of VPython model design for use in introductory classes
What factors make for a good animations
Tversky et al., (2002) describe two principles for good diagrams, and explain that animations tend to violate both:
- Congruity: structure and content of visualization should match structure and content of desired representation; people comprehend continuous events as a sequence of discrete steps.
- Apprehension: structure and content of visualization should be readily perceived and comprehended; animations are frequently too complex and too fast.
Animations that do succeed tend to use interactivity to overcome the congruity and apprehension issues. Tversky et al., (2002) suggest that users' ability to control the view (starting, stopping, replaying, zooming and changing the speed) allows for selective focusing, reviewing and reanalysis of the information in the model.
A taxonomy for VPython visualizations
This general taxonomy is not specific to VPython models, but is a useful method for describing these models in the context of VPython's capabilities.
- trivial models such as the H and He atom models are dynamic 3d models but include no interactivity.
- simple models, such as the water wave model which include some interactivity but are not particularly complex.
- sophisticated models like the atmospheric stability model and the solar system model that are interactive and allow for the demonstration of complex interactions. The freedom derived from the complex interaction allowed by these models often make it difficult for students to apprehend the pertinent relationships. As a consequence, these models are best used by instructors or in carefully guided exercises.
- fully realized models like the coriolis model and the nebula model1 that are sophisticated and fully interactive but can easily be operated by students. These models also include elements that take advantage of VPython's 3d capabilities to capture student interest. The coriolis model for example, allows users to attempt to hit a target moving on a rotating disk and see the path of the projectile from the perspective of the projectile.
This taxonomy does not represent a simple increase in complexity. The sophisticated models tend to be significantly more complex than the fully realized models, but their very complexity make them less useful for student interaction. The fully realized models however tend not to have the flexibility or full capability of the sophisticated models. Irrespective of the type of model, the VPython code is available for improvement.
Advantages of VPython models
Design to take advantage of the key VPython advantages:
- Coolness factor: Something to make even today's jaded students say "Wow". Radical changes in perspective can do that, like the orbit of a planet around the sun from a slightly skewed view of the planet.
- Game based: It is suprising how much students get into hitting a simple target on the coriolis model.
Current models
As this is an ongoing, open-source project, the models are constantly being added, improved and adapted. The models in varying stages of development can be found on the GeoMod website, but the ones that have been adapted for undergraduate labs and lectures are posted on the main page. The models can be categorized by their closeness to the ideal models envisioned in the design principles.
Fully realized models
Even though these are called fully realized there are many potential improvements and additions that could substantially improve the models.
- Nebula Collapse: This is a model of the gravitational collapse of a number of particles in space. Particles start with semi-randomly assigned initial positions and masses and their motion is governed by their initial velocity and Newtonian attraction. When particles collide they coalesce and eventually, a central star forms while a few planets remain in orbit. Because the final orbits do not lie on a single plane this model can be used to explain both the advantages and limitations of numerical modeling. This model was originally created by Chabay and Sherwood (2007a) but has been adapted so that selected planets leave trails that mark their orbits and so that the point of view (camera) can follow the motion of the planets. The tracing of orbits demonstrates orbital variability and the interaction of the planets. The ability to follow a planet's point of view was put in to incite student interest, and magnifies the changes in planetary velocity in different parts of the orbit.
- Seasons: Designed to illustrate the effect of axial tilt on hemispheric insolation, this conceptual model shows the Earth as a blue sphere with a few lines of longitude and latitude marked and the Sun (not to scale). There are two dots located on the surface of the planet that can be moved along lines of longitude. The user controls the rotation rate of the planet and its orbital velocity. A typical demonstration with this model would start with the Earth slowly rotating at the northern hemisphere's summer solstice. The dots on the surface change color as they move from the day to night side of the planet so they can be used to demonstrate the relationship between day length and longitude. The scene can then be tilted to view from a direction perpendicular to the plane of the ecliptic, which is useful for showing the 24 hour days above the arctic circle. The planet can then be orbited to demonstrate the equinoxes and the other solstices. With the wide variety of controls, we have found that this model works best when demonstrated by the instructor.
- Coriolis Effect: Like a number of 2-D Javascript applications available on the web, this model allows the user to fire a ball across a rotating disk, and marks its position relative to the disk and the general co-ordinate system. In this VPython model the user can also control the velocity of the ball, the angular velocity of the disk and the friction between the ball and the disk. This model is particularly useful in illustrating the effect of coriolis on atmospheric motion where these three parameters interact. A target can be placed on the disk to offer an objective of shooting the ball and to illustrate angular velocity. The model also permits the user to view the scene from the perspective of the ball, which has proven to be an extremely popular feature for all ages. This model and its application in a large lecture is described in Urbano and Houghton (2006).
Partially realized models
- Gully erosion: Originally, created by Ms. Ekta Amar as her project for the class "Introduction to Modeling in the Earth Sciences", this surface erosion model solves the mass conservation equations of Istanbulluoglu et al. (2003) and captures many aspects of gully erosion, including kinematic erosional waves. It has been adapted to use in undergraduate labs with the addition of a button that allows the user to step through each timestep, and another button to reset the model. Two relatively simple additions would aid in the fuller realization of this model. First, allowing a user to drop a particle on the grid and watch it flow downward would add another level of interaction. Allowing the user to follow the point of view of the particle would add some visual interest and perhaps add another layer of understanding of the dynamics of the physical processes. Secondly, the model can import existing raster data-sets such as exported from ArcGIS. This would allow students to simulate the future erosion of familiar landscapes.
- Ellipticity: This is a simple model showing an elliptical orbit of a planet around a Sun where the ellipticity can be changed between 0 and 1. The planet's velocity changes with its position in the orbit in accord with Newtonian physics. This model is used in explanations of Milankovitch forcing. This is an essentially 2-D illustration, but the ability to tilt the scene to see the orbit from parallel to the plane of the ecliptic adds veracity.
- Solar system: The planets in the solar system and Pluto are shown at their proper relative orbital speeds and in their proper orbits. The key benefit of this scene is the ability to tilt the scene to view the ecliptic plane, particularly with Pluto's deviation. The ability to zoom into and out allow viewing the relative speeds of the orbits, especially of the inner planets.
- Atmospheric Stablility: This purely 2-D model is used to demonstrate the effect of humidity and changing atmospheric conditions on atmospheric stability. It displays a graph with lines for the saturated and unsaturated lapse rates and the environmental lapse rate (ELR). The user can move these lines and adjust the slope of the ELR. A separate window shows how the temperature inside and out of a theoretical parcel of air would change with changes in the graph. The parcel of air can expand or contract with elevation change and its color changes with temperature. This model can be used to illustrate, for example, how atmospheric instability develops over the course of a day to produce convective thunderstorms. This model does not use VPython's 3-D properties and similar graphics have been created on for textbook animations (eg. Ref??). As a result, its greatest utility is as a demonstration of VPython's capabilities.
- Phase changes: This very simple model shows a block of ice in a cylindrical glass on a hot plate/cold sink. The user can adjust the heat added to the glass and observe the relative rates of change as the ice melts/freezes or water evaporates/condenses. The simplicity of this model is intended to allow students to develop observational skills through personal interaction. The three-dimensionality of this model adds veracity but the simple shapes and uniform colors permitted by VPython result in a cartoon-like model. Recent improvements in the VPython code will allow for greater complexity of texture and transparency in the models, however, the ability to export VPython scenes to POV-Ray a ray-tracing software for generating photo-realistic images, allows the production of much more realistic images and movies from the VPython models.
Trivial Models
Assessment
Developing a course in Numerical Methods using VPython
Other approaches to numerical methods classes
Numerical methods are invading all aspects of Geosciences, and numerous approaches using a variety of software and programing languages have been developed to teach them. Menking (2006) and Brice (2001) describe the use of the iconographic box modeling software STELLA to introduce numerical techniques. Box models, where modelers define the mathematical relationships between a small number of discrete "boxes", accurately and intuitivly describe the fundamental precepts behind the numerical methods used to solve problems the many geoscience problems governed by partial differntial equations; groundwater flow, atmospheric circulation and plastic deformation are but a few examples. Menking, 2006 successfully used box modeling execises as a prelude to introductory programming using the programming language FORTRAN, which is still in common use in many geoscience models.
With rapid increases in computer speed and memory, the importance of the speed of the low level computing languages like FORTRAN is receeding, particularly for educational applications. Higher level languages can also be programmed more quickly. Anderson (2003) reported the successful use of the programming language MATLAB to introduce modeling.
A key advantage of the STELLA and MATLAB approaches is that the built in graphical capabilities makes model visualization extremely efficient. Movie generation was found to be an excellent motivator for students (Anderson, 2003). The primary disadvantage of these methods that these software packages are commercial. This limits the availability of underlying software as well as restricts the distribution of models and exercises created with them.
Finally, Becker and Schuetz (2003) use the Virtual Reality Modeling Language (VRML) to allow students to observe solutions from numerical models in an introductory hydrogeology class. Although students do not run the numerical model, the USGS code MODFLOW in this case (McDonald and Harbaugh, 1988) they can acquire the experience of numerical modeling without the fustrations of learning and running the software.
Modeling with MS Excel
I have developed a modeling class called "Introduction to Modeling in the Earth Sciences." This class was originally taught using MicroSoft Excel as the primary programming software. Although also a commercial program, the ubiquity of MicroSoft Excel makes it an extremely useful language for introductory modeling classes. Excel provides an excellent environment for creating introductory models. With Excel's spreadsheet functions and built-in itterative solver, steady-state and transient box type models (eg. point source/sink models) and steady-state distributed models (eg. finite difference models) are easily and intuitively produced.
In addition to the spreadsheet capabilities, Visual Basic for Excel provides a full programming language tied directly to spreadsheets and charts for display, although graphical capabilities are not as sophisticated as MATLAB. These permit the production of sophisticated numerical models. Excel models are used in a wide range of hydrogeology and engineering educational applications.
Excel does have some significant limitations however. One set of limitations arize due to the restrictions imposed by 2D spreadsheets. Spreadsheets are also currently limited to only 256 columns. Creating Visual Basic for Excel also imposes the substantial memory overhead of the Excel software, which quickly becomes an issue for larger distributed models.
Intro to modeling class
- I have created a number of 2d-classes that make it easier to address geospatial problems.
- I have taught a class (currently at the graduate level but the only pre-requisite is a class in computer programming) using VPython.
- Significant success.
Assessment
- Note to self: create survey for students of that class to assess the effectiveness and utility of the course.
References
Anderson, R.S., 2003. Introducing Earth Sciences Students to Modeling Using MATLAB Exercises, Eos Trans. AGU, 84(46), Fall Meet. Suppl., Abstract ED31C-1175, 2003. (Abstract)
Brice, D. M., 2001. Using STELLA models to explore the dynamics of Earth systems; experimenting with Earth's climate system using a simple computer model, Journal of Geoscience Education, v. 49, n. 2, p. 170-181. (Abstract)
Becker, M. W. and Schuetz, J. W., 2003. An introduction to ground-water modeling using virtual reality modeling language (VRML). Journal of Geoscience Education, v. 51, n. 5, p. 506-511. (Abstract)
Chabay, R. and Sherwood, B., 2006. Restructuring the introductory electricity and magnetism course. American Journal of Physics, v. 74, n. 4, p. 329-336.
Chabay, R., and Sherwood, B., 2007a. Matter and Interactions I: Modern Mechanics, 2nd Edition, John Wiley & Sons, 488 p. (Link)
Chabay, R., and Sherwood, B., 2007b. Matter and Interactions II: Electric and Magnetic Interactions, 2nd Edition, John Wiley & Sons, 480 p. (Link)
Istanbulluoglu E., Tarboton D., Pack R., 2003. A sediment transport model for incision of gullies on steep topography. Water Resources Research, v. 39, n. 4. p. 1103.
Menking, K. M., 2006. Creation of a Computer Modeling Course for Undergraduate Earth Science Students, Journal of Geoscience Education, v. 54, n. 4, pg. (Abstract)
Scherer et al., 2000: Scherer, D., Dubois, P., & Sherwood, B. (2000). VPython: 3D Interactive Scientific Graphics for Students, Computing in Science and Engineering, Sept./Oct. 2000, 82-88.
Urbano, L., and Houghton, J., 2006. An Interactive Computer Model for Coriolis Demonstrations, Journal of Geoscience Education, 54, no. 1 pg. 54-60.

