How to use fix gcmc

Dear Aidan,

     Thank you very much for your answers.

     I think I understand all your explanations except the one for Q7. So I
aks for more details.

     Again, let's take the H2O system as an example. There are already 100
H2O inside the box, and more H2O is going to be inserted. Assume that the
group for H2O is set as water, and the type for H is 1 and O is 2. For each
atoms in a water molecule, they have unique IDs. For example,

Atom_ID Molecule_ID atom_type
1 1 1
2 1 1
3 1 2
4 2 1
5 2 1
6 2 2
7 3 1
8 3 1
9 3 2
298 100 1
299 100 1
300 100 2

As for a newly inserted H2O, it will has the follows

Atom_ID Molecule_ID atom_type
301 101 1
302 101 1
303 101 2

Because in the system, only H2O is included, so they all belongs to the
group "all" or "water". As new H2O is inserted, the ID for atoms increases,
the number of atom/molecule in the "all" group increases. Since there are
only H2O, why does the type of atom also increase?

Or, maybe my understanding is wrong that the increase of atom type is for a
new group of atoms. E.g., originally there are only H2O in the box (atom
type H-1 and O-2), then CO2 is going to be inserted, which has atom types
C-1 and O-2 in the template file. In this case, new atom type is added to
the system originly including only H2O. Thus the atom type has to be changed
and the atom types for CO2 can not be the same as in the template file. Is
this true?

Yes, this is a case where you should set the value of type=2, so that
the types of
inserted C atoms are 1+2=3, and inserted O atoms in CO2 are 2+2=4. Note
that there are now O atoms of type 2 in H2O and type 4 in CO2.

Another question. If I want to use a combination of npT and gcmc. In the box
there is originally only water, and I am going to insert CO2 and O2. Then,
how to write the subscript?
Assume that group 1 for water, group 2 for CO2 and group 3 for O2.
As for the atom ID, 1-H in H2O, 2-O in H2O, 3-C in CO2, 4-O in CO2, 5-O in

fix 1 water npt temp 300.0 300.0 100.0 iso 0.0 0.0 1000.0
fix 2 water gcmc 10 1000 1000 3 4 seed1 T=300.0 mu-CO2 displace
fix 3 water gcmc 10 1000 1000 5 seed2 T=300.0 mu-O2 displace

All I can tell is that you have an extra argument in the second line. You can
not write '3 4' and expect LAMMPS to understand. In principle the above
approach should work, but we are not going to work out al the details in a
chain of e-mails. You are on the right track, keep working. If you hit a real
problem, not just some minor confusion, post a well-thought out question.
And remember to do a lot of testing.

or here the group-ID should be "all" instead of "water"?

That "type = atom type to assign to inserted atoms (offset for molecule
Does it make any difference if the inserted molecules have different number
of atoms?
(e.g., CO2 has 3 atoms but 2 types, O2 has 2 atoms but 1 type)

Another question, if I want to change the rule for inserting molecules,
which subroutine should I modify?
Before I used only fortran, C++ seems a little difficult for me to read and
I have spent two weeks on reading the codes of Lammps. It is really
difficult to me.

It takes time to learn new things, as I am sure you know. Stick at it, and
you will soon be able to answer all your questions about fix gcmc yourself.

I am sorry that maybe my questions are too simple for you.

Actually, they are mostly too complicated. Try making them simpler.

Anyway, thanks a