pierrehirel / atomsk

Atomsk: A Tool For Manipulating And Converting Atomic Data Files -
https://atomsk.univ-lille.fr
GNU General Public License v3.0
203 stars 75 forks source link

Problem when using "--create ... random ..." to generate binary alloys #50

Closed c-uiiin closed 10 months ago

c-uiiin commented 11 months ago

Hi,

I'm trying to generate dozens of the binary alloys with the same composition by a shell script like this:

`

!/bin/bash

export PATH=$PATH:~/atomsk_b0.12.1_Linux-amd64

lattice=3.165 element1='W' element2='V'
ratio='5%'
structure_size_x=20 structure_size_y=20 structure_size_z=20 structure_file_name='data.lmp'

for i in seq 1 1 20
do mkdir $i cd $i atomsk --create bcc $lattice $element1 -duplicate $structure_size_x $structure_size_y $structure_size_z -select random $ratio $element1 -substitute $element1 $element2 $structure_file_name cd .. done `

The output structure should be WV alloy with 5% V content. But sometime the output structure become WV alloy with 5% W content.

This situation occurred approximately 1 to 2 times in 20 iterations.

I'm not sure what's going here.

Thanks for your help!

Best regards, Cui

pierrehirel commented 11 months ago

Dear Sir,

I was able to run your script and reproduce what you describe. It all boils down to the way data is written in LAMMPS data file.

In your script, you manipulate V and W atoms. But when writing the final file (in LAMMPS data format *.lmp), this format does not allow writing atomic numbers, only atom "types". Since you did not specify what type to assign for each atom, then Atomsk creates new types on-the-fly, and then proceeds to write the LAMMPS data file.

In most cases, the first atom is your "element1", i.e. tungsten (W). So Atomsk assigns type 1 to W, and type 2 to V.

However in some cases, the first atom is substituted, so that it becomes vanadium (V). In such cases, Atomsk assigns type 1 to V, and type 2 to W. You do not end up with inverted ratios, but the atom types that are generated are no longer the same.

If you output the results to another file format that supports atomic numbers, like CFG, then you will see that all the systems are W with 5% V.

Solution: Write in a text file the "type" that you want to assign to atoms, with the following format:

type
W  1
V  2

Save it as a text file (for instance "types.txt"). Then at the end of your command, after substituting atoms, add the option:

-properties types.txt

This way Atomsk will always assign type 1 to W and type 2 to V.

I hope this helps you

Best regards

c-uiiin commented 10 months ago

Thanks, I have tried your method. I think this perfectly solved my problem.