Skip to content

Conversation

@epretti
Copy link
Member

@epretti epretti commented Oct 23, 2025

Adds a tutorial on setting up a constant potential simulation. Effectively shows how to replicate one data point from this paper.

@github-actions
Copy link
Contributor

Example docs for this PR rendered here

Copy link
Member

@peastman peastman left a comment

Choose a reason for hiding this comment

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

This is a well written tutorial. I wonder if it could be made simpler, though. Building everything by hand is complicated. What about this?

  • Load a PDB file with the model.
  • Use a ForceField to create a System. You can use a standard force field for the water and ions, and provide a minimal XML file for the AU residues.
  • Provide code to take a System and "constant potentialify" it: add a ConstantPotentialForce, copy the Coulomb parameters from the NonbondedForce, set them to zero in the NonbondedForce.

This should take less code overall, and users will be able to copy it directly for their own simulations, even if they involve different molecules.

" system.addConstraint(i_o, i_h2, L_OH)\n",
" system.addConstraint(i_h1, i_h2, L_HH)\n",
"\n",
" residue = topology.addResidue(\"WAT\", chain_water)\n",
Copy link
Member

Choose a reason for hiding this comment

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

The name should be "HOH".

Comment on lines +623 to +627
" # Get all of the charges, and find the sum of the electrode charges.\n",
" # We divide out OpenMM's units before passing charges to Python's sum() function.\n",
" charges = self._conp.getCharges(simulation.context).value_in_unit(openmm.unit.elementary_charge)\n",
" charge_i = sum([charges[i] for i in self._i_indices]) * openmm.unit.elementary_charge\n",
" charge_j = sum([charges[j] for j in self._j_indices]) * openmm.unit.elementary_charge\n",
Copy link
Member

Choose a reason for hiding this comment

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

You can use openmm.unit.sum(), which knows how to add Quantities.

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