"In the process of using create_bonds, an issue occurred."

When using the “create_bonds many” command in LAMMPS, if the system does not have periodic boundary conditions in the z direction, many bonds between atoms cannot be created. Conversely, if the system has periodic boundary conditions in the z direction, bonds will be created between all defined pairs of atoms, but the resulting data file will have approximately 8 duplicate bond definitions. Can anyone help me solve this problem? Any assistance would be greatly appreciated.

When reporting problems, please always report which version of LAMMPS you are using.

To be able to address the problem, one first needs to be able to reproduce it. Thus please construct a small test case that can be run quickly and then be used for debugging. Explain which output you expect and what you get instead. Please also make sure that you have tested this with the latest feature release of development version of LAMMPS. If there is a bug found, it will only be fixed in such a version. If you are using an x86_64 Linux machine, you can download precompiled universal binaries from here

I am using the version LAMMPS (29 Sep 2021 - Update 2).https://github.com/Zxj3/lammpserroy.git

When my z-direction boundary conditions change, as in the 6.26.data file, many bonds are missing. When I use periodic boundary conditions for all directions, the bonds in the generated 6.251 data file have repeated definitions.

This is all too cryptic for somebody from the outside that has no idea of what your research is or what you are intending to do.

Can you please give a short explanation of what the input is and what the output and provide different input files for different conditions and explain what each does and where exactly things go wrong.

Please note that there has been a significant bug fix for the create_bonds command in September 2022 for cases where the command is used multiple times. So you need to confirm with a more recent version, if the issue still exists.

Please only use file with ASCII (latin) characters. Most people in the group here have no option or no experience in entering non-ASCII characters to their computer. If you want good/quick help, you have to make it easy to help you.

Last night, I tried to update LAMMPS to the 15 Jun 2023 version, but when I rebuilt the model, I still encountered the same issue. I am now working on a model where all atoms are on the same plane, and the model contains two types of atoms. I want to create 3 types of bonds between these two types of atoms, with each atom forming up to 6 bonds.The atomic coordinate information is in the PY.data file. The file 6.26.data has non-periodic boundary conditions in the z-direction, while 6.261.data has periodic boundary conditions in the z-direction. The file 6.26jm.txt contains the code for creating bonds between atoms in the PY.data file.
6.26.data (780.1 KB)
PY.data (717.9 KB)
6.261.data (2.0 MB)
PY.data (717.9 KB)

I don’t understand what you mean by this and what it is exactly you expect as output and how you determine that the output by the create_bonds command is incorrect and thus how I can quickly and easily check it. Furthermore, the system you are providing is far too large manually check this. Please try to create a much smaller system where this is going to be much easier to debug.

I have spent some time playing around with your input and data file and cannot reproduce the data files with redundant bonds.

I do notice, however, you have very strange unit and parameter settings.

Also, your create_bonds cmmands don’t seem to properly accommodate for rounding errors. By slightly tweaking rmin/rmax one can see that you are missing a large number of bonds.

How should I modify these parameters? Not only will the bonds be lost in some cases, but when the z-direction has periodic boundary conditions, bonds will also be defined repeatedly. This can be seen from the data file, where multiple bonds will be defined between two atoms.

How should I know? You don’t provide any information about what kind of model this is, where you took the parameters from or how you derived them, what you are trying to represent, and what you want to learn from it.

That is usually a consequence of bad model parameters and a bad system setup.

Which would be the correct result. Your box length in z-direction is only one length unit (i.e. 1 meter in si units), yet your bond creation requirements specify a cutoff of about 10 length units (i.e. 10 meters), thus you’ll be creating bonds not only between atoms in the principal cell, but also bonds between atoms in the principal cell and periodic images of atoms in z-direction. Of course, those will show up in the data file as redundant bonds, since the periodic image atoms have the same atom IDs as the original atoms. Overall, the data file you provide looks like it should be used for a 2d-simulation and not a 3d-simulation.

As I stated before, I cannot find a way to have create_bonds generate duplicate bonds for any meaningful input. I don’t think setting periodic boundaries in z-direction is meaningful for this system.

Thank you very much .I have already changed it from three-dimensional to two-dimensional. I have found the error. When I use the following command, it loses bonds.create_bonds many first first 1 9.9 10.1
create_bonds many first second 2 9.9 10.1
create_bonds many second second 3 9.9 10.1
If I swap the position of the second command with the third command, it won’t lose bonds.like this