1
Open Source Physics Curriculum Material for Teaching Upper Level Physics Wolfgang Christian Jan Tobochnik, and Harvey Gould Teaching Computational Physics Good programming practice is best taught by having students modify, compile, test, and debug their own code. A typical exercise in An Introduction to Computer Simulation Methods begins with a discussion of theory, the presentation of an algorithm, and the introduction of the necessary Java syntax. We implement the algorithm in a sample application and then ask the reader to test it with various parameters. The user then modifies the model, adds visualizations such as graphs and tables, and performs further analysis. The focus is on both the physics and programming. The user interface need not be very sophisticated, and a simple user interface that includes a few buttons and a table for data entry is all that is needed for a computational physics textbook. Modifications to the program, such as a custom user interface or web delivery, allow the program to be used with different pedagogies such as in-class demonstrations, Peer Instruction, traditional homework, and Just-in-Time Teaching as described below. Because Open Source Physics code is released under a GNU GPL license, our code can be used without restrictions. Users can write their own narrative for other contexts such as astronomy and classical mechanics. However, if a program uses any portion of the code in the org.opensourcephysics package or any subpackage (subdirectory) of this library, this code must also be released under the GNU GPL license. Curriculum Packages The OSP technologies that were developed to teach computational physics are now being used to create simulations for upper level physics. These simulations are distributed in Java archive (jar) files that can be executed by clicking (or double- clicking) on the file in a file-system browser if Java has been installed using default parameters. Although it would be possible to distribute every OSP simulation in its own jar file, this approach is not well suited for the distribution of curricular packages. A large curriculum development project creates many programs and each program may be used in multiple contexts with different initial conditions. The Launcher program addresses this distribution requirement. Launcher is a Java application that can launch (execute) other Java programs. We use Launcher to organize and distribute collections of ready-to-use programs, documentation, and curricular material in a single easily modifiable package. Delivering curricular material in Launcher packages has several advantages. First, the material can be made self-contained. Second, the material is only dependent on having a Java VM on a local machine and not on the type of operating system or browser used. The OSP curriculum packages can be downloaded from the Open Source Physics website. Introduction The Open Source Physics (OSP) project has developed a Java library and an easy to use xml vocabulary for the development of physics software and the distribution of Web-based curricular material. This technology enables us to develop new curricular materials, teach computational physics, store parameters, initial conditions, and results from a computer simulation, associate a simulation, a set of initial conditions, and a narrative into a topical unit, and combine topical units into a curriculum module that can be further adapted and customized by users. We have used the OSP framework to author and organize curricular material from computational physics, classical mechanics, E&M, statistical physics, and quantum mechanics. The Open Source Physics code library, documentation, and sample curricular material is available on CD and can be downloaded from <http://www.opensourcephysics.org> Open Source Physics Project Although there are many computer-based resources for teaching physics, few are based on an object- oriented open source code library. What is needed by the physics education community is not another computer program (although programs are essential), but a synthesis of curriculum development, computational physics, computer science, and physics education research that will be useful for students and adaptable for teachers wishing to write their own simulations and develop their own curricular material. The Open Source Physics (OSP) project was established to meet this need. OSP is an NSF-funded curriculum development project that is developing and distributing a code library, programs, and examples of computer-based interactive curricular material. Distribution of compiled programs fails for upper- level physics simulations that require advanced computational techniques or discipline-specific expertise. Users and developers of these types of programs often have specialized curricular needs that can only be addressed by having access to the source code. However, anyone who has ever written a Java program knows that writing code for opening windows and creating buttons, text fields, and graphs can be tedious and time consuming. Moreover, it is not in the spirit of object-oriented programming to rewrite these methods for each application or applet. The Open Source Physics project solves this problem by providing a consistent object-oriented library of Java components for anyone wishing to write their own simulations. The basic Open Source Physics library includes the following packages: controls: A framework for building graphical user interfaces and components. display: A drawing framework based on the DrawingPanel class and the Drawable interface. display2d: Tools for two-dimensional visualizations such as contour and surface plots. display3d: Tools for three-dimensional visualizations. ejs: Custom user-interface components. numerics: Analysis tools such as ordinary differential equation solvers. tools: Small programs, such as data analysis and video capture, that collect data from other programs. Tools can be added to a menu bar. Open Source Physics libraries are based on Swing and Java 1.4. Although the focus of the basic libraries is traditional computational physics, they have already been extended to include topics not covered in computational physics texts such as video analysis. These packages are available from other OSP developers and from the OSP web site. A number of authors have adopted OSP for their projects and have agreed to let the OSP project distribute their programs as examples. These projects include: An Introduction to Computer Simulation Methods (3rd ed.) by Harvey Gould, Jan Tobochnik, and Wolfgang Christian. Statistical and Thermal Physics by Harvey Gould and Jan Tobochnik. Easy Java Simulations high-level modeling tool by Francisco Esquembre. Tracker video analysis program by Doug Brown. The development of these programs has enabled the Open Source Physics project to improve the core library in may ways. The API has been made more consistent, bugs have been found and squashed, and we have learned what tools are useful to the developer community. But most importantly, Open Source Physics developers have produced great tools for the physics education community. Partial funding for this work was obtained through NSF grant DUE- 0442581 and Davidson College. General Relativity: Consider the computation of particle trajectories in the vicinity of a black hole. The book narrative develops the differential equations for particle motion from the Schwarzschild metric and then asks the reader to do the following: Exercise 18.6. Modify the PlanetApp program introduced in Chapter 5 so that the classical trajectory of a particle is calculated using polar variables rather than Cartesian variables. Use (10.10) and (18.13) to determine the initial state and compare your results with those of the previous program. Exercise 18.11a. Write a program that plots the general relativistic trajectory of a particle using Schwarzschild coordinates. Verify that circular orbits are obtained for v = (M/r)1/2. Exercise 18.11b. Show that there are no stable circular orbits for r < 6M. Exercise 18.11c. Add the differential equation for proper time. What is the proper time for one complete orbit at r = 6? This interval is the orbital period as measured by an observer traveling with the particle. Compare this wristwatch orbital period to the faraway orbital period and to the time interval predicted by (18.24). Explain any differences in your numerical values. Exercise 18.11d. Perturb the circular orbit at r=9 by giving the particle an initial tangential velocity of v = 0.345c. At what rate does the perihelion of the orbit advance? Electromagnetism: Consider the computation of electric field lines. The book narrative asks the reader to do the following: Problem 10.2a. Use the FieldLineApp program to draw field lines for a few simple sets of one, two, and three charges. Choose sets of charges for which all have the same sign, and sets for which they are different. Verify that the field lines never connect charges of the same sign. Why do field lines never cross? Are the units of charge and distance relevant? Problem 10.4a. The FieldLineApp program plots field lines in two dimensions. Sometimes this restriction can lead to spurious results (see Freeman). Consider four identical charges placed at the corners of a square. Use the program to plot the field lines. What, if anything, is wrong with the results? What should happen to the field lines near the center of the square? Problem 10.4b. The two-dimensional analog of a point charge is an infinite line (thin cylinder) of charge perpendicular to the plane. The electric field due to an infinite line of charge is proportional to the linear charge density and inversely proportional to the distance (instead of the distance squared) from the line of charge to a point in the plane. Modify the FieldLine class to compute the field lines from line charges with E(r) = 1/r. Use your modified class to draw the field lines due to four identical line charges located at the corners of a square, and compare the field Mechanics: Consider the classical three-body model of Helium. The book narrative asks the reader to do the following: Project 5.19a. Modify the program PlanetApp to simulate the classical Helium atom. Let the initial value of the time step be t = 0.001. Some of the possible orbits are similar to those we have already studied in our mini-solar system Project 5.19b. The initial condition r1 = (1.4,0), r2 = (-1,0), v1 = (0,0.86), and v2 = (0,-1) gives “braiding” orbits. Most initial conditions result in unstable orbits in which one electron eventually leaves the atom (autoionization). Make small changes in this initial condition to observe autoionization. Project 5.19c. The classical helium atom is capable of very complex orbits (see Figure 3). Investigate the motion for the initial condition r1 = (3,0), r2 = (1,0), v1 = ( 0,0.4), and v2 = (0,-1). Does the motion conserve the total angular momentum? Project 5.19d. Choose the initial condition r1 = (2,0), r2 = (-1,0), and v2 = (0,-1).Then vary the initial value of v1 from (0.6,0) to (1.3,0) in steps of vx = 0.02. For each set of initial conditions calculate the time it takes for autoionization. Assume that ionization occurs when either electron exceeds a distance of six from the nucleus. Run each simulation for a maximum time equal to 2000. Plot the ionization time versus v1x. Repeat for a smaller interval of v centered about one of the longer ionization times.

Open Source Physics Curriculum Material for Teaching Upper Level Physics Wolfgang Christian Jan Tobochnik, and Harvey Gould Teaching Computational Physics

Embed Size (px)

Citation preview

Page 1: Open Source Physics Curriculum Material for Teaching Upper Level Physics Wolfgang Christian Jan Tobochnik, and Harvey Gould Teaching Computational Physics

Open Source Physics Curriculum Material for Teaching Upper Level Physics

Wolfgang Christian

Jan Tobochnik, and Harvey Gould

Teaching Computational PhysicsGood programming practice is best taught by having students modify, compile, test, and debug their own code. A typical exercise in An Introduction to Computer Simulation Methods begins with a discussion of theory, the presentation of an algorithm, and the introduction of the necessary Java syntax. We implement the algorithm in a sample application and then ask the reader to test it with various parameters. The user then modifies the model, adds visualizations such as graphs and tables, and performs further analysis.

The focus is on both the physics and programming. The user interface need not be very sophisticated, and a simple user interface that includes a few buttons and a table for data entry is all that is needed for a computational physics textbook. Modifications to the program, such as a custom user interface or web delivery, allow the program to be used with different pedagogies such as in-class demonstrations, Peer Instruction, traditional homework, and Just-in-Time Teaching as described below.

Because Open Source Physics code is released under a GNU GPL license, our code can be used without restrictions. Users can write their own narrative for other contexts such as astronomy and classical mechanics. However, if a program uses any portion of the code in the org.opensourcephysics package or any subpackage (subdirectory) of this library, this code must also be released under the GNU GPL license.

Curriculum PackagesThe OSP technologies that were developed to teach computational physics are now being used to create simulations for upper level physics. These simulations are distributed in Java archive (jar) files that can be executed by clicking (or double-clicking) on the file in a file-system browser if Java has been installed using default parameters. Although it would be possible to distribute every OSP simulation in its own jar file, this approach is not well suited for the distribution of curricular packages.

A large curriculum development project creates many programs and each program may be used in multiple contexts with different initial conditions. The Launcher program addresses this distribution requirement. Launcher is a Java application that can launch (execute) other Java programs. We use Launcher to organize and distribute collections of ready-to-use programs, documentation, and curricular material in a single easily modifiable package. Delivering curricular material in Launcher packages has several advantages. First, the material can be made self-contained. Second, the material is only dependent on having a Java VM on a local machine and not on the type of operating system or browser used.

The OSP curriculum packages can be downloaded from the Open Source Physics website.

IntroductionThe Open Source Physics (OSP) project has developed a Java library and an easy to use xml vocabulary for the development of physics software and the distribution of Web-based curricular material. This technology enables us to develop new curricular materials, teach computational physics, store parameters, initial conditions, and results from a computer simulation, associate a simulation, a set of initial conditions, and a narrative into a topical unit, and combine topical units into a curriculum module that can be further adapted and customized by users. We have used the OSP framework to author and organize curricular material from computational physics, classical mechanics, E&M, statistical physics, and quantum mechanics. The Open Source Physics code library, documentation, and sample curricular material is available on CD and can be downloaded from

<http://www.opensourcephysics.org>

Open Source Physics ProjectAlthough there are many computer-based resources for teaching physics, few are based on an object-oriented open source code library. What is needed by the physics education community is not another computer program (although programs are essential), but a synthesis of curriculum development, computational physics, computer science, and physics education research that will be useful for students and adaptable for teachers wishing to write their own simulations and develop their own curricular material. The Open Source Physics (OSP) project was established to meet this need. OSP is an NSF-funded curriculum development project that is developing and distributing a code library, programs, and examples of computer-based interactive curricular material.

Distribution of compiled programs fails for upper-level physics simulations that require advanced computational techniques or discipline-specific expertise. Users and developers of these types of programs often have specialized curricular needs that can only be addressed by having access to the source code. However, anyone who has ever written a Java program knows that writing code for opening windows and creating buttons, text fields, and graphs can be tedious and time consuming. Moreover, it is not in the spirit of object-oriented programming to rewrite these methods for each application or applet. The Open Source Physics project solves this problem by providing a consistent object-oriented library of Java components for anyone wishing to write their own simulations.

The basic Open Source Physics library includes the following packages:

•controls: A framework for building graphical user interfaces and components.

•display: A drawing framework based on the DrawingPanel class and the Drawable interface.

•display2d: Tools for two-dimensional visualizations such as contour and surface plots.

•display3d: Tools for three-dimensional visualizations.

•ejs: Custom user-interface components.

•numerics: Analysis tools such as ordinary differential equation solvers.

•tools: Small programs, such as data analysis and video capture, that collect data from other programs. Tools can be added to a menu bar.

Open Source Physics libraries are based on Swing and Java 1.4. Although the focus of the basic libraries is traditional computational physics, they have already been extended to include topics not covered in computational physics texts such as video analysis. These packages are available from other OSP developers and from the OSP web site.

A number of authors have adopted OSP for their projects and have agreed to let the OSP project distribute their programs as examples. These projects include:

•An Introduction to Computer Simulation Methods (3rd ed.) by Harvey Gould, Jan Tobochnik, and Wolfgang Christian.

•Statistical and Thermal Physics by Harvey Gould and Jan Tobochnik.

•Easy Java Simulations high-level modeling tool by Francisco Esquembre.

•Tracker video analysis program by Doug Brown.The development of these programs has enabled the Open Source Physics project to improve the core library in may ways. The API has been made more consistent, bugs have been found and squashed, and we have learned what tools are useful to the developer community. But most importantly, Open Source Physics developers have produced great tools for the physics education community.

Partial funding for this work was obtained through NSF grant DUE-0442581 and Davidson College.

General Relativity: Consider the computation of particle trajectories in the vicinity of a black hole. The book narrative develops the differential equations for particle motion from the Schwarzschild metric and then asks the reader to do the following:

Exercise 18.6. Modify the PlanetApp program introduced inChapter 5 so that the classical trajectory of a particle is calculated using polar variables rather than Cartesian variables. Use (10.10) and (18.13) to determine the initial state and compare your results with those of the previous program.Exercise 18.11a. Write a program that plots the general relativistic trajectory of a particle using Schwarzschild coordinates. Verify that circular orbits are obtained for v = (M/r)1/2. Exercise 18.11b. Show that there are no stable circular orbits for r < 6M. Exercise 18.11c. Add the differential equation for proper time. What is the proper time for one complete orbit at r = 6? This interval is the orbital period as measured by an observer traveling with the particle. Compare this wristwatch orbital period to the faraway orbital period and to the time interval predicted by (18.24). Explain any differences in your numerical values.Exercise 18.11d. Perturb the circular orbit at r=9 by giving the particle an initial tangential velocity of v = 0.345c. At what rate does the perihelion of the orbit advance?

Electromagnetism: Consider the computation of electric field lines. The book narrative asks the reader to do the following:

Problem 10.2a. Use the FieldLineApp program to draw field lines for a few simple sets of one, two, and three charges. Choose sets of charges for which all have the same sign, and sets for which they are different. Verify that the field lines never connect charges of the same sign. Why do field lines never cross? Are the units of charge and distance relevant? Problem 10.4a. The FieldLineApp program plots field lines in two dimensions. Sometimes this restriction can lead to spurious results (see Freeman). Consider four identical charges placed at the corners of a square. Use the program to plot the field lines. What, if anything, is wrong with the results? What should happen to the field lines near the center of the square?Problem 10.4b. The two-dimensional analog of a point charge is an infinite line (thin cylinder) of charge perpendicular to the plane. The electric field due to an infinite line of charge is proportional to the linear charge density and inversely proportional to the distance (instead of the distance squared) from the line of charge to a point in the plane. Modify the FieldLine class to compute the field lines from line charges with E(r) = 1/r. Use your modified class to draw the field lines due to four identical line charges located at the corners of a square, and compare the field lines with your results in part a.Problem 10.4c. Use your modified program from part b to draw the field lines for the two-dimensional analogs of the distributions considered in Problem 10.3. Compare the results for two and three dimensions and discuss any qualitative differences.Problem 10.4d. Can your program be used to demonstrate Gauss's law using point charges? What about line charges?

Mechanics: Consider the classical three-body model of Helium. The book narrative asks the reader to do the following:

Project 5.19a. Modify the program PlanetApp to simulate the classical Helium atom. Let the initial value of the time step be t = 0.001. Some of the possible orbits are similar to those we have already studied in our mini-solar systemProject 5.19b. The initial condition r1 = (1.4,0), r2 = (-1,0), v1 = (0,0.86), and v2 = (0,-1) gives “braiding” orbits. Most initial conditions result in unstable orbits in which one electron eventually leaves the atom (autoionization). Make small changes in this initial condition to observe autoionization.Project 5.19c. The classical helium atom is capable of very complex orbits (see Figure 3). Investigate the motion for the initial condition r1 = (3,0), r2 = (1,0), v1 = ( 0,0.4), and v2 = (0,-1). Does the motion conserve the total angular momentum?Project 5.19d. Choose the initial condition r1 = (2,0), r2 = (-1,0), and v2 = (0,-1).Then vary the initial value of v1 from (0.6,0) to (1.3,0) in steps of vx = 0.02. For each set of initial conditions calculate the time it takes for autoionization. Assume that ionization occurs when either electron exceeds a distance of six from the nucleus. Run each simulation for a maximum time equal to 2000. Plot the ionization time versus v1x. Repeat for a smaller interval of v centered about one of the longer ionization times.