I am aware that it is possible to sort by atom types when outputting data to a dump file, but I am trying to "internally" sort the atoms within LAMMPS by atom type.
I'll provide a simplified example of what I am doing to better show my issue, with a zinc blende diatomic structure since my main issue revolves around this.
I have a C++ code that is coupled with LAMMPS, where I setup the simulation as follows (in C++):
lmp->input->one("neighbor 1.0 multi");
lmp->input->one("boundary p p p");
lmp->input->one("units metal");
lmp->input->one("atom_style atomic");
lmp->input->one("atom_modify map array");
// System geometry and atom creation
lmp->input->one("lattice diamond 5.469");
lmp->input->one("region box block 0 2 0 2 0 2 units lattice");
lmp->input->one("create_box 2 box");
lmp->input->one("create_atoms 2 box basis 1 1 basis 2 1 basis 3 1 basis 4 1 basis 5 2 basis 6 2 basis 7 2 basis 8 2"); // atom1 on basis 1, atom2 on basis 2
lmp->input->one("mass 1 69.723"); // arsenic mass
lmp->input->one("mass 2 74.9216"); // gallium mass
// Pair style and pair coefficients
lmp->input->one("pair_style tersoff");
lmp->input->one("pair_coeff * * GaAs.tersoff Ga As");
These inputs simply prepare the atoms and the simulation. The potential file is irrelevant, as my question is just about how to sort the atoms by atom type.
Next, I would like to "scatter" the atoms using (in C++):
lammps_scatter_atoms(lmp,"x",1,3,r_vector);
where "r_vector" is a vector of position values (x, y, z) for each atom in the system.
The issue I have is that the atoms in "r_vector" are sorted according to atom type, so the first portion is atom 1 (arsenic in this case) and the second portion is atom 2 (gallium in this case). Basically, for 64 atoms the first 32 are arsenic, and the next 32 are gallium in my "r_vector".
Because of this, I cannot simply scatter the atoms according to these positions because of the way the atoms are created in LAMMPS.
I would therefore like to create the atoms in a zinc blende structure like I am doing, but have them sorted by atom type so that when I scatter them with "r_vector", the positions and atom types match up. Is there a way to do this?
Thanks for your time.