openforcefield / openff-interchange

A project (and object) for storing, manipulating, and converting molecular mechanics data.
https://docs.openforcefield.org/projects/interchange
MIT License
71 stars 22 forks source link

Dealing with partially/un-parametrized systems #20

Closed mattwthompson closed 1 year ago

mattwthompson commented 4 years ago

Consider the current constructor:

class System(BaseModel):
    """The OpenFF System object."""

    topology: Union[Topology, OpenMMTopology]
    forcefield: Union[ForceField, ParameterHandler] = None
    slot_smirks_map: Dict = None
    smirks_potential_map: Dict = None
    term_collection: SMIRNOFFTermCollection = None
    positions: UnitArray
    box: UnitArray

This is effectively a topology, a handful of ways to deal with force field data and typing information, positions, and box vectors. It may seem counter-intuitive, but in order to facilitate #19 it may be valuable to support states with no parameters, in addition to those with some but not all.

# specify a topology, force field, positions, and box vectors

mysystem = System(topology, positions, box)  # Create an "empty" system

# Apply select ParameterHandler objects, instead of the entire force field all at once
mysystem.apply_parameter_handler(forcefield['vdW'])
mysystem.apply_parameter_handler(forcefield['Bonds'])
...

This may be feasible with a subclass from System or perhaps a common ancestor that specifies the common components. Or maybe composition over inheritance.

mattwthompson commented 4 years ago

https://github.com/openforcefield/openff-system/blob/beea7ae236016c311c7b71b77435d7c5f0522247/system/tests/test_system.py#L124-L143