Problem with replicate command

Hello LAMMPS community,

I’m preparing a 3×3×3 supercell of a periodic MOF for test runs, and I need the LAMMPS data file to contain the correct per-atom partial charges. Charges were assigned by a charge equilibration method on the unit cell (each atom has a specific charge). I begin with a correct unit-cell LAMMPS data file where atoms, bonds, angles, and dihedrals are all defined properly.

work flow:

  1. read_data unit.data
  2. replicate 3 3 3
  3. write_data supercell.data

The replicated data file correctly preserves the per-atom partial charges.
However, the Bonds, Angles, and Dihedrals sections contain some entries whose type numbers do not match the atom-type combinations I expect.

For example (simplified illustration):

Bonds
1   1   101   102    # bond type 1 for atom types 1-1 (expected)
2   1   150   201    # bond type 1 for atom types 2-1 (unexpected)
  1. Why does this happen?
    Could the issue come from the atom types, or from how bond/angle/dihedral types are defined in the original unit cell?
    If the atom types in my unit cell are correct, is it valid to generate the supercell and then use a Python script to reassign bond/angle/dihedral types based on the atom-type pairs? Or does that risk breaking force-field consistency?
  2. Could these topology mismatches be related to bonds crossing periodic boundaries during replication?
    Does LAMMPS modify bonded types or reassign types when expanding the cell across periodic images?
  3. Is using the replicate command a safe and recommended method for generating a supercell data file that must preserve (a) atom types, (b) partial charges, and (c) all bonded topologies?
    Or is it better practice to generate the full supercell externally (moltemplate, VMD/topotools, Python, etc.) and write a fresh data file?
    Thanks

Yes.

This is impossible to answer in this generality.

That depends on the specific LAMMPS version you are using and the details of the input.
What it can and cannot do is discussed in the documentation. The most difficult issue are bonded interactions that wrap around periodic boundaries. Those are non-trivial to replicate since those must be broken and then reformed differently and then only the “outside” bonded interactions must wrap back. I suspect pretty much all external tools will have the same limitations. Using an external tool can be simpler, since the data does not need to be distributed across processors, which is a major challenge in LAMMPS.

Whatever works correctly for a given case is what is the best solution. However, what that is, is difficult to say in general and would depend on the individual example.

Best practice is IMO creating a small / tiny test case with all possible complications and experiment with that until the result is satisfactory.

Thanks for the reply.
The problem was related to the wrong bond/angle/dihedral types in my unit cell. In my case, the problem solved by using topotools.