-
Notifications
You must be signed in to change notification settings - Fork 0
/
nlist.f90
89 lines (63 loc) · 2.54 KB
/
nlist.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
MODULE nlistmod
USE prms
USE data
IMPLICIT none
TYPE :: listelm
integer :: ll ! point index of neighbor
integer :: mm ! cell index of neighbor
END TYPE listelm
CONTAINS
SUBROUTINE atomcell(X,Icell,hspace,Nmax)
real,dimension(2,Np) :: X ! particle positions
integer,dimension(2,Np) :: Icell ! atom cell list
real,dimension(2) :: hspace ! mesh cell spacing for distribution
integer,dimension(2) :: Nmax ! max cell
integer :: l
do l = 1,2
Icell(l,:) = INT( (X(l,:) - FLOOR(X(l,:)/Lb(l))*Lb(l))/hspace(l)) + 1
end do
END SUBROUTINE atomcell
SUBROUTINE chainlist(LL,HOC,N,X,tl)
integer,dimension(Np) :: LL ! next in list pointer
integer,dimension(2) :: N ! number of cells
integer,dimension(0:N(1)+1,0:N(2)+1) :: HOC ! Head-of-Chain pointer
! with perioidic continuation
real ,dimension(2,Np) :: X ! particle positions
real :: tl ! time
integer,dimension(2,Np) :: Icell ! atom cell list
integer :: i
real,dimension(2) :: HMf ! cell spacing
HMf = Lb/REAL(N)
call atomcell(X,Icell,HMf,N)
HOC = 0
do i = 1,Np
LL(i) = HOC(Icell(1,i),Icell(2,i))
HOC(Icell(1,i),Icell(2,i)) = i
end do
call makeper(HOC,N,tl)
END SUBROUTINE chainlist
SUBROUTINE makeper(HOC,N,tl)
integer,dimension(2) :: N ! number of cells
integer,dimension(0:N(1)+1,0:N(2)+1) :: HOC ! Head-of-Chain pointer
real :: tl ! time
integer :: ic,icsh
integer, dimension(2) :: i
if (N(2).gt.2) then
if (Ueps.eq.0) then
HOC(:,0) = HOC(:,N(2))
HOC(:,N(2)+1) = HOC(:,1)
else
do ic = 0,N(1)+1
icsh = MOD(ic-1-INT(MOD(Ueps*(tl-T_sh_on),Lb(2))*REAL(N(1))/Lb(1))+2*N(1),N(1)) + 1
HOC(ic,N(2)+1) = HOC(icsh,1)
icsh = MOD(ic-1+INT(Ueps*(tl-T_sh_on)*REAL(N(1))/Lb(1)),N(1)) + 1
HOC(ic,0) = HOC(icsh,N(2))
end do
end if
end if
if (N(1).gt.2) then
HOC(0,:) = HOC(N(1),:)
HOC(N(1)+1,:) = HOC(1,:)
end if
END SUBROUTINE makeper
END MODULE nlistmod