-
Notifications
You must be signed in to change notification settings - Fork 12
/
create_fcc.f90
executable file
·136 lines (110 loc) · 4.12 KB
/
create_fcc.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
!begin rubric
!****************************************************************************** *
!* Original Author: Mark Gilbert *
!* copyright, 2015 (first version), 2018 (first git repository), UKAEA *
!******************************************************************************
!end rubric
SUBROUTINE create_fcc()
use configs
IMPLICIT NONE
integer :: islx
integer :: isly,islz
INTEGER, allocatable :: id(:)
integer :: ijk
REAL (KIND=DBL) :: ww(3)
islx=box_nunits
isly=islx
islz=islx
!WRITE(*,*) islx,latt,lx
lx(1)=REAL(islx,DBL)*latt
lx(2)=REAL(isly,DBL)*latt
lx(3)=REAL(islz,DBL)*latt
natoms=4*islx*isly*islz
!WRITE(*,*) natoms
!WRITE(*,*) islx,latt,lx
allocate(id(natoms),x(natoms,3),xe(natoms,3))
ijk=0
do i=0,islx-1
do j=0,isly-1
do k=0,islz-1
ijk=ijk+1
id(ijk)=ijk
x(ijk,1)=latt*REAL(i,DBL)
x(ijk,2)=latt*REAL(j,DBL)
x(ijk,3)=latt*REAL(k,DBL)
! tests
!CALL define_atom_position_fcc(ijk,ww)
!write(111,*) ijk,i,j,k,x(ijk,:)
! in a fcc lattice there arw 3 more atoms in each unit cell:
! the body-centre atom at (0.5,0.5,0),(0,0.5,0.5),(0.5,0,0.5)
ijk=ijk+1
id(ijk)=ijk
x(ijk,1)=latt*(REAL(i,DBL)+0.5_DBL)
x(ijk,2)=latt*(REAL(j,DBL)+0.5_DBL)
x(ijk,3)=latt*(REAL(k,DBL))
!CALL define_atom_position_fcc(ijk,ww)
!write(111,*) ijk,i,j,k,x(ijk,:)
ijk=ijk+1
id(ijk)=ijk
x(ijk,1)=latt*(REAL(i,DBL))
x(ijk,2)=latt*(REAL(j,DBL)+0.5_DBL)
x(ijk,3)=latt*(REAL(k,DBL)+0.5_DBL)
!CALL define_atom_position_fcc(ijk,ww)
!write(111,*) ijk,i,j,k,x(ijk,:)
ijk=ijk+1
id(ijk)=ijk
x(ijk,1)=latt*(REAL(i,DBL)+0.5_DBL)
x(ijk,2)=latt*(REAL(j,DBL))
x(ijk,3)=latt*(REAL(k,DBL)+0.5_DBL)
!CALL define_atom_position_fcc(ijk,ww)
!write(111,*) ijk,i,j,k,x(ijk,:)
end do
end do
end do
END SUBROUTINE create_fcc
SUBROUTINE define_atom_position_fcc(nn,xx)
use configs
IMPLICIT NONE
integer, INTENT(in) :: nn ! atom number
integer :: isly,islz,islx,mm
REAL (KIND=DBL), intent(out) :: xx(3)
integer :: ijk
islx=box_nunits
isly=islx
islz=islx
IF (nn>natoms) THEN
PRINT *,'atom id outside of bounds, quiting',nn,natoms
STOP
END IF
!WRITE(*,*) natoms
!WRITE(*,*) islx,latt,lx
!natoms=4*islx*isly*islz
ijk=nn
IF(mod(nn,4)==0) ijk=nn-1
i=INT(REAL(ijk,DBL)/(4._DBL*REAL(isly,DBL)*REAL(islz,DBL)))
j=INT((REAL(ijk,DBL)-REAL(i,DBL)*4._DBL*REAL(isly,DBL)*REAL(islz,DBL))/ &
(4._DBL*REAL(islz,DBL)))
k=INT((REAL(ijk,DBL)-REAL(i,DBL)*4._DBL*REAL(isly,DBL)*REAL(islz,DBL)-&
REAL(j,DBL)*4._DBL*REAL(islz,DBL))/4._DBL)
mm=mod(nn-1,4)
SELECT CASE(mm)
CASE(0)
xx(1)=latt*(REAL(i,DBL))
xx(2)=latt*(REAL(j,DBL))
xx(3)=latt*(REAL(k,DBL))
CASE(1)
xx(1)=latt*(REAL(i,DBL)+REAL(mm,DBL)*0.5_DBL)
xx(2)=latt*(REAL(j,DBL)+REAL(mm,DBL)*0.5_DBL)
xx(3)=latt*(REAL(k,DBL))
CASE(2)
xx(1)=latt*(REAL(i,DBL))
xx(2)=latt*(REAL(j,DBL)+REAL(mm,DBL)*0.5_DBL)
xx(3)=latt*(REAL(k,DBL)+REAL(mm,DBL)*0.5_DBL)
CASE(3)
xx(1)=latt*(REAL(i,DBL)+REAL(mm,DBL)*0.5_DBL)
xx(2)=latt*(REAL(j,DBL))
xx(3)=latt*(REAL(k,DBL)+REAL(mm,DBL)*0.5_DBL)
END SELECT
!write(111,*) nn,i,j,k,xx
END SUBROUTINE define_atom_position_fcc