Pyclaw Controller Class

The pyclaw controller object is a convenience class for running simulations based on the classic clawpack formats and output specifications. It allows for a variety of output time specifications, output styles and other ways to keep a simulation organized.

The main way to use a Controller object then is to provide it with an appropriate Solver and initial Solution object. Then specify what kind of output you would like different than the defaults (see Controller for details on what those are). Then simply call run() in order to run the desired simulation.

>>> import pyclaw.controller as controller
>>> claw = controller.Controller()            # Instantiate a new controller
>>> claw.solver = my_solver                   # Assign a solver              
>>> claw.solution = my_initial_solution       # Assign an initial condition  

Here we would set a variety of run parameters such as tfinal, keep_copy if we wanted to plot the solutions immediately, or output_format to specify a format other than ascii or no output files if we are going to use keep_copy = True. After we are all set up we just need to call the controller’s run() method and off we go.


Please see the PyClaw tutorial: Solve the acoustics equations for a detailed example of how this would work in its entirety.


class clawpack.pyclaw.controller.Controller

Controller for pyclaw simulation runs and plotting


Input: None

>>> import clawpack.pyclaw as pyclaw
>>> x = pyclaw.Dimension(0.,1.,100,name='x')
>>> domain = pyclaw.Domain((x))
>>> state = pyclaw.State(domain,3,2)
>>> claw = pyclaw.Controller()
>>> claw.solution = pyclaw.Solution(state,domain)
>>> claw.solver = pyclaw.ClawSolver1D()

Check that the controller has been properly set up and is ready to run.

Also checks validity of the solver, solution and states.


Plot from memory.


Convenience routine that will evolve solution based on the traditional clawpack output and run parameters.

This function uses the run parameters and solver parameters to evolve the solution to the end time specified in run_data, outputting at the appropriate times.

Ouput:(dict) - Return a dictionary of the status of the solver.
F_file_name = None

(string) - Name of text file containing functionals


(string) - Full path to output file for functionals

compute_F = None

(function) - Function that computes density of functional F

compute_p = None

(function) - function that computes derived quantities

file_prefix_p = None

(string) - File prefix to be prepended to derived quantity output files

frames = None

(list) - List of saved frames if keep_copy is set to True

keep_copy = None

(bool) - Keep a copy in memory of every output time, default = False

nstepout = None

(int) - Number of steps between output, only used with output_style = 3, default = 1

num_output_times = None

(int) - Number of output times, only used with output_style = 1, default = 10

out_times = None

(int) - Output time list, only used with output_style = 2, default = numpy.linspace(0.0,tfinal,num_output_times)

outdir = None

(string) - Output directory, directs output files to outdir


(string) - Directory to use for writing derived quantity files

output_file_prefix = None

(string) - File prefix to be appended to output files, default = None

output_format = None

(list of strings) - Format or list of formats to output the data, if this is None, no output is performed. See _pyclaw_io for more info on available formats. default = 'ascii'

output_options = None

(dict) - Output options passed to function writing and reading data in output_format’s format. default = {}

output_style = None

(int) - Time output style, default = 1

overwrite = None

(bool) - Ok to overwrite old result in outdir, default = True

plotdata = None

(ClawPlotData) - An instance of a ClawPlotData object defining the objects plot parameters.

rundir = None

(string) - Directory to run from (containing *.data files), uses *.data from rundir

runmake = None

(bool) - Run make in xdir before xclawcmd

savecode = None

(bool) - Save a copy of *.f files in outdir

solver = None

(Solver) - Solver object

tfinal = None

(float) - Final time output, default = 1.0


(int) - Level of output to screen; default = 3

viewable_attributes = None

(list) - Viewable attributes of the :class:`~pyclaw.controller.Controller

write_aux_always = None

(bool) - Write out auxiliary array at every time step, default = False

write_aux_init = None

(bool) - Write out initial auxiliary array, default = False

xclawcmd = None

(string) - Command to execute (if using fortran), defaults to xclaw or xclaw.exe if cygwin is being used (which it checks vis sys.platform)

xclawerr = None

(string) - Where to write error messages

xclawout = None

(string) - Where to write timestep messages

xdir = None

(string) - Executable path, executes xclawcmd in xdir