Hi Everyone,
I am trying to change the atom type of oxygen attached to the carbon with atom type 12 and the atom type of oxygen attached to the carbon with atom type 14. The different atom types are circled in red ink. I tried using the “if” statement to do the grouping for the different oxygen but was throwing this error “Illegal if command”. I am not too sure why I am having this error. Your suggestions on how to resolve this error or a better way to group the different oxygen atoms without the if statement would be greatly appreciated. Thanks. Please find attached the structure and the input file. Thanks.
Overall, you are misunderstanding how looping and accessing data works. LAMMPS input file scripting is not a full programming language, so the logic that you want to employ cannot work. If you can manually look up individual atom IDs that need to be changed, you can use the set command on them or define a group and then apply set to the group.
Thank you for your reply. It will be difficult to manually look up the atom IDs because it is a polymer with over 60,000 atoms and I have even completed the production run. That’s why I am looking for a way to group and apply the set command. Could you please give me an idea of how I can do the grouping since you said the proposed way is not going to work?
You won’t need to look them up manually. You just need some kind of property with a predictable pattern. For example, you can use atom style variables to select atoms. The following will define a group picking the 5th atom in each monomer of 20 atoms for a polymer that has a single atom as terminating group.
variable get5th atom ((id-1)%20)==4
group fifth variable get5th
You can also include checks for the existing atom type etc. Multiple conditions can be combined by multiplication. See the documentation for the group and the variable commands for more details and background information.
Thanks for your help akohlmey. I have thought of this approach, but it is difficult to get a regular pattern because of the terminal monomers. One approach I am thinking of is to use the carbon atoms the oxygen atoms share bonds with to group the oxygen atoms since the carbon atoms have different atom types. Any suggestion on how I can do this?
I have shown you the path of how you have to think and looks at possible solutions. There are lots of features and trickery that can be done based on the various facilities and LAMMPS. It is mostly a matter of creativity to come up with more elaborate strategies. Since this is not my research, I know too little about the specifics (And I am not interested to learn them. That is between you and your adviser/supervisor/tutor) and your descriptions are too vague anyway.
I usually do complex system manipulation tasks with VMD since I know this program well and am comfortable with scripting in Tcl (hell, I have contributed quite a few extensions to VMD written in Tcl and am - to the best of my knowledge - the only person that was crazy enough to write an interface between Tcl and MPI for parallel programming using Tcl), but takes a while to pick up and learn. So I won’t recommend that unless you are already familiar with writing scripts in Tcl.
My only other advice, in case none of my suggestions are viable to you, is to find a sufficiently competent collaborator.
At any rate, this is now too specific to keep discussing it in this forum.
‘fix bond/react’ can do what you need without using an “if” statement. however, generally speaking as Axel mentioned, this type of task is better done with pre/prost-processing tools if possible