I would like to perform a semi-grand canonical ensemble run on a lattice. Essentially I have two species (one uncharged and one charged) that I would like to be able to swap in and out with a reservoir. I looked at using atom/swap which does just this, but the issue is that charge is not conserved for the species, from the manual on atom/swap.
“As a consequence, no checks on atomic charges are performed, and successful switches update the atom type but not the atom charge”
The charge can be modified on the group using the set command but to my understanding this would only be implemented after a swap has taken place.
I know in most cases you desire overall charge in the system to be conserved, but in this case I am assuming that this is unimportant.
Thanks for any help
Hi - not sure what you are asking. I think you are saying the code does what that
paragraph in the atom/swap doc page explains for semi-grand and charge. Are you
asking for an option to do something different, e.g. also swap charge when performing semi-grand?
I’m going to defer to Aidan on this (CCd), since I am fuzzy on the concept of semi-grand swaps.
Thanks for the response. Yes indeed that is what I was asking about. I was able to modify fix_atom_swap.cpp to accomplish the charge swapping. However I had another thought that may be more realistic, one in which two separate non-interacting regions are created and swaps are attempted between the two. It is similar to a semi-grand ensemble (in this case it would be NVT) except that now overall charge could be conserved as particles are switched from finite reservoir instead of an infinite reservoir and a chemical potential would not have to be set. Is there a procedure for creating this setup, i.e. where two separate simulations can be run simultaneously, but allowing for particle swapping to be attempted between the two different boxes?
If you are asking for one large simulation with 2 regions (far enough apart to
be non-interacting), and perform swaps between them, then that option could
be added to fix atom/swap, e.g. as a region2 keyword.
If you are asking for two independent simulations, and swaps to be performed
between them (e.g. like a Gibbs ensemble), then you can write a code
(e.g. Python script or C program) which uses LAMMPS as a library, instantiates
it twice, and performs the swaps by making calls to the 2 simulations.