Pairs

class Pair(atom_a: Atom, atom_b: Atom, pair_type: int)[source]

Bases: object

Represents interactions between a pair of atoms in a molecular system not reflected by bonds.

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

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

  • pair_type (int) – The type of the pair (e.g., 1-4 interactions).

static from_atoms(atom_a: Atom, atom_b: Atom) Pair[source]

Class method to construct Pair from two Atoms.

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

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

Returns:

the new Pair.

Return type:

Pair

classmethod from_dict(data: Dict[str, int | float], atoms: List['Atom']) Pair[source]

Create a new Pair from a dictionary (such as that created with Pair.to_dict()) and list of Atoms.

The structure of the dictionary is as below: {‘atom_a’: self.atom_a.atom_id, ‘atom_b’: self.atom_b.atom_id, ‘pair_type’: self.pair_type}

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

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

Returns:

a new Pair

Return type:

Pair

classmethod from_line(line: str, atoms: List['Atom']) Pair[source]

Class method to construct Pair from the line of an ITP file.

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

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

Returns:

a new Pair object

Return type:

Pair

remove()[source]

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

to_dict() dict[source]

Convert this Pair 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, ‘pair_type’: self.pair_type}

Returns:

a dictionary containing the id’s of its Atoms and the type of this Pair.

Return type:

dict