-
Notifications
You must be signed in to change notification settings - Fork 2
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 alchemical ion support #51
Conversation
Note that the test failures are expected:
|
From testing I can see a possible issue (unless I'm misunderstanding the functionality) - when using the For example, running the EG5 056~410 perturbation without the |
I think this is okay. The swapping is only done internally by Sire dynamics itself, i.e. the input system is not swapped. The flag is simply used to swap the direction of the perturbation that is passed in. We should consider all of the setup stage, i.e. pre dynamics to operate on the system in the input order, i.e. non-swapped. |
Okay, that makes sense. |
Yes, exactly. The Sire code doesn't care about how many perturbable molecules there are. When setting them up in converting to a OpenMMMolecule it will just invert the properties (other than coordintes) if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go 👍
This PR adds support for adding alchemical ions to enforce charge neutrality during a perturbation. Currently the number of ions to apply to the perturbed state is configured via the
--charge-difference
command-line option. This specifies the difference in charge between the perturbed and reference states, i.e. charge(perturbed) minus charge(reference). For reference, the indices of the water molecules that are perturbed are written to the log. We also check the difference in end-state charge for all simulations and warn the user when there is a mismatch, i.e. suggesting to use--charge-difference
if they want to preserve neutrality. In future, all of this could be automated if we want to completely remove the option, e.g. we could have some--charge-neutral
flag that isTrue
by default.Currently we use the
furthest N from X,Y,Z
syntax to choose water molecules for perturbation. HereN
is the number of ions that we need andX,Y,Z
specifies the coordinates for the center of mass of the perturbable molecule. This results in a reproducible search for the same input. If we find that this causes issues, e.g. choosing a problematic water, then we could increase the number of molecules in the search, then pick randomly, e.g. first choosing10N
closest waters, then randomly choosingN
from within this.One point of difference with
somd1
is the definition of thecharge_difference
option. Here it specifies the difference in charge between the perturbed and reference states, whereas forsomd1
the difference appears to be reversed. (Which means the charge difference is the charge you need to add to the perturbed state to make it the same as the reference.) I'm happy to swap to whatever, but this definition seems less confusing to me and more in line with have the reference state actually be a reference.The PR also contains a commit to save topology files for both end states to the output directory, i.e.
system0.prm7
andsystem1.prm7
. This allows a user to visualise or analyse trajectories using either topology as a reference. (This has been very useful for debugging angle distributions around perturbing atoms, for example.)Happy for this PR to sit here so that @jmichel80 can comment before merging.