openff.interchange.Interchange

pydantic model openff.interchange.Interchange[source]

Bases: DefaultModel

A object for storing, manipulating, and converting molecular mechanics data.

Warning

This object is in an early and experimental state and unsuitable for production.

Warning

This API is experimental and subject to change.

Fields
Validators
field handlers: Dict[str, PotentialHandler] = {}
field topology: Topology = None
Validated by
field mdconfig: MDConfig = None
field box: ArrayQuantity = None
Validated by
field positions: ArrayQuantity = None
field velocities: ArrayQuantity = None
validator validate_box  »  box[source]
validator validate_topology  »  topology[source]
classmethod from_smirnoff(force_field: ForceField, topology: Union[Topology, List[Molecule]], box=None, charge_from_molecules: Optional[List[Molecule]] = None, partial_bond_orders_from_molecules: Optional[List[Molecule]] = None, allow_nonintegral_charges: bool = False) Interchange[source]

Create a new object by parameterizing a topology with a SMIRNOFF force field.

Parameters
  • force_field (openff.toolkit.ForceField) – The force field to parameterize the topology with.

  • topology (openff.toolkit.topology.Topology or List[openff.toolkit.topology.Molecule]) – The topology to parameterize, or a list of molecules to construct a topology from and parameterize.

  • box (openff.unit.Quantity, optional) – The box vectors associated with the Interchange. If None, box vectors are taken from the topology, if present.

  • charge_from_molecules (List[openff.toolkit.molecule.Molecule], optional) – If specified, partial charges will be taken from the given molecules instead of being determined by the force field.

  • partial_bond_orders_from_molecules (List[openff.toolkit.molecule.Molecule], optional) – If specified, partial bond orders will be taken from the given molecules instead of being determined by the force field.

  • allow_nonintegral_charges (bool, optional, default=False) – If True, allow molecules to have approximately non-integral charges.

Notes

If the Molecule objects in the topology argument each contain conformers, the returned Interchange object will have its positions set via concatenating the 0th conformer of each Molecule.

Examples

Generate an Interchange object from a single-molecule (OpenFF) topology and OpenFF 2.0.0 “Sage”

>>> from openff.interchange import Interchange
>>> from openff.toolkit.topology import Molecule
>>> from openff.toolkit.typing.engines.smirnoff import ForceField
>>> mol = Molecule.from_smiles("CC")
>>> mol.generate_conformers(n_conformers=1)
>>> sage = ForceField("openff-2.0.0.offxml")
>>> interchange = Interchange.from_smirnoff(topology=[mol], force_field=sage)
>>> interchange
Interchange with 8 atoms, non-periodic topology
visualize(backend: str = 'nglview')[source]

Visualize this Interchange.

This currently only uses NGLview. Other engines may be added in the future.

Parameters

backend (str, default=”nglview”) – The backend to use for visualization. Currently only “nglview” is supported.

Returns

widget – The NGLWidget containing the visualization.

Return type

nglview.NGLWidget

to_gro(file_path: Union[Path, str], writer='internal', decimal: int = 3)[source]

Export this Interchange object to a .gro file.

to_top(file_path: Union[Path, str], writer='internal')[source]

Export this Interchange to a .top file.

to_lammps(file_path: Union[Path, str], writer='internal')[source]

Export this Interchange to a LAMMPS data file.

to_openmm(combine_nonbonded_forces: bool = True)[source]

Export this Interchange to an OpenMM System.

to_openmm_topology(ensure_unique_atom_names: Union[str, bool] = 'residues')[source]

Export components of this Interchange to an OpenMM Topology.

to_prmtop(file_path: Union[Path, str], writer='internal')[source]

Export this Interchange to an Amber .prmtop file.

to_pdb(file_path: Union[Path, str], writer='openmm')[source]

Export this Interchange to a .pdb file.

to_psf(file_path: Union[Path, str])[source]

Export this Interchange to a CHARMM-style .psf file.

to_crd(file_path: Union[Path, str])[source]

Export this Interchange to a CHARMM-style .crd file.

to_inpcrd(file_path: Union[Path, str], writer='internal')[source]

Export this Interchange to an Amber .inpcrd file.

classmethod from_foyer(force_field: FoyerForcefield, topology: Topology, **kwargs) Interchange[source]

Create an Interchange object from a Foyer force field and an OpenFF topology.

Examples

Generate an Interchange object from a single-molecule (OpenFF) topology and the Foyer implementation of OPLS-AA

>>> from openff.interchange import Interchange
>>> from openff.toolkit.topology import Molecule, Topology
>>> from foyer import Forcefield
>>> mol = Molecule.from_smiles("CC")
>>> mol.generate_conformers(n_conformers=1)
>>> top = Topology.from_molecules([mol])
>>> oplsaa = Forcefield(name="oplsaa")
>>> interchange = Interchange.from_foyer(topology=top, force_field=oplsaa)
>>> interchange
Interchange with 8 atoms, non-periodic topology
classmethod from_gromacs(topology_file: Union[Path, str], gro_file: Union[Path, str], reader='intermol') Interchange[source]

Create an Interchange object from GROMACS files.