Skip to content

Dev guide for the HTF and tests#2

Open
jthorton wants to merge 12 commits into
mainfrom
dev_guide
Open

Dev guide for the HTF and tests#2
jthorton wants to merge 12 commits into
mainfrom
dev_guide

Conversation

@jthorton
Copy link
Copy Markdown
Owner

@jthorton jthorton commented Nov 4, 2025

No description provided.

@jthorton jthorton changed the title Dev guide for the HTF Dev guide for the HTF and tests Nov 10, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 10, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Copy Markdown
Contributor

@hannahbaumann hannahbaumann left a comment

Choose a reason for hiding this comment

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

Thanks @jthorton these look great! I did a first pass looking through the 4 tests you had mentioned. Some of my comments may just be things that I didn't understand correctly in the htf =)

Comment thread htf/tests/test_htf.py Outdated

for end_state, ref_system, ref_top, pos in [
(0, htf._old_system, htf._old_topology, htf._old_positions),
(1, htf._new_system, htf._old_topology, htf._new_positions)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are the topologies the same or should this be the htf._new_topology?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

They are the same due to the transforms I chose but I'll update it to use the new_topology

Comment thread htf/tests/test_htf.py Outdated
Comment thread htf/tests/test_htf.py Outdated

for end_state, ref_system, ref_top, pos in [
(0, htf._old_system, htf._old_topology, htf._old_positions),
(1, htf._new_system, htf._old_topology, htf._new_positions)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as below, I'm probably just missing something, or should this be the _new_topology?

Comment thread htf/tests/test_htf.py Outdated
ref_energy = ref_state.getPotentialEnergy().value_in_unit(unit.kilojoule_per_mole)
# energies should be the same
# this is only true if we correctly interpolate the 1-4 interactions involving dummy atoms
assert pytest.approx(hybrid_energy) == ref_energy
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe put approx on the right hand side, e.g.
assert hybrid_energy == pytest.approx(ref_energy, rel=1e-5)

Comment thread htf/tests/test_htf.py
platform=platform
)

for end_state, ref_system, ref_top, pos in [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you also have to set the NoCutoff for the reference system as above for the hybrid system?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yes we should to make the test more stable incase the default is not nocutoff in future which it seems to be.

Comment thread htf/tests/test_htf.py
ref_state = ref_simulation.context.getState(getEnergy=True, groups={1})
ref_energy = ref_state.getPotentialEnergy().value_in_unit(unit.kilojoule_per_mole)
# energies should be the same
# this is only true if we correctly interpolate the 1-4 interactions involving dummy atoms
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you also want to check for a non-zero energy, as in the PME test?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Good idea!

Comment thread htf/tests/test_htf.py

# set the nonbonded forces to group 1 to easily extract their energies and all others to 0
for force in hybrid_system.getForces():
if force.getName() in ["NonbondedForce", "CustomNonbondedForce", "CustomBondForce_exceptions"]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I'm a bit confused about the "CustomBondForce_exceptions", where does that come from?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

CustomBondForce_exceptions is a custom bond force used to interpolate the 1-4 steric and electrostatic exceptions rather than using the nonbonded potential. It allows the use of the softcore potential for sterics as well, so the total nonbonded force in the hybrid system is split across the 3 potentials.

Comment thread htf/tests/test_htf.py
assert non_zero_exceptions == 9

def test_nonbonded_exceptions_dummy(htf_chloro_ethane):
"""Test that the nonbonded exceptions are correctly set when we have dummy atoms, any involving a dummy should be zeroed."""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do I understand it correctly that we would want to keep exceptions within dummy groups, meaning when all atoms are dummy? If so, should we also have a test with a larger dummy group that checks for that?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yeah thats how I assumed this should be done, but I think the HTF is currently interpolating those terms off as well (sudo softening the torsions in the dummy region) I think once we decide how this should be handled then we should add a test for this as well!

Comment thread htf/tests/test_htf.py Outdated
Comment thread htf/tests/test_htf.py Outdated
jthorton and others added 4 commits November 11, 2025 11:30
Co-authored-by: Hannah Baumann <43765638+hannahbaumann@users.noreply.github.com>
Co-authored-by: Hannah Baumann <43765638+hannahbaumann@users.noreply.github.com>
Comment thread htf/dev_guide/READEME.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo in the file name?

Comment thread htf/tests/test_htf.py
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From a very brief look through - this seems reasonable. I will have a deeper look through the code when you push these tests again openfe, but please go ahead with the merge here if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants