-
Notifications
You must be signed in to change notification settings - Fork 5
/
IdentifyNonBonded.f
278 lines (229 loc) · 10.2 KB
/
IdentifyNonBonded.f
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
! Identify intramolecular non-bonded atom pairs; general use ...
module NonBondPairs
use constants_m
use MM_types , only : MM_molecular
private
public :: Identify_NonBondPairs
contains
!
!
!
!
!===============================================
subroutine Identify_NonBondPairs( species , a )
!===============================================
implicit none
type(MM_molecular) , intent(inout) :: species(:)
integer , intent(in) :: a
! local variables ...
integer , allocatable :: vector_of_pairs(:,:) , vector_of_pairs14(:,:)
integer :: i , j , k , m , n , NN , MM , idx
logical :: flagB1, flagB2, flagA1, flagA2, flagD1, flagD2, flagB11, flagB12, flagB21, flagB22
logical :: flagB111, flagB112, flagB121, flagB122, flagB211, flagB212, flagB221, flagB222 , flag1, flag2
logical , allocatable :: InputRef(:,:) , Input14(:,:)
!==============================================================================================
If( species(a) % N_of_atoms <= 3 ) return
NN = 10000
!NN = species(a)% Nbonds
allocate( InputRef ( NN , NN ) , source = .true. )
allocate( Input14 ( NN , NN ) , source = .false. )
! Intramolecular LJ list generation ...
! Preparing ...
do i = 1 , species(a) % N_of_atoms
idx = 1
! Looking for bonds ...
do k = 1 , species(a) % Nbonds
flagB1 = ( species(a) % atom(i) % my_id == species(a) % bonds(k,1) )
flagB2 = ( species(a) % atom(i) % my_id == species(a) % bonds(k,2) )
if ( flagB1 ) then
InputRef(i,species(a)%bonds(k,2)) = .false.
idx = idx + 1
! looking for angle connections ...
do n = 1 , species(a) % Nbonds
flagB11 = ( species(a) % bonds(k,2) == species(a) % bonds(n,1) )
flagB12 = ( species(a) % bonds(k,2) == species(a) % bonds(n,2) )
if ( flagB11 ) then
InputRef(i,species(a)%bonds(n,2)) = .false.
idx = idx + 1
! looking for dihedral connections ...
do m = 1 , species(a) % Nbonds
flagB111 = ( species(a) % bonds(n,2) == species(a) % bonds(m,1) )
flagB112 = ( species(a) % bonds(n,2) == species(a) % bonds(m,2) )
if ( flagB111 ) then
InputRef(i,species(a)%bonds(m,2)) = .false.
Input14(i,species(a)%bonds(m,2)) = .true.
idx = idx + 1
elseif ( flagB112 ) then
InputRef(i,species(a)%bonds(m,1)) = .false.
Input14(i,species(a)%bonds(m,1)) = .true.
idx = idx + 1
end if
end do
! looking for angle connections ...
elseif ( flagB12 ) then
InputRef(i,species(a)%bonds(n,1)) = .false.
idx = idx + 1
! looking for dihedral connections ...
do m = 1 , species(a) % Nbonds
flagB121 = ( species(a) % bonds(n,1) == species(a) % bonds(m,1) )
flagB122 = ( species(a) % bonds(n,1) == species(a) % bonds(m,2) )
if ( flagB121 ) then
InputRef(i,species(a)%bonds(m,2)) = .false.
Input14(i,species(a)%bonds(m,2)) = .true.
idx = idx + 1
elseif ( flagB122 ) then
InputRef(i,species(a)%bonds(m,1)) = .false.
Input14(i,species(a)%bonds(m,1)) = .true.
idx = idx + 1
end if
end do
end if
end do
! Looking for bonds ...
elseif ( flagB2 ) then
InputRef(i,species(a)%bonds(k,1)) = .false.
idx = idx + 1
! looking for angle connections ...
do n = 1 , species(a) % Nbonds
flagB21 = ( species(a) % bonds(k,1) == species(a) % bonds(n,1) )
flagB22 = ( species(a) % bonds(k,1) == species(a) % bonds(n,2) )
if ( flagB21 ) then
InputRef(i,species(a)%bonds(n,2)) = .false.
idx = idx + 1
! looking for dihedral connections ...
do m = 1 , species(a) % Nbonds
flagB211 = ( species(a) % bonds(n,2) == species(a) % bonds(m,1) )
flagB212 = ( species(a) % bonds(n,2) == species(a) % bonds(m,2) )
if ( flagB211 ) then
InputRef(i,species(a)%bonds(m,2)) = .false.
Input14(i,species(a)%bonds(m,2)) = .true.
idx = idx + 1
elseif ( flagB212 ) then
InputRef(i,species(a)%bonds(m,1)) = .false.
Input14(i,species(a)%bonds(m,1)) = .true.
idx = idx + 1
end if
end do
! looking for angle connections ...
elseif ( flagB22 ) then
InputRef(i,species(a)%bonds(n,1)) = .false.
idx = idx + 1
! looking for dihedral connections ...
do m = 1 , species(a) % Nbonds
flagB221 = ( species(a) % bonds(n,1) == species(a) % bonds(m,1) )
flagB222 = ( species(a) % bonds(n,1) == species(a) % bonds(m,2) )
if ( flagB221 ) then
InputRef(i,species(a)%bonds(m,2)) = .false.
Input14(i,species(a)%bonds(m,2)) = .true.
idx = idx + 1
elseif ( flagB222 ) then
InputRef(i,species(a)%bonds(m,1)) = .false.
Input14(i,species(a)%bonds(m,1)) = .true.
idx = idx + 1
end if
end do
end if
end do
end if
end do
! Looking for 'explicit' dihedrals (just in case) ...
do k = 1 , species(a) % Ndiheds
if( species(a) %funct_dihed(k) == 3 ) then
flagD1 = ( species(a) % atom(i) % my_id == species(a) % diheds(k,1) )
flagD2 = ( species(a) % atom(i) % my_id == species(a) % diheds(k,4) )
if ( flagD1 ) then
InputRef(i,species(a)%diheds(k,4)) = .false.
Input14(i,species(a)%diheds(k,4)) = .true.
idx = idx + 1
elseif ( flagD2 ) then
InputRef(i,species(a)%diheds(k,1)) = .false.
Input14(i,species(a)%diheds(k,1)) = .true.
idx = idx + 1
end if
end if
end do
! Looking for 'explicit' angles (just in case) ...
do k = 1 , species(a) % Nangs
flagA1 = ( species(a) % atom(i) % my_id == species(a) % angs(k,1) )
flagA2 = ( species(a) % atom(i) % my_id == species(a) % angs(k,3) )
if ( flagA1 ) then
InputRef(i,species(a)%angs(k,3)) = .false.
Input14(i,species(a)%angs(k,3)) = .false.
idx = idx + 1
elseif ( flagA2 ) then
InputRef(i,species(a)%angs(k,1)) = .false.
Input14(i,species(a)%angs(k,1)) = .false.
idx = idx + 1
end if
end do
! Looking for 'explicit' bonds (just in case for 1,4 ints) ...
do k = 1 , species(a) % Nbonds
flag1 = ( species(a) % atom(i) % my_id == species(a) % bonds(k,1) )
flag2 = ( species(a) % atom(i) % my_id == species(a) % bonds(k,2) )
if ( flag1 ) then
Input14(i,species(a)%bonds(k,2)) = .false.
idx = idx + 1
elseif ( flag2 ) then
Input14(i,species(a)%bonds(k,1)) = .false.
idx = idx + 1
end if
end do
end do
! Intermediate variable ...
allocate( vector_of_pairs( species(a) % N_of_Atoms * species(a) % N_of_Atoms , 2 ) , source = I_zero )
k = 1
do i = 1 , species(a) % N_of_Atoms - 1
do j = i , species(a) % N_of_Atoms
if ( InputRef(i,j) == .true. ) then
vector_of_pairs(k,1) = i
vector_of_pairs(k,2) = j
k = k + 1
end if
end do
end do
MM = count(vector_of_pairs(:,2) /= 0 )
allocate( species(a) % IntraIJ( MM , 3 ) , source=I_zero )
species(a)%NintraIJ = MM
! Finally associating the nonbonded interactions to species ...
do i = 1 , MM
species(a) % IntraIJ(i,1) = vector_of_pairs(i,1)
species(a) % IntraIJ(i,2) = vector_of_pairs(i,2)
species(a) % IntraIJ(i,3) = 1 ! <== LJ interaction
end do
! 1--4 Interactions: only if [ pairs ] is not read in the .itp file ...
if ( .NOT. allocated (species(a) % bonds14) ) then
! Intermediate variable for 1-4...
allocate( vector_of_pairs14( 20000, 2 ) , source = I_zero )
!allocate( vector_of_pairs14( species(a) % N_of_Atoms * species(a) % N_of_Atoms ,2 ) , source = I_zero )
k = 1
do i = 1 , species(a) % N_of_Atoms - 1
do j = i , species(a) % N_of_Atoms
if ( Input14(i,j) == .true. ) then
vector_of_pairs14(k,1) = i
vector_of_pairs14(k,2) = j
k = k + 1
end if
end do
end do
species(a) % Nbonds14 = ( size( pack( vector_of_pairs14(:,2), vector_of_pairs14(:,2) /= 0 ) ) )
! Preparing 1--4 interactions ...
allocate( species(a) % bonds14(species(a) % Nbonds14,2 ) )
! Associating 1--4 interactions to species ...
k = 1
do i = 1 , species(a) % N_of_atoms
do j = i , species(a) % N_of_atoms
if( Input14(i,j) .eqv. .true. ) then
species(a) % bonds14(k,1) = i
species(a) % bonds14(k,2) = j
k = k + 1
end if
end do
end do
end if
deallocate( InputRef , Input14 , vector_of_pairs )
!==============================================================================================
end subroutine Identify_NonBondPairs
!
!
!
end module NonBondPairs