openff-interchange
openff-interchange copied to clipboard
Easier indexing into collections
Description
In [17]: out = ForceField("openff-2.1.0.offxml").create_interchange(
...: Molecule.from_smiles("CCO").to_topology()
...: )
Indexing into a collection to get (physics) parameters with known atom indices requires creating a new instance of a key:
In [18]: out["Bonds"].potentials[out["Bonds"].key_map[BondKey(atom_indices=(0, 1))]]
Out[18]: Potential(parameters={'k': <Quantity(419.986927, 'kilocalorie / angstrom ** 2 / mole')>, 'length': <Quantity(1.52794022, 'angstrom')>}, map_key=None)
It'd be a little more convenient to, at least in simpler cases, allow lookup just by atom indices. That's really all of the information that's stored in some of those key objects:
In [19]: out["Bonds"].potentials[(0, 1)]
I'm not sure if this should return a PotentialKey
or Potential