-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.f90
76 lines (64 loc) · 1.18 KB
/
init.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
PROGRAM initialization
! Building a FCC lattice
IMPLICIT NONE
INTEGER, PARAMETER :: d = 8 ! dimension of the box in angstrom
INTEGER, PARAMETER :: Ntot = 8*d*d
REAL*8, DIMENSION (Ntot,3) :: pos
REAL*8, PARAMETER :: a = 3.89 ! in angstrom
INTEGER :: i,j,k
OPEN (UNIT = 10, FILE = "slab.ascii", STATUS = "replace")
!build the lattice
k=1
!first layer
do i=0,d-1
do j=0,d-1
pos(k,1)=a*i
pos(k,2)=a*j
pos(k,3)=0
pos(k+1,1)=a*(i+0.5)
pos(k+1,2)=a*(j+0.5)
pos(k+1,3)=0
k=k+2
end do
end do
!second layer
do i=0,d-1
do j=0,d-1
pos(k,1)=a*i
pos(k,2)=a*(j+0.5)
pos(k,3)=a*0.5
pos(k+1,1)=a*(i+0.5)
pos(k+1,2)=a*j
pos(k+1,3)=a*0.5
k=k+2
end do
end do
!third layer
do i=0,d-1
do j=0,d-1
pos(k,1)=a*i
pos(k,2)=a*j
pos(k,3)=a
pos(k+1,1)=a*(i+0.5)
pos(k+1,2)=a*(j+0.5)
pos(k+1,3)=a
k=k+2
end do
end do
!fourth layer
do i=0,d-1
do j=0,d-1
pos(k,1)=a*i
pos(k,2)=a*(j+0.5)
pos(k,3)=a*1.5
pos(k+1,1)=a*(i+0.5)
pos(k+1,2)=a*j
pos(k+1,3)=a*1.5
k=k+2
end do
end do
do k= 1, Ntot
write(10,'(a,3(3x,F18.10))') 'C', (pos(k,i),i=1,3)
enddo
close(10)
END PROGRAM initialization