Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM]: Add experimental "auto" idivf #893

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mattwthompson
Copy link
Member

@mattwthompson mattwthompson commented Feb 7, 2024

Description

Requires installing a branch of the same name from the toolkit. Here's a script that demonstrates it:

import openmm
from openff.toolkit import ForceField, Molecule, Quantity, unit
from openff.toolkit.typing.engines.smirnoff.parameters import (
    ParameterList,
    ProperTorsionType,
)


def get_torsion_force_constants(system: openmm.System) -> set[float]:
    k = list()
    for force in system.getForces():
        if isinstance(force, openmm.PeriodicTorsionForce):
            for torison_index in range(force.getNumTorsions()):
                torsion = force.getTorsionParameters(torison_index)
                k.append(torsion[6]._value)

    return set(k)


force_field = ForceField("openff-2.1.0.offxml")

force_field.deregister_parameter_handler("ImproperTorsions")

# This is super illegal
force_field["ProperTorsions"]._parameters = ParameterList(
    [
        ProperTorsionType(
            smirks="[#1:1]-[*:2]~[*:3]-[#1:4]",
            periodicity=[1],
            phase=[0],
            k=[Quantity(10.0, unit.kilojoule_per_mole)],
            idivf=["experimental-auto"],
            id="expt1",
        )
    ]
)

for smiles in ["CC", "CO", "C=C", "C#C"]:
    print(
        smiles,
        get_torsion_force_constants(
            force_field.create_openmm_system(Molecule.from_smiles(smiles).to_topology())
        ),
    )

# CC {1.1111111111111112}
# CO {3.3333333333333335}
# C=C {2.5}
# C#C {10.0}

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Merging #893 (cd88a77) into main (1c4e383) will decrease coverage by 0.11%.
Report is 11 commits behind head on main.
The diff coverage is 60.00%.

Additional details and impacted files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant