Previous topic

Managing jobs remotely

Next topic

Analysis

This Page

gromacs.run – Running simulations

Helper functions and classes around gromacs.tools.Mdrun.

class gromacs.run.MDrunner(dirname='.', **kwargs)

A class to manage running mdrun in various ways.

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

In addition there are two methods named prehook() and 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.

The run() method can take arguments for the mpiexec launcher but it can also be used to supersede the arguments for mdrun.

Note

Changing mdrun arguments permanently changes the default arguments for this instance of MDrunner. (This is arguably a bug.)

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 mdrun commandline. Note that only keyword arguments are allowed.

check_success()

Check if mdrun finished successfully.

(See check_mdrun_success() for details)

commandline(**mpiargs)

Returns simple command line to invoke mdrun.

If mpiexec is set then mpicommand() provides the mpi launcher command that prefixes the actual mdrun invocation:

mpiexec [mpiargs] mdrun [mdrun-args]

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

mdrun = 'mdrun'

path to the mdrun executable (or the name if it can be found on PATH)

mpicommand(*args, **kwargs)

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.)

mpiexec = None

path to the MPI launcher (e.g. mpiexec)

posthook(**kwargs)

Called directly after the process terminated (also if it failed).

prehook(**kwargs)

Called directly before launching the process.

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

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

Keywords :
pre

a dictionary containing keyword arguments for the prehook()

post

a dictionary containing keyword arguments for the posthook()

mdrunargs

a dictionary with keyword arguments for mdrun which supersede and update the defaults given to the class constructor

mpiargs

all other keyword arguments that are processed by mpicommand()

run_check(**kwargs)

Run 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 run() (typically used for mpi things)

Returns :
  • True if run completed successfully
  • False otherwise
class gromacs.run.MDrunnerOpenMP(dirname='.', **kwargs)

Manage running mdrun as an OpenMP multiprocessor job.

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 mdrun commandline. Note that only keyword arguments are allowed.

class gromacs.run.MDrunnerOpenMP64(dirname='.', **kwargs)

Manage running mdrun as an OpenMP multiprocessor job (64-bit executable).

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 mdrun commandline. Note that only keyword arguments are allowed.

class gromacs.run.MDrunnerMpich2Smpd(dirname='.', **kwargs)

Manage running mdrun as mpich2 multiprocessor job with the SMPD mechanism.

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 mdrun commandline. Note that only keyword arguments are allowed.

gromacs.run.check_mdrun_success(logfile)

Check if mdrun finished successfully.

Analyses the output from mdrun in logfile. Right now we are simply looking for the line “Finished mdrun on node” in the last 1kb of the file. (The file must be seeakable.)

Arguments :
logfile : filename

Logfile produced by mdrun.

Returns :

True if all ok, False if not finished, and None if the logfile cannot be opened