-
Notifications
You must be signed in to change notification settings - Fork 22
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
Log charge assignment #1053
Open
mattwthompson
wants to merge
10
commits into
develop
Choose a base branch
from
log-charge-assignment
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+560
−1
Open
Log charge assignment #1053
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0320282
ENH: Initial implementation of charge assignment logging
mattwthompson 754cbe5
TST: Test some cases of charge assignment logging
mattwthompson 3eef5da
TST: Add more test cases
mattwthompson bd9762a
ENH: Log virtual site charge increments
mattwthompson e32ed5f
TST: Test virtual site charge assignment logging
mattwthompson 716eac3
ENH: Log charge increment model charge assignment
mattwthompson 452a7f1
TST: Test cases with ff14SB and protein
mattwthompson 9f7d004
FIX: Fix test
mattwthompson 6099933
DOC: Document charge assignment logging
mattwthompson a3679db
FIX: Fix test
mattwthompson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ using/plugins.md | |
using/status.md | ||
using/edges.md | ||
using/experimental.md | ||
using/advanced.md | ||
|
||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||
# Advanced features | ||||||
|
||||||
## Charge assignment logging | ||||||
|
||||||
SMIRNOFF force fields support several different partial charge assignment methods. These are applied, in the following order | ||||||
|
||||||
1. Look for preset charges from the `charge_from_molecules` argument | ||||||
1. Look for chemical environment matches within the `<LibraryCharges>` section | ||||||
1. Look for chemical environment matches within the `<ChargeIncrementModel>` section | ||||||
1. Try to run AM1-BCC or some variant | ||||||
Comment on lines
+7
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do virtual site charge increments come in here? |
||||||
|
||||||
If a molecule gets charges from one method, attempts to match charges for later methods are skipped. For more on how SMIRNOFF defines this behavior, see [this issue](https://github.com/openforcefield/standards/issues/68) and linked discussions. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think clarifying that this is an escape hatch is useful. |
||||||
|
||||||
Given this complexity, it may be useful to track how each atom actually got charges assigned. Interchange has opt-in logging to track this behavior. This uses the [standard library `logging` module](https://docs.python.org/3/library/logging.html) at the `INFO` level. The easiest way to get started is by adding something like `logging.basicConfig(level=logging.INFO)` to the beginning of a script or program. For example, this script: | ||||||
|
||||||
```python | ||||||
import logging | ||||||
|
||||||
from openff.toolkit import ForceField, Molecule | ||||||
|
||||||
logging.basicConfig(level=logging.INFO) | ||||||
|
||||||
ForceField("openff-2.2.0.offxml").create_interchange( | ||||||
Molecule.from_smiles("CCO").to_topology() | ||||||
) | ||||||
``` | ||||||
|
||||||
will produce output including something like | ||||||
|
||||||
```shell | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 0 | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 1 | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 2 | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 3 | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 4 | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 5 | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 6 | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 7 | ||||||
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bcc, applied to (topology) atom index 8 | ||||||
``` | ||||||
|
||||||
This functionality is only available with SMIRNOFF force fields. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify that this is still following the force field