Package gromacs :: Package analysis :: Module core :: Class Simulation
[hide private]
[frames] | no frames]

Class Simulation

source code

object --+
         |
        Simulation

Class that represents one simulation.

Analysis capabilities are added via plugins. 

1. Set the *active plugin* with the :meth:`Simulation.set_plugin` method. 
2. Analyze the trajectory with the active plugin by calling the 
   :meth:`Simulation.run` method.
3. Analyze the output from :meth:`run` with :meth:`Simulation.analyze`; results are stored 
   in the plugin's :attr:`~Worker.results` dictionary.
4. Plot results with :meth:`Simulation.plot`.

Instance Methods [hide private]
 
__init__(self, **kwargs)
Set up a Simulation object.
source code
 
add_plugin(self, plugin, **kwargs)
Add a plugin to the registry.
source code
 
topdir(self, *args)
Returns a path under self.analysis_dir, which is guaranteed to exist.
source code
 
plugindir(self, plugin_name, *args)
Directory where the plugin creates and looks for files.
source code
 
figdir(self, plugin_name, *args)
Directory where the plugin saves figures.
source code
 
check_file(self, filetype, path)
Raise :exc:`ValueError` if path does not exist.
source code
 
check_plugin_name(self, plugin_name)
Raises a exc:ValueError if plugin_name is not registered.
source code
 
has_plugin(self, plugin_name)
Returns True if plugin_name is registered.
source code
 
set_plugin(self, plugin_name)
Set the plugin that should be used by default.
source code
 
get_plugin(self, plugin_name=None)
Return valid plugin or the default for *plugin_name*=``None``.
source code
 
current_plugin(self)
The currently active plugin (set with :meth:`Simulation.set_plugin`).
source code
 
run(self, plugin_name=None, **kwargs)
Generate data files as prerequisite to analysis.
source code
 
run_all(self, **kwargs)
Execute the run() method for all registered plugins.
source code
 
analyze(self, plugin_name=None, **kwargs)
Run analysis for the plugin.
source code
 
analyze_all(self, **kwargs)
Execute the analyze() method for all registered plugins.
source code
 
plot(self, plugin_name=None, figure=False, **kwargs)
Plot all data for the selected plugin::
source code
 
_apply_all(self, func, **kwargs)
Execute func for all plugins.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Instance Variables [hide private]
  plugins
Registry for plugins: This dict is central.
  default_plugin_name
Use this plugin if none is explicitly specified.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 
Set up a Simulation object.

:Keywords:
   *sim*
     Any object that contains the attributes *tpr*, *xtc*,
     and optionally *ndx*
     (e.g. :class:`gromacs.cbook.Transformer`). The individual keywrods such
     as *xtc* override the values in *sim*.
   *tpr*
     Gromacs tpr file (**required**)
   *xtc*
     Gromacs trajectory, can also be a trr (**required**)
   *edr*
     Gromacs energy file (only required for some plugins)
   *ndx*
     Gromacs index file
   *analysisdir*
     directory under which derived data are stored;
     defaults to the directory containing the tpr [None]
   *plugins* : list
     plugin instances or tuples (*plugin class*, *kwarg dict*) or tuples
     (*plugin_class_name*, *kwarg dict*) to be used; more can be
     added later with :meth:`Simulation.add_plugin`.

Overrides: object.__init__

add_plugin(self, plugin, **kwargs)

source code 
Add a plugin to the registry.

- If *plugin* is a :class:`Plugin` instance then the
  instance is directly registered and any keyword arguments
  are ignored.

- If *plugin* is a :class:`Plugin` class object or a
  string that can be found in :mod:`gromacs.analysis.plugins`
  then first an instance is created with the given keyword
  arguments and then registered.

:Arguments:
    *plugin* : class or string, or instance
       If the parameter is a class then it should have been derived
       from :class:`Plugin`. If it is a string then it is taken as a
       plugin name in :mod:`gromacs.analysis.plugins` and the
       corresponding class is added. In both cases any parameters for
       initizlization should be provided.

       If *plugin* is already a :class:`Plugin` instance then the kwargs 
       will be ignored.
    *kwargs*
       The kwargs are specific for the plugin and should be
       described in its documentation.

topdir(self, *args)

source code 

Returns a path under self.analysis_dir, which is guaranteed to exist.

Note

Parent dirs are created if necessary.

check_file(self, filetype, path)

source code 
Raise :exc:`ValueError` if path does not exist. Uses *filetype* in message.

set_plugin(self, plugin_name)

source code 
Set the plugin that should be used by default.

If no *plugin_name* is supplied to :meth:`run`, :meth:`analyze` etc. then
this will be used.

current_plugin(self)

source code 
The currently active plugin (set with :meth:`Simulation.set_plugin`).

Decorators:
  • @property

plot(self, plugin_name=None, figure=False, **kwargs)

source code 
Plot all data for the selected plugin::

  plot(plugin_name, **kwargs)

:Arguments:
   *plugin_name*
      name of the plugin to plot data from
   *figure*
      - ``True``: plot to file with default name.
      - string: use this filename (+extension for format)
      - ``False``: only display
   *kwargs*
      arguments for plugin plot function (in many cases
      provided by :meth:`gromacs.formats.XVG.plot` and
      ultimately by :func:`pylab.plot`)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

Instance Variable Details [hide private]

default_plugin_name

Use this plugin if none is explicitly specified. Typically set with :meth:`~Simulation.set_plugin`.