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

Add ChargeIncrementModelHandler #471

Merged
merged 86 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
28cb5a6
Fix typo in chargeincrementhandler example offxml
j-wags Dec 4, 2019
0c58167
Add basic tests for chargeincrementmodelhandler
j-wags Dec 4, 2019
c0308f0
Fix smirnoff docs CIM example
j-wags Dec 5, 2019
5f7dae8
Update basic CIMH tests
j-wags Dec 5, 2019
28680ba
Add method compatibility matrix to ATTKW
j-wags Dec 5, 2019
3a26190
Implemented partial charge method resolution test
j-wags Dec 7, 2019
643a750
standardize partial charge calc apis
j-wags Dec 7, 2019
1e369b4
standardize partial charge calc "raises"es
j-wags Dec 7, 2019
3ff5783
fix variable name
j-wags Dec 7, 2019
71a097f
Resolve #348
j-wags Dec 11, 2019
7268ec1
remove qc_method from CIM API, default n_confs=1
j-wags Dec 11, 2019
4d865f7
Resolve #465
j-wags Dec 11, 2019
c9d63b2
Update tests for #348
j-wags Dec 11, 2019
96629df
Correct error types in charge calc, add tests for new charge methods
j-wags Dec 11, 2019
c44d990
Add builtintoolkitwrapper and tests
j-wags Dec 11, 2019
6153fdd
pass partial_charge_method through in molecule.calc_part_charges
j-wags Dec 11, 2019
880faec
update release history
j-wags Dec 11, 2019
ddd69e8
update CIM spec docs to default n_confs 1 and remove quantum method
j-wags Dec 12, 2019
84fd4ea
Fix CIM spec example
j-wags Dec 14, 2019
2611145
Enforce use of dict to prevent chargeincrement SMIRKS from getting in…
j-wags Dec 14, 2019
0711222
Finish initial implementation of chargeincrementmodelhandler
j-wags Dec 14, 2019
e3e47fb
add create_reversed_ethanol and CIM test
j-wags Dec 14, 2019
8826d06
fix tests for changes in #465. Atom.formal_charge accepts int or Quant
j-wags Dec 19, 2019
3f6fbb8
clarify reason for overriding transformed_dict_cls in CIMH
j-wags Dec 19, 2019
f3840fb
Fix tests for new API/defaults to CIMH
j-wags Dec 19, 2019
6a22604
Update error handling in molecule.__init__ for more specific exceptions
j-wags Dec 19, 2019
12aba0e
Relax charge sum tolerance in tests
j-wags Dec 21, 2019
b8b7b31
Merge branch 'master' into chargeincrementhandler
j-wags Dec 21, 2019
8ac2cfb
Drafting release history for CIMH
j-wags Jan 6, 2020
8fb0cd7
Extend input validation tests for CIMH
j-wags Jan 6, 2020
cc600d5
Make ToolkitRegistry.call handle NotImplementedErrors gracefully
j-wags Jan 6, 2020
148b0eb
Merge remote-tracking branch 'origin/chargeincrementhandler' into cha…
j-wags Jan 6, 2020
be72b0a
Merge branch 'master' into chargeincrementhandler
j-wags Jan 7, 2020
8cc98dd
add compute_partial_charges kwarg strict_n_conformers
j-wags Jan 15, 2020
66f7309
fix syntax errors
j-wags Jan 16, 2020
5a42f4b
Merge branch 'master' into chargeincrementhandler
j-wags Feb 21, 2020
9eb15fd
Add compute_partial_charges_am1bcc deprecation warning
j-wags Feb 22, 2020
5ad3a44
switch ambertools partial charge calc to use subprocess
j-wags Feb 22, 2020
c762a3b
merge and resolve conflicts
j-wags Feb 24, 2020
5fb3fac
change compute_partial_charges to assign_partial_charges
j-wags Feb 25, 2020
0c3e5ec
Add rms_cutoff kwarg to generate_conformers
j-wags Feb 25, 2020
0b20a49
Fix to_qcschema formal charge unit
j-wags Feb 25, 2020
75c9e99
rename tests for assign_partial_charges, add tests for rms_cutoff
j-wags Feb 25, 2020
5293fbb
implement assign_partial_charges for toolkits, major refactors, tests
j-wags Feb 29, 2020
c0f7f70
Merge branch 'master' into chargeincrementhandler
j-wags Mar 3, 2020
14e951d
Merge branch 'master' into chargeincrementhandler
j-wags Apr 14, 2020
110a97d
document deduplication scheme for chargeincrementmodel
j-wags Apr 21, 2020
5d6c4c4
progress commit
j-wags Apr 24, 2020
ed09582
add tests for different behaviors of cimh matches/hierarchy
j-wags Apr 28, 2020
5fc2260
allow parameterhandlers to be initialized with no parameters
j-wags Apr 29, 2020
973b29c
change error to warning if CIMH or TKAM1BCCH cant assign charges
j-wags Apr 29, 2020
89cc2d2
add charge method hierarchy test for CIMH (comes after TKAM1BCCH)
j-wags Apr 29, 2020
1b55c4c
enforce n_tagged_atoms==idxed_attrs, behavior tests for CIMH and LibChgH
j-wags Apr 29, 2020
c79005c
add conformer dependence tests
j-wags May 1, 2020
9f898d6
Have individual toolkitwrappers raise specific exception types, but t…
j-wags May 28, 2020
9eceb31
update qcschema input to have unitless total charge
j-wags May 28, 2020
ba95d59
Merge branch 'master' into chargeincrementhandler
j-wags May 28, 2020
9bd877e
add raise_first_error kwarg to TKR.call
j-wags May 28, 2020
7021722
Update tests and properties for formal charge units
j-wags May 28, 2020
cca65e9
make toolkit read and write formats INSTANCE attributes of TKWs
j-wags May 28, 2020
2631a36
switch lc and ci validation to use minimal chemicalenvironment class
j-wags May 28, 2020
4d21f4f
drafting release notes
j-wags May 29, 2020
131d566
Further updates to releasenotes
j-wags May 30, 2020
f2a3398
fix LGTM complaints
j-wags Jun 2, 2020
c5758d2
molecule.gen_confs with kwarg n_confs=0 now doesn't use tkw, but inst…
j-wags Jun 2, 2020
73f9a6f
update expected error types for mol.assign_partial_charges
j-wags Jun 2, 2020
70ad705
fix exception types expected in oe tests
j-wags Jun 2, 2020
3278f78
refactored ToolkitRegistry.call to use raise_exception_types
j-wags Jun 3, 2020
783a11b
toolkit.py cleanup and fix test_partial_charge_res toolkit avail checks
j-wags Jun 3, 2020
1afcd66
attkw checks whether rdkit is available
j-wags Jun 3, 2020
cb3a423
fix some imports
j-wags Jun 3, 2020
216ac97
add temp_cd back (#595) for antechamber methods
j-wags Jun 4, 2020
dd79fb2
make toolkitam1bcc charge calc errors non fatal
j-wags Jun 4, 2020
61143f9
make it so compute_partial_charges_am1bcc still returns charges as we…
j-wags Jun 5, 2020
a59d77e
Cleanups in preparation for review
j-wags Jun 9, 2020
0a465fc
simplify release notes
j-wags Jun 9, 2020
e89687a
fix docstring example
j-wags Jun 9, 2020
3d3c9ef
Merge branch 'master' into chargeincrementhandler
j-wags Jun 9, 2020
92c0df4
Small cosmetic fixes
dotsdl Jun 16, 2020
982fa49
Merge branch 'master' into chargeincrementhandler
j-wags Jun 17, 2020
d7e092a
Update openforcefield/typing/engines/smirnoff/parameters.py
j-wags Jun 17, 2020
49d4dc3
add fixes per Dotson review
j-wags Jun 18, 2020
fff6051
Merge remote-tracking branch 'origin/chargeincrementhandler' into cha…
j-wags Jun 18, 2020
e363a70
add more fixes per Dotson review
j-wags Jun 19, 2020
e910488
Merge branch 'master' into chargeincrementhandler
j-wags Jun 19, 2020
efe98bb
Merge branch 'master' into chargeincrementhandler
j-wags Jun 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions The-SMIRNOFF-force-field-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,30 +225,27 @@ For example, to ensure water molecules are assigned partial charges for [TIP3P](

### `<ChargeIncrementModel>`: Small molecule and fragment charges

.. warning:: This functionality is not yet implemented and will appear in a future version of the toolkit. This area of the SMIRNOFF spec is under further consideration. Please see `Issue 208 on the Open Force Field Toolkit issue tracker <https://github.com/openforcefield/openforcefield/issues/208>`_.

In keeping with the AMBER force field philosophy, especially as implemented in small molecule force fields such as [GAFF](http://ambermd.org/antechamber/gaff.html), [GAFF2](https://mulan.swmed.edu/group/gaff.php), and [parm@Frosst](http://www.ccl.net/cca/data/parm_at_Frosst/), partial charges for small molecules are usually assigned using a quantum chemical method (usually a semiempirical method such as [AM1](https://en.wikipedia.org/wiki/Austin_Model_1)) and a [partial charge determination scheme](https://en.wikipedia.org/wiki/Partial_charge) (such as [CM2](http://doi.org/10.1021/jp972682r) or [RESP](http://doi.org/10.1021/ja00074a030)), then subsequently corrected via charge increment rules, as in the highly successful [AM1-BCC](https://dx.doi.org/10.1002/jcc.10128) approach.

Here is an example:
```XML
<ChargeIncrementModel version="0.3" number_of_conformers="10" quantum_chemical_method="AM1" partial_charge_method="CM2">
<ChargeIncrementModel version="0.3" number_of_conformers="1" partial_charge_method="AM1-Mulliken">
j-wags marked this conversation as resolved.
Show resolved Hide resolved
<!-- A fractional charge can be moved along a single bond -->
<ChargeIncrement smirks="[#6X4:1]-[#6X3a:2]" chargeincrement1="-0.0073*elementary_charge" chargeincrement2="+0.0073*elementary_charge"/>
<ChargeIncrement smirks="[#6X4:1]-[#6X3a:2]-[#7]" chargeincrement1="+0.0943*elementary_charge" chargeincrement2="-0.0943*elementary_charge"/>
<ChargeIncrement smirks="[#6X4:1]-[#8:2]" chargeincrement1="-0.0718*elementary_charge" chargeincrement2="+0.0718*elementary_charge"/>
<!--- Alternatively, factional charges can be redistributed among any number of bonded atoms -->
<ChargeIncrement smirks="[N:1](H:2)(H:3)" chargeincrement1="+0.02*elementary_charge" chargeincrement2="-0.01*elementary_charge" chargeincrement3="-0.01*elementary_charge"/>
<ChargeIncrement smirks="[#6X4:1]-[#6X3a:2]" charge_increment1="-0.0073*elementary_charge" charge_increment2="0.0073*elementary_charge"/>
<ChargeIncrement smirks="[#6X4:1]-[#6X3a:2]-[#7]" charge_increment1="0.0943*elementary_charge" charge_increment2="-0.0943*elementary_charge"/>
<ChargeIncrement smirks="[#6X4:1]-[#8:2]" charge_increment1="-0.0718*elementary_charge" charge_increment2="0.0718*elementary_charge"/>
<!--- Alternatively, fractional charges can be redistributed among any number of bonded atoms -->
<ChargeIncrement smirks="[N:1]([H:2])([H:3])" charge_increment1="0.02*elementary_charge" charge_increment2="-0.01*elementary_charge" charge_increment3="-0.01*elementary_charge"/>
</ChargeIncrementModel>
```
The sum of formal charges for the molecule or fragment will be used to determine the total charge the molecule or fragment will possess.

`<ChargeIncrementModel>` provides several optional attributes to control its behavior:
* The `number_of_conformers` attribute (default: `"10"`) is used to specify how many conformers will be generated for the molecule (or capped fragment) prior to charging.
* The `quantum_chemical_method` attribute (default: `"AM1"`) is used to specify the quantum chemical method applied to the molecule or capped fragment.
* The `partial_charge_method` attribute (default: `"CM2"`) is used to specify how uncorrected partial charges are to be generated from the quantum chemical wavefunction. Later additions will add restrained electrostatic potential fitting (RESP) capabilities.
* The `number_of_conformers` attribute (default: `"1"`) is used to specify how many conformers will be generated for the molecule (or capped fragment) prior to charging.
* The `partial_charge_method` attribute (default: `"AM1-Mulliken"`) is used to specify how uncorrected partial charges are to be generated. Later additions will add restrained electrostatic potential fitting (RESP) capabilities.

The `<ChargeIncrement>` tags specify how the quantum chemical derived charges are to be corrected to produce the final charges.
The `chargeincrement#` attributes specify how much the charge on the associated tagged atom index (replacing `#`) should be modified.
The `charge_increment#` attributes specify how much the charge on the associated tagged atom index (replacing `#`) should be modified.
The sum of charge increments should equal zero.

Note that atoms for which library charges have already been applied are excluded from charging via `<ChargeIncrementModel>`.
Expand Down Expand Up @@ -654,7 +651,7 @@ We will support the following different types or geometries of off-center charge
- `TrivalentLonePair`: This is suitable for planar or tetrahedral nitrogen lone pairs; a charge site `S` lies above the central atom (e.g. nitrogen, blue) a distance `d` along the vector perpendicular to the plane of the three connected atoms (2,3,4). With positive values of `d` the site lies above the nitrogen and with negative values it lies below the nitrogen.
![Trivalent lone pair virtual site](figures/vsite_trivalent.jpg)

Each virtual site receives charge which is transferred from the desired atoms specified in the SMIRKS pattern via a `chargeincrement#` parameter, e.g., if `chargeincrement1=+0.1*elementary_charge` then the virtual site will receive a charge of -0.1 and the atom labeled `1` will have its charge adjusted upwards by +0.1.
Each virtual site receives charge which is transferred from the desired atoms specified in the SMIRKS pattern via a `charge_increment#` parameter, e.g., if `charge_increment1=+0.1*elementary_charge` then the virtual site will receive a charge of -0.1 and the atom labeled `1` will have its charge adjusted upwards by +0.1.
N may index any indexed atom.
Increments which are left unspecified default to zero.
Additionally, each virtual site can bear Lennard-Jones parameters, specified by `sigma` and `epsilon` or `rmin_half` and `epsilon`.
Expand All @@ -665,23 +662,23 @@ In the SMIRNOFF format, these are encoded as:
<VirtualSites version="0.3">
<!-- sigma hole for halogens: "distance" denotes distance along the 2->1 bond vector, measured from atom 2 -->
<!-- Specify that 0.2 charge from atom 1 and 0.1 charge units from atom 2 are to be moved to the virtual site, and a small Lennard-Jones site is to be added (sigma = 0.1*angstroms, epsilon=0.05*kcal/mol) -->
<VirtualSite type="BondCharge" smirks="[Cl:1]-[C:2]" distance="0.30*angstrom" chargeincrement1="+0.2*elementary_charge" chargeincrement2="+0.1*elementary_charge" sigma="0.1*angstrom" epsilon="0.05*kilocalories_per_mole" />
<VirtualSite type="BondCharge" smirks="[Cl:1]-[C:2]" distance="0.30*angstrom" charge_increment1="+0.2*elementary_charge" charge_increment2="+0.1*elementary_charge" sigma="0.1*angstrom" epsilon="0.05*kilocalories_per_mole" />
<!-- Charge increments can extend out to as many atoms as are labeled, e.g. with a third atom: -->
<VirtualSite type="BondCharge" smirks="[Cl:1]-[C:2]~[*:3]" distance="0.30*angstrom" chargeincrement1="+0.1*elementary_charge" chargeincrement2="+0.1*elementary_charge" chargeincrement3="+0.05*elementary_charge" sigma="0.1*angstrom" epsilon="0.05*kilocalories_per_mole" />
<VirtualSite type="BondCharge" smirks="[Cl:1]-[C:2]~[*:3]" distance="0.30*angstrom" charge_increment1="+0.1*elementary_charge" charge_increment2="+0.1*elementary_charge" charge_increment3="+0.05*elementary_charge" sigma="0.1*angstrom" epsilon="0.05*kilocalories_per_mole" />
<!-- monovalent lone pairs: carbonyl -->
<!-- X denotes the charge site, and P denotes the projection of the charge site into the plane of 1 and 2. -->
<!-- inPlaneAngle is angle point P makes with 1 and 2, i.e. P-1-2 -->
<!-- outOfPlaneAngle is angle charge site (X) makes out of the plane of 2-1-3 (and P) measured from 1 -->
<!-- Since unspecified here, sigma and epsilon for the virtual site default to zero -->
<VirtualSite type="MonovalentLonePair" smirks="[O:1]=[C:2]-[*:3]" distance="0.30*angstrom" outOfPlaneAngle="0*degree" inPlaneAngle="120*degree" chargeincrement1="+0.2*elementary_charge" />
<VirtualSite type="MonovalentLonePair" smirks="[O:1]=[C:2]-[*:3]" distance="0.30*angstrom" outOfPlaneAngle="0*degree" inPlaneAngle="120*degree" charge_increment1="+0.2*elementary_charge" />
<!-- divalent lone pair: pyrimidine, TIP4P, TIP5P -->
<!-- The atoms 2-1-3 define the X-Y plane, with Z perpendicular. If outOfPlaneAngle is 0, the charge site is a specified distance along the in-plane vector which bisects the angle left by taking 360 degrees minus angle(2,1,3). If outOfPlaneAngle is nonzero, the charge sites lie out of the plane by the specified angle (at the specified distance) and their in-plane projection lines along the angle's bisector. -->
<VirtualSite type="DivalentLonePair" smirks="[*:2]~[#7X2:1]~[*:3]" distance="0.30*angstrom" outOfPlaneAngle="0.0*degree" chargeincrement1="+0.1*elementary_charge" />
<VirtualSite type="DivalentLonePair" smirks="[*:2]~[#7X2:1]~[*:3]" distance="0.30*angstrom" outOfPlaneAngle="0.0*degree" charge_increment1="+0.1*elementary_charge" />
<!-- trivalent nitrogen lone pair -->
<!-- charge sites lie above and below the nitrogen at specified distances from the nitrogen, along the vector perpendicular to the plane of (2,3,4) that passes through the nitrogen. If the nitrogen is co-planar with the connected atom, charge sites are simply above and below the plane-->
<!-- Positive and negative values refer to above or below the nitrogen as measured relative to the plane of (2,3,4), i.e. below the nitrogen means nearer the 2,3,4 plane unless they are co-planar -->
<VirtualSite type="TrivalentLonePair" smirks="[*:2]~[#7X3:1](~[*:4])~[*:3]" distance="0.30*angstrom" chargeincrement1="+0.1*elementary_charge"/>
<VirtualSite type="TrivalentLonePair" smirks="[*:2]~[#7X3:1](~[*:4])~[*:3]" distance="-0.30*angstrom" chargeincrement1="+0.1*elementary_charge"/>
<VirtualSite type="TrivalentLonePair" smirks="[*:2]~[#7X3:1](~[*:4])~[*:3]" distance="0.30*angstrom" charge_increment1="+0.1*elementary_charge"/>
<VirtualSite type="TrivalentLonePair" smirks="[*:2]~[#7X3:1](~[*:4])~[*:3]" distance="-0.30*angstrom" charge_increment1="+0.1*elementary_charge"/>
</VirtualSites>
```

Expand Down
Loading