openff-interchange icon indicating copy to clipboard operation
openff-interchange copied to clipboard

Improve GROMACS parsing

Open mattwthompson opened this issue 2 years ago • 1 comments

Description

Checklist

  • [ ] Add tests
  • [ ] Lint
  • [ ] Update docstrings

mattwthompson avatar Jun 01 '23 22:06 mattwthompson

from rich.pretty import pprint

from openff.interchange import Interchange
from openff.interchange.drivers import get_summary_data
from openff.interchange.drivers.gromacs import _run_gmx_energy

x = Interchange.from_gromacs("complex.top", "complex.gro")

pprint(
    get_summary_data(
        x,
        _engines=(
            "OpenMM",
            "GROMACS",
        ),
    ),
)
"""
│   │   │      Bond       Angle     Torsion  Electrostatics           vdW   RBTorsion
OpenMM   169.766615  893.146719  202.419998  -110750.242984  13047.227256         NaN
GROMACS  169.766602  893.146606  202.777481  -110755.550903  13047.001633  184.087524
"""

x.to_gromacs(prefix="gromacs", decimal=12)

for prefix in ["complex", "gromacs"]:
    pprint(
        _run_gmx_energy(
            top_file=f"{prefix}.top",
            gro_file=f"{prefix}.gro",
            mdp_file="../mdp/default.mdp",
            maxwarn=1,
        )["Per. Imp. Dih."],
    )
"""
<Quantity(50.2272034, 'kilojoule / mole')>
<Quantity(50.2272034, 'kilojoule / mole')>
"""

mattwthompson avatar Jun 01 '23 22:06 mattwthompson