Regarding set type/fraction with ternary alloy, unable to modify initially set atoms

Hi all,

Using LAMMPS (22 Aug 2018) to generate a Fe-17Cr-12Ni alloy

Generating a ternary alloy using the ‘set type/fraction’ command does not work as expected, or the documentation may be ambiguous. Initially I tried to set the at% using two consecutive set commands:

create_atoms 1 box

set group all type/fraction 2 0.18 12345

45948 settings made for type/fraction

set type 1 type/fraction 3 0.13 12345

0 settings made for type/fraction

group gFe type 1

210052 atoms in group gFe

group gCr type 2

45948 atoms in group gCr

group gNi type 3

0 atoms in group gNi

From the man page, it seems that using the ‘type’ style, one should be able to select/set ONLY type 1 atoms to the specified fraction. In fact, it seems that only type 2 atoms are able to be modified at all with the second ‘set’ command. In the following output only type 2 atoms are modified, but the fraction of type 3 atoms generated corresponds to the fraction of the whole system still:

create_atoms 1 box

Created 256000 atoms

set group all type/fraction 2 0.18 12345

45948 settings made for type/fraction

set group all type/fraction 3 0.13 12345

33252 settings made for type/fraction

group gFe type 1

210052 atoms in group gFe

group gCr type 2

12696 atoms in group gCr

group gNi type 3

33252 atoms in group gNi

Alternate methods I’ve tried are:

-Initializing the box with type 3 and converting to type 1,2 (in this case, type 3 atoms could not be modified with the second ‘set’ command)

-Creating a separate group by type, and then using set group type/fraction on the new group

The workaround for me is that I only modify type 2 atoms with the second ‘set’ command, and set an intentionally large fraction X2, where X2-X3 is the actual at% desired. Again, the fraction is still at% of the whole system, not of the subset selected by type.

Set group all type/fraction 2 0.29 288585

131447 settings made for type/fraction

set type 2 type/fraction 3 0.11 288585

50041 settings made for type/fraction

Unsure if this is a bug, or this was the intended use.

Thanks in advance,

Kevin Chu

there are two problems. 1) your math for the fractions is not correct,
2) you keep using the same random number generator seeds.
the commands work as expected. but with the same seed you are trying
to pick atoms that have already been converted, that is why you have
empty groups.

the most straightforward procedure is: 1) convert the fraction of Cr
*and* Ni atoms to type 2 and then convert only type 2 atoms according
to the ratio Ni/Cr.
this can be easily expressed in variables as follows (which allows to
switch the fractions conveniently):

variable fCr equal 17.0
variable fNi equal 12.0

create_box 3 box
create_atoms 1 box
set type 1 type/fraction 2 \(\(v\_fCr\+v\_fNi\)/100\.0\) 1734536 set type 2 type/fraction 3 (v_fNi/(v_fCr+v_fNi)) 1734535

group gFe type 1
group gCr type 2
group gNi type 3

print "type 1 percent: \(100\.0\-v\_fCr\-v\_fNi\) vs (count(gFe)/atoms*100.0)"
print "type 2 percent: \{fCr\} vs (count(gCr)/atoms*100.0)"
print "type 3 percent: \{fNi\} vs (count(gNi)/atoms*100.0)"

which results in:

Created 256000 atoms
  Time spent = 0.0257802 secs
Setting atom values ...
  74184 settings made for type/fraction
Setting atom values ...
  30656 settings made for type/fraction
181816 atoms in group gFe
43528 atoms in group gCr
30656 atoms in group gNi
type 1 percent: 71 vs 71.021874999999994316
type 2 percent: 17.0 vs 17.003125000000000711
type 3 percent: 12.0 vs 11.974999999999999645

axel.

Okay I see, I must have misunderstood the purpose of the random number seed; I figured it would randomly repick atoms from the new selection set by the 'type' style.
I forgot to specify that the fractions for the Cr and Ni are in wt%, which corresponds to ~18at% and 11at%, respectively. Of course your method is more straightforward, but just out of curiosity, if the same random number seed were used for consecutive commands (and thus the same atoms selected to convert), then would the procedure I specified effectively yield the same result or am I missing something else? .29*(Ntot) - .11*(Ntot) = .18*(Ntot) = net type 2 atoms.
Thank you for the helpful explanation and the improved procedure!

Best,
Kevin

Okay I see, I must have misunderstood the purpose of the random number seed; I figured it would randomly repick atoms from the new selection set by the 'type' style.

well, you have to understand the difference between "truly random" and
"pseudo random". for efficiency, LAMMPS uses "pseudo random" numbers
("truly random" takes a lot more effort and are required for
cryptographic purposes, for example). the problem here is, that LAMMPS
uses a special algorithm here, that guarantees the selection of the
same sequence of atoms regardless of how many processors are used, and
that is the cause for those unexpected inconsistencies, when the same
random number seed is used. the documentation mentioned only the first
part of this, so i am adding a sentence explaining that the random
number seed must be changed for multiple invocations of set
type/fraction.

I forgot to specify that the fractions for the Cr and Ni are in wt%, which corresponds to ~18at% and 11at%, respectively. Of course your method is more straightforward, but just out of curiosity, if the same random number seed were used for consecutive commands (and thus the same atoms selected to convert), then would the procedure I specified effectively yield the same result or am I missing something else? .29*(Ntot) - .11*(Ntot) = .18*(Ntot) = net type 2 atoms.

that is a superfluous question. you can apply the scientific approach
and easily test this yourself. you have to account for the changes in
the fractions, i.e. if you convert 18% of type 1 atoms to type 2, you
have to account for that in a second conversion from type 1. i.e. you
would have to convert with a fraction of 11/(100-18) = 0.13415 to get
11% type 3 of the total number of atoms. ...and you can obviously not
convert from group all, since part of those are converted to type 2
(so you would get the expected total percentage of type 3, but type 1
and type 2 would be off).

axel.