utils

utils

Utilities for building plugins, shell convenience functions and GROMACS related functions

Attributes

Name Description
TopologyAtomAddress Address to an atom in the topology.

Functions

Name Description
check_gmx_version Check for an existing gromacs installation.
get_atominfo_from_atomnrs Use topology atoms section to convert from atomnr to atomtype
get_atomnrs_from_plumedid Convert from plumedid to atomnr, information from the plumed file is used.
get_bondprm_from_atomtypes Returns bond parameters (b0, kb) for a set of two atomtypes.
get_edissoc_from_atomnames Returns dissociation energy E_dissoc for a set of two atomnames.
get_gmx_dir Returns the path to the gromacs installation
get_shell_stdout Run command in shell and capture stdout.
get_task_directories create list of subdirectories that match the tasks.
morse_transition_rate Calculates reaction rate constant for a bond breaking event.
run_gmx Run GROMACS command in shell.
run_shell_cmd Run command in shell.
truncate_sim_files Truncates latest trr, xtc, edr, and gro to the time to a previous

check_gmx_version

utils.check_gmx_version(config)

Check for an existing gromacs installation.

If PLUMED is meant to be used it additionally checks for the keyword ‘MODIFIED’ or ‘plumed’ in the version name.

If slow growth pairs are used, it checks for gromacs version >= 2023.2

get_atominfo_from_atomnrs

utils.get_atominfo_from_atomnrs(atomnrs, top)

Use topology atoms section to convert from atomnr to atomtype

get_atomnrs_from_plumedid

utils.get_atomnrs_from_plumedid(plumedid, plumed)

Convert from plumedid to atomnr, information from the plumed file is used.

Parameters

Name Type Description Default
plumedid str Identifier from a plumed input file (e.g d0). required
plumed Plumed_dict Parsed plumed input file required

get_bondprm_from_atomtypes

utils.get_bondprm_from_atomtypes(atomtypes, ffbonded)

Returns bond parameters (b0, kb) for a set of two atomtypes.

Parameters

Name Type Description Default
atomtypes list[str] Two atomtypes as defined in the respective force field required
ffbonded dict Force field ffbonded.itp file parsed through the rtp parser required

get_edissoc_from_atomnames

utils.get_edissoc_from_atomnames(atomnames, edissoc, residue='_')

Returns dissociation energy E_dissoc for a set of two atomnames.

Parameters

Name Type Description Default
atomnames list[str] Two atomnames as defined in the respective force field required
edissoc dict Parsed file with dissociation energies per bond between two atomtypes or elements required
residue str Residue for which the atomnames are defined '_'

get_gmx_dir

utils.get_gmx_dir(gromacs_alias='gmx')

Returns the path to the gromacs installation

get_shell_stdout

utils.get_shell_stdout(s)

Run command in shell and capture stdout.

get_task_directories

utils.get_task_directories(dir, tasks='all')

create list of subdirectories that match the tasks. If tasks is “all”, all subdirectories are returned.

Parameters

Name Type Description Default
dir Path Directory to search for subdirectories required
tasks Union[list[str], str] List of steps e.g. [“equilibrium”, “production”]. Or a string “all” to return all subdirectories 'all'

morse_transition_rate

utils.morse_transition_rate(
    r_curr
    r_0
    dissociation_energy
    k_f
    frequency_factor=0.288
    temperature=300
)

Calculates reaction rate constant for a bond breaking event.

Uses the Morse potential model for this calculation. For an array of bond distances of the same bond, first calculates the forces on the bond, then the minima and maxima of the shifted Morse potential to get an energy barrier and finally a reaction rate constant using the Arrhenius equation. For intramolecular reactions, the reaction rate constant is equal to the reaction rate.

The calculation should be according to the derivation in the original KIMMDY paper: DOI: 10.1021/acs.jctc.9b00786

Parameters

Name Type Description Default
r_curr list[float] Bond distances for a single bond, typically from a time series. required
r_0 float Equilibrium bond length of the bond. required
dissociation Dissociation energy of the bond. required
k_f float Spring constant of the bond. required
frequency_factor float Prefactor of the Arrhenius equation in [1/ps]. Default value from fitting averaged C_a - N data to gromacs data, see original KIMMDY paper Alternatively 1/2pi sqrt(k/m). 0.288
temperature float Temperature for the Arrhenius equation in GROMACS units. 300

run_gmx

utils.run_gmx(s, cwd=None)

Run GROMACS command in shell.

Adds a ‘-quiet’ flag to the command and checks the return code.

run_shell_cmd

utils.run_shell_cmd(s, cwd=None)

Run command in shell.

truncate_sim_files

utils.truncate_sim_files(files, time, keep_tail=True)

Truncates latest trr, xtc, edr, and gro to the time to a previous point in time.

The files stay in place, the truncated tail is by default kept and renamed to ‘[…xtc].tail’

Parameters

Name Type Description Default
time Optional[float] Time in ps up to which the data should be truncated. required
files TaskFiles TaskFiles to get the latest files. required
Back to top