|
Clawpack and Python code to reproduce results in the paper
Python Tools for Reproducible Research on Hyperbolic Problems
by R. J. LeVeque, CiSE (2008) ...
paper/cise08draft.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 use NumPy for array
operations and mathematics and you may need to install this first and ensure
that it is on the PYTHONPATH.
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 and errortables.tex
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.
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 mathcode2html.py to covert code
into html files. The version included in this directory, in doc/mathcode2html.py does not require jsMath
(and does not recognize latex commands in comments). See the
mathcode2html
webpage for a more general version and some examples of its use.
Python files
- clawtest.py
... clawtest.py.html
- Module to run the tests presented in the paper and generate the tables
of errors.
- clawtools.py
... clawtools.py.html
- Module of Python tools for Clawpack that are used in clawtest.py.
- plotgrids.py
... plotgrids.py.html
- Module to plot the grids and solution shown in Figure 1 of the paper.
- ploterrs.py
... ploterrs.py.html
- Module to create a log-log plot of the errors from all the tests performed by running clawtest.py. (These are "shelved" in table.db by clawtest.py.)
If all tests are run (using itest=3 in clawtest.py) then the resulting plot
should look like paper/errors.png.
- clawplotting.py
... clawplotting.py.html
- Module of Python plotting tools for Clawpack using
matplotlib.
- setplot2user.py
... setplot2user.py.html
- This file contains commands that are executed
when plotting is done, and sets various plotting parameters.
- afterframe.py
... 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
... claw2ez.data.html
-
Standard parameter values that are read by library routine claw2ez.f.
These parameters are described in the
Clawpack documentation.
- setprob.data
... setprob.data.html
-
Problem-specific parameters.
- setplot2.data
... setplot2.data.html
- Contains plot parameters that are read in by setplot2user.py, modified by
clawtest.py and plotgrids.py.
Fortran files
- Makefile
- Determines which version of fortran files
are used when compiling the code with make.
- driver.f ...
driver.f.html
- The driver routine (main program) allocates storage.
- setprob.f ...
setprob.f.html
- Sets problem-specific data values.
- qinit.f ...
qinit.f.html
- Sets the initial conditions.
- Riemann solvers:
- rpn2ad1.f ...
rpn2ad1.f.html
- Normal Riemann solver (normal to cell interface).
- rpt2ad1.f ...
rpt2ad1.f.html
- Transverse Riemann solver.
- Library routines:
The routines in the lib subdirectory are from the
clawpack/2d/lib directory
and are standard library routines for two-dimensional clawpack.
See the Makefile to see which ones are used in this
example.
|