Changing the atoms' group dynamically based on their types

Message: 4
Date: Wed, 26 Apr 2017 18:27:53 +0000 (UTC)
From: “S.Solhjoo” <[email protected]…16…>
Subject: [lammps-users] Changing the atoms’ group dynamically based on
their types
To: LAMMPS Users Mailing List <[email protected]…42…e.net>
Message-ID: <[email protected]…1241…436…>
Content-Type: text/plain; charset=“utf-8”
Dear all,
I’d like to use dynamic style of group command, based on the atoms’ type: in my system, the type of the atoms can change based on some conditions. Then, the atoms’ movement of the new type should be restricted along the z axis. To do so, I need to identify these atoms as members of a group.
I tried “group new dynamic all type 4”, but obviously I’m making a mistake, because this line produces the “Illegal group command” error; however, unfortunately, I couldn’t figure out how to solve this problem with reading through the manual.
Is it the case that the dynamic option works only with “region”, and not “type”? I’d appreciate any comment on this issue and possible solutions.
With regards,Soheil

From the doc page, there are three possible keywords to define a dynamic group: region or var or every. In your case only var and every are possible. The command should look like this:

group new dynamic all var variable_name every N

If the var keyword is used, the variable name must be an atom-style or atomfile-style variable.

“Type” of an atom is an atom-style variable. So you can define a new atom-style variable for atoms type 4. There is a good example in doc page about how to define that kind of variable

Many thanks, Trung, for the detailed answer. Now, I can use it in my code.

Also, thanks to Axel, for the hint. My problem with the documentation is that the PDF version of the manual (26 Jan 2017) is not complete (at least for this command).

Message: 4
Date: Wed, 26 Apr 2017 18:27:53 +0000 (UTC)
From: “S.Solhjoo” <[email protected]…16…>
Subject: [lammps-users] Changing the atoms’ group dynamically based on
their types
To: LAMMPS Users Mailing List <[email protected]…42… e.net>
Message-ID: <1688721005.5301230.1493231273 [email protected]…5436…>
Content-Type: text/plain; charset=“utf-8”
Dear all,
I’d like to use dynamic style of group command, based on the atoms’ type: in my system, the type of the atoms can change based on some conditions. Then, the atoms’ movement of the new type should be restricted along the z axis. To do so, I need to identify these atoms as members of a group.
I tried “group new dynamic all type 4”, but obviously I’m making a mistake, because this line produces the “Illegal group command” error; however, unfortunately, I couldn’t figure out how to solve this problem with reading through the manual.
Is it the case that the dynamic option works only with “region”, and not “type”? I’d appreciate any comment on this issue and possible solutions.
With regards,Soheil

From the doc page, there are three possible keywords to define a dynamic group: region or var or every. In your case only var and every are possible. The command should look like this:

group new dynamic all var variable_name every N

If the var keyword is used, the variable name must be an atom-style or atomfile-style variable.

“Type” of an atom is an atom-style variable. So you can define a new atom-style variable for atoms type 4. There is a good example in doc page about how to define that kind of variable