11 |
|
|
12 |
|
type, public :: simtype |
13 |
|
PRIVATE |
14 |
< |
SEQUENCE |
14 |
> |
! SEQUENCE |
15 |
|
!! Number of particles on this processor |
16 |
|
integer :: nLRparticles |
17 |
|
!! Periodic Box |
38 |
|
integer, allocatable, dimension(:) :: tag_column |
39 |
|
#endif |
40 |
|
|
41 |
< |
|
41 |
> |
!! WARNING: use_pbc hardcoded, fixme |
42 |
> |
logical :: use_pbc = .true. |
43 |
|
logical :: setSim = .false. |
43 |
– |
|
44 |
– |
real( kind = dp ), allocatable(:,:),save :: q0 |
44 |
|
|
45 |
+ |
!! array for saving previous positions for neighbor lists. |
46 |
+ |
real( kind = dp ), allocatable,dimension(:,:),save :: q0 |
47 |
+ |
|
48 |
+ |
|
49 |
|
public :: check |
50 |
|
public :: save_nlist |
51 |
|
public :: wrap |
52 |
|
public :: getBox |
53 |
|
public :: getRcut |
54 |
< |
public :: setRcut |
54 |
> |
public :: getRlist |
55 |
> |
public :: getNlocal |
56 |
> |
public :: setSimulation |
57 |
> |
! public :: setRcut |
58 |
|
|
59 |
|
interface wrap |
60 |
|
module procedure wrap_1d |
79 |
|
|
80 |
|
subroutine setSimulation(nLRParticles,box,rlist,rcut) |
81 |
|
integer, intent(in) :: nLRParticles |
82 |
< |
real(kind = dp ), intent(in) :: box |
82 |
> |
real(kind = dp ), intent(in), dimension(3) :: box |
83 |
|
real(kind = dp ), intent(in) :: rlist |
84 |
|
real(kind = dp ), intent(in) :: rcut |
85 |
|
|
91 |
|
thisSim%rlist = rlist |
92 |
|
thisSim%rcut = rcut |
93 |
|
thisSim%rcutsq = rcut * rcut |
94 |
< |
thisSim%rcut6 = rcutsq * rcutsq * rcutsq |
94 |
> |
thisSim%rcut6 = thisSim%rcutsq * thisSim%rcutsq * thisSim%rcutsq |
95 |
|
|
96 |
|
end subroutine setSimulation |
97 |
|
|
109 |
|
end subroutine change_box_size |
110 |
|
|
111 |
|
|
112 |
< |
elemental function getBox_3d() result(thisBox) |
112 |
> |
function getBox_3d() result(thisBox) |
113 |
|
real( kind = dp ), dimension(3) :: thisBox |
114 |
|
thisBox = thisSim%box |
115 |
|
end function getBox_3d |
121 |
|
thisBox = thisSim%box(dim) |
122 |
|
end function getBox_dim |
123 |
|
|
124 |
< |
subroutine check(update_nlist) |
125 |
< |
|
124 |
> |
subroutine check(q,update_nlist) |
125 |
> |
real( kind = dp ), dimension(:,:) :: q |
126 |
|
integer :: i |
127 |
|
real( kind = DP ) :: dispmx |
128 |
|
logical, intent(out) :: update_nlist |
129 |
|
real( kind = DP ) :: dispmx_tmp |
130 |
< |
|
130 |
> |
real( kind = dp ) :: skin_thickness |
131 |
> |
integer :: natoms |
132 |
> |
|
133 |
> |
natoms = thisSim%nLRparticles |
134 |
> |
skin_thickness = thisSim%rlist |
135 |
|
dispmx = 0.0E0_DP |
126 |
– |
|
136 |
|
!! calculate the largest displacement of any atom in any direction |
137 |
|
|
138 |
|
#ifdef MPI |
168 |
|
|
169 |
|
if (.not. allocated(q0)) then |
170 |
|
allocate(q0(3,list_size)) |
171 |
< |
else if( list_size > size(q0)) |
171 |
> |
else if( list_size > size(q0)) then |
172 |
|
deallocate(q0) |
173 |
|
allocate(q0(3,list_size)) |
174 |
|
endif |
195 |
|
return |
196 |
|
end function wrap_1d |
197 |
|
|
198 |
< |
elemental function wrap_3d(r) result(this_wrap) |
198 |
> |
function wrap_3d(r) result(this_wrap) |
199 |
|
real( kind = dp ), dimension(3), intent(in) :: r |
200 |
|
real( kind = dp ), dimension(3) :: this_wrap |
201 |
|
|
202 |
|
|
203 |
|
if (use_pbc) then |
204 |
|
! this_wrap = r - box(dim)*dsign(1.0E0_DP,r)*int(abs(r/box(dim)) + 0.5E0_DP) |
205 |
< |
this_wrap(1:3) = r(1:3) - box(1:3)*nint(r(1:3)/box(1:3)) |
205 |
> |
this_wrap = r - thisSim%box*nint(r/thisSim%box) |
206 |
|
else |
207 |
|
this_wrap = r |
208 |
|
endif |
209 |
|
end function wrap_3d |
210 |
|
|
211 |
< |
|
212 |
< |
|
211 |
> |
|
212 |
> |
|
213 |
|
subroutine getRcut(thisrcut,rcut2,rcut6,status) |
214 |
|
real( kind = dp ), intent(out) :: thisrcut |
215 |
|
real( kind = dp ), intent(out), optional :: rcut2 |
216 |
< |
real( kind = dp ), intent(out), optional :: thisrcut6 |
216 |
> |
real( kind = dp ), intent(out), optional :: rcut6 |
217 |
|
integer, optional :: status |
218 |
|
|
219 |
|
if (present(status)) status = 0 |
223 |
|
return |
224 |
|
end if |
225 |
|
|
226 |
< |
thisrcut = rcut |
227 |
< |
if(present(rcut2)) rcut2 = rcutsq |
228 |
< |
if(present(rcut2)) rcut6 = rcut_6 |
226 |
> |
thisrcut = thisSim%rcut |
227 |
> |
if(present(rcut2)) rcut2 = thisSim%rcutsq |
228 |
> |
if(present(rcut2)) rcut6 = thisSim%rcut6 |
229 |
|
|
230 |
|
end subroutine getRcut |
231 |
|
|
232 |
+ |
|
233 |
+ |
|
234 |
+ |
|
235 |
+ |
subroutine getRlist(thisrlist,rlist2,status) |
236 |
+ |
real( kind = dp ), intent(out) :: thisrlist |
237 |
+ |
real( kind = dp ), intent(out), optional :: rlist2 |
238 |
|
|
239 |
+ |
integer, optional :: status |
240 |
|
|
241 |
+ |
if (present(status)) status = 0 |
242 |
|
|
243 |
+ |
if (.not.setSim ) then |
244 |
+ |
if (present(status)) status = -1 |
245 |
+ |
return |
246 |
+ |
end if |
247 |
+ |
|
248 |
+ |
thisrlist = thisSim%rlist |
249 |
+ |
if(present(rlist2)) rlist2 = thisSim%rlistsq |
250 |
+ |
|
251 |
+ |
end subroutine getRlist |
252 |
+ |
|
253 |
+ |
|
254 |
+ |
|
255 |
+ |
pure function getNlocal() result(nlocal) |
256 |
+ |
integer :: nlocal |
257 |
+ |
nlocal = thisSim%nLRparticles |
258 |
+ |
end function getNlocal |
259 |
+ |
|
260 |
+ |
|
261 |
+ |
|
262 |
|
end module simulation |