Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ce39641
RESP Charges
tkramer-motion Jun 2, 2025
f2711b9
cleanup
tkramer-motion Jun 2, 2025
5199f27
forcefield
tkramer-motion Jun 2, 2025
99767e5
tests
tkramer-motion Jun 2, 2025
9dd8327
PR fixes
tkramer-motion Jun 2, 2025
8e221df
move imports into function
tkramer-motion Jun 3, 2025
bcc3d8d
comments
tkramer-motion Jun 3, 2025
39a9780
lint
tkramer-motion Jun 3, 2025
10ce70d
versions
tkramer-motion Jun 3, 2025
ed3a6fe
lint
tkramer-motion Jun 3, 2025
a1df258
lint
tkramer-motion Jun 3, 2025
1114435
lint
tkramer-motion Jun 4, 2025
07575ee
test
tkramer-motion Jun 4, 2025
9f9839a
lint
tkramer-motion Jun 4, 2025
6a67d5d
lint
tkramer-motion Jun 4, 2025
2d24e29
test
tkramer-motion Jun 5, 2025
d5f18df
test
tkramer-motion Jun 5, 2025
c088dc6
handle case where no-gpu is available
tkramer-motion Jun 5, 2025
442682c
lint
tkramer-motion Jun 5, 2025
1b51ef8
unmark nocuda for resp
tkramer-motion Jun 5, 2025
011bf63
lint
tkramer-motion Jun 5, 2025
4ff04da
handle case of no initial coordinates
tkramer-motion Jun 6, 2025
35d0301
test
tkramer-motion Jun 6, 2025
386e3cf
test
tkramer-motion Jun 6, 2025
1658d30
cuda deps
tkramer-motion Jun 9, 2025
459c7bc
cuda deps
tkramer-motion Jun 10, 2025
17ed988
cuda deps
tkramer-motion Jun 10, 2025
9004ea4
Merge remote-tracking branch 'origin/master' into resp
tkramer-motion Jun 10, 2025
8403107
handle case where rdkit can't generate conformers
tkramer-motion Jun 10, 2025
e648476
keep ids
tkramer-motion Jun 12, 2025
0ce9713
Merge remote-tracking branch 'origin/keep_ids' into resp
tkramer-motion Jun 12, 2025
a30e447
remove keep ids
tkramer-motion Jun 13, 2025
cf3ded5
Update requirements.txt
tkramer-motion Sep 27, 2025
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
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ dependencies:
# Include numpy/scipy to reduce the size of the Docker container
- numpy=2.2.2
- scipy=1.15.1
- openff-toolkit
- openff-recharge
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ rdkit==2024.9.4
--extra-index-url https://pypi.anaconda.org/OpenEye/simple
openeye-toolkits==2020.2.0
openmm==8.2.0
gpu4pyscf-cuda12x
Comment thread
tkramer-motion marked this conversation as resolved.
Outdated
cutensor-cu12
Auto3D
torch
torchvision
Comment thread
tkramer-motion marked this conversation as resolved.
Outdated
torchaudio
28 changes: 28 additions & 0 deletions tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,34 @@ def test_am1bcc_parameterization():
# assert vjp_fn(charges_adjoints) == None


def test_resp_parameterization():

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test for determinism (either in the presence or absence of a seed) since the underlying algorithm uses a stochastic conformer generator. i.e. we want to make sure that calling RESP multiple items returns identical charges on fresh non-cached molecules.

# currently takes no parameters
smirks = []
params = []
props = None

cache_key = nonbonded.RESP
am1h = nonbonded.RESPHandler(smirks, params, props)
mol = Chem.AddHs(Chem.MolFromSmiles("C1CNCOC1F"))
AllChem.EmbedMolecule(mol)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If RESP to be independent of the initial conformer, we should explicitly be calling mol.RemoveAllConformers() beforehand as opposed to EmbedMolecule()


assert not mol.HasProp(cache_key)

charges = am1h.parameterize(mol)

assert len(charges) == mol.GetNumAtoms()
assert mol.HasProp(cache_key)

cached_charges = am1h.parameterize(mol)
np.testing.assert_equal(charges, cached_charges)

new_charges, vjp_fn = jax.vjp(functools.partial(am1h.partial_parameterize, None, mol))

# charges_adjoints = np.random.randn(*charges.shape)
Comment thread
tkramer-motion marked this conversation as resolved.
Outdated

# assert vjp_fn(charges_adjoints) == None


def test_am1_ccc():
patterns = [
["[#6X4:1]-[#1:2]", 0.46323257920556493],
Expand Down
15 changes: 15 additions & 0 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,21 @@ def test_am1bcc():
assert am1.props == am1.props


def test_resp():
smirks = []
params = []
props = None

am1 = nonbonded.RESPHandler(smirks, params, props)
obj = am1.serialize()
all_handlers, _, _ = deserialize_handlers(bin_to_str(obj))

am1 = all_handlers[0]
np.testing.assert_equal(am1.smirks, am1.smirks)
np.testing.assert_equal(am1.params, am1.params)
assert am1.props == am1.props


def test_am1ccc():
patterns = [
["[#6X4:1]-[#1:2]", 0.46323257920556493],
Expand Down
3 changes: 3 additions & 0 deletions timemachine/ff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Forcefield:
Union[
nonbonded.SimpleChargeHandler,
nonbonded.AM1BCCHandler,
nonbonded.RESPHandler,
nonbonded.AM1CCCHandler,
nonbonded.AM1BCCCCCHandler,
nonbonded.PrecomputedChargeHandler,
Expand Down Expand Up @@ -252,6 +253,8 @@ def from_handlers(
q_handle_intra = nonbonded.AM1CCCIntraHandler(q_handle.smirks, q_handle.params, q_handle.props)
elif isinstance(q_handle, nonbonded.AM1BCCHandler):
q_handle_intra = nonbonded.AM1BCCIntraHandler(q_handle.smirks, q_handle.params, q_handle.props)
elif isinstance(q_handle, nonbonded.RESPHandler):
q_handle_intra = nonbonded.RESPHandler(q_handle.smirks, q_handle.params, q_handle.props)
elif isinstance(q_handle, nonbonded.SimpleChargeHandler):
q_handle_intra = nonbonded.SimpleChargeIntraHandler(q_handle.smirks, q_handle.params, q_handle.props)
elif isinstance(q_handle, nonbonded.PrecomputedChargeHandler):
Expand Down
Loading