Post on 13-Feb-2017
Tools & Resources for Teaching
Undergraduate Computational
Physics
Amde A, Dept. of Physics, University of Gondar, P.O. Box 196,
Ethiopia, mdselassie@gmail.com
“Computers are incredibly fast, accurate, and stupid; humans are incredibly
slow, inaccurate, and brilliant; together they are powerful beyond imagination”.
- Albert Einstein
“Computational scientists solve tomorrow’s problems with yesterday’s
computers; computer scientists seem to do it the other way round”.
- (Unknown)
What is Computational Physics?
A multidisciplinary subject that uses computing approach to
gain understanding in complex systems, like QCD,
electronic structure, molecular dynamics, nuclear fusion,
climate dynamics, relativistic astrophysics.
Provides the capability to study and gain novel insights into
physical systems, especially for those where no analytical
solutions can be found or an experimental study is too
complicated or expensive.
An essential and integral part of contemporary sciences,
and has become as important as theory and experiment.
Computational Physics is multidisciplinary. It combines disciplines like Computer Science and
Mathematics with Physics (Landau)
Computation is as important as theory & experiment Use of computation and simulation has now become an
essential and integral part of contemporary basic and
applied sciences (Landau)
Some Uses of Computers in Physics (Gould)
I. Numerical analysis
II. Symbolic manipulation
III. Visualization
IV. Simulation
V. Data acquisition & analysis
VI. Technology Enabled Learning
I. Numerical Analysis - Creates, analyzes, & implements algorithms
for solving numerically the problems of continuous math.
Used to compute multidimensional integral & differential
equations, manipulate large matrices, or solve linear & nonlinear
differential equations
Some software: MATLAB, LabVIEW, GNU Octave & SciLab
II. Symbolic Manipulation
Used to manipulate differentiation, integration, matrix
inversion, power series expansion, …
Some software: Mathematica, Maple, Maxima & SAGE
III. Visual Representation (Gould)
◦ The Eye + Visual Processing Capacity of the Brain
◦ Patterns & trends that might not be evident from tables of data
can be determined. Example: Run Sfile\osp_qm_twostate.jar
◦ Changes be observed & can lead to insight into the important
mechanisms underlying a system’s behavior
IV. Technology Enabled Learning
developed by integrating education research results with
technology tools
transform learning from teacher-centered to student-centered
requires new physical and cognitive architecture
Some Examples
1. Lecture Based Model - Just in Time Teaching, Peer Instruction,
Interactive Lecture Demonstrations, …
2. TEAL (Technology Enabled Active Learning),
http://icampus.mit.edu/projects/teal/
3. SCALEUP (Student Centered Active Learning
Environment with Upside down Pedagogy)
http://scaleup.ncsu.edu/
4. Laboratory:
a. Remote Controlled Lab, i-Lab
real experimental facilities/setups that can be controlled
remotely over the internet.
Examples:
◦ robotic telescopes, rcl (http://rcl.physik.uni-kl.de/),
◦ i-labs (http://icampus.mit.edu/iLabs/default.aspx)
b. Virtual Lab
interactive pc-based activity where students conduct or create
simulated experiments. Virtual instruments & apparatus that
simulate the functions & characteristics of real ones are used.
Examples:
◦ Run: Sfile\ub_optics.jar
◦ PhET Interactive Simulation: https://phet.colorado.edu/
Example:
Run: Sfile\nve_damping.ms9
5. Data Acquisition & Analysis
◦ Computer based measurement that requires interfacing the
computer with various instrumentations & sensors
◦ Involves real-time control & interactive data analysis
◦ You need: computer hardware, software, sensors, interfaces
Example:
◦ Software: LabVIEW
The Importance of Computer Simulation
Simulation – implementing a model on a computer (to understand
its behavior & predictions)
Frequently uses computational tools of numerical analysis &
visualization.
Why is computation becoming so important in physics?
1. Explore nonlinear phenomena. Many natural phenomena
are nonlinear & most are difficult to solve by analytical
methods. Example: Download & Run Sfile\ejs_sip_ch06.jar
2. Investigate systems with many variables or with many
degrees of freedom
3. Investigate systems whose experimental studies are too
complicated & expensive.
Language & Content Selection Dilemma
Though undergraduate computational physics (UCP) is now
becoming an integral part of the physics curriculum, there is
no still standardization in the contents & programming
language used to teach the course.
Content Options?
◦ Linear Systems,
◦ Non-linear, Chaotic & Multi-variable Systems, or
◦ Both (Linear & Non-linear)
Language Options?
◦ Symbolic or Numeric Computing Environment (MATLAB,
Octave, Mathematica, Maple …)
◦ Non-Specific Pseudo-code (Giordano), or
◦ General Purpose (FORTRAN, C/C++, Java, Python …)
… Language & Content
The decision of what contents & languages to use to teach
UCP is not an easy one, but depends mostly on:
◦ Objectives of the UCP Course and time allotted for it,
◦ Computing skills & experience of both Instructors and
Students,
◦ Availability & cost of Computational Resources and
Facilities,
◦ Numerical performance, ease of use, good graphical
interfaces, & Web-based & database driven applications
of Language/Computing Environment.
… Language & Content
At University of Gondar we chose following contents &
language to teach UCP & have been using it since 2005:
◦ Both (Linear & Non-linear Systems) for Content, &
◦ Java for Language
◦ Currently, we are considering using Java with Python.
Why Linear & Nonlinear Contents?
◦ The course focuses on studying & developing simulation
for nonlinear & many variable systems, but
◦ Linear systems are used for introducing the basics of the
Language & Numerical Methods
… Language & Content
Why Java?
◦ Platform independent; (API, neutral byte code, JVM)
◦ Flexible standard graphics libraries & good performance
◦ Web-based & server-based applets
◦ Free and relatively simple to learn
◦ Supported by OSP (OpenSourcePhysics), extensive library of
open-source Java routines for computational work
(www.compadre.org/OSP/ ).
Disadvantage:
◦ Despite the high level of abstraction and platform
independence, the speed & performance of Java is not
comparable with C++ or Fortran.
◦ It is not supported by numerical libraries.
Installation
Download the JDK Installer (from www.java.com or
www.oracle.com/technetwork/java/javase/downloads/index.html)
JDK on Windows:
Run the JDK Installer & follow the instructions. (JDK should
be installed in the directory C:\ )
Add the jdk/bin directory into the execution path
JDK on Linux (for root users):
Uncompress the binary file (for 64-bit & update 60):
tar zxvf jdk-8u60-linux-x64.tar.gz
Move the JDK directory to /usr/lib
sudo mkdir -p /usr/lib/jvm
sudo mv /jdk1.8.60 /usr/lib/jvm/
… Installation
JDK on Linux:
Now enable Java
sudo update-alternatives --install "/usr/bin/java" "java"
"/usr/lib/jvm/jdk1.8.0_60/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac"
"/usr/lib/jvm/jdk1.8.0_60/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws"
"/usr/lib/jvm/jdk1.8.0_60/bin/javaws" 1
Change the file ownership & permissions of the
executables; use the chmod a+x command.
Configure Project/Development Environment
(Based on OpenSourcePhysics & An Introduction to Computer Simulation
Methods, 3ed, by Gould & Tobochinik)
Windows:
Create a Project Directory (e.g. “C:\cp_projects”)
Download the OpenSourcePhysics Eclipse Workspace (from
www.compadre.org/OSP/ ) and unpack the source code for the
OSP core library (src.zip) in to the Project Dir.
Create a Dir. named classes under the Project Dir.:
C:\cp_projects\classes
Create a Dir. named org under classes & a Dir. named
opensourcephysics under the org Dir.:
C:\cp_projects\classes\org\opensourcephysics
Copy the resource Dir. from …src\org\opensourcephysics to
…classes\org\opensourcephysics
…Configure Project
Linux:
Create a Project Dir. under the user’s Home Dir., unpack
the core library src.zip, & make directory named classes:
mkdir /cp_projects
unzip /cp_projects/src.zip
mkdir /cp_projects/classes
Create a directory named org under classes & a directory
named opensourcephysics under the org Dir.:
mkdir /cp_projects/classes/org/opensourcephysics
Copy the resource Dir. from …src\org\opensourcephysics to
…classes\org\opensourcephysics
Edit
Windows:
the source code can be edited using Notepad (++) &
saved as “FileName”.java under Directory:
C:\cp_project\src\”package”
Linux:
the source code can be edited using text editor gedit &
saved as “FileName”.java under Directory:
home/”user”/cp_project/src/”package”
Compile
Windows:
Open Command Prompt (C:\_)
Change Directory to Project Directory (C:\cp_project)
Compile:
javac –d classes/ -sourcepath src/ src/”package”/”FileName”.java
Linux:
Open the Terminal
Change Directory to Project Directory
cd cp_project
Compile:
javac -d classes/ -sourcepath src/ src/”package”/”FileName”.java
Run
Windows:
Open Command Prompt (C:\_)
Change Directory to Project Directory (C:\cp_project)
Run:
java -classpath classes/ “package name”/”FileName”
Linux:
Open the Terminal
Change Directory to Project Directory
cd cp_project
Run:
java -classpath classes/ “package name”/”FileName”
References & Resources
1. Landau, A First Course in Scientific Computing. Princeton Univ. Press, 2005.
2. Gould & Tobochnik, An Introduction to Computer Simulation Methods, 3ed.
Addison-Wesley 2006.
3. OpenSourcePhysics, www.compadre.org/OSP/
4. Giordano & Nakanishi, Computational Physics, 2ed. Prentice Hall 2005.
5. Cook, Computation and Problem Solving in Undergraduate Physics.
http://www.lawrence.edu/dept/physics/ccli
6. Yevick, A First Course in Computational Physics & Object-Oriented
Programming with C++. Cambridge Univ. Press, 2005.
7. Hjorth-Jensen, Computational Physics Lecture Notes, Univ. of Oslo, 2012
8. Thijssen, Computational Physics, Cambridge Univ. Press, 1999
9. Gershenfeld, The Nature of Mathematical Modeling. Cambridge Univ. P, 1999
10. Landau, Computational Physics: A Better Model for Physics Education?
Computing in Science & Engineering, 2006