Skip to content

Feature vsites#424

Merged
lohedges merged 34 commits intodevelfrom
feature_vsites
Apr 16, 2026
Merged

Feature vsites#424
lohedges merged 34 commits intodevelfrom
feature_vsites

Conversation

@tom-potter-cresset
Copy link
Copy Markdown
Collaborator

This PR adds virtual site support to the Sire-to-OpenMM conversion, via the OpenMM LocalCoordinatesSite virtual site type.

  • I confirm that I have merged the latest version of devel into this branch before issuing this pull request (e.g. by running git pull origin devel): y
  • I confirm that I have added a test for any new functionality in this pull request: y
  • I confirm that I have added documentation (e.g. a new tutorial page or detailed guide) for any new functionality in this pull request: [y/n]
  • I confirm that I have added a changelog entry to the changelog (we will add a link to this PR as part of the review): y
  • I confirm that I have permission to release this code under the GPL3 license: y

Suggested reviewers:

@chryswoods, @lohedges

Any additional context of information?

Virtual site parameters are passed to Sire via properties added to a sr.mol.Molecule, which are converted to OpenMM LocalCoordinatesSites by sire_to_openmm(). Virtual sites are not considered as separate atoms by Sire, so their positions and velocities are not stored in the Molecule or output to trajectories by Sire.

For example:

vsite_dict = {
    "0": {
        "vs_indices": [0, 1, 2],
        "vs_ows": [1, 0, 0],
        "vs_xs": [1, -1, 0],
         vs_ys": [0, 1, -1],
        "vs_local": [0.03, 0, 0],
    }
}
vs_charges = [0.5]
parents = {str(i): [] for i in range(mol.num_atoms())}
parents["0"].append(0)

cursor = mol.cursor()
cursor.set("n_virtual_sites", 1)
cursor.set("vs_charges0", vs_charges)
cursor.set("virtual_sites", vsite_dict)
cursor.set("parents", parents)
mol = cursor.commit()

this->perturbed->kappas = this->kappas;

for (int i = 0; i < cljs.count(); ++i)
//for (int i = 0; i < cljs.count(); ++i)
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.

If this is redundant, could the comment line be removed.

Comment on lines +333 to +336
// if (mols_data[i].hasProperty("n_virtual_sites"))
// {
// offset += mols_data[i].property("n_virtual_sites").asAnInteger();
// }
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.

Remove if no longer needed.

Copy link
Copy Markdown
Contributor

@lohedges lohedges left a comment

Choose a reason for hiding this comment

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

Thanks for this great contribution. I'll work on updating loch to support OpenMM systems containing virtual sites.

@lohedges lohedges merged commit 43a08ef into devel Apr 16, 2026
@lohedges lohedges deleted the feature_vsites branch April 16, 2026 09:33
@lohedges lohedges added enhancement New feature or request cresset related to work with cresset labels Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cresset related to work with cresset enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants