Clawpack and Python code to reproduce results in the paper

    Python Tools for Reproducible Research on Hyperbolic Problems
       by R. J. LeVeque, CiSE (submitted) ... paper/cise08levequeV2.pdf

Description

The test problem is two-dimensional advection with solid body rotation using the Clawpack software. This directory is a self-contained version of this code along with some additional Python tools.

Reproducible Results

The tables in the paper are generated by the Python script clawtest.py, which uses several functions from the module clawtools.py (see below for links to these files).

These modules assume you are using Python 2.4 or later.

NumPy is used for for array operations and mathematics and you may need to install this first and ensure that it is on the PYTHONPATH.

The plotting also requires that matplotlib be installed from SciPy .

See pythonhints.html for advice on obtaining an appropriate version of Python and other required modules.

You also need to set the environment variable FC to the Fortran compiler that should be used to compile the Clawpack code, e.g.

    unix>  setenv FC f77

Check that the clawtest.py script works by doing

    unix>  python clawtest.py
This is set to run only two tests on a single grid type with coarse grids, so it should run quickly.

To run all the tests presented in the paper, do

    unix>  python clawtest.py itest=3
Alternatively, you can execute this from within Python:
    unix>  python 
    >>> from clawtest import *
    >>> runtests(itest=3)
    >>> quit()

This will generate files errortables.txt, errortables.tex, and errors.png that should agree with those archived in paper subdirectory.

If you want to generate plots of the solution evolving on each grid, try

     >>> runtests(itest=3,plotsoln=True)

This requires that matplotlib be installed. See pythonhints.html for advice.

Related EagleClaw examples

You can also experiment with a related example (different initial conditions) online at this page .

Links to files in this directory:

Two versions are listed for each file, the original file and an html version that is created by executing "make htmls" in this directory. If the original file is changed then you will have to "make htmls" again to see the changed reflected in the html versions.

Executing "make htmls" invokes the script clawcode2html.py to covert code into html files, if you have this code from Clawpack. See the mathcode2html webpage for a more general version and some examples of its use.

Python files

clawtest.py [.html]
Module to run the tests presented in the paper and generate the tables of errors.

clawtestsubset.py [.html]
The short version of clawtest.py [.html] that appears in the paper.

clawtools.py [.html]
Module of Python tools for Clawpack that are used in clawtest.py.

plotgrids.py [.html]
Module to plot the grids shown in Figure 1 of the paper.

clawplotting.py [.html]
Module of Python plotting tools for Clawpack using matplotlib.

mapc2p.py [.html]
Maps the computational rectangular domain to the physical grid.

setplot2user.py [.html]
This file contains commands that are executed on start-up, and sets various plotting parameters.

afterframe.py [.html]
This file contains commands that are executed after plotting each frame (i.e. each specified output time).

Data files

These data files are read by the Fortran code when Clawpack is run. Some of the values in these files are changed by the Python script in order to run a sequence of tests (see the ClawData class in clawtools.py).

claw2ez.data [.html]
Standard parameter values that are read by library routine claw/clawpack/2d/lib/claw2ez.f [.html] Each line contains one or more values to be read in, followed by comments that are ignored by the Fortran code but used by the Python read or write methods of class clawtools.ClawData.

Some parameters that you might want to modify are described in the documentation .

setprob.data [.html]
Problem-specific parameters.

setplot2.data [.html]
This file contains plotting parameters.

Fortran files

Makefile
Determines which version of fortran files are used when compiling the code with make.

driver.f [.html]
This is the main program. This code declares a few arrays and then calls the library routine claw/clawpack/1d/lib/claw1ez.f [.html]. For most applications of CLAWPACK calling this routine or higher dimensional versions is sufficient to solve the problem and the driver routine rarely changes, except to adjust the array dimensions if necessary.

The parameter mx in the data file claw1ez.data [.html] determines how many grid cells are used in the computation. Some arrays in driver.f.html [.html] are dimensioned using the parameter maxmx. If mx > maxmx then an error will result and the value of maxmx must be adjusted, along with another parameter mwork that is the length of a work array. The error message will tell you how to fix these parameters if necessary. After fixing driver.f [.html] you must recompile with the make command.

setprob.f [.html]
A routine by this name is called by the library routine claw/clawpack/1d/lib/claw1ez.f [.html] and is generally used to set any values needed for the specific problem being solved. In this example, the value of the advection velocity $u$ and a parameter $\beta$ used in setting the initial conditions are read from the file setprob.data [.html].

mapc2p.f [.html]
Maps the computational rectangular domain to the physical grid.

Riemann solvers:

rpn2ad1.f [.html]
Normal Riemann solver (normal to cell interface).

rpt2ad1.f [.html]
Transverse Riemann solver.

Library routines:

The routines in the lib subdirectory are from the kingkong.amath.washington.edu/claw/clawpack/2d/lib/ directory and are standard library routines for two-dimensional clawpack. These were taken from Subversion revision 282, though the codes in this directory should work with any other version of Clawpack 4.3 or 5.0. See the Clawpack wiki for information on the Subversion repository.

See the Makefile to see which library routines are used in this example.