Dihedrals

class Dihedral(atom_a: Atom, atom_b: Atom, atom_c: Atom, atom_d: Atom, dihedral_type: Dihedral_type, phase_angle: float = None, force_constant: float = None, multiplicity: int = None, constants: list[float] = None, format: str = 'gromos')[source]

Bases: object

Represents a dihedral angle formed by four atoms in a molecular system.

Parameters:
  • atom_a (Atom) – The first atom involved in the dihedral angle.

  • atom_b (Atom) – The second atom involved in the dihedral angle.

  • atom_c (Atom) – The third atom involved in the dihedral angle.

  • atom_d (Atom) – The fourth atom involved in the dihedral angle.

  • dihedral_type (Dihedral_type) – The type of the dihedral angle (e.g., proper, improper).

  • phase_angle (float) – The phase angle of the dihedral angle in degrees.

  • force_constant (float) – The force constant associated with the dihedral angle.

  • multiplicity (int) – The multiplicity of the dihedral angle.

Raises:
  • ValueError – If unable to find an Angle for the Dihedral.

  • ValueError – If an unknown Dihedral_type is provided.

clone_dihedral_changing(from_atom: Atom, to_atom: Atom) Dihedral[source]

Clone the dihedral, changing the atom that is being replaced. Used during the polymer.extend() algorithm to copy and modify angles where a new Monomer is joined to the Polymer.

Parameters:
  • from_atom (Atom) – the outgoing “Atom”, to be replaced

  • to_atom (Atom) – the incoming “Atom”, will replace the position of the outgoing Atom in this Dihedral

Raises:

ValueError – if ‘from_atom’ is not in the Dihedral

Returns:

the new, modified Dihedral

Return type:

Dihedral

contains_atom(atom: Atom) bool[source]

Check if this Dihedral contains a given Atom.

Parameters:

atom (Atom) – the Atom you wish to check if it is in this Dihedral or not

Returns:

True if the Dihedral contains the given “Atom”, or False if not

Return type:

bool

static find_angles(atom_a: Atom, atom_b: Atom, atom_c: Atom, atom_d: Atom, format: str = 'gromos') tuple[Angle | None, Angle | None][source]

Class method to find Angles present in this Dihedral.

Parameters:
  • atom_a (Atom) – The first atom involved in the Dihedral.

  • atom_b (Atom) – The second atom involved in the Dihedral.

  • atom_c (Atom) – The third atom involved in the Dihedral.

  • atom_d (Atom) – The fourth atom involved in the Dihedral.

  • format (str, defaults to "gromos" for GROMOS forcefields.) – The forcefield the ITP file is formatted as, options are “gromos”, “amber”, “opls” and “charmm”

Returns:

a tuple containing the two Angles involved in this Dihedral

Return type:

tuple[Angle, Angle] or tuple[None, None] if dihedral type is neither proper or improper

static from_atoms(atom_a: Atom, atom_b: Atom, atom_c: Atom, atom_d: Atom, format: str = 'gromos') Dihedral[source]

Class method to construct Dihedral from four Atoms. There must be at least two Angles between these atom pairs that correspond to a valid Dihedral_type configuration.

Parameters:
  • atom_a (Atom) – The first atom involved in the Dihedral.

  • atom_b (Atom) – The second atom involved in the Dihedral.

  • atom_c (Atom) – The third atom involved in the Dihedral

  • atom_d (Atom) – The fourth atom involved in the Dihedral

  • format (str, defaults to "gromos" for GROMOS forcefields.) – The forcefield the ITP file is formatted as, options are “gromos”, “amber”, “opls” and “charmm”

Returns:

the new Dihedral, or None if the Dihedral_type is neither proper or improper

Return type:

Dihedral

classmethod from_dict(data: Dict[str, int | float], atoms: List['Atom'], format: str = 'gromos') Dihedral[source]

Create a new Dihedral from a dictionary (such as that created with Dihedral.to_dict()) and list of Atoms. Will retrieve an existing Dihedral if it already exists between these Atoms.

The structure of the dictionary is as below: {‘atom_a’: self.atom_a.atom_id, ‘atom_b’: self.atom_b.atom_id, ‘atom_c’: self.atom_c.atom_id, ‘atom_d’: self.atom_d.atom_id, ‘dihedral_type’: self.dihedral_type, ‘phase_angle’: self.phase_angle, ‘force_constant’: self.force_constant, ‘multiplicity’: self.multiplicity, ‘constants’ = self.constants}

Parameters:
  • data (dict) – dictionary containing data to make a Dihedral, generate with ‘to_dict()’.

  • atoms (List[Atom]) – list of Atoms. The list may contain more than 4 atoms, as long as the id’s of the four atoms specified in the data dict are present.

  • format (str, defaults to "gromos" for GROMOS forcefields.) – The forcefield the ITP file is formatted as, options are “gromos”, “amber”, “opls” and “charmm”

Returns:

a new Dihedral

Return type:

Dihedral

classmethod from_line(line: str, atoms, format: str = 'gromos') Dihedral[source]

Class method to construct Dihedral from the line of an ITP file and a list of all Atom’s present in the topology.

Parameters:
  • line (str) – the ITP file line

  • atoms (List[Atom]) – list of all Atoms in the Topology

  • format (str, defaults to "gromos" for GROMOS forcefields.) – The forcefield the ITP file is formatted as, options are “gromos”, “amber”, “opls” and “charmm”

Returns:

the new Dihedral

Return type:

Dihedral

other_atoms(atom: Atom) List['Atom'][source]

Check if the given Atom is in this Dihedral and return a list of the other atoms present in this Dihedral (i.e. discluding ‘atom’).

Parameters:

atom (Atom) – the Atom you wish to check if it is in this Dihedral or not

Raises:

ValueError – if ‘atom’ is not in this Dihedral

Returns:

a list of the Atoms in this Dihderal, not including the Atom provided ‘atom’. None if ‘atom’ is not in this Angle.

Return type:

List[Atom]

remove()[source]

Delete self from all related Angles. Used to cleanup and remove attributes during Polymer.extend().

to_dict() dict[source]

Convert this Dihedral to a dictionary representation.

The structure of the dictionary is as below: {‘atom_a’: self.atom_a.atom_id, ‘atom_b’: self.atom_b.atom_id, ‘atom_c’: self.atom_c.atom_id, ‘atom_d’: self.atom_d.atom_id, ‘dihedral_type’: self.dihedral_type, ‘phase_angle’: self.phase_angle, ‘force_constant’: self.force_constant, ‘multiplicity’: self.multiplicity, ‘constants’ = self.constants}

Returns:

a dictionary containing the id’s of its Atoms and other attributes of this Dihedral.

Return type:

dict

class Dihedral_type(*values)[source]

Bases: IntEnum

Enum to track Dihedral types including proper (1) and improper (2).

Proper dihedrals also include: Ryckaert-Bellemans (3), Fourier (5), proper (multiple) (9), tabulated (8) and restricted (10). Improper dihedrals also include: periodic improper (4).

For more information, see GROMACS documentation <https://manual.gromacs.org/nightly/reference-manual/topologies/topology-file-formats.html#tab-topfile2> and view Table 14.

fourier = 5
improper = 2
property is_periodic_planar_constraint: bool
constrains orientation of D WRT the CAB plane. In

other words, the two angles are B-A-C and B-A-D

B |
| |
C -◜A◝ - D |
Returns:

True if this Dihedral is periodic improper, and False if not.

Return type:

bool

Type:

Improper dihedral

property is_planar_constraint: bool
constrains orientation of D WRT the CAB plane. In

other words, the two angles are B-A-C and B-A-D

B |
| |
C -◜A◝ - D |
Returns:

True if this Dihedral is improper, and False if not.

Return type:

bool

Type:

Improper dihedral

property is_rotational_constraint: bool

constrains torsional rotation around the BC bond

A -◟B |
/ |
C◝- D |
Returns:

True if this Dihedral is proper, and False if not.

Return type:

bool

Type:

Proper dihedral

property is_rotational_constraint_with_constants: bool

constrains torsional rotation around the BC bond, but is defined with 6 constants increase of degrees, energy and multiplicity.

A -◟B |
/ |
C◝- D |
Returns:

True if this Dihedral is proper with constants, and False if not.

Return type:

bool

Type:

Proper dihedral

multiple = 9
periodic_improper = 4
proper = 1
restricted = 10
ryckaert_bellemans = 3
tabulated = 8