ForceBalance API  1.3
Automated optimization of force fields and empirical potentials
Classes | Functions | Variables
src.gmxio Namespace Reference

Classes

class  AbInitio_GMX
 Subclass of AbInitio for force and energy matching using GROMACS. More...
 
class  BindingEnergy_GMX
 Binding energy matching using Gromacs. More...
 
class  GMX
 Derived from Engine object for carrying out general purpose GROMACS calculations. More...
 
class  Interaction_GMX
 Interaction energy matching using GROMACS. More...
 
class  ITP_Reader
 Finite state machine for parsing GROMACS force field files. More...
 
class  Lipid_GMX
 
class  Liquid_GMX
 
class  Moments_GMX
 Multipole moment matching using GROMACS. More...
 
class  Thermo_GMX
 Thermodynamical property matching using GROMACS. More...
 
class  Vibration_GMX
 Vibrational frequency matching using GROMACS. More...
 

Functions

def edit_mdp (fin=None, fout=None, options={}, defaults={}, verbose=False)
 Read, create or edit a Gromacs MDP file. More...
 
def write_ndx (fout, grps, fin=None)
 Create or edit a Gromacs ndx file. More...
 
def parse_atomtype_line (line)
 Parses the 'atomtype' line. More...
 
def rm_gmx_baks (dir)
 

Variables

 logger = getLogger(__name__)
 
list nftypes = [None, 'VDW', 'VDW_BHAM']
 VdW interaction function types. More...
 
list pftypes = [None, 'VPAIR', 'VPAIR_BHAM']
 Pairwise interaction function types. More...
 
list bftypes = [None, 'BONDS', 'G96BONDS', 'MORSE']
 Bonded interaction function types. More...
 
list aftypes
 Angle interaction function types. More...
 
list dftypes = [None, 'PDIHS', 'IDIHS', 'RBDIHS', 'PIMPDIHS', 'FOURDIHS', None, None, 'TABDIHS', 'PDIHMULS']
 Dihedral interaction function types. More...
 
dictionary fdict
 Section -> Interaction type dictionary. More...
 
dictionary pdict
 Interaction type -> Parameter Dictionary. More...
 

Function Documentation

◆ edit_mdp()

def src.gmxio.edit_mdp (   fin = None,
  fout = None,
  options = {},
  defaults = {},
  verbose = False 
)

Read, create or edit a Gromacs MDP file.

The MDP file contains GROMACS run parameters. If the input file exists, it is parsed and options are replaced where "options" overrides them. If the "options" dictionary contains more options, they are added at the end. If the "defaults" dictionary contains more options, they are added at the end. Keys are standardized to lower-case strings where all dashes are replaced by underscores. The output file contains the same comments and "dressing" as the input. Also returns a dictionary with the final key/value pairs.

Parameters

fin : str, optional Input .mdp file name containing options that are more important than "defaults", but less important than "options" fout : str, optional Output .mdp file name. options : dict, optional Dictionary containing mdp options. Existing options are replaced, new options are added at the end, None values are deleted from output mdp. defaults : dict, optional defaults Dictionary containing "default" mdp options, added only if they don't already exist. verbose : bool, optional Print out additional information

Returns

OrderedDict Key-value pairs combined from the input .mdp and the supplied options/defaults and equivalent to what's printed in the output mdp.

Definition at line 69 of file gmxio.py.

Here is the call graph for this function:

◆ parse_atomtype_line()

def src.gmxio.parse_atomtype_line (   line)

Parses the 'atomtype' line.

Parses lines like this:
opls_135 CT 6 12.0107 0.0000 A 3.5000e-01 2.7614e-01
C 12.0107 0.0000 A 3.7500e-01 4.3932e-01
Na 11 22.9897 0.0000 A 6.068128070229e+03 2.662662556402e+01 0.0000e+00 ; PRM 5 6
Look at all the variety!

Parameters
[in]lineInput line.
Returns
answer Dictionary containing:
atom type
bonded atom type (if any)
atomic number (if any)
atomic mass
charge
particle type
force field parameters
number of optional fields

Definition at line 268 of file gmxio.py.

Here is the call graph for this function:

◆ rm_gmx_baks()

def src.gmxio.rm_gmx_baks (   dir)

Definition at line 524 of file gmxio.py.

◆ write_ndx()

def src.gmxio.write_ndx (   fout,
  grps,
  fin = None 
)

Create or edit a Gromacs ndx file.

Parameters
[in]foutOutput file name, can be the same as input file name.
[in]grpsDictionary containing key : atom selections.
[in]finInput file name.

Definition at line 148 of file gmxio.py.

Here is the call graph for this function:

Variable Documentation

◆ aftypes

list src.gmxio.aftypes
Initial value:
1 = [None, 'ANGLES', 'G96ANGLES', 'CROSS_BOND_BOND',
2  'CROSS_BOND_ANGLE', 'UREY_BRADLEY', 'QANGLES']

Angle interaction function types.

Definition at line 176 of file gmxio.py.

◆ bftypes

list src.gmxio.bftypes = [None, 'BONDS', 'G96BONDS', 'MORSE']

Bonded interaction function types.

Definition at line 174 of file gmxio.py.

◆ dftypes

list src.gmxio.dftypes = [None, 'PDIHS', 'IDIHS', 'RBDIHS', 'PIMPDIHS', 'FOURDIHS', None, None, 'TABDIHS', 'PDIHMULS']

Dihedral interaction function types.

Definition at line 179 of file gmxio.py.

◆ fdict

dictionary src.gmxio.fdict
Initial value:
1 = {
2  'atomtypes' : nftypes,
3  'nonbond_params': pftypes,
4  'pairtypes' : pftypes,
5  'bonds' : bftypes,
6  'bondtypes' : bftypes,
7  'angles' : aftypes,
8  'angletypes' : aftypes,
9  'dihedrals' : dftypes,
10  'dihedraltypes' : dftypes,
11  'virtual_sites2': ['NONE','VSITE2'],
12  'virtual_sites3': ['NONE','VSITE3','VSITE3FD','VSITE3FAD','VSITE3OUT'],
13  'virtual_sites4': ['NONE','VSITE4FD','VSITE4FDN']
14  }

Section -> Interaction type dictionary.

Based on the section you're in and the integer given on the current line, this looks up the 'interaction type' - for example, within bonded interactions there are four interaction types: harmonic, G96, Morse, and quartic interactions.

Definition at line 187 of file gmxio.py.

◆ logger

src.gmxio.logger = getLogger(__name__)

Definition at line 39 of file gmxio.py.

◆ nftypes

list src.gmxio.nftypes = [None, 'VDW', 'VDW_BHAM']

VdW interaction function types.

Definition at line 170 of file gmxio.py.

◆ pdict

dictionary src.gmxio.pdict

Interaction type -> Parameter Dictionary.

A list of supported GROMACS interaction types in force matching. The keys in this dictionary (e.g. 'BONDS','ANGLES') are values in the interaction type dictionary. As the program loops through the force field file, it first looks up the interaction types in 'fdict' and then goes here to do the parameter lookup by field.

Todo:

This needs to become more flexible because the parameter isn't always in the same field. Still need to figure out how to do this.

How about making the PDIHS less ugly?

Definition at line 211 of file gmxio.py.

◆ pftypes

list src.gmxio.pftypes = [None, 'VPAIR', 'VPAIR_BHAM']

Pairwise interaction function types.

Definition at line 172 of file gmxio.py.