-
Notifications
You must be signed in to change notification settings - Fork 6
/
pbc_mod.f90
56 lines (32 loc) · 1.12 KB
/
pbc_mod.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
module pbc_mod
use global_mod, only: dim,Lbox,LboxHalf
implicit none
contains
!-----------------------------------------------------------------------
subroutine BoundaryConditions(k,xij)
implicit none
real (kind=8) :: xij
integer (kind=4) :: k
!if (xij>Lbox(k)) xij = xij-Lbox(k)
!if (xij<0.d0) xij = xij+Lbox(k)
if (xij> LboxHalf(k)) xij = xij-Lbox(k)
if (xij<-LboxHalf(k)) xij = xij+Lbox(k)
return
end subroutine BoundaryConditions
!-----------------------------------------------------------------------
subroutine MinimumImage(xij,rij2)
implicit none
real (kind=8) :: rij2
integer (kind=4) :: k
real (kind=8),dimension (dim) :: xij
rij2 = 0.d0
do k=1,dim
if (xij(k)> LboxHalf(k)) xij(k) = xij(k)-Lbox(k)
if (xij(k)<-LboxHalf(k)) xij(k) = xij(k)+Lbox(k)
!if (abs(xij(k)>LboxHalf(k)) xij(k) = xij(k)-sign(Lbox(k),xij(k))
rij2 = rij2+xij(k)*xij(k)
end do
return
end subroutine MinimumImage
!-----------------------------------------------------------------------
end module pbc_mod