Package gromacs :: Module run :: Class MDrunner
[hide private]
[frames] | no frames]

Class MDrunner

source code

         object --+    
                  |    
utilities.FileUtils --+
                      |
                     MDrunner
Known Subclasses:

A class to manage running :program:`mdrun` in various ways.

In order to do complicated multiprocessor runs with mpiexec or
similar you need to derive from this class and override

- :attr:`MDrunner.mdrun` with the path to the ``mdrun`` executable
- :attr:`MDrunner.mpiexec` with the path to the MPI launcher
- :meth:`MDrunner.mpicommand` with a function that returns the mpi command as a list

In addition there are two methods named :meth:`prehook` and
:meth:`posthook` that are called right before and after the
process is started. If they are overriden appropriately then they
can be used to set up a mpi environment.

Instance Methods [hide private]
 
__init__(self, dirname='.', **kwargs)
Set up a simple run with ``mdrun``.
source code
 
commandline(self, **mpiargs)
Returns simple command line to invoke mdrun.
source code
 
mpicommand(self, *args, **kwargs)
Return a list of the mpi command portion of the commandline.
source code
 
prehook(self, **kwargs)
Called directly before launching the process.
source code
 
posthook(self, **kwargs)
Called directly after the process terminated (also if it failed).
source code
 
run(self, pre=None, post=None, **mpiargs)
Execute the mdrun command (possibly as a MPI command) and run the simulation.
source code
 
run_check(self, **kwargs)
Run :program:`mdrun` and check if run completed when it finishes.
source code
 
check_success(self)
Check if :program:`mdrun` finished successfully.
source code

Inherited from utilities.FileUtils: __repr__, check_file_exists, filename, infix_filename

Inherited from utilities.FileUtils (private): _init_filename

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

Class Variables [hide private]
  mdrun = 'mdrun'
path to the :program:`mdrun` executable (or the name if it can be found on :envvar:`PATH`)
  mpiexec = None
path to the MPI launcher (e.g.

Inherited from utilities.FileUtils: default_extension

Instance Variables [hide private]

Inherited from utilities.FileUtils: real_filename

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, dirname='.', **kwargs)
(Constructor)

source code 
Set up a simple run with ``mdrun``.

:Keywords:
   *dirname*
       Change to this directory before launching the job. Input
       files must be supplied relative to this directory.
   *keywords*
       All other keword arguments are used to construct the
       :class:`~gromacs.tools.mdrun` commandline. Note that only
       keyword arguments are allowed.

Overrides: object.__init__

commandline(self, **mpiargs)

source code 
Returns simple command line to invoke mdrun.

If :attr:`mpiexec` is set then :meth:`mpicommand` provides the mpi
launcher command that prefixes the actual ``mdrun`` invocation:

   :attr:`mpiexec` [*mpiargs*]  :attr:`mdrun` [*mdrun-args*] 

The *mdrun-args* are set on initializing the class. Override
:meth:`mpicommand` to fit your system if the simple default
OpenMP launcher is not appropriate.

mpicommand(self, *args, **kwargs)

source code 

Return a list of the mpi command portion of the commandline.

Only allows primitive mpi at the moment:
mpiexec -n ncores mdrun mdrun-args

(This is a primitive example for OpenMP. Override it for more complicated cases.)

run(self, pre=None, post=None, **mpiargs)

source code 
Execute the mdrun command (possibly as a MPI command) and run the simulation.

:Keywords:
  *pre*
     a dictionary containing keyword arguments for the :meth:`prehook`
  *post*
     a dictionary containing keyword arguments for the :meth:`posthook`
  *mpiargs*
     keyword arguments that are processed by :meth:`mpicommand`

run_check(self, **kwargs)

source code 
Run :program:`mdrun` and check if run completed when it finishes.

This works by looking at the mdrun log file for 'Finished
mdrun on node'. It is useful to implement robust simulation
techniques.

:Arguments:
   *kwargs* are keyword arguments that are passed on to
   :meth:`run` (typically used for mpi things)
   
:Returns:
   - ``True`` if run completed successfully
   - ``False`` otherwise

check_success(self)

source code 
Check if :program:`mdrun` finished successfully.

(See :func:`check_mdrun_success` for details)


Class Variable Details [hide private]

mpiexec

path to the MPI launcher (e.g. :program:`mpiexec`)

Value:
None