I just want to assign a name to particles in a configuration. E.g.
I have e.g N=125
particle in a 3D cubic structure and I have two kinds of particles A
and B
.
I want to use a random generator r=ran(0,1)
and if r<0.5
then particle is A
in the otherwise particle is B
.
and then I want to use A
, B
to compute other properties like energy and etc.
How can I do that?
this is my code to make a mixture configuration
subroutine init_order(rx,ry,rz,n)
use LJ_POT
implicit none
!assign initial position to the particles
double precision rx(num),ry(num),rz(num)
integer i,j,k,n
real*8 u,ir1
open(10,file='conf.in',status='unknown')
ir1=19375.d0
n=0
do i=1,nx
do j=1,ny
do k=1,nz
n=n+1
rx(n)=(dble(i)-0.5d0)*gsize
ry(n)=(dble(j)-0.5d0)*gsize
rz(n)=(dble(k)-0.5d0)*gsize
call usran(ir1,u)
if (u.le.0.5d0) then
write(10,*) rx(n),ry(n),rz(n),'red'
else if (u.gt.0.5d0) then
write(10,*) rx(n),ry(n),rz(n),'blue'
end if
end do
end do
end do
close(10)
175 format(4(f12.5))
return
end subroutine
Which make this configuration for N=8
:
0.75000000000000000 0.75000000000000000 0.75000000000000000 red
0.75000000000000000 0.75000000000000000 2.2500000000000000 blue
0.75000000000000000 2.2500000000000000 0.75000000000000000 blue
0.75000000000000000 2.2500000000000000 2.2500000000000000 blue
2.2500000000000000 0.75000000000000000 0.75000000000000000 blue
2.2500000000000000 0.75000000000000000 2.2500000000000000 red
2.2500000000000000 2.2500000000000000 0.75000000000000000 red
2.2500000000000000 2.2500000000000000 2.2500000000000000 red