{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " Note: \n", " Interchange is in the process of replacing ParmEd in many workflows, but it still in an alpha testing phase. Our internal tests indicate it is reliable for many small-molecule systems, but it is not yet reliable for complex, multi-component systems and there are likely still rough edges throughout. Feedback is welcome on the Interchange issue tracker.
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using OpenFF force fields in Amber and GROMACS\n", "\n", "The Open Forcefield Toolkit can create parametrized `openmm.System` objects that can be natively simulated with OpenMM. This example shows the Interchange project can enable parallel workflows using Amber and GROMACS." ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### Preparing an OpenFF Topology\n", "\n", "We start by loading a PDB file containing one copy of ethanol and cyclohexane. Our goal is to create an OpenFF `Topology` object describing this system that we can parametrize with the SMIRNOFF-format \"Sage\" 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 \"Sage\" force field. Note that the OpenFF Toolkit produces 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 openmm import app\n", "\n", "from openff.toolkit import ForceField, Molecule, Topology" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ethanol = Molecule.from_smiles(\"CCO\")\n", "cyclohexane = Molecule.from_smiles(\"C1CCCCC1\")\n", "\n", "# Load the PDB file using OpenMM and save the OpenMM Topology\n", "pdbfile = app.PDBFile(\"1_cyclohexane_1_ethanol.pdb\")\n", "omm_topology = pdbfile.topology\n", "\n", "# Create the OpenFF Topology.\n", "off_topology = Topology.from_openmm(\n", " omm_topology, unique_molecules=[ethanol, cyclohexane]\n", ")\n", "off_topology" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Preparing an OpenFF ForceField\n", "\n", "Once the `ForceField` class is imported, the only decision to make is which force field to use. An exhaustive list of force fields released by the Open Force Field Initiative can be found [here](from openff.toolkit.typing.engines.smirnoff import ForceField\n", ").\n", "\n", "Here we will use force field from the \"Sage\" line." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "forcefield = ForceField(\"openff-2.0.0.offxml\")\n", "forcefield" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Preparing an OpenMM System\n", "\n", "Once a force field and topology have been loaded, an `openmm.System` can be generated natively with the OpenFF Toolkit." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ " >" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "omm_system = forcefield.create_openmm_system(off_topology)\n", "omm_system" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### Preparing an Interchange object\n", "\n", "To exports to engines other than OpenMM, we will make use of the [Interchange](https://openff-interchange.readthedocs.io/) project. There is a high-level `Interchange.from_smirnoff` function that consumes OpenFF Toolkit and ForceField objects and produces an `Interchange` object which can then be exported to formats understood by other molecular simulation engines. This extra step is needed to provide a clean interface between _applied_ parameters and engines. Note also that this step does not require an OpenMM System to be generated; `ForceField.create_openmm_system` does not need to be called to use Amber and GROMACS." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Interchange with 27 atoms, periodic topology" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from openff.interchange import Interchange\n", "\n", "interchange = Interchange.from_smirnoff(\n", " force_field=forcefield,\n", " topology=off_topology,\n", ")\n", "interchange.positions = pdbfile.positions\n", "interchange" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exporting to Amber and GROMACS files\n", "\n", "Once an `Interchange` object has been constructed, its API can be used to export to files understood by GROMACS, Amber, and more." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# Export AMBER files.\n", "interchange.to_prmtop(\"system.prmtop\")\n", "interchange.to_inpcrd(\"system.inpcrd\")\n", "\n", "# Export GROMACS files.\n", "interchange.to_top(\"system.top\")\n", "interchange.to_gro(\"system.gro\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Validating the conversion to Amber files\n", "\n", "The Interchange project includes functions that take in an `Interchange` object and call out to simulation engines to run single-point energy calculations (with no minimization or dynamics) for the purpose of validating the export layer with each engine. Under the hood, each of these functions calls API points like those used above while converting to files understood by each engine. These rely on having each engine installed and accessible in the current `$PATH`." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "from openff.interchange.drivers import get_amber_energies, get_openmm_energies" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "{'Bond': 0.2952878475189209 ,\n", " 'Angle': 155.7012939453125 ,\n", " 'Torsion': 19.563228607177734 ,\n", " 'vdW': 9.6586229795419 ,\n", " 'Electrostatics': -15.220786403489484 }" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "openmm_energies = get_openmm_energies(interchange)\n", "openmm_energies.energies" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " 27 0.0000000e+00\n", " 12.5320000 10.8130000 10.3860000 12.3480000 10.3390000 11.8250000\n", " 10.8800000 10.3650000 12.2440000 10.2560000 11.7390000 12.0200000\n", " 10.4390000 12.2130000 10.5810000 11.9070000 12.1870000 10.1620000\n", " 12.0720000 10.0880000 9.7030000 13.6000000 10.8490000 10.1430000\n", " 12.7450000 9.3240000 11.9320000 12.9300000 10.9820000 12.4970000\n", " 10.3240000 9.6140000 11.6690000 10.7930000 10.0880000 13.3000000\n", " 9.1880000 11.7030000 12.2640000 10.7160000 12.4640000 12.7040000\n", " 9.8580000 11.5710000 9.9090000 10.0430000 13.2300000 10.4740000\n", " 11.9940000 12.4650000 9.1050000 12.4630000 12.9380000 10.7370000\n", " 10.1720000 31.2760000 27.8660000 8.7460000 30.9610000 27.4710000\n", " 8.7520000 30.2640000 26.2340000 10.2040000 31.8150000 28.8180000\n", " 10.7580000 30.3560000 27.9620000 10.6610000 31.8860000 27.0990000\n", " 8.1690000 31.8830000 27.3520000 8.2670000 30.3330000 28.2280000\n", " 7.8260000 30.0790000 26.0110000\n", " 31.8850000 31.8850000 31.8850000 90.0000000 90.0000000 90.0000000\n", "%VERSION VERSION_STAMP = V0001.000 DATE = 03/25/22 16:03:26\n", "%FLAG TITLE\n", "%FORMAT(20a4)\n", "\n", "%FLAG POINTERS\n", "%FORMAT(10I8)\n", " 27 5 18 8 42 7 64 18 0 0\n", " 140 1 8 7 18 4 3 10 1 0\n", " 0 0 0 0 0 0 0 1 27 0\n", " 0 0\n", "%FLAG ATOM_NAME\n", "%FORMAT(20a4)\n", "C1 C2 C3 C4 C5 C6 H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 C7 C8 \n", "O1 H13 H14 H15 H16 H17 H18 \n", "%FLAG CHARGE\n", "%FORMAT(5E16.8)\n", " -1.37596591E+00 -1.37487258E+00 -1.37487258E+00 -1.37487258E+00 -1.37487258E+00\n", " -1.37487258E+00 6.87527403E-01 6.87527403E-01 6.87527403E-01 6.87527403E-01\n", " 6.87527403E-01 6.87527403E-01 6.87527403E-01 6.87527403E-01 6.87527403E-01\n", " 6.87527403E-01 6.87527403E-01 6.87527403E-01 -1.76938530E+00 2.39495687E+00\n", " -1.09577978E+01 8.15630125E-01 8.15630125E-01 8.15630125E-01 3.15610207E-01\n", " 3.15610207E-01 7.25411547E+00\n", "%FLAG ATOMIC_NUMBER\n", "%FORMAT(10I8)\n", " 6 6 6 6 6 6 1 1 1 1\n", " 1 1 1 1 1 1 1 1 6 6\n", " 8 1 1 1 1 1 1\n", "%FLAG MASS\n", "%FORMAT(5E16.8)\n", " 1.20107800E+01 1.20107800E+01 1.20107800E+01 1.20107800E+01 1.20107800E+01\n", " 1.20107800E+01 1.00794700E+00 1.00794700E+00 1.00794700E+00 1.00794700E+00\n", " 1.00794700E+00 1.00794700E+00 1.00794700E+00 1.00794700E+00 1.00794700E+00\n", " 1.00794700E+00 1.00794700E+00 1.00794700E+00 1.20107800E+01 1.20107800E+01\n", " 1.59994300E+01 1.00794700E+00 1.00794700E+00 1.00794700E+00 1.00794700E+00\n", " 1.00794700E+00 1.00794700E+00\n", "%FLAG ATOM_TYPE_INDEX\n", "%FORMAT(10I8)\n", " 1 1 1 1 1 1 2 2 2 2\n", " 2 2 2 2 2 2 2 2 1 1\n", " 3 2 2 2 4 4 5\n", "%FLAG NUMBER_EXCLUDED_ATOMS\n", "%FORMAT(10I8)\n", " 15 14 13 12 11 10 5 4 3 2\n", " 3 2 3 2 3 2 1 1 8 7\n", " 6 4 3 2 2 1 1\n", "%FLAG NONBONDED_PARM_INDEX\n", "%FORMAT(10I8)\n", " 1 2 4 7 11 2 3 5 8 12\n", " 4 5 6 9 13 7 8 9 10 14\n", " 11 12 13 14 15\n", "%FLAG RESIDUE_LABEL\n", "%FORMAT(20a4)\n", "RES \n", "%FLAG RESIDUE_POINTER\n", "%FORMAT(10I8)\n", " 2\n", "%FLAG BOND_FORCE_CONSTANT\n", "%FORMAT(5E16.8)\n", " 2.64621486E+02 3.70046707E+02 3.29969981E+02 5.43526783E+02\n", "%FLAG BOND_EQUIL_VALUE\n", "%FORMAT(5E16.8)\n", " 1.52190126E+00 1.09389949E+00 1.42734396E+00 9.71676331E-01\n", "%FLAG ANGLE_FORCE_CONSTANT\n", "%FORMAT(5E16.8)\n", " 5.32053163E+01 4.87764926E+01 6.50906161E+01\n", "%FLAG ANGLE_EQUIL_VALUE\n", "%FORMAT(5E16.8)\n", " 2.03413912E+00 2.01765472E+00 1.92603856E+00\n", "%FLAG DIHEDRAL_FORCE_CONSTANT\n", "%FORMAT(5E16.8)\n", " 9.22387404E-02 3.15993592E-01 3.24779681E-01 1.04066385E-01 1.91192672E-01\n", " 3.44538215E-01 1.36455637E-01 1.11552567E-01 3.43249022E-01 3.02639017E-01\n", "%FLAG DIHEDRAL_PERIODICITY\n", "%FORMAT(5E16.8)\n", " 3.00000000E+00 2.00000000E+00 1.00000000E+00 3.00000000E+00 3.00000000E+00\n", " 3.00000000E+00 1.00000000E+00 3.00000000E+00 1.00000000E+00 3.00000000E+00\n", "%FLAG DIHEDRAL_PHASE\n", "%FORMAT(5E16.8)\n", " 0.00000000E+00 3.14159265E+00 3.14159265E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", "%FLAG SCEE_SCALE_FACTOR\n", "%FORMAT(5E16.8)\n", " 1.20000000E+00 1.20000000E+00 1.20000000E+00 1.20000000E+00 1.20000000E+00\n", " 1.20000000E+00 1.20000000E+00 1.20000000E+00 1.20000000E+00 1.20000000E+00\n", "%FLAG SCNB_SCALE_FACTOR\n", "%FORMAT(5E16.8)\n", " 2.00000000E+00 2.00000000E+00 2.00000000E+00 2.00000000E+00 2.00000000E+00\n", " 2.00000000E+00 2.00000000E+00 2.00000000E+00 2.00000000E+00 2.00000000E+00\n", "%FLAG SOLTY\n", "%FORMAT(5E16.8)\n", " 0.00000000E+00\n", "%FLAG LENNARD_JONES_ACOEF\n", "%FORMAT(5E16.8)\n", " 9.66338652E+05 9.24328843E+04 7.38518138E+03 6.66507729E+05 5.83759564E+04\n", " 4.40259018E+05 8.33691908E+04 6.54768129E+03 5.22131072E+04 5.79557957E+03\n", " 1.46234885E+01 4.58964736E-01 5.90854038E+00 3.70489465E-01 2.68310183E-08\n", "%FLAG LENNARD_JONES_BCOEF\n", "%FORMAT(5E16.8)\n", " 6.48619732E+02 1.23783906E+02 2.15902147E+01 6.34472236E+02 1.15865057E+02\n", " 6.07363521E+02 1.18714205E+02 2.05290621E+01 1.10655807E+02 1.95039576E+01\n", " 2.60290771E-01 2.84543313E-02 1.94875807E-01 2.58163965E-02 1.15016368E-06\n", "%FLAG BONDS_INC_HYDROGEN\n", "%FORMAT(10I8)\n", " 0 18 2 0 21 2 3 24 2 3\n", " 27 2 6 30 2 6 33 2 9 36\n", " 2 9 39 2 12 42 2 12 45 2\n", " 15 48 2 15 51 2 54 63 2 54\n", " 66 2 54 69 2 57 72 2 57 75\n", " 2 60 78 4\n", "%FLAG BONDS_WITHOUT_HYDROGEN\n", "%FORMAT(10I8)\n", " 0 3 1 0 15 1 3 6 1 6\n", " 9 1 9 12 1 12 15 1 54 57\n", " 1 57 60 3\n", "%FLAG ANGLES_INC_HYDROGEN\n", "%FORMAT(10I8)\n", " 0 3 24 1 0 3 27 1 0 15\n", " 48 1 0 15 51 1 3 0 18 1\n", " 3 0 21 1 3 6 30 1 3 6\n", " 33 1 6 3 24 1 6 3 27 1\n", " 6 9 36 1 6 9 39 1 9 6\n", " 30 1 9 6 33 1 9 12 42 1\n", " 9 12 45 1 12 9 36 1 12 9\n", " 39 1 12 15 48 1 12 15 51 1\n", " 15 0 18 1 15 0 21 1 15 12\n", " 42 1 15 12 45 1 18 0 21 2\n", " 24 3 27 2 30 6 33 2 36 9\n", " 39 2 42 12 45 2 48 15 51 2\n", " 54 57 72 1 54 57 75 1 57 54\n", " 63 1 57 54 66 1 57 54 69 1\n", " 57 60 78 3 60 57 72 1 60 57\n", " 75 1 63 54 66 2 63 54 69 2\n", " 66 54 69 2 72 57 75 2\n", "%FLAG ANGLES_WITHOUT_HYDROGEN\n", "%FORMAT(10I8)\n", " 0 3 6 1 0 15 12 1 3 0\n", " 15 1 3 6 9 1 6 9 12 1\n", " 9 12 15 1 54 57 60 1\n", "%FLAG DIHEDRALS_INC_HYDROGEN\n", "%FORMAT(10I8)\n", " 0 3 6 30 4 0 3 6 33 4\n", " 0 15 12 42 4 0 15 12 45 4\n", " 3 0 15 48 4 3 0 15 51 4\n", " 3 6 9 36 4 3 6 9 39 4\n", " 18 0 3 6 4 21 0 3 6 4\n", " 6 9 12 42 4 6 9 12 45 4\n", " 9 6 3 24 4 9 6 3 27 4\n", " 9 12 15 48 4 9 12 15 51 4\n", " 12 9 6 30 4 12 9 6 33 4\n", " 18 0 15 12 4 21 0 15 12 4\n", " 15 0 3 24 4 15 0 3 27 4\n", " 15 12 9 36 4 15 12 9 39 4\n", " 18 0 3 24 5 18 0 3 27 5\n", " 18 0 15 48 5 18 0 15 51 5\n", " 21 0 3 24 5 21 0 3 27 5\n", " 21 0 15 48 5 21 0 15 51 5\n", " 24 3 6 30 5 24 3 6 33 5\n", " 27 3 6 30 5 27 3 6 33 5\n", " 30 6 9 36 5 30 6 9 39 5\n", " 33 6 9 36 5 33 6 9 39 5\n", " 36 9 12 42 5 36 9 12 45 5\n", " 39 9 12 42 5 39 9 12 45 5\n", " 42 12 15 48 5 42 12 15 51 5\n", " 45 12 15 48 5 45 12 15 51 5\n", " 54 57 60 78 6 54 57 -60 78 7\n", " 60 57 54 63 8 60 57 -54 63 9\n", " 60 57 54 66 8 60 57 -54 66 9\n", " 60 57 54 69 8 60 57 -54 69 9\n", " 63 54 57 72 5 63 54 57 75 5\n", " 66 54 57 72 5 66 54 57 75 5\n", " 69 54 57 72 5 69 54 57 75 5\n", " 72 57 60 78 10 75 57 60 78 10\n", "%FLAG DIHEDRALS_WITHOUT_HYDROGEN\n", "%FORMAT(10I8)\n", " 0 3 6 9 1 0 3 -6 9 2\n", " 0 3 -6 9 3 0 15 -12 9 1\n", " 0 15 -12 9 2 0 15 -12 9 3\n", " 3 0 15 12 1 3 0 -15 12 2\n", " 3 0 -15 12 3 3 6 -9 12 1\n", " 3 6 -9 12 2 3 6 -9 12 3\n", " 15 0 3 6 1 15 0 -3 6 2\n", " 15 0 -3 6 3 6 9 -12 15 1\n", " 6 9 -12 15 2 6 9 -12 15 3\n", "%FLAG EXCLUDED_ATOMS_LIST\n", "%FORMAT(10I8)\n", " 2 6 7 8 3 4 11 12 9 10\n", " 5 15 16 17 18 3 9 10 6 5\n", " 17 18 7 8 4 13 14 11 12 6\n", " 7 8 4 11 12 9 10 5 15 16\n", " 13 14 9 10 5 13 14 11 12 6\n", " 17 18 15 16 11 12 6 15 16 13\n", " 14 7 8 17 18 9 10 17 18 7\n", " 8 13 14 15 16 9 10 17 18 8\n", " 9 10 17 18 11 12 10 11 12 13\n", " 14 12 13 14 15 16 14 15 16 17\n", " 18 16 17 18 18 0 20 22 23 24\n", " 21 27 25 26 21 25 26 22 23 24\n", " 27 22 23 24 27 25 26 25 26 23\n", " 24 25 26 24 25 26 27 26 27 0\n", "%FLAG HBOND_ACOEF\n", "%FORMAT(5E16.8)\n", "\n", "%FLAG HBOND_BCOEF\n", "%FORMAT(5E16.8)\n", "\n", "%FLAG HBCUT\n", "%FORMAT(5E16.8)\n", "\n", "%FLAG AMBER_ATOM_TYPE\n", "%FORMAT(20a4)\n", "C1 C2 C3 C4 C5 C6 H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 C7 C8 \n", "O1 H13 H14 H15 H16 H17 H18 \n", "%FLAG TREE_CHAIN_CLASSIFICATION\n", "%FORMAT(20a4)\n", "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA \n", "BLA BLA BLA BLA BLA BLA BLA \n", "%FLAG JOIN_ARRAY\n", "%FORMAT(10I8)\n", " 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0\n", "%FLAG IROTAT\n", "%FORMAT(10I8)\n", " 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0\n", "%FLAG SOLVENT_POINTERS\n", "%FORMAT(3I8)\n", " 1 1 2\n", "%FLAG ATOMS_PER_MOLECULE\n", "%FORMAT(10I8)\n", " 27\n", "%FLAG BOX_DIMENSIONS\n", "%FORMAT(5E16.8)\n", " 9.00000000E+01 3.18850000E+01 3.18850000E+01 3.18850000E+01\n", "%FLAG RADIUS_SET\n", "%FORMAT(1a80)\n", "0\n", "%FLAG RADII\n", "%FORMAT(5E16.8)\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00\n", "%FLAG SCREEN\n", "%FORMAT(5E16.8)\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00\n", " 0.00000000E+00 0.00000000E+00\n", "%FLAG IPOL\n", "%FORMAT(1I8)\n", " 0\n", "; Generated by Interchange\n", "[ defaults ]\n", "; nbfunc\tcomb-rule\tgen-pairs\tfudgeLJ\tfudgeQQ\n", " 1\t 2\tno 0.500000 0.833333\n", "\n", "[ atomtypes ]\n", ";type, bondingtype, mass, charge, ptype, sigma, epsilon\n", "C1 6 12.01078 0.0000000000000000 A 0.337953176162662 0.4553891161106184\n", "C2 6 12.01078 0.0000000000000000 A 0.337953176162662 0.4553891161106184\n", "C3 6 12.01078 0.0000000000000000 A 0.337953176162662 0.4553891161106184\n", "C4 6 12.01078 0.0000000000000000 A 0.337953176162662 0.4553891161106184\n", "C5 6 12.01078 0.0000000000000000 A 0.337953176162662 0.4553891161106184\n", "C6 6 12.01078 0.0000000000000000 A 0.337953176162662 0.4553891161106184\n", "H1 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H2 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H3 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H4 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H5 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H6 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H7 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H8 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H9 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H10 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H11 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H12 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "C7 6 12.01078 0.0000000000000000 A 0.337953176162662 0.4553891161106184\n", "C8 6 12.01078 0.0000000000000000 A 0.337953176162662 0.4553891161106184\n", "O1 8 15.99943 0.0000000000000000 A 0.2997159987248637 0.8764372596155737\n", "H13 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H14 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H15 1 1.007947 0.0000000000000000 A 0.2644543413268124 0.06602135607582665\n", "H16 1 1.007947 0.0000000000000000 A 0.2583225710839196 0.068656285380106\n", "H17 1 1.007947 0.0000000000000000 A 0.2583225710839196 0.068656285380106\n", "H18 1 1.007947 0.0000000000000000 A 0.0534539230883669 5.157198260534728e-05\n", "\n", "[ moleculetype ]\n", "; Name\tnrexcl\n", "x0\t3\n", "\n", "[ atoms ]\n", ";num, type, resnum, resname, atomname, cgnr, q, m\n", " 1 C1 1 ZBE C1 1 -0.07551000 12.01078000\n", " 2 C2 1 ZBE C2 2 -0.07545000 12.01078000\n", " 3 C3 1 ZBE C3 3 -0.07545000 12.01078000\n", " 4 C4 1 ZBE C4 4 -0.07545000 12.01078000\n", " 5 C5 1 ZBE C5 5 -0.07545000 12.01078000\n", " 6 C6 1 ZBE C6 6 -0.07545000 12.01078000\n", " 7 H1 1 ZBE H1 7 0.03773000 1.00794700\n", " 8 H2 1 ZBE H2 8 0.03773000 1.00794700\n", " 9 H3 1 ZBE H3 9 0.03773000 1.00794700\n", " 10 H4 1 ZBE H4 10 0.03773000 1.00794700\n", " 11 H5 1 ZBE H5 11 0.03773000 1.00794700\n", " 12 H6 1 ZBE H6 12 0.03773000 1.00794700\n", " 13 H7 1 ZBE H7 13 0.03773000 1.00794700\n", " 14 H8 1 ZBE H8 14 0.03773000 1.00794700\n", " 15 H9 1 ZBE H9 15 0.03773000 1.00794700\n", " 16 H10 1 ZBE H10 16 0.03773000 1.00794700\n", " 17 H11 1 ZBE H11 17 0.03773000 1.00794700\n", " 18 H12 1 ZBE H12 18 0.03773000 1.00794700\n", "\n", "[ pairs ]\n", "; ai\taj\tfunct\n", " 2 5 1 0.337953 0.227695\n", " 8 18 1 0.264454 0.0330107\n", " 10 11 1 0.264454 0.0330107\n", " 4 17 1 0.301204 0.0866969\n", " 5 11 1 0.301204 0.0866969\n", " 10 12 1 0.264454 0.0330107\n", " 11 13 1 0.264454 0.0330107\n", " 6 9 1 0.301204 0.0866969\n", " 4 18 1 0.301204 0.0866969\n", " 5 12 1 0.301204 0.0866969\n", " 7 9 1 0.264454 0.0330107\n", " 13 15 1 0.264454 0.0330107\n", " 6 10 1 0.301204 0.0866969\n", " 12 13 1 0.264454 0.0330107\n", " 6 13 1 0.301204 0.0866969\n", " 11 14 1 0.264454 0.0330107\n", " 6 14 1 0.301204 0.0866969\n", " 14 15 1 0.264454 0.0330107\n", " 7 10 1 0.264454 0.0330107\n", " 13 16 1 0.264454 0.0330107\n", " 12 14 1 0.264454 0.0330107\n", " 1 11 1 0.301204 0.0866969\n", " 3 6 1 0.337953 0.227695\n", " 14 16 1 0.264454 0.0330107\n", " 1 15 1 0.301204 0.0866969\n", " 3 7 1 0.301204 0.0866969\n", " 1 12 1 0.301204 0.0866969\n", " 2 13 1 0.301204 0.0866969\n", " 1 16 1 0.301204 0.0866969\n", " 3 8 1 0.301204 0.0866969\n", " 2 14 1 0.301204 0.0866969\n", " 7 17 1 0.264454 0.0330107\n", " 8 9 1 0.264454 0.0330107\n", " 15 17 1 0.264454 0.0330107\n", " 8 10 1 0.264454 0.0330107\n", " 7 18 1 0.264454 0.0330107\n", " 4 9 1 0.301204 0.0866969\n", " 1 4 1 0.337953 0.227695\n", " 5 7 1 0.301204 0.0866969\n", " 15 18 1 0.264454 0.0330107\n", " 4 10 1 0.301204 0.0866969\n", " 2 17 1 0.301204 0.0866969\n", " 3 15 1 0.301204 0.0866969\n", " 5 8 1 0.301204 0.0866969\n", " 9 11 1 0.264454 0.0330107\n", " 2 18 1 0.301204 0.0866969\n", " 16 17 1 0.264454 0.0330107\n", " 9 12 1 0.264454 0.0330107\n", " 3 16 1 0.301204 0.0866969\n", " 8 17 1 0.264454 0.0330107\n", " 16 18 1 0.264454 0.0330107\n", "\n", "[ bonds ]\n", "; ai\taj\tfunc\tr\tk\n", " 1 2 1 0.152190126495 221435.2592902858\n", " 1 6 1 0.152190126495 221435.2592902858\n", " 1 7 1 0.1093899492634 309655.084322414\n", " 1 8 1 0.1093899492634 309655.084322414\n", " 2 3 1 0.152190126495 221435.2592902858\n", " 2 9 1 0.1093899492634 309655.084322414\n", " 2 10 1 0.1093899492634 309655.084322414\n", " 3 4 1 0.152190126495 221435.2592902858\n", " 3 11 1 0.1093899492634 309655.084322414\n", " 3 12 1 0.1093899492634 309655.084322414\n", " 4 5 1 0.152190126495 221435.2592902858\n", " 4 13 1 0.1093899492634 309655.084322414\n", " 4 14 1 0.1093899492634 309655.084322414\n", " 5 6 1 0.152190126495 221435.2592902858\n", " 5 15 1 0.1093899492634 309655.084322414\n", " 5 16 1 0.1093899492634 309655.084322414\n", " 6 17 1 0.1093899492634 309655.084322414\n", " 6 18 1 0.1093899492634 309655.084322414\n", "\n", "\n", "[ angles ]\n", "; ai\taj\tak\tfunc\tr\tk\n", " 2 3 12 1 116.5475862634 445.2220865092856\n", " 9 2 10 1 115.6030999533 408.161690475075\n", " 11 3 12 1 115.6030999533 408.161690475075\n", " 3 2 9 1 116.5475862634 445.2220865092856\n", " 7 1 8 1 115.6030999533 408.161690475075\n", " 3 2 10 1 116.5475862634 445.2220865092856\n", " 5 6 17 1 116.5475862634 445.2220865092856\n", " 6 1 7 1 116.5475862634 445.2220865092856\n", " 13 4 14 1 115.6030999533 408.161690475075\n", " 3 4 5 1 116.5475862634 445.2220865092856\n", " 4 5 6 1 116.5475862634 445.2220865092856\n", " 5 6 18 1 116.5475862634 445.2220865092856\n", " 17 6 18 1 115.6030999533 408.161690475075\n", " 6 1 8 1 116.5475862634 445.2220865092856\n", " 2 3 4 1 116.5475862634 445.2220865092856\n", " 2 1 6 1 116.5475862634 445.2220865092856\n", " 6 5 15 1 116.5475862634 445.2220865092856\n", " 4 3 11 1 116.5475862634 445.2220865092856\n", " 6 5 16 1 116.5475862634 445.2220865092856\n", " 4 3 12 1 116.5475862634 445.2220865092856\n", " 2 1 7 1 116.5475862634 445.2220865092856\n", " 1 2 9 1 116.5475862634 445.2220865092856\n", " 2 1 8 1 116.5475862634 445.2220865092856\n", " 5 4 13 1 116.5475862634 445.2220865092856\n", " 15 5 16 1 115.6030999533 408.161690475075\n", " 1 2 10 1 116.5475862634 445.2220865092856\n", " 3 4 13 1 116.5475862634 445.2220865092856\n", " 1 6 17 1 116.5475862634 445.2220865092856\n", " 5 4 14 1 116.5475862634 445.2220865092856\n", " 1 6 18 1 116.5475862634 445.2220865092856\n", " 3 4 14 1 116.5475862634 445.2220865092856\n", " 4 5 15 1 116.5475862634 445.2220865092856\n", " 4 5 16 1 116.5475862634 445.2220865092856\n", " 1 6 5 1 116.5475862634 445.2220865092856\n", " 2 3 11 1 116.5475862634 445.2220865092856\n", " 1 2 3 1 116.5475862634 445.2220865092856\n", "\n", "[ dihedrals ]\n", "; i j k l func\n", " 4 3 2 10 1 0 0.435414 3\n", " 8 1 6 17 1 0 0.79995 3\n", " 15 5 6 17 1 0 0.79995 3\n", " 15 5 6 18 1 0 0.79995 3\n", " 5 4 3 11 1 0 0.435414 3\n", " 6 1 2 9 1 0 0.435414 3\n", " 12 3 4 13 1 0 0.79995 3\n", " 8 1 6 18 1 0 0.79995 3\n", " 5 4 3 12 1 0 0.435414 3\n", " 6 1 2 10 1 0 0.435414 3\n", " 1 6 5 15 1 0 0.435414 3\n", " 12 3 4 14 1 0 0.79995 3\n", " 3 4 5 6 1 0 0.385927 3\n", " 3 4 5 6 1 180 1.32212 2\n", " 3 4 5 6 1 180 1.35888 1\n", " 1 6 5 16 1 0 0.435414 3\n", " 1 2 3 4 1 0 0.385927 3\n", " 1 2 3 4 1 180 1.32212 2\n", " 1 2 3 4 1 180 1.35888 1\n", " 4 5 6 17 1 0 0.435414 3\n", " 8 1 2 9 1 0 0.79995 3\n", " 13 4 5 15 1 0 0.79995 3\n", " 2 3 4 5 1 0 0.385927 3\n", " 2 3 4 5 1 180 1.32212 2\n", " 2 3 4 5 1 180 1.35888 1\n", " 4 5 6 18 1 0 0.435414 3\n", " 10 2 3 11 1 0 0.79995 3\n", " 13 4 5 16 1 0 0.79995 3\n", " 1 6 5 4 1 0 0.385927 3\n", " 1 6 5 4 1 180 1.32212 2\n", " 1 6 5 4 1 180 1.35888 1\n", " 6 5 4 13 1 0 0.435414 3\n", " 10 2 3 12 1 0 0.79995 3\n", " 6 5 4 14 1 0 0.435414 3\n", " 9 2 3 11 1 0 0.79995 3\n", " 7 1 2 9 1 0 0.79995 3\n", " 3 4 5 15 1 0 0.435414 3\n", " 2 1 6 17 1 0 0.435414 3\n", " 7 1 6 17 1 0 0.79995 3\n", " 9 2 3 12 1 0 0.79995 3\n", " 7 1 6 18 1 0 0.79995 3\n", " 2 1 6 18 1 0 0.435414 3\n", " 11 3 4 13 1 0 0.79995 3\n", " 7 1 2 10 1 0 0.79995 3\n", " 2 3 4 13 1 0 0.435414 3\n", " 3 4 5 16 1 0 0.435414 3\n", " 16 5 6 17 1 0 0.79995 3\n", " 5 6 1 7 1 0 0.435414 3\n", " 11 3 4 14 1 0 0.79995 3\n", " 16 5 6 18 1 0 0.79995 3\n", " 5 6 1 8 1 0 0.435414 3\n", " 3 2 1 6 1 0 0.385927 3\n", " 3 2 1 6 1 180 1.32212 2\n", " 3 2 1 6 1 180 1.35888 1\n", " 14 4 5 15 1 0 0.79995 3\n", " 2 3 4 14 1 0 0.435414 3\n", " 1 2 3 11 1 0 0.435414 3\n", " 14 4 5 16 1 0 0.79995 3\n", " 8 1 2 10 1 0 0.79995 3\n", " 2 1 6 5 1 0 0.385927 3\n", " 2 1 6 5 1 180 1.32212 2\n", " 2 1 6 5 1 180 1.35888 1\n", " 4 3 2 9 1 0 0.435414 3\n", " 3 2 1 7 1 0 0.435414 3\n", " 1 2 3 12 1 0 0.435414 3\n", " 3 2 1 8 1 0 0.435414 3\n", "\n", "[ moleculetype ]\n", "; Name\tnrexcl\n", "x1\t3\n", "\n", "[ atoms ]\n", ";num, type, resnum, resname, atomname, cgnr, q, m\n", " 1 C7 1 ZXQ C7 1 -0.09710000 12.01078000\n", " 2 C8 1 ZXQ C8 2 0.13143000 12.01078000\n", " 3 O1 1 ZXQ O1 3 -0.60134000 15.99943000\n", " 4 H13 1 ZXQ H13 4 0.04476000 1.00794700\n", " 5 H14 1 ZXQ H14 5 0.04476000 1.00794700\n", " 6 H15 1 ZXQ H15 6 0.04476000 1.00794700\n", " 7 H16 1 ZXQ H16 7 0.01732000 1.00794700\n", " 8 H17 1 ZXQ H17 8 0.01732000 1.00794700\n", " 9 H18 1 ZXQ H18 9 0.39809000 1.00794700\n", "\n", "[ pairs ]\n", "; ai\taj\tfunct\n", " 8 9 1 0.155888 0.000940843\n", " 4 8 1 0.261388 0.033663\n", " 3 6 1 0.282085 0.120274\n", " 1 9 1 0.195704 0.00242308\n", " 3 4 1 0.282085 0.120274\n", " 5 8 1 0.261388 0.033663\n", " 7 9 1 0.155888 0.000940843\n", " 6 7 1 0.261388 0.033663\n", " 5 7 1 0.261388 0.033663\n", " 6 8 1 0.261388 0.033663\n", " 4 7 1 0.261388 0.033663\n", " 3 5 1 0.282085 0.120274\n", "\n", "[ bonds ]\n", "; ai\taj\tfunc\tr\tk\n", " 1 2 1 0.152190126495 221435.2592902858\n", " 1 4 1 0.1093899492634 309655.084322414\n", " 1 5 1 0.1093899492634 309655.084322414\n", " 1 6 1 0.1093899492634 309655.084322414\n", " 2 3 1 0.1427343958716 276118.8797485491\n", " 2 7 1 0.1093899492634 309655.084322414\n", " 2 8 1 0.1093899492634 309655.084322414\n", " 3 9 1 0.09716763312559 454823.2121721368\n", "\n", "\n", "[ angles ]\n", "; ai\taj\tak\tfunc\tr\tk\n", " 1 2 7 1 116.5475862634 445.2220865092856\n", " 3 2 8 1 116.5475862634 445.2220865092856\n", " 2 1 5 1 116.5475862634 445.2220865092856\n", " 1 2 8 1 116.5475862634 445.2220865092856\n", " 4 1 5 1 115.6030999533 408.161690475075\n", " 2 3 9 1 110.3538806181 544.678275491328\n", " 2 1 6 1 116.5475862634 445.2220865092856\n", " 5 1 6 1 115.6030999533 408.161690475075\n", " 7 2 8 1 115.6030999533 408.161690475075\n", " 1 2 3 1 116.5475862634 445.2220865092856\n", " 3 2 7 1 116.5475862634 445.2220865092856\n", " 4 1 6 1 115.6030999533 408.161690475075\n", " 2 1 4 1 116.5475862634 445.2220865092856\n", "\n", "[ dihedrals ]\n", "; i j k l func\n", " 3 2 1 6 1 0 0.466736 3\n", " 3 2 1 6 1 0 1.43615 1\n", " 7 2 3 9 1 0 1.26624 3\n", " 6 1 2 7 1 0 0.79995 3\n", " 5 1 2 8 1 0 0.79995 3\n", " 4 1 2 7 1 0 0.79995 3\n", " 3 2 1 4 1 0 0.466736 3\n", " 3 2 1 4 1 0 1.43615 1\n", " 3 2 1 5 1 0 0.466736 3\n", " 3 2 1 5 1 0 1.43615 1\n", " 6 1 2 8 1 0 0.79995 3\n", " 4 1 2 8 1 0 0.79995 3\n", " 8 2 3 9 1 0 1.26624 3\n", " 1 2 3 9 1 0 1.44155 3\n", " 1 2 3 9 1 0 0.57093 1\n", " 5 1 2 7 1 0 0.79995 3\n", "\n", "[ system ]\n", "; name \n", "System name\n", "\n", "[ molecules ]\n", "; Compound\tnmols\n", "x0\t1\n", "x1\t1\n", "\n", "Generated by Interchange\n", "27\n", " 1ZBE C1 1 1.25320000 1.08130000 1.03860000\n", " 1ZBE C2 2 1.23480000 1.03390000 1.18250000\n", " 1ZBE C3 3 1.08800000 1.03650000 1.22440000\n", " 1ZBE C4 4 1.02560000 1.17390000 1.20200000\n", " 1ZBE C5 5 1.04390000 1.22130000 1.05810000\n", " 1ZBE C6 6 1.19070000 1.21870000 1.01620000\n", " 1ZBE H1 7 1.20720000 1.00880000 0.97030000\n", " 1ZBE H2 8 1.36000000 1.08490000 1.01430000\n", " 1ZBE H3 9 1.27450000 0.93240000 1.19320000\n", " 1ZBE H4 10 1.29300000 1.09820000 1.24970000\n", " 1ZBE H5 11 1.03240000 0.96140000 1.16690000\n", " 1ZBE H6 12 1.07930000 1.00880000 1.33000000\n", " 1ZBE H7 13 0.91880000 1.17030000 1.22640000\n", " 1ZBE H8 14 1.07160000 1.24640000 1.27040000\n", " 1ZBE H9 15 0.98580000 1.15710000 0.99090000\n", " 1ZBE H10 16 1.00430000 1.32300000 1.04740000\n", " 1ZBE H11 17 1.19940000 1.24650000 0.91050000\n", " 1ZBE H12 18 1.24630000 1.29380000 1.07370000\n", " 1ZXQ C7 19 1.01720000 3.12760000 2.78660000\n", " 1ZXQ C8 20 0.87460000 3.09610000 2.74710000\n", " 1ZXQ O1 21 0.87520000 3.02640000 2.62340000\n", " 1ZXQ H13 22 1.02040000 3.18150000 2.88180000\n", " 1ZXQ H14 23 1.07580000 3.03560000 2.79620000\n", " 1ZXQ H15 24 1.06610000 3.18860000 2.70990000\n", " 1ZXQ H16 25 0.81690000 3.18830000 2.73520000\n", " 1ZXQ H17 26 0.82670000 3.03330000 2.82280000\n", " 1ZXQ H18 27 0.78260000 3.00790000 2.60110000\n", " 3.1885000 3.1885000 3.1885000\n" ] }, { "data": { "text/plain": [ "{'Bond': 0.0741 ,\n", " 'Angle': 37.2023 ,\n", " 'Torsion': 4.6778 ,\n", " 'vdW': 9.7231976 ,\n", " 'Electrostatics': -15.217207999999996 }" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "!cat system.inpcrd\n", "!cat system.prmtop\n", "!cat system.top\n", "!cat system.gro\n", "amber_energies = get_amber_energies(interchange)\n", "amber_energies.energies" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Appendix: Validating the conversion to GROMACS and LAMMPS files\n", "\n", "If GROMACS and/or LAMMPS are installed on your machine, the same comparisons can also take place with those engines. They are available via `conda` by running a command like:\n", "\n", "```conda install \"gromacs >=2021=nompi*\" lammps -c conda-forge```" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "from distutils.spawn import find_executable\n", "from pprint import pprint\n", "\n", "from openff.interchange.drivers import get_gromacs_energies, get_lammps_energies" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'Angle': ,\n", " 'Bond': ,\n", " 'Electrostatics': ,\n", " 'Torsion': ,\n", " 'vdW': }\n" ] } ], "source": [ "if find_executable(\"lmp_serial\"):\n", " pprint(get_lammps_energies(interchange).energies)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "if find_executable(\"gmx\"):\n", " pprint(get_gromacs_energies(interchange).energies)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, there is a helper function `get_summary_data` that will attempt to run drivers of each engine. A summary reported is prepared as a Pandas `DataFrame`." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BondAngleTorsionvdWElectrostatics
OpenMM0.295288155.70129419.5632299.658623-15.220786
Amber0.310034155.65442319.5719159.723198-15.217208
LAMMPS0.440418155.70134319.5632339.630999-15.224689
\n", "
" ], "text/plain": [ " Bond Angle Torsion vdW Electrostatics\n", "OpenMM 0.295288 155.701294 19.563229 9.658623 -15.220786\n", "Amber 0.310034 155.654423 19.571915 9.723198 -15.217208\n", "LAMMPS 0.440418 155.701343 19.563233 9.630999 -15.224689" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from openff.interchange.drivers.all import get_summary_data\n", "\n", "get_summary_data(interchange)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.12" } }, "nbformat": 4, "nbformat_minor": 4 }