410-505 Tools and Software Fall 2011

Home   |   Syllabus   |   Tools   |   Topic 1   |   Topic 2   |   Topic 3   |   Topic 4   |   Topic 5

This Page:  Home  >>  tools.html

Math Library   ml.py   ml.hpp

ml.py  ml.py.txt  ml.hpp  ml.hpp.txt 

  make sure you have the latest update Fri Nov 25 18:50:23 2011


The Python version ml.py can be inserted at the top of your Python application code file. The best way to use it is as a Module

import ml

The functions in the module can be accessed like functions in the standard Python modules

>>> dir(ml)
>>> help(ml.RK4_step)
>>> ml.RK4_step(f, x, dx)

For Python to find the module the module file ml.py must be located in the Module Search Path. You can save it in any folder in Python's search path, or append the folder in which it resides to the search path:

>>> import sys
>>> print sys.path
>>> sys.path.append("C:\\mylibraryfolder")
>>> import ml


The C++ version ml.hpp can be inserted at the the top of your C++ application code, but it is most convenient to store it in a single location and include it as a Header file

#include "ml.hpp"
ml::RK4_step(f, x, dx);     // must specify namespace
using namespace ml;         // namespace need not be specified
RK4_step(f, x, dx);

To ensure that your compiler can find ml.hpp you can (1) save it in the same folder as your application file, (2) save it in a standard location where your compiler looks for header files to include, or (3) tell your compiler where it is located:

C:\myapplicationfolder> g++ -I"C:\\mylibraryfolder" -o prog prog.cpp

Graphics Library   gl.py   gl.hpp

gl.py  gl.py.txt  gl.hpp  gl.hpp.txt 

  make sure you have the latest update Sat Nov 26 07:30:16 2011


The Graphics Library is based on OpenGL and GLUT.


Python has a simpler graphics library based on Tkinter - Python Interface to Tcl/Tk.
Check out the Tkinter demo programs by Guido and Matt.


Essential Required Software


The Python Programming Language and IDLE development enviroment provide a complete set of tools to code, debug, and run simulations for this course

Python is included in most Linux distributions. Several thousand Python scripts are used to manage the Ubuntu Linux distribution. Open a Terminal window and type
Version 2.5 or higher will be sufficient for this course. Typing
should start an IDLE session: if it does not, IDLE might not be installed, and you can get it by typing
sudo apt-get install idle
or via the Ubuntu Synaptic package manager.

Mac OS:
Apple supplies a version of Python with OS X but it has some limitations. If you find this is a problem you can install Python 2.7.2 from the Python Download Page. To use Idle you need to make sure that a compatible version of Tcl/Tk is also installed, see IDLE and tkinter with Tcl/Tk on Mac OS X. This installation will not interfere with the Apple Python.

Download and install Python 2.7.2 from the official Python Download Page.

Python References: The official documentation is excellent.

Gnuplot for Plotting Data

Computers are very good at analyzing observational and experimental datasets, and computer simulations often generated large amounts of data. Gnuplot is an easy to use free plotting tool to visualize and analyze numerical data.

If gnuplot is not installed get it by typing
sudo apt-get install gnuplot
or via the Ubuntu Synaptic package manager.

Mac OS:
Gnuplot works fine on Mac OS X but installing it can be challenging because the official website does not provide a binary version and suggests compiling it from source. Try this binary version gnuplot-4.4.3-aqua-i386.dmg on OS X 10.7 Lion or 10.6 SnowLeopard, or gnuplot-4.2.5-i386.dmg on OS X 10.5 Leopard: download the dmg, double click on it, and drag the Gnuplot icon to your Applications folder (or any other folder). Double clicking the icon should start a Gnuplot session in a terminal window. If it complains that AquaTerm is not available, try the following:
gnuplot> set term x11

Download and install Gnuplot from http://sourceforge.net/projects/gnuplot/files/gnuplot/4.4.3/. The file you need is gp443win32.zip. Save this file on your Desktop (or any other folder), double click it to view it in Windows Explorer, and "Extract All Files" into any folder for example C:\gnuplot. The Gnuplot executable is wgnuplot.exe in the gnuplot\bin folder.

Gnuplot references: www.gnuplot.info has excellent docs, demos, and FAQ. Also check out the excellent Gnuplot not so FAQ.

C/C++, Fortran, Java, TeX: Compilers and Tools

Python, Idle, Gnuplot, plus any word processing software to make PDF files for homework submission, should suffice for completing all the homework assignments in this course.

Physics research and publication makes use of more powerful software and tools, in particular the C/C++ and Fortran programming languages, and the TeX typesetting software system. This course is an opportunity to learn to install and use these tools, and you are encouraged to do so.

All of these tools can easily be installed on Linux by using the package manager. On Ubuntu you can use the Synaptic package manager.

Mac OS:
To develop software on Mac OS X you really need to download and install Xcode, which includes compilers and tools, as well as an integrated development environment or IDE. The download is free but you first need to register as an Apple Developer at The Mac Dev Center.

Xcode will provide everything you need for C/C++ and Java (as well as Objective C, Python, etc). Fortran may need to be downloaded separately: a good source for Fortran and other High Performance Computing tools on the Mac is http://hpc.sourceforge.net/.

To use LaTeX on the Mac download and install the The MacTeX-2011 Distribution. Note that this is a very large download: if this is a problem just download BasicTeX.

There are many free programming language compilers and tools available for Windows. The most convenient to install and use is the MinGW compiler set and MSYS (which includes a convenient Bash shell) from http://www.mingw.org/. Follow the instructions for GUI Installation at Getting Started | MinGW and select C++, Fortran and MSYS.

Java is not included in Windows. If you would like to develop Java programs or install the Eclipse IDE, you need to download and install a Java Development Kit (JDK). Java SE 6 from Oracle http://www.oracle.com/technetwork/java/javase/downloads/index.html is recommended. You need to download the JDK (which includes the JRE). Don't download the latest Java SE 7: there are reports on the web that it has bugs.

To use LaTeX on Windows download and install the TeXLive distribution. Download the install-tl.zip archive from Installing TeX Live over the Internet. Double click the zip file to open it in Windows Explorer and "Extract All Files" to any directory. Open the unzipped folder and double click the install-tl-advanced.bat file, which allows you to select which components you want to install. For a minimal installation change "Selected scheme" to basic scheme (plain and LaTeX), change "Language collections" to English plus any others you plan to use, and change "Default paper size" to letter. If you prefer to install the complete distribution (more than 1GB) just double click install-tl.bat.

Command Line and Integrated Development Environment

Now that the C/C++, Fortran, Java, and TeX compilers and tools have been installed, we need tools to create, compile and run computer codes. There are two popular ways of doing this: (1) The Command Line method uses a programmer's text editor to write code, and a command shell to compile and run it. (2) The IDE method combines these functionalities in an integrated environment with a Graphical User Interface (GUI).

Python's IDLE is a simple IDE: you can open one or more editor windows to write code, and there is one shell window to execute code.

Command Line

The recommended programmer's editor for this course is Vim the editor, which is small, fast, powerful, and free! You should install the GUI version which has menus and allows you to use the mouse. If you don't like Gvim there a numerous other editors available Wikipedia: Comparison of Text Editors.

The recommended command shell for this course is Bash. This is the default Terminal shell on most Linux distributions, and on Mac OS X. Downloading MinGW with MSYS will give you a Bash shell on Windows.

Eclipse IDE

IDE's are becomming more and more popular for program development. There are many excellent IDE's available, see Wikipedia: Comparison of IDE's. The recommended IDE for this course is Eclipse: http://www.eclipse.org/. To install Eclipse on Linux, Mac, or Windows:

  1. Install Java BEFORE downloading Eclipse. Eclipse is coded in Java and requires a JRE to work. On Linux or Mac, open a Terminal window and type javac -version. If you don't have at least version 1.5 you need to install it. On Windows install Java SE 6 JDK.

  2. Eclipse DOES NOT include compilers and tools. You must install compilers for any language (C/C++, Fortran, LaTeX) you wish to write code for BEFORE downloading Eclipse.

  3. Download and install the "Eclipse IDE for Parallel Application Developers (includes Incubating components" package from http://www.eclipse.org/downloads/. This will give you the C/C++, Fortran, and MPI plugins.

  4. If you would like to use Eclipse for Java development, click Help -> Install, enter http://download.eclipse.org/releases/indigo and select and install Programming Languages -> Eclipse Java Development Tools.

  5. You can also install the plugins PyDev for Python development and TeXlipse for editing and compiling LaTeX documents. To install these plugins, click Help -> Eclipse Marketplace, type pydev (or texlipse) in the search box, and hit the Install button.

© 2011   Richard J. Gonsalves

Department of Physics  |  University at Buffalo