{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Convert Open Forcefield System to AMBER and GROMACS input files\n", "\n", "The Open Forcefield Toolkit can create parametrized `System` objects that can be natively simulated with OpenMM. This example shows how you can convert such an OpenMM `System` into AMBER prmtop/inpcrd and GROMACS top/gro input files through the ParmEd library." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create an OpenMM System\n", "\n", "We start by loading a PDB file containing one copy of ethanol and cyclohexane. Our goal is to create an OFF `Topology` object describing this system that we can parametrize with the SMIRNOFF-format \"Parsley\" force field.\n", "\n", "The two `Molecule` objects created from the SMILES strings can contain information such as partial charges and stereochemistry that is not included in an OpenMM topology. In this example, partial charges are not explicitly given, and `ForceField` will assign AM1/BCC charges as specified by the \"Parsley\" force field. Note that the Open Force Field Toolkit produces deterministic partial charges that do not depend on the input conformation of parameterized molecules. See the [FAQ](https://open-forcefield-toolkit.readthedocs.io/en/latest/faq.html#the-partial-charges-generated-by-the-toolkit-don-t-seem-to-depend-on-the-molecule-s-conformation-is-this-a-bug) for more information." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from simtk.openmm.app import PDBFile\n", "from openff.toolkit.topology import Molecule, Topology\n", "from openff.toolkit.typing.engines.smirnoff import ForceField" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ethanol = Molecule.from_smiles(\"CCO\")\n", "cyclohexane = Molecule.from_smiles(\"C1CCCCC1\")\n", "\n", "# Obtain the OpenMM Topology object from the PDB file.\n", "pdbfile = PDBFile('1_cyclohexane_1_ethanol.pdb')\n", "omm_topology = pdbfile.topology\n", "\n", "# Create the Open Forcefield Topology.\n", "off_topology = Topology.from_openmm(omm_topology, unique_molecules=[ethanol, cyclohexane])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we parametrize the OFF `Topology` to create an OpenMM `System`. Since ParmEd will run with the `constraints=HBonds` keyword later, we use the _unconstrained_ version of the Parsley force field here." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Load the \"Parsley\" force field.\n", "forcefield = ForceField('openff_unconstrained-1.0.0.offxml')\n", "omm_system = forcefield.create_openmm_system(off_topology)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Convert OpenMM System to AMBER and GROMACS files\n", "\n", "\n", "First, we convert the OpenMM `System` into a ParmEd `Structure`. We'll use the atom positions in the PDB to create the coordinate files.\n", "\n", "