# questions about fix deposit command in sputtering

Dear All
Now I am doing the simulation of Ga ion bombardement of Silicon.And I want to establish the model as the figure shows:

Now I have some questions in lammps command (fix deposit) to achieve this goal.
Q1:how i can guarantee the z coordinates of incident ions are the same?That is mean how I can create the ions in a circular area.I notice that if i use the command like this: region region insert sphere 135 135 120 15.0 units box; *fix 5 yinsert deposit 3 2 100 12345 region insert local 120.0 120.0 0 vz -2102.0 -2102.0 units box .*Then the initial z coordinate of all ion seems are the same ,that is 120.0,while they have different x and y coordinate.
Q2:how i can guarantee the ions are in the gaussian distribution?
Q3:I notice that in fix deposit command ,there is target keyword.The mannua says that it can make ions like a beam.So I want to make certain that the target keyword can only change the direction of the ion velocity .If i want to simulate straight beam like the figure,I just create the ions in an circular area,and give the vz velocity .Then these ions can head toward the substrate like a straight beam while ignoring target keyword .Am i right?
Best regards.

Dear All
Now I am doing the simulation of Ga ion bombardement of
Silicon.And I want to establish the model as the figure shows:
!QQ截图20160623161636.jpg|522x395
Now I have some questions in lammps command (fix deposit) to
achieve this goal.
Q1:how i can guarantee the z coordinates of incident ions are
the same?That is mean how I can create the ions in a circular area.I notice
that if i use the command like this: region region insert sphere 135 135
120 15.0 units box;* fix 5 yinsert deposit 3 2 100 12345 region insert
local 120.0 120.0 0 vz -2102.0 -2102.0 units box .*Then the initial z
coordinate of all ion seems are the same ,that is 120.0,while they have
different x and y coordinate.

"local" keyword.​

Q2:how i can guarantee the ions are in the gaussian
distribution?

​i think you will need to change the source code for that. currently fix
deposit uses a uniform distribution.

Q3:I notice that in fix deposit command ,there is target
keyword.The mannua says that it can make ions like a beam.So I want to make
certain that the target keyword can only change the direction of the ion
velocity .If i want to simulate straight beam like the figure,I just create
the ions in an circular area,and give the vz velocity .Then these ions can
head toward the substrate like a straight beam while ignoring target
keyword .Am i right?

​if you don't use the (optional) target ke​yword its functionality will not
be applied.

axel.

Why using fix deposit ?

Insert an ion, run your dynamics, and re-insert another ion, etc… No need of the fix deposit, just a loop.

In that case, it is also possible to generates a gaussian distribution, with the adequat variable command.

Julien.

Thanks for Axel.Now I really want to make particles in gaussian distribution in fix deposit command.I notice that there is a file named random_park.cpp in the src folder.And in this file,I find that there are RanPark::uniform() fuction and RanPark::gaussian() function.Then in the file named fix_deposit.cpp,I notice the source code beginning in row 338 which i guess have the function to create random position for new particle within region.Here is the source code:

// choose random position for new particle within region
coord[0] = xlo + random->uniform() * (xhi-xlo);

coord[1] = ylo + random->uniform() * (yhi-ylo);

coord[2] = zlo + random->uniform() * (zhi-zlo);

while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {

coord[0] = xlo + random->uniform() * (xhi-xlo);

coord[1] = ylo + random->uniform() * (yhi-ylo);

coord[2] = zlo + random->uniform() * (zhi-zlo);
}

Then I think that if I change the code random->uniform() to random ->gaussian(),then the fix_deposit command can have the particles in gaussian diribution .Am i right?Best regards.

Thanks for Axel.Now I really want to make particles in gaussian
distribution in fix deposit command.I notice that there is a file named
random_park.cpp in the src folder.And in this file,I find that there are
RanPark::uniform() fuction and RanPark::gaussian() function.Then in the
file named fix_deposit.cpp,I notice the source code beginning in row 338
which i guess have the function to create random position for new particle
within region.Here is the source code:

* // choose random position for new particle within region *
* coord[0] = xlo + random->uniform() * (xhi-xlo);*

* coord[1] = ylo + random->uniform() * (yhi-ylo);*

* coord[2] = zlo + random->uniform() * (zhi-zlo);*

* while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0)
{*

* coord[0] = xlo + random->uniform() * (xhi-xlo);*

* coord[1] = ylo + random->uniform() * (yhi-ylo);*

* coord[2] = zlo + random->uniform() * (zhi-zlo);*
* }*

Then I think that if I change the code random->uniform() to random
->gaussian(),then the fix_deposit command can have the particles in
gaussian diribution .Am i right?Best regards.

but ​not exactly the way you want it, as random->uniform() will return a
number between 0.0 and 1.0 and random->gaussian() a number between
-infinity and +infinity centered on 0.0 with a variance of 1.0. so it is
not a simple drop in replacement.

axel.

These days I am thinking to change the source code,so that atoms are in gaussian distribution.

First,Ichange the gaussian function code.The red code are added by me.

double RanPark::gaussian()

{

double first,v1,v2,rsq,fac;

double sigma=1.486313;

double u=0.0

if (!save) {

int again = 1;

while (again) {

v1 = 2.0*uniform()-1.0;

v2 = 2.0*uniform()-1.0;

rsq = v1v1 + v2v2;

if (rsq < 1.0 && rsq != 0.0) again = 0;

}

fac = sqrt(-2.0*log(rsq)/rsq);

second = v1*fac;

first = v2*fac;

save = 1;

} else {

first = second;

save = 0;

}

return (first*sigma+u);

}

The modified fuction above can generate random numbers which follow the gausian distribution.And the variance is 1.486313^2.And we know that the probability of random number between -31.486313nm and 31.486313nm is 99.7%.

Then in the file fix_deposit.cpp,I change the code which have the fuction to

set coordinates for new particles.

The original code is:

// choose random position for new particle within region

coord[0] = xlo + random->uniform() * (xhi-xlo);

coord[1] = ylo + random->uniform() * (yhi-ylo);

coord[2] = zlo + random->uniform() * (zhi-zlo);

while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {

coord[0] = xlo + random->uniform() * (xhi-xlo);

coord[1] = ylo + random->uniform() * (yhi-ylo);

coord[2] = zlo + random->uniform() * (zhi-zlo);

}

From the code above,I know that the coord[0] is a number between xlo and xhi.And xlo and xhi are the boundary coordinate of the deposit region.So that I plan to modify the code :

double x_1=random->gaussian()*10;

double y_1= random->gaussian()*10;

double z_1= random->gaussian()*10;

if(x_1>60)

x_1=60;

if(x_1<-60)

x_1=-60;

if(y_1>60)

y_1=60;

if(y_1<-60)

y_1=-60;

if(z_1>60)

z_1=60;

if(z_1<-60)

z_1=-60;

coord[0] = x_1

coord[1] = y_1

coord[2] = z_1

while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {

coord[0] = x_1;

coord[1] = y_1;

coord[2] = z_1;

}

Then in my lammps input script,I establish a specific deposit region for my simulation only.This region is a cube ,whose length of a side is 6 or 7.in a short ,the length of a side is greater than 6 but smaller than the box boundary.

Those are my idea to modify the lammps source code to santisfy my simulation.Is that OK?By the way,I want to know the units of xlo and xhi,so that I can change the units of 6 in my code.I suppose the xlo and coord[0] have the units A.

Best regards.

These days I am thinking to change the source code,so that atoms are in
gaussian distribution.

First,Ichange the gaussian function code.The red code are added by me.

​no, no!, NOOOO!!!​

​there is no need to do this change, and it is a very, very bad idea. other
parts of LAMMPS use this code and expect sigma to be 1.0.

think about it. you can do the same change in fix deposit.

double RanPark::gaussian()

{

double first,v1,v2,rsq,fac;

double sigma=1.486313;

double u=0.0

if (!save) {

int again = 1;

while (again) {

v1 = 2.0*uniform()-1.0;

v2 = 2.0*uniform()-1.0;

rsq = v1*v1 + v2*v2;

if (rsq < 1.0 && rsq != 0.0) again = 0;

}

fac = sqrt(-2.0*log(rsq)/rsq);

second = v1*fac;

first = v2*fac;

save = 1;

} else {

first = second;

save = 0;

}

return (first*sigma+u);

}

The modified fuction above can generate random numbers which follow the
gausian distribution.And the variance is 1.486313^2.And we know that the probability
of random number between -3*1.486313nm and 3*1.486313nm is 99.7%.

Then in the file fix_deposit.cpp,I change the code which have the fuction
to

set coordinates for new particles.

The original code is:

// choose random position for new particle within region

coord[0] = xlo + random->uniform() * (xhi-xlo);

coord[1] = ylo + random->uniform() * (yhi-ylo);

coord[2] = zlo + random->uniform() * (zhi-zlo);

while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) ==
0) {

coord[0] = xlo + random->uniform() * (xhi-xlo);

coord[1] = ylo + random->uniform() * (yhi-ylo);

coord[2] = zlo + random->uniform() * (zhi-zlo);

}

From the code above,I know that the coord[0] is a number between xlo and
xhi.And xlo and xhi are the boundary coordinate of the deposit region.So
that I plan to modify the code :

double x_1=random->gaussian()*10;

double y_1= random->gaussian()*10;

double z_1= random->gaussian()*10;

if(x_1>60)

x_1=60;

if(x_1<-60)

x_1=-60;

if(y_1>60)

y_1=60;

if(y_1<-60)

y_1=-60;

if(z_1>60)

z_1=60;

if(z_1<-60)

z_1=-60;

​​this is another very ugly hack that makes assumptions that are only true
for you, and particularly for one specific input.
why not add an optional flag to choose between uniform and gaussian
distribution and also specify sigma and the center of the gaussian
distribution?
this way the change would be generic and could be integrated in LAMMPS
proper and others could use it as well.

coord[0] = x_1

coord[1] = y_1

coord[2] = z_1

while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) ==
0) {

coord[0] = x_1;

coord[1] = y_1;

coord[2] = z_1;

}

this code *cannot* work. it will create a deadlock. you need to improve

axel.​

Now I am reading the file fix_deposit.cpp.And I want to know that the code :

while (attempt < maxattempt) {
attempt++;

// choose random position for new particle within region

coord[0] = xlo + random->uniform() * (xhi-xlo);
coord[1] = ylo + random->uniform() * (yhi-ylo);
coord[2] = zlo + random->uniform() * (zhi-zlo);

There is a while circulation.In this file,the default value of maxattempt is 10 if attempt keyword is not defined.And i want to know that why this value is 10?
Now I try to added a keyword gaussian with two parameters(u and σ ) in fix deposit command.In source code,I also added an gaussflag.The whole idea is like other keyword in fix deposit command.
Then I combile my lammps and i get a lmp exe file.Then I run my input file .
if a use the command line:
region insert sphere 81.475 81.475 380.135 30.0 units box
fix 5 yinsert deposit 1 2 5 12345 region insert local 380.5 380.5 0 vz -2881.47 -2881.47 units box
run 5
Then the result is normal.in the group yinsert,there is an atom.
But when I use the command line
fix 5 yinsert deposit 1 2 5 12345 region insert local 380.5 380.5 0 vz -2881.47 -2881.47 gaussian 81.4575 14.863 units box

It can run and output the result.But at the very start there are 63 atoms in the group yinsert.I am confused.
And i also provide my modifued code here.
Best regards.

fix_deposit.cpp (28.2 KB)

fix_deposit.h (4.4 KB)

random_park.cpp (4.14 KB)

random_park.h (1.13 KB)

Maxattempt is a user-settable param. See the attempt keyword

for fix deposit. It’s purpose is to not allow the

code to try endlessly to insert an atom when

there is no room for it.

Steve

this is getting out of hand. please have a look at:

https://github.com/lammps/lammps/commit/2f04cd2bc5d640dbcc2484e354e14dbf30053088