begin_html

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. [http://numpy.scipy.org 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 [http://matplotlib.sourceforge.net/ matplotlib] be installed from [http://numpy.scipy.org SciPy]. See [link: 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 [link: paper] subdirectory. If you want to generate plots of the solution evolving on each grid, try
     >>> runtests(itest=3,plotsoln=True)
This requires that [http://matplotlib.sourceforge.net/ matplotlib] be installed. See [link: pythonhints.html] for advice.

Related EagleClaw examples

You can also experiment with a related example (different initial conditions) online at [http://kingkong.amath.washington.edu/claw/examples/advection/2d/example1/eagleclaw/index.html 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 [http://www.amath.washington.edu/~rjl/mathcode2html mathcode2html webpage] for a more general version and some examples of its use.

Python files

[code: clawtest.py]
Module to run the tests presented in the paper and generate the tables of errors.
[code: clawtestsubset.py]
The short version of [code: clawtest.py] that appears in the paper.
[code: clawtools.py]
Module of Python tools for Clawpack that are used in clawtest.py.
[code: plotgrids.py]
Module to plot the grids shown in Figure 1 of the paper.
[code: clawplotting.py]
Module of Python plotting tools for Clawpack using matplotlib.
[code:mapc2p.py]
Maps the computational rectangular domain to the physical grid.
[code: setplot2user.py]
This file contains commands that are executed on start-up, and sets various plotting parameters.
[code: afterframe.py]
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).

[code: claw2ez.data]
Standard parameter values that are read by library routine [clawcode:clawpack/2d/lib/claw2ez.f] 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 [www.clawpack.org/doc.html documentation].

[code: setprob.data]
Problem-specific parameters.

[code: setplot2.data]
This file contains plotting parameters.

Fortran files

[link: Makefile]
Determines which version of fortran files are used when compiling the code with make.
[code: driver.f]
This is the main program. This code declares a few arrays and then calls the library routine [clawcode: clawpack/1d/lib/claw1ez.f]. 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 [code: claw1ez.data] determines how many grid cells are used in the computation. Some arrays in [code: driver.f.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 [code: driver.f] you must recompile with the make command.

[code: setprob.f]
A routine by this name is called by the library routine [clawcode: clawpack/1d/lib/claw1ez.f] 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 [code: setprob.data].
[code: mapc2p.f]
Maps the computational rectangular domain to the physical grid.

Riemann solvers:

[code: rpn2ad1.f]
Normal Riemann solver (normal to cell interface).
[code: rpt2ad1.f]
Transverse Riemann solver.
Library routines: The routines in the [link:lib/index.html lib] subdirectory are from the [http://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 [http://kingkong.amath.washington.edu/trac/claw Clawpack wiki] for information on the Subversion repository. See the Makefile to see which library routines are used in this example. end_html