Copying a LAMMPS instance

I had moderate success in writing a LAMMPS compute style that calculates
the chemical potential of a system via Widom sampling, but I've hit a
major snag that I suspect doesn't have a good solution.

My idea was to create another LAMMPS instance with no particular
parameters, then read in all the box data, atom positions, etc. via a
restart file. I can then run the sampling on that system without changing
the original LAMMPS instance at all. It works perfectly (if slowly, but
such is the nature of insertion-deletion averaging) for pair styles, such
as lj/cut, that write out all relevant pair coefficients to the restart
file, but fails for styles, such as eam, that do not.

It does not work, of course, to simply copy the LAMMPS instance; the
default copy constructors are shallow copies, so it has the net effect of
making both instances point to the same position/force/etc. data, which is
no good. Writing a deep copy constructor for every class would work, but
be a big project and a maintenance nightmare, I would expect.

I appreciate any insight others may have. There is of course the MC
package's "fix gcmc" which might work for fluids, but that's more a way to
do GCMD than a way to calculate the chemical potential. Thank you!

Karl D. Hammond
University of Tennessee, Knoxville
[email protected]...

"You can never know everything, and part of what you know is always
   wrong. A portion of wisdom lies in knowing that. A portion of courage
   lies in going on anyway."
"Nothing ever goes as you expect. Expect nothing, and you will not be
   surprised."

You're correct that there is no copy constructor for the base LAMMPS
class - we don't intend people to do that. You could think about
running with 2 partitions. They will both read the input script
and setup the simulation, and have all the info. Then you
could make one partition do one thing, and the other something
else. And they can talk to each other. Note that there is a partition
command that allows an input script to talk to one partition at a time.

E.g. we've thought before
about doing a Gibbs ensemble that way. I don't know if it makes
sense for GCMC.

Steve