Fix atom/swap - 3 types of atoms

Hi. In my simulation, I have three types of atoms and I’m not sure how to use fix atom/swap. Can anyone help me?
Thank you in advance.

To achieve what?

I am using it in MD/MC hybrid to form a precipitate

If you want people to provide help, you need to explain what is so specific about your system that you can’t simply apply the fix atom/swap command described in the documentation.

So I use:
fix 7 all atom/swap 100 50 14359 400.0 region swapRegion types 1 2
fix 8 all atom/swap 100 50 18279 400.0 region swapRegion types 1 3
fix 9 all atom/swap 100 50 29837 400.0 region swapRegion types 2 3
but nothing happens and after reading the documentation carefully, I couldn’t figure out what’s the problem with my code or how should I use that fix correctly for three types of atoms. Additionally, I need atom fractions to be conserved.

According to the documentation, you can use more than two types of atoms per atom/swap command, so you can try and simplify your code to use only one fix atom/swap.

There are two major problems with your posts here:

  • You are assuming we all know what your research is and that your assessment of the situation is correct. But we don’t know you or your research and not even your input, since you only quote three lines. With that limited information we have not much else that we can tell you to re-read and check out the documentation.
  • You are assuming that the problem stems from having to swap around three atom types, but have you checked that your setup works with a simpler system with only two atom types. There are many more reasons that things can go wrong, e.g. your choice of region or your specific swap settings. In general, it is a good idea to “build” an input in small stages and validate all details and all choices you make at every step to see that this is working as expected. We understand that it is tempting to jump ahead and implicitly assume that you don’t make any mistakes and follow the documentation correctly, but our observation is that even the most experienced people make mistakes so you are better off to assume that everything you will need to be checked.

I found " The types keyword is required. At least two atom types must be specified. If not using semi-grand, exactly two atom types are required." in the documentation. Since I am not using semi-grand in my code, doesn’t that mean that I can not use more than two types of atoms per atom/swap?

I have used atom/swap for two types and it has worked correctly. Additionally, I have checked the region and it seems to be correct. I did not found any other potential problems.

The situation is very simple. There are three possible scenarios

  • Your input is not correct. We cannot check this with the available information, so you are on your own unless you provide detailed explanations of every input choice you made and a way to reproduce your observations independently.
  • your expectations are not in accord with your input. Again, we cannot confirm this from remote without detailed explanations, a good knowledge of your research objectives and motivation for the specific details in your input. So with the current state of this topic, you are on your own.
  • There is a bug in LAMMPS. This is quite unlikely and the burden is on you to provide a simple and quick to run test case that confirms that LAMMPS is not acting according to the documentation. But at this point we don’t even know whether you are using an up-to-date LAMMPS version or something from the “stone ages”.

In all cases, the burden is on you to provide sufficient context and a simple(!) way to reproduce your problem. Nobody here is a genius or mind reader that just needs to look at a couple of lines of LAMMPS input (without any context!) and can immediately know what the problem is and tell you what to change. Just telling us, that you checked everything and that everything is in order on your side, is not sufficient. You need to provide convincing proof. And as implied in my list of options above, the fact that you don’t get the desired result is no proof at all.

Bottom line, if you don’t put in much more effort to make it easier to help you, you have gotten all the help that you can be given under the circumstances.

I’m not sure what else information do you need. I am using latest LAMMPS version, so it’s not from the “stone ages”. In overall, in my simulation, the fraction of atoms should be conserved so I can not use semi-ground to use a code like: fix 7 all atom/swap 100 50 14359 400.0 region swapRegion types 1 2 3. Also, I am saying that my provided code does not work, based on that I see no atom changes, but in two atom types for example Ni atoms have segregated in GBs (Al matrix). All other information of my simulation seem to be useless to mention.

I have already commented and explained on that.

This is a perfect example for your incomplete and unscientific communication. The “latest” version can mean multiple different version depending on where you get your LAMMPS version. The scientific answer is to provide the exact version date. See the manual: 1.2. What does a LAMMPS version mean — LAMMPS documentation

They are crucial to reproduce what you are seeing. How can you know what is important or not? Also, by not providing an easy and quick way to reproduce test case, you are forcing people to have to build their own. Please keep in mind, that this forum is based on people volunteering their time, so anything problem or question that requires extra effort is reducing the probability of getting useful help. There also is a discussion how and what to communicate in this forum in the “Guidelines” post.

Bottom line, if you are not willing to comply with what is needed to make it easy to help you, you are massively reducing your chances of getting help. In the end, it is your choice. I for my part have now spent enough time on this and will help more cooperative people instead.