We developed a new method for coarse-grained simulations of acid-base equilibria in a system coupled to a reservoir at a given pH and concentration of added salt, that we term the Grand-reaction method. More generally, it can be used for simulations of any reactive system coupled to a reservoir of a known composition. Conceptually, it can be regarded as an extension of the reaction ensemble, combining explicit simulations of reactions within the system and Grand-canonical exchange of particles with the reservoir. To demonstrate its strength, we applied our method to a solution of weak polyelectrolytes in equilibrium with a reservoir. Our results show that the ionization and swelling of a weak polyelectrolyte are affected by the Donnan effect due to the partitioning of ions and by the polyelectrolyte effect due to electrostatic repulsion along the chain. Both effects lead to a similar shift in ionization and swelling as a function of pH; albeit for different physical reasons. By comparison with published results, we showed that neglecting one or the other effect may lead to erroneous predictions or misinterpretations of results. In contrast, the Grand-reaction method accounts for both effects on the results and allows us to quantify them. Finally, we outline possible extensions and generalizations of the method and provide a set of guidelines for its safe application by a broad community of users.
This is a second version of this manuscript, after a major revision. The original version, submitted in August 2019, contained a major flaw which we now removed, re-computed all affected results, and corrected the interpretation.