Computational Physics With Python: Rubin H. Landau, Cristian C. Bordeianu Manuel J. Paez
Computational Physics With Python: Rubin H. Landau, Cristian C. Bordeianu Manuel J. Paez
Computational Physics With Python: Rubin H. Landau, Cristian C. Bordeianu Manuel J. Paez
Abstract
A coherent set of material for upper-division university education in computational
physics/science has been developed at Oregon State University, USA. It contains an
introductory course in scientific computing, a course in Computational Physics, and
a coordinated collection of multimedia interactive animations which enhance the
book and the courses. Computational Physics programs using Python programming
language are presented and displayed. It is proposed that presentation using Python
is a more effective and efficient way to teach physics than the traditional one.
3 What to teach
In Figure 4 we present a concept map for our Computational Physics course and text
(Landau et al, 2008). After two years in administrative processing, in October 2001 the
Oregon State Board of Higher Education approved a Bachelor degree in Computational
Physics (Landau, 2004). The first students entered in fall 2002, the first graduate left in
June 2003, and 3-5 students typically graduate each year. Although these numbers are
small, the classes are well attended by physics majors, graduate students, and engineering
students. A sample of the Computational Physics curriculum is given in Table 1. It is an
example of how a complete package of computation classes can be fit into a four-year
curriculum that is still strong in its mother discipline.
This curriculum has been built up course by course since 1989 as we proposed,
developed, taught, and modified new courses. The computer classes (bold) are seen to be
116 University of Bucharest and Gh. Asachi Tehnical University of Iasi
distributed throughout all years of study. In total, the curriculum is a mix of existing
applied math and CS classes, with the new computation classes acting as the glue that
holds it together.
There is another way to answer the questions What to teach? and How to teach it?
That way is to provide computation-based textbooks that help define which topics
constitute proper computational education, and provide a coherent presentation of the
subject. The OSU Computational Physics Education group has been trying to do that for
the last 15 years. Lists of more than 50 texts and other resources are to be found in a
recent resource letter (Landau, 2008). Although most of those resources and most of this
paper focus on more specialized computational topics, there is still very much an open
question on what and how to teach computation to beginning college science students,
and who should be doing the teaching. Our attempt takes the form of an Introductory
Scientific Computing course designed to provide first and second year students with the
computational tools needed throughout their undergraduate careers, and its associated
text, A First Course in Scientific Computing (Landau, 2005). In recognition of the
widespread disagreement over which computing tools lower division college students
should learn, the paper text covers Maple and Java, while the accompanying CD
contained essentially identical texts in Mathematica and Fortran90, as well as the
associated notebooks, worksheets, programs, and data sets. The combination of A First
Course in Scientific Computing and A Survey of Computational Physics (Landau et al,
2008) pave a continuous computational path throughout the undergraduate curriculum.
Figure 4. Concept map. Shows hardware and software components from computer
science, applied mathematics algorithms, and physics applications.
The 4th International Conference on Virtual Learning ICVL 2009 117
5 Using Python
Python is a popular programming language used for both standalone programs and
scripting applications in a wide variety of domains. It is free, portable, powerful, and
remarkably easy to use.
One of the reasons why we decided to migrate to Python in our CP books and courses
is that it provides a really nice balance between the practical and the conceptual (Downey
et al, 2008). Since Python is interpreted, beginners can pick up the language and start
doing neat things almost immediately without getting lost in the problems of compilation
and linking. Furthermore, Python comes with a large library of modules that can be used
to do all sorts of tasks ranging from web-programming to graphics. Having such a
practical focus is a great way to engage students and it allows them to complete
significant projects. However, Python can also serve as an excellent foundation for
introducing important computer science concepts. Since Python fully supports procedures
and classes, students can be gradually introduced to topics such as procedural abstraction,
data structures, and object-oriented programming.
Another reason is the fact that Python is freely available for download. Versions are
available for almost every operating system, including UNIX, Windows, Macintosh, and
Java. In addition, the Python website includes links to documentation, how-to guides, and
a wide assortment of third-party software.
The tools we have used in preparing the visualizations are:
Matplotlib: Matplotlib is a very powerful library of plotting functions callable from
within Python that is capable of producing publication quality figures in a number of
output formats. It is, by design, similar to the plotting packages with Matlab, and is made
118 University of Bucharest and Gh. Asachi Tehnical University of Iasi
more powerful by its use of the numpy package for numerical work. In addition to 2-D
plots, Matplotlib can also create interactive, 3-D visualizations of data.
Visual (VPython): The programming language Python is so often employed with
the Visual graphics module and the IDLE interface that the combination is often referred
to as Vpython. Much of the use of the Visual extension has been to create 3-D
demonstrations and animations for education, which are surprisingly easy to make and
useful.
Tkinter: Python also contains a graphical user interface (GUI) programming module
called Tkinter or Tk.
6 Conclusions
We think that only time will judge the viability of computational physics programs such
as ours. However they do appear to attract new students and to provide them with broad
preparation for future career choices. Also the use of Python programming language
seems to be a good choice judging by the feedback of the students.
REFERENCES