Line data Source code
1 : !!****m* ABINIT/m_per_cond
2 : !! NAME
3 : !! m_per_cond
4 : !!
5 : !! FUNCTION
6 : !! This module contains basic tools for periodic conditions traitement.
7 : !!
8 : !! COPYRIGHT
9 : !! Copyright (C) 2008-2026 ABINIT group (MM)
10 : !! This file is distributed under the terms of the
11 : !! GNU General Public License, see ~abinit/COPYING
12 : !! or http://www.gnu.org/copyleft/gpl.txt .
13 : !!
14 : !! INPUTS
15 : !!
16 : !! OUTPUT
17 : !!
18 : !! SOURCE
19 :
20 : #if defined HAVE_CONFIG_H
21 : #include "config.h"
22 : #endif
23 :
24 : #include "abi_common.h"
25 :
26 : MODULE m_per_cond
27 :
28 : use defs_basis
29 : use m_abicore
30 :
31 : implicit none
32 :
33 : private
34 :
35 : public :: per_cond ! Return an arithmetic progression
36 : public :: per_dist ! Return the distance on a periodic grid
37 :
38 :
39 : interface per_cond
40 : module procedure per_cond_re
41 : module procedure per_cond_int
42 : module procedure per_cond_int3
43 : end interface per_cond
44 :
45 : interface per_dist
46 : module procedure per_dist_int
47 : module procedure per_dist_int1
48 : module procedure per_dist_int3
49 : end interface per_dist
50 :
51 : CONTAINS !===========================================================
52 : !!***
53 :
54 : !!****f* m_per_cond/per_cond_re
55 : !! NAME
56 : !! per_cond_re
57 : !!
58 : !! FUNCTION
59 : !! Given a 2d-array of integer initial(3,nb), it calulates the values
60 : !! of any of the array in the periodic orthogonal discretized
61 : !! grid begining in 0 and of lengths dim_grid(3)
62 : !!
63 : !!
64 : !! INPUTS
65 : !! initial(1:3,0:nb-1)=initial point
66 : !! dim_grid(1:3)= box lengths
67 : !! nb= dimension
68 : !! metric=is the factor scale of the box axes
69 : !!
70 : !! OUTPUT
71 : !! per_cond_re= initial in the box
72 : !!
73 : !! SOURCE
74 :
75 0 : function per_cond_re(nb,initial,dim_grid,metric)
76 :
77 : !Arguments ------------------------------------
78 : !scalars
79 : integer,intent(in) :: nb
80 : integer,intent(in) :: dim_grid(3)
81 : integer :: per_cond_re(3,0:nb-1)
82 : real(dp),intent(in) :: initial(3,0:nb-1)
83 : real(dp),intent(in) :: metric(1:3)
84 :
85 : !Local variables-------------------------------
86 : integer :: ii,jj
87 :
88 : ! *********************************************************************
89 0 : do jj=0,nb-1
90 0 : do ii=1,3
91 0 : per_cond_re(ii,jj)=modulo(nint(initial(ii,jj)/metric(ii)),dim_grid(ii))
92 : end do
93 : end do
94 :
95 :
96 : end function per_cond_re
97 : !!***
98 :
99 : !!****f* m_per_cond/per_cond_int
100 : !! NAME
101 : !! per_cond_int
102 : !!
103 : !! FUNCTION
104 : !! Given a 2d-array of integer initial(3,nb), it calulates the values
105 : !! of any of the array in the periodic orthogonal discretized
106 : !! grid begining in 0 and of lengths dim_grid(3)
107 : !!
108 : !!
109 : !! INPUTS
110 : !! initial(1:3,0:nb-1)=initial point
111 : !! dim_grid(1:3)= box lengths
112 : !! nb= dimension
113 : !! metric=is the factor scale of the box axes
114 : !!
115 : !! OUTPUT
116 : !! per_cond_int= initial in the box
117 : !!
118 : !! SOURCE
119 :
120 0 : function per_cond_int(nb,initial,dim_grid)
121 :
122 : !Arguments ------------------------------------
123 : !scalars
124 : integer,intent(in) :: nb
125 : integer,intent(in) :: dim_grid(3)
126 : integer :: per_cond_int(3,0:nb-1)
127 : integer, intent(in) :: initial(3,0:nb-1)
128 :
129 : !Local variables-------------------------------
130 : integer :: ii,jj
131 :
132 : ! *********************************************************************
133 0 : do jj=0,nb-1
134 0 : do ii=1,3
135 0 : per_cond_int(ii,jj)=modulo(initial(ii,jj),dim_grid(ii))
136 : end do
137 : end do
138 :
139 :
140 : end function per_cond_int
141 : !!***
142 :
143 : !!****f* m_per_cond/per_cond_int3
144 : !! NAME
145 : !! per_cond_int3
146 : !!
147 : !! FUNCTION
148 : !! Given a 2d-array of integer initial(3,nb), it calulates the values
149 : !! of any of the array in the periodic orthogonal discretized
150 : !! grid begining in 0 and of lengths dim_grid(3)
151 : !!
152 : !!
153 : !! INPUTS
154 : !! initial(1:3,0:nb-1)=initial point
155 : !! dim_grid(1:3)= box lengths
156 : !! nb= dimension
157 : !! metric=is the factor scale of the box axes
158 : !!
159 : !! OUTPUT
160 : !! per_cond_int3= initial in the box
161 : !!
162 : !! SOURCE
163 :
164 0 : function per_cond_int3(initial,dim_grid)
165 :
166 : !Arguments ------------------------------------
167 : !scalars
168 : integer,intent(in) :: dim_grid(3)
169 : integer :: per_cond_int3(3)
170 : integer,intent(in) :: initial(3)
171 :
172 :
173 : !Local variables-------------------------------
174 : integer :: ii
175 :
176 : ! *********************************************************************
177 :
178 0 : do ii=1,3
179 0 : per_cond_int3(ii) = modulo(initial(ii),dim_grid(ii))
180 : end do
181 :
182 : end function per_cond_int3
183 : !!***
184 :
185 : !!****f* m_per_cond/per_dist_int
186 : !! NAME
187 : !! per_dist_int
188 : !!
189 : !! FUNCTION
190 : !! Given a two 2d-array of integer initA(3,nb),initB(3,nb) in the
191 : !! periodic grid, it calulates the values
192 : !! of any of the distances in the periodic orthogonal discretized
193 : !! grid begining in 0 and of lengths dim_grid(3)
194 : !!
195 : !!
196 : !! INPUTS
197 : !! initA(1:3,0:nb-1)=initial point
198 : !! initB(1:3,0:nb-1)=initial point
199 : !! dim_grid(1:3)= box lengths
200 : !! nb= dimension
201 : !!
202 : !! OUTPUT
203 : !! per_dist_int= initial in the box
204 : !!
205 : !! SOURCE
206 :
207 0 : function per_dist_int(nb,initA,initB,dim_grid)
208 :
209 : !Arguments ------------------------------------
210 : !scalars
211 : integer,intent(in) :: nb
212 : integer,intent(in) :: dim_grid(3)
213 : integer :: per_dist_int(3,0:nb-1)
214 : integer,intent(in) :: initA(3,0:nb-1),initB(3,0:nb-1)
215 :
216 :
217 : !Local variables-------------------------------
218 : integer :: ii,jj, bo
219 :
220 : ! *********************************************************************
221 0 : do jj=0,nb-1
222 0 : do ii=1,3
223 0 : bo = abs(initA(ii,jj)-initB(ii,jj))
224 0 : per_dist_int(ii,jj) = minval((/ bo,dim_grid(ii)-bo/))
225 : end do
226 : end do
227 :
228 :
229 : end function per_dist_int
230 : !!***
231 :
232 :
233 : !!****f* m_per_cond/per_dist_int1
234 : !! NAME
235 : !! per_dist_int1
236 : !!
237 : !! FUNCTION
238 : !! Given a two scalars of integer initA,initB in the
239 : !! periodic grid, it calulates the values
240 : !! of any of the distances in the periodic orthogonal discretized
241 : !! grid begining in 0 and of lengths dim_grid
242 : !!
243 : !!
244 : !! INPUTS
245 : !! initA=initial point
246 : !! initB=initial point
247 : !! dim_grid= box lengths
248 : !!
249 : !! OUTPUT
250 : !! per_dist_int1= initial in the box
251 : !!
252 : !! SOURCE
253 :
254 0 : function per_dist_int1(initA,initB,dim_grid)
255 :
256 : !Arguments ------------------------------------
257 : !scalars
258 : integer,intent(in) :: dim_grid,initA,initB
259 : integer :: per_dist_int1
260 :
261 :
262 : !Local variables-------------------------------
263 : integer :: bo
264 :
265 : ! *********************************************************************
266 0 : bo = abs(initA-initB)
267 0 : per_dist_int1 = minval((/ bo,dim_grid-bo/))
268 :
269 0 : end function per_dist_int1
270 : !!***
271 :
272 :
273 : !!****f* m_per_cond/per_dist_int3
274 : !! NAME
275 : !! per_dist_int3
276 : !!
277 : !! FUNCTION
278 : !! Given a two 3d-vector of integer initA(3),initB(3) in the
279 : !! periodic grid, it calulates the values
280 : !! of any of the distances in the periodic orthogonal discretized
281 : !! grid begining in 0 and of lengths dim_grid(3)
282 : !!
283 : !!
284 : !! INPUTS
285 : !! initA(1:3)=initial point
286 : !! initB(1:3)=initial point
287 : !! dim_grid(1:3)= box lengths
288 : !!
289 : !! OUTPUT
290 : !! per_dist_int3= initial in the box
291 : !!
292 : !! SOURCE
293 :
294 0 : function per_dist_int3(initA,initB,dim_grid)
295 :
296 : !Arguments ------------------------------------
297 : !scalars
298 : integer,intent(in) :: dim_grid(3)
299 : integer :: per_dist_int3(3)
300 : integer,intent(in) :: initA(3),initB(3)
301 :
302 :
303 : !Local variables-------------------------------
304 : integer :: ii, bo
305 :
306 : ! *********************************************************************
307 0 : do ii=1,3
308 0 : bo = abs(initA(ii)-initB(ii))
309 0 : per_dist_int3(ii) = minval((/ bo,dim_grid(ii)-bo/))
310 : end do
311 :
312 : end function per_dist_int3
313 : !!***
314 :
315 : END MODULE m_per_cond
316 : !!***
|