coffee.actions package

Submodules

coffee.actions.actions module

class coffee.actions.actions.BlowupCutoff(cutoff=10, **kwds)[source]

Bases: Prototype

An action that stops the simulation if some component of the computed solution is above the given value.

above_cutoff(u)[source]

Returns true if the absolute value of any component of the data in the timeslice u is above the absolute value of the given cutoff.

Parameters:

u (tslice.TimeSlice) – The timeslice to be checked.

Returns:

True if there is a component greater than the cutoff.

Return type:

boolean

class coffee.actions.actions.Info(*args, **kwds)[source]

Bases: Prototype

Logs the current iterations and data slice.

Included more as an example than anything else.

class coffee.actions.actions.Prototype(frequency=1, start=-inf, stop=inf, thits=None, thits_toll=1e-14)[source]

Bases: object

The prototype of all actions.

This class provides basic functionality that all actions require.

To subclass this class: 1) define the method _doit in the subclass 2) call the Prototypes constructor to ensure that frequency, start and stop are properly initialised.

will_run(it, u)[source]

Returns true if the action will run for the given iteration and time slice.

Parameters:
  • it (int) – The number of iterations in this simulation.

  • u (tslice.TimeSlice) – The current timeslice.

Returns:

True if the action will run.

Return type:

boolean

coffee.actions.gp_plotter module

coffee.actions.hdf_output module

This module writes the data of a timeslice to an hdf file.

The main class SimOutput uses objects of class SimOutput.SimOutputType to actually write the data. By subclassing SimOutput.SimOutputType in the manner specified below non - numpy array data can be stored conviently.

I think of this method as a plugin for the system. The user writes a new output method for some kind of new data type in a sub class of SimOutputType and ‘plugs’ this method into the ‘action’ list of SimOutput.

class coffee.actions.hdf_output.SimOutput(hdf_file, solver, theSystem, theInterval, actionTypes, cmp_=None, overwrite=True, name=None, **kwds)[source]

Bases: Prototype

An action to handle output of data to hdf.

Each piece of data to be output is passed, as an object, to this class in the array actionTypes.

These objects are subclasses of SimOutputType a class which is accessible as an attribute of SimOutput.

Note that there is a dependence on io.simulation data. In particular on the dgTypes dictionary which provides information on the appropriate names for created datagroups. For information about how to access this data please see the simulation_data module.

Details on how to subclass SimOutputType are given in the documentation for the SimOutputType class.

class Data(derivedAttrs=None)[source]

Bases: SimOutputType

Writes out tslices.TimeSlice.data.

This class assumes that tslice.TimeSlice.data has a type that h5py understands.

groupname = 'Raw_Data'
class DerivedData(name, function, frequency=1, start=0, derivedAttrs=None)[source]

Bases: SimOutputType

Runs the data through a user defined function before writing out to the data_set.

The function must have the signature function(int, tslice.TimeSlice, system.System) and must return data of a type that h5py recognises.

Note that there is a size limitation on the .attrs variable and therefore this SimOutputType maybe more appropriate.

class Domains(derivedAttrs=None)[source]

Bases: SimOutputType

Records domains of the simulation.

This SimOutputType does not record the grid object, but rather the axes and comparison variables of the grid. Hence no mpi information is collected here.

Currently this is because ibvp.IBVP before it runs actions collates all the data together so that, from the point of view of the hdf file there is only one process accessing it.

This will need to be changed at some point. h5py has routines to allow more than one process to write to a file. But coffee does not currently capitalise on these routines.

groupname = 'Domain'
class Exact(derivedAttrs=None)[source]

Bases: SimOutputType

Calls system.exact_value to write out the exact value of the system.

This is useful if, during error calculation, you want the error rates against an exact solution.

groupname = 'Exact_Data'
class SimOutputType(derivedAttrs=None)[source]

Bases: object

If you want to customise the output to the hdf file subclass this class.

This class handles the organisation of the hdf file structure so that you don’t have to. It slices, it dices, it picks the group to store the datasets that will contain your data. That data group is stored in the atribute self.data_group.

It also handles the inclusion of derived attribute in the .attrs variable of the relevant data_set. Sometimes this is needed if more than a numpy array needs to be retreived.

setup(parent)[source]

This method is called by SimOuput on construction.

Overide this is additional setup as needed, in particular if data should be extracted from parent. See SimOutputType.System for an example.

This method should always to called so if you do override it, make sure to include a call to super(YourClass, self).setup(partent). This is necessary because without the call the data_group may not be configured correctly.

Parameters:

SimOuput – parent the SimOutput class that this SimOutputType belongs to.

class System(derivedAttrs=None)[source]

Bases: SimOutputType

Attempts to write out enough information about the system to allow for exact reconstruction of the simulation that produced the data being stored.

Of course most things arn’t that simple… and this SimOutput type requires care during use.

groupname = 'System'
setup(parent)[source]

This method is called by SimOuput on construction.

Overide this is additional setup as needed, in particular if data should be extracted from parent. See SimOutputType.System for an example.

This method should always to called so if you do override it, make sure to include a call to super(YourClass, self).setup(partent). This is necessary because without the call the data_group may not be configured correctly.

Parameters:

SimOuput – parent the SimOutput class that this SimOutputType belongs to.

class TimeStep(derivedAttrs=None)[source]

Bases: SimOutputType

Just like time buts tells you what the calculated dt was.

This can be calculated from the data in Times, only if you are recording the data in the next timestep…

groupname = 'Time_Step'
class Times(derivedAttrs=None)[source]

Bases: SimOutputType

Would you like to know what time the data at a particular data_set is meant to correspond to?

Then you need this SimOutputType.

groupname = 'Time'

coffee.actions.mpl_plotter module

class coffee.actions.mpl_plotter.Plotter(frequency=1, xlim=(-1, 1), ylim=(-1, 1), findex=None, delay=0.0)[source]

Bases: Prototype

An action that plots data using matplotlib.

Module contents

An action is a class which performs some additinonal processing to a time_slice before each iteration.

Please see the help for the prototype action for implementation details.