Package to fluctuate the number of counterions in an OpenMM simulation
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

DOI experimental Build Status


saltswap simulates dynamic anion-cation (salt) explicit solvent environments in OpenMM. saltswap uses the semi-grand canonical ensemble to couple a simulation box to a reservoir at a given macroscopic salt concentration. The applied chemical potential in saltswap reflects the salt concentration of the reservoir.


Please cite the following: DOI

    author = {Gregory A. Ross, Ari\"{e}n S. Rustenburg, Patrick B. Grinaway, Josh Fass, and John D. Chodera.},
    title = {Biomolecular simulations under realistic macroscopic salt conditions},
    journal = {bioRxiv},
    doi = {10.1101/226001}
    year = {2017},


To install:

python install

Dependencies are currently listed in saltswap/devtools/conda-recipe/meta.yaml.

Quick example

We'll first create a box water in which to try the insertion and deletion of salt:

from simtk import openmm, unit
from simtk.openmm import app
from openmmtools.testsystems import WaterBox
wbox = WaterBox(box_edge=25.0 * unit.angstrom, nonbondedMethod=app.PME,
        cutoff=10 * unit.angstrom, ewaldErrorTolerance=1E-4)

Initializing the sampler that will perform Markov chain Monte Carlo by mixing molecular dynamics moves that transform pairs of water molecules to anions and cations:

from saltswap.swapper import MCMCSampler
sampler = MCMCSampler(wbox.system, wbox.topology, wbox.positions, delta_chem=800)

The chemical potential is specified by delta_chem and is in kJ/mol. The chemical potential corresponding to each macroscopic salt concentration must be calibrated for each water and ion pair forcefield, as well as the specific nonbonded treatment.

By default, saltswap makes instantaneous swaps between water and salt. To achieve usable acceptance rates, we use nonequilibrium candidate Monte Carlo (NCMC).

To run a simulation for 1000 iterations of MD and salt-swap moves, we use the move method:


More detailed examples can be found in examples/.