MM_engines.openmm module

Description

This module defines the ParaMol.MM_engines.openmm.OpenMMEngine class which is the ParaMol wrapper for OpenMM.

class ParaMol.MM_engines.openmm.OpenMMEngine(init_openmm=False, topology_format=None, top_file=None, crd_format=None, crd_file=None, charmm_param_file=None, xml_file=None, platform_name='Reference', system=None, integrator=None, platform=None, context=None, topology=None, integrator_params={'frictionCoeff': Quantity(value=2.0, unit=/picosecond), 'stepSize': Quantity(value=0.001, unit=picosecond), 'temperature': Quantity(value=300.0, unit=kelvin)}, create_system_params={'constraints': None, 'nonbondedCutoff': Quantity(value=1.2, unit=nanometer), 'nonbondedMethod': NoCutoff, 'rigidWater': True})

Bases: object

ParaMol’s OpenMM wrapper.

Parameters
  • init_openmm (bool, optional, default=False) – Whether or not to create the OpenMM system, topology, integrator and context and platform upon creation of an OpenMMEngine instance. Note that the only objects created are the ones not passed as parameters.

  • topology_format (str, optional, default=None) – Available options are “AMBER”, “GROMACS”, “CHARMM”, or “XML”.

  • top_file (str, optional, default=None) – Path to the AMBER, GROMACS or CHARMM topology file.

  • crd_format (str) – Available options are “AMBER”, “GROMACS”, “CHARMM”, or “PDB”.

  • crd_file (str, optional, default=None) – Path to the AMBER, GROMACS or CHARMM coordinates file.

  • charmm_param_file (str) – Path to the CHARMM param file.

  • xml_file (str, optional, default=None) – Path to the .xml OpenMM system file.

  • platform_name (str, optional, default='Reference') – Name of the OpenMM platform.

  • integrator_params (dict, optional, default={'temperature' : 300.0 * unit.kelvin, 'stepSize' : 0.001 * unit.picoseconds, 'frictionCoeff' : 2.0 / unit.picoseconds}) – Keyword arguments passed to the simtk.openmm.openmm.LangevinIntegrator. Ignored if an OpenMM Integrator is provided through the integrator parameter.

  • create_system_params (dict, optional, default={'temperature' : 300.0 * unit.kelvin, 'stepSize' : 0.001 * unit.picoseconds, 'frictionCoeff' : 2.0 / unit.picoseconds}) – Keyword arguments passed to simtk.openmm.app.amberprmtopfile.createSystem. Ignored if an OpenMM System is provided through the system parameter.

  • system (simtk.openmm.openmm.System, optional, default=None) – OpenMM system.

  • integrator (any OpenMM integrator, optional, default=None) – OpenMM integrator.

  • platform (simtk.openmm.openmm.Platform, optional, default=None) – OpenMM platform

  • context (simtk.openmm.openmm.Context, optional, default=None) – OpenMM context.

  • topology (simtk.openmm.app.topology.Topology, optional, default=None) – OpenMM topology.

Variables
  • topology_format (str) – Available options are “AMBER”, “GROMACS”, “CHARMM”, or “XML”.

  • top_file (str) – Path to the AMBER, GROMACS or CHARMM topology file.

  • crd_format (str) – Available options are “AMBER”, “GROMACS”, “CHARMM”, or “PDB”.

  • charmm_param_file (str) – Path to the CHARMM param file.

  • xml_file (str) – Path to the .xml OpenMM system file.

  • crd_file (str) – Path to the AMBER, GROMACS or CHARMM coordinates file.

  • platform_name (str, optional, default='Reference') – Name of the OpenMM platform.

  • system (simtk.openmm.openmm.System) – OpenMM system.

  • integrator (any OpenMM integrator) – OpenMM integrator.

  • platform (simtk.openmm.openmm.Platform) – OpenMM platform

  • context (simtk.openmm.openmm.Context) – OpenMM context.

  • topology (simtk.openmm.app.topology.Topology) – OpenMM topology.

  • force_groups (list of int) – List containing all the force groups present in the system.

  • atom_list (list of str) – List containing the atom symbols of the system. Method get_atom_list has to be run to set this attribute variable.

  • atomic_number_list (list of int) – List containing the atomic numbers of the system. Method get_atomic_numbers has to be run to set this attribute variable.

  • masses_list (list of float) – List containing the masses of the atoms of the system. Method get_masses has to be run to set this attribute variable.

  • n_atoms (int) – Number of atoms of the system.

  • cell (np.ndarray, shape=(3, 3), dtype=float) – Array containing the box size cell vectors (in angstroms). Method get_cell has to be run to set this attribute variable.

  • scnb (float) – 1-4 scaling factor for LJ interactions(0.833333).

  • scee (float) – 1-4 scaling factor for electrostatic interaction

_set_force_groups()

Method that sets the force groups of all forces present in the system accordingly to the mapping defined in the forces_groups_dict dictionary.

Returns

force_groups (list of int) – List containing all the force groups present in the system.

add_torsion_terms(periodicities=[1, 2, 3, 4], phase_default=0.0, v_default=0.0)

Method that adds the torsional terms with periodicities to the OpenMM system ‘PeriodicTorsionForce’ force group.

Parameters
  • periodicities (list of int) – Torsional terms periodicities to be added. If these already exist nothing happens.

  • phase_default – Value of the phase angle upon creation of the torsional term in radians.

  • v_default – Value of the torsion barrier height upon creation of the torsional term in kJ/mol.

Notes

This should be used before creating the ParaMol representation of the Force Field.

Returns

context (simtk.openmm.openmm.Context) – Updated OpenMM Context.

force_groups_dict = {'CMAPTorsionForce': 12, 'CMMotionRemover': 3, 'CustomAngleForce': 6, 'CustomBondForce': 5, 'CustomTorsionForce': 7, 'HarmonicAngleForce': 1, 'HarmonicBondForce': 0, 'NonbondedForce': 11, 'PeriodicTorsionForce': 2}
generate_maxwell_boltzmann_velocities(temperature)

Generate random velocities for the solute.

get_atom_list()

Method that gets a list of the atom symbols.

Returns

atom_list (list of str) – List of the atom symbols of the system.

get_atomic_numbers()

Method that gets a list of the atomic numbers of the system.

Returns

atom_list (list of str) – List of the atomic numbers of the system.

get_cell()

Method that gets the cell vectors.

Returns

cell (np.array) – (3,3) array containing the cell vectors in angstrom but no simtk.units.

get_forces(positions)

Method that, given an array of positions (in nanometers), sets the context atomic positions and computes the forces.

Parameters

positions (list or np.array) – Positions array

Returns

forces (np.array) – (Natoms,3) arrary containing forces in kJ/mol/nm.

get_kinetic_energy(velocities=None)

Method that computes the kinetic energy.

Returns

ekin (float) – Kinetic energy value in kJ/mol.

get_masses()

Method that gets the masses of atoms of the system (in amu).

Returns

masses (list of floats) – Masses of the atoms of the system.

get_number_of_atoms()

Method that gets the number of atoms of the system.

Returns

n_atoms (n_int) – Number of atoms of the system.

get_positions()

Method that gets the Context positions.

Returns

positions (np.array) – Array containing the positions.

get_potential_energy(positions)

Method that, given an array of positions (in nanometers), sets the context atomic positions and computes the potential energy.

Parameters

positions (list or np.array) – Positions array

Returns

epot (float) – Potential energy value in kJ/mol.

get_velocities()

Method that gets the Context velocities.

Returns

velocities (np.array) – Array containing the velocities.

init_openmm(integrator_params=None, create_system_params=None)

Method that initiates OpenMM by creating

Parameters
  • integrator_params (dict) – Keyword arguments passed to the simtk.openmm.openmm.LangevinIntegrator

  • create_system_params (dict) – Keyword arguments passed to simtk.openmm.app.amberprmtopfile.createSystem

Returns

system (simtk.openmm.openmm.System) – OpenMM system created.

minimize_system(tolerance=1, max_iter=0)

Method that minimizes the system’s energy starting from the state stored at the context attribute.

Notes

More information can be found at: https://simtk.org/api_docs/openmm/api3_1/classOpenMM_1_1LocalEnergyMinimizer.html

Parameters
  • tolerance (float) – Specifies how precisely the energy minimum must be located. Minimization will be halted once the root-mean-square value of all force components reaches this tolerance.

  • max_iter (int) – Maximum number of iterations to perform. If this is 0, minimation is continued until the results converge without regard to how many iterations it takes. The default value is 0.

Returns

context (simtk.openmm.openmm.Context) – Updated OpenMM Context.

set_bonded_parameters(force_field_optimizable)

Method that wraps the methods set_harmonic_bond_force_parameters, set_harmonic_angle_force_parameters, and set_periodic_torsion_force_parameters in order to ease the procedure of updating the system’s bonded parameters.

Parameters

force_field_optimizable (dict) – Dictionary that contains as keys force groups names as values and the correspondent ParaMol.Force_field.force_field_term.FFTerm.

Returns

context (simtk.openmm.openmm.Context) – Updated OpenMM Context.

set_harmonic_angle_force_parameters(ff_angle_terms)

Method that updates in the OpenMM system the parameters of the terms belonging to the force group ‘HarmonicAngleForce’.

Parameters

ff_angle_terms (list of ParaMol.Force_field.force_field_term.FFTerm) – List containing instances of ParaMol.Force_field.force_field_term_parameter.Parameter which belong to the force group ‘HarmonicAngleForce’.

Returns

context (simtk.openmm.openmm.Context) – Updated OpenMM Context.

set_harmonic_bond_force_parameters(ff_bond_terms)

Method that updates in the OpenMM system the parameters of the terms belonging to the force group ‘HarmonicBondForce’.

Parameters

ff_bond_terms (list of ParaMol.Force_field.force_field_term.FFTerm) – List containing instances of ParaMol.Force_field.force_field_term_parameter.Parameter which belong to the force group ‘HarmonicBondForce’.

Returns

context (simtk.openmm.openmm.Context) – Updated OpenMM Context.

set_non_bonded_parameters_to_zero()

Method that sets all non bonded parameters to zero, namely sigma, epsilon and charge to zero. This is done for all the particles and exceptions.

Notes

When a Context is created, it decides which interactions need to be calculated as exceptions and which ones are “just exclusions”. Hence, any exception to be included has to be given a nonzero chargeprod initially. Once the Context is created, the number of exceptions can’t be changed. More information: https://github.com/pandegroup/openmm/issues/252

Returns

context (simtk.openmm.openmm.Context) – Updated OpenMM Context.

set_nonbonded_parameters(force_field_optimizable)

Method that updates the non-bonded parameters of the OpenMM system.

Parameters

force_field_optimizable (dict) – Dictionary that contains as keys force groups names as values and the correspondent ParaMol.Force_field.force_field_term.FFTerm.

Returns

context (simtk.openmm.openmm.Context) – Updated OpenMM Context.

set_periodic_torsion_force_parameters(ff_torsion_terms)

Method that updates in the OpenMM system the parameters of the terms belonging to the force group ‘PeriodicTorsionForce’.

Parameters

ff_torsion_terms (list of ParaMol.Force_field.force_field_term.FFTerm) – List containing instances of ParaMol.Force_field.force_field_term_parameter.Parameter which belong to the force group ‘PeriodicTorsionForce’.

Returns

context (simtk.openmm.openmm.Context) – Updated OpenMM Context.

set_positions(positions)

Method that sets the Context positions.

Parameters

positions (np.array) – Array containing the positions.

set_velocities(velocities)

Method that sets the Context positions.

Parameters

velocities (np.array) – Array containing the velocities.

write_system_xml(file_name)

Method that writes the OpenMM system stored in the system attribute to an XML file.

Parameters

file_name (str) – Name of the XML file to be written.

Returns

True if file was closed successfully. False otherwise.