Skip to content

Commit

Permalink
Merge pull request #997 from openforcefield/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
mattwthompson authored Jul 8, 2024
2 parents a649485 + 5854e84 commit 65f36d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ repos:
exclude: openff/interchange/_version.py|setup.py
args: ["--py310-plus"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
rev: v0.5.1
hooks:
- id: ruff
args: ["check", "--select", "NPY"]
Expand All @@ -63,7 +63,7 @@ repos:
args: ["openff/interchange/", "-e", "openff/interchange/_tests/"]
pass_filenames: false
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
rev: 1.18.0
hooks:
- id: blacken-docs
files: ^docs/
Expand Down
13 changes: 7 additions & 6 deletions docs/using/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The [`Interchange.collections`] attribute maps names to the corresponding collec
dict_keys(['Bonds', 'Constraints', 'Angles', 'ProperTorsions',
'ImproperTorsions', 'vdW', 'Electrostatics'])
>>> # Ethane has no improper torsions, so both maps will be empty
>>> interchange.collections['ImproperTorsions'] # doctest: +NORMALIZE_WHITESPACE,+ELLIPSIS
>>> interchange.collections["ImproperTorsions"] # doctest: +NORMALIZE_WHITESPACE,+ELLIPSIS
SMIRNOFFImproperTorsionCollection(type='ImproperTorsions',
expression='k*(1+cos(periodicity*theta-phase))',
key_map={},
Expand All @@ -97,7 +97,7 @@ carbon-hydrogen bonds. It's clear from the SMIRKS codes that atoms 0 and 1 are
the carbon atoms, and atoms 2 through 7 are the hydrogens:

```pycon
>>> interchange.collections['Bonds'].key_map # doctest: +NORMALIZE_WHITESPACE,+ELLIPSIS
>>> interchange.collections["Bonds"].key_map # doctest: +NORMALIZE_WHITESPACE,+ELLIPSIS
{TopologyKey(atom_indices=(0, 1), ...): PotentialKey(id='[#6X4:1]-[#6X4:2]', ...),
TopologyKey(atom_indices=(0, 2), ...): PotentialKey(id='[#6X4:1]-[#1:2]', ...),
TopologyKey(atom_indices=(0, 3), ...): PotentialKey(id='[#6X4:1]-[#1:2]', ...),
Expand All @@ -117,7 +117,7 @@ The bond collection also maps the two potential keys to the appropriate `Potenti
Here we can read off the force constant and length:

```pycon
>>> interchange.collections['Bonds'].potentials # doctest: +NORMALIZE_WHITESPACE,+ELLIPSIS
>>> interchange.collections["Bonds"].potentials # doctest: +NORMALIZE_WHITESPACE,+ELLIPSIS
{PotentialKey(id='[#6X4:1]-[#6X4:2]', ...):
Potential(parameters={'k': <Quantity(529.242972, 'kilocalorie / angstrom ** 2 / mole')>,
'length': <Quantity(1.52190126, 'angstrom')>}, ...),
Expand All @@ -135,14 +135,15 @@ the bonds have been updated:
>>> from openff.units import unit
>>> # Get the potential from the first C-H bond
>>> top_key = TopologyKey(atom_indices=(0, 2))
>>> pot_key = interchange.collections['Bonds'].key_map[top_key]
>>> potential = interchange.collections['Bonds'].potentials[pot_key]
>>> pot_key = interchange.collections["Bonds"].key_map[top_key]
>>> potential = interchange.collections["Bonds"].potentials[pot_key]
>>> # Modify the potential
>>> potential.parameters['length'] = 3.1415926 * unit.nanometer
>>> potential.parameters["length"] = 3.1415926 * unit.nanometer
>>> # Write out the modified interchange to a GROMACS .top file
>>> interchange.to_top("out.top")
>>> with open("out.top") as f:
... print(f.read()) # doctest: +NORMALIZE_WHITESPACE,+ELLIPSIS
...
; Generated by Interchange
...
[ bonds ]
Expand Down

0 comments on commit 65f36d5

Please sign in to comment.