forked from lgcrego/Dynemol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checklist.f
409 lines (312 loc) · 13.4 KB
/
checklist.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
MODULE setup_checklist
use type_m
use parameters_m
use MM_input
use OMP_lib
use MPI_definitions_m , only : np
public :: checklist , dump_driver_parameters_and_tuning , Checking_Topology
private
! module variables ...
logical :: done = .false.
contains
!
!
!
!====================
subroutine checklist
!====================
implicit none
! local parameters ...
logical , parameter :: T_ = .true. , F_ = .false.
! local variables ...
! feel free to add your own dynemol-for-dummies checklist ...
select case( DRIVER )
case( "q_dynamics" , "slice_Cheb" , "slice_AO" , "slice_FSSH" , "slice_CSDM" )
If( ad_hoc == F_ .OR. Survival == F_ ) then
CALL warning("halting: the DRIVER you chose must go with Survival = T_ AND ad_hoc = T")
stop
end If
case( "avrg_confgs" )
If( file_type /= "trajectory" ) stop ">>> Mind: if DRIVER=^avrg_confgs^: file_type must be ^trajectory^; check parameters.f"
If( nuclear_matter /= "extended_sys" ) stop ">>> Mind: if DRIVER=^avrg_confgs^: nuclear_matter must be ^extended_sys^; check parameters.f"
case( "Genetic_Alg" )
If( nuclear_matter /= "extended_sys" ) stop ">>> Mind: if DRIVER=^Genetic_Alg^: nuclear_matter must be ^extended_sys^; check parameters.f"
If( EnvField_ == .true. ) stop ">>> Mind: if DRIVER=^Genetic_Alg^: flag ^EnvField_ = F_^; check parameters.f"
end select
If ( (frame_step /= 1) .AND. (file_type /= "trajectory") ) then
CALL warning("halting: frame_step /= 1, only for avrg_confgs or time-slice dynamics")
stop
End If
end subroutine checklist
!
!
!
!
!============================================
subroutine dump_driver_parameters_and_tuning
!============================================
implicit none
! local parameters ...
character(len=3) :: month(12)=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
! local variables ...
integer :: date_time(8)
character(len=3) :: tag
character(len=12) :: number_string
open (10, file='log.trunk/driver_parms_and_tuning.log', status='unknown')
call date_and_time(values=date_time)
write(10,29) month(date_time(2)),date_time(3),date_time(1),date_time(5),date_time(6)
write(10,27) np
write(10,28) OMP_GET_MAX_threads()
write(10,'(''<====== ############### ==>'')')
write(10,'(''<==== PARAMETERS.F ====>'')')
write(10,'(''<== ############### ======>'')')
write(10,*)
write(10,'(" DRIVER :" , A12 )') DRIVER
if( .not. static ) then
if( DRIVER /= "MM_Dynamics" ) then
tag = merge("no ","yes", (DRIVER == "slice_CSDM") .OR. (DRIVER == "slice_FSSH") )
write(10,'(" QMMM :" , A10)' , advance=tag) merge(".true. <==",".false. ",QMMM)
If( tag == "no" ) then
write(10,'(" rnd_seed =" , A11)') merge(" .true. <=="," .false. ",rnd_seed)
write(10,'(t29," DK_of_mixing = " , A6)') DK_of_mixing
end IF
write(10,'(" OPT_parms :" , A10)') merge(".true. <==",".false. ",OPT_parms)
write(10,'(" SPECTRUM :" , A10)') merge(".true. <==",".false. ",SPECTRUM)
write(10,'(" Alpha_Tensor :" , A10)') merge(".true. <==",".false. ",Alpha_Tensor)
tag = merge("no ","yes",GaussianCube)
write(10 , '(" GaussianCube :" , A10)' , advance=tag) merge(".true. <==",".false. ",GaussianCube)
If( GaussianCube ) &
write(10,'(" GaussianCube_step = " , I0)') GaussianCube_step
tag = merge("no ","yes",NetCharge)
write(10 , '(" NetCharge :" , A10)' , advance=tag) merge(".true. <==",".false. ",NetCharge)
If( NetCharge ) &
write(10,'(" CH_and_DP_step = " , I0)') CH_and_DP_step
write(10,'(" DensityMatrix :" , A10)') merge(".true. <==",".false. ",DensityMatrix)
write(10,'(" AutoCorrelation :" , A10)') merge(".true. <==",".false. ",AutoCorrelation)
write(10,'(" VDOS_ :" , A10)') merge(".true. <==",".false. ",VDOS_)
tag = merge("no ","yes",EnvField_)
write(10 , '(" EnvField_ :" , A10)' , advance=tag) merge(".true. <==",".false. ",EnvField_)
If( EnvField_) then
write(10,'(" Environ_Type =" , A6)' , advance=tag) Environ_Type
write(10,'(" / Environ_step = " , I0)') Environ_step
end IF
write(10,'(" Coulomb_ :" , A10)') merge(".true. <==",".false. ",Coulomb_)
write(10,'(" Induced_ :" , A10)') merge(".true. <==",".false. ",Induced_)
write(10,'(" frame_step : " , I0)') frame_step
end if
write(10,'(" ad_hoc :" , A10)') merge(".true. <==",".false. ",ad_hoc)
write(10,'(" restart :" , A10)') merge(".true. <==",".false. ",restart)
write( number_string , '(F12.4)' ) t_f
write(10,'(" t_f : " , A12)') adjustl(number_string)
write(10,'(" n_t : " , I0)') n_t
if( (DRIVER(1:5) == "slice") .or. DRIVER == "q_dynamics" .or. DRIVER == "avrg_confgs") then
write(10,'(" CT_dump_step : " , I0)') CT_dump_step
write(10,'(" n_part : " , I0)') n_part
write(10,'(" hole_state : " , I0)') hole_state
write(10,'(" electron_state : " , I0)') electron_state
end if
write(10,'(" nnx , nny : " , I0,I2)') nnx , nny
write(10,'(" PBC : " , I0,I2,I2)') PBC
write(10,*)
elseif( DRIVER == "Genetic_Alg" ) then
write(10,'(" OPT_parms :" , A10)') merge(".true. <==",".false. ",OPT_parms)
write(10,'(" DP_Moment :" , A10)') merge(".true. <==",".false. ",DP_Moment)
write(10,'(" Alpha_Tensor :" , A10)') merge(".true. <==",".false. ",Alpha_Tensor)
write(10,'(" ad_hoc :" , A10)') merge(".true. <==",".false. ",ad_hoc)
write(10,'(" GaussianCube :" , A10)') merge(".true. <==",".false. ",GaussianCube)
write(10,'(" Pop_Size :" , I0)') Pop_Size
write(10,'(" N_generations :" , I0)') N_generations
write( number_string , '(F8.5)' ) Pop_range
write(10,'(" Pop_range :" , A8)') adjustl(number_string)
write(10,'(" selection_by :" , A8)') adjustl(selection_by)
tag = merge("no ","yes",Mutate_Cross)
write(10 , '(" Mutate_Cross :" , A10)' , advance=tag) merge(".true. <==",".false. ",Mutate_Cross)
If( Mutate_Cross ) &
write(10,'(" Mutation_rate = " , F5.3)') Mutation_rate
write(10,'(" Adaptive_ :" , A10)') merge(".true. <==",".false. ",Adaptive_)
tag = merge("no ","yes",CG_)
write(10,'(" CG_ :" , A10)' , advance=tag) merge(".true. <==",".false. ",CG_ )
If( CG_ ) write(10,'(" Top_Selection = " , I0)') Top_Selection
write(10,'(" profiling :" , A10)') merge(".true. <==",".false. ",profiling)
end if
if( nuclear_matter == "MDynamics" ) then
write(10,'(''<====== ############### ==>'')')
write(10,'(''<==== parameters_MM.f ====>'')')
write(10,'(''<== ############### ======>'')')
write(10,*)
tag = merge("no ","yes",driver_MM == "MM_Dynamics")
write(10 , '(" driver_MM : " , A11)' , advance=tag) driver_MM
If( driver_MM == "MM_Dynamics" ) then
write(10,'(" <== thermostat = " , A14)' ) thermostat
If( thermostat /= "Microcanonical" ) then
write( number_string , '(F6.2)' ) temperature
write(10,'(t36,"temperature = " , A6)') adjustl(number_string)
write( number_string , '(F8.5)' ) thermal_relaxation_time
write(10,'(t36,"relax time = " , A7)') adjustl(number_string)
end If
write(10,'(t36,"read_velocities :" , A10)') merge(".true. <==",".false. ",read_velocities)
end IF
write( number_string , '(F6.2)' ) cutoff_radius
write(10,'(" Wolf_cutoff : " , A6)') adjustl(number_string)
write( number_string , '(F8.5)' ) damping_Wolf
write(10,'(" Wolf_damping : " , A8)') adjustl(number_string)
write(10,'(" MM_input_format : " , A4)') MM_input_format
write(10,'(" MM_log_step : " , I0)') MM_log_step
write(10,'(" MM_frame_step : " , I0)') MM_frame_step
write(10,*)
end if
close (10)
if( ad_hoc ) then
open (10, file='log.trunk/driver_parms_and_tuning.log', status='old', access='append')
write(10,'(''<====== ############### ==>'')')
write(10,'(''<==== TUNING.F ====>'')')
write(10,'(''<== ############### ======>'')')
write(10,*)
close (10)
if( DRIVER /= "MM_Dynamics" ) then
open (10, file='log.trunk/driver_parms_and_tuning.log', status='old', access='append')
write(10,'("== Electronic Tuning ==")')
write(10,*)
CALL system("awk '/univ/ && NR >= 37 && NR <= 85' < $DYNEMOLDIR/tuning.f | awk '!/ !/' >> log.trunk/driver_parms_and_tuning.log")
close(10)
end if
if( nuclear_matter == "MDynamics" ) then
open (10, file='log.trunk/driver_parms_and_tuning.log', status='old', access='append')
write(10,*)
write(10,'("== Nuclear Tuning ==")')
write(10,*)
CALL system("awk '/atom/&&/%/&&/=/' < $DYNEMOLDIR/tuning.f | awk '!/univ/' | awk '!/ !/' | awk '{gsub(/^[ \t]+/,x); print}' >> log.trunk/driver_parms_and_tuning.log")
close(10)
end if
end if
include 'formats.h'
end subroutine dump_driver_parameters_and_tuning
!
!
!
!================================================================
function Checking_Topology( bonds , angs , diheds ) result(TorF)
!================================================================
implicit none
integer , intent(in) :: bonds (:,:)
integer , intent(in) :: angs (:,:)
integer , intent(in) :: diheds(:,:)
logical :: TorF
! local variables ...
integer :: i , x , y , z
integer :: Nbonds , Nangs , Ndiheds , KeyLeft , KeyRight
integer , allocatable :: BondKeys(:) , AngKeys(:)
logical :: flag
Nbonds = size(bonds (:,1))
Nangs = size(angs (:,1))
Ndiheds = size(diheds(:,1))
! checking bonds topology ...
allocate( BondKeys(Nbonds) )
do i = 1 , Nbonds
x = bonds(i,1) ; y = bonds(i,2)
BondKeys(i) = PairingFunction( x , y , verbose = .true. )
end do
! checking angs topology ...
do i = 1 , Nangs
flag = .false.
x = angs(i,1) ; y = angs(i,2)
KeyLeft = PairingFunction(x,y)
If( .not. any(KeyLeft == BondKeys) ) call error_message(i,angs,flag,instance="ang")
x = angs(i,2) ; y = angs(i,3)
KeyRight = PairingFunction(x,y)
If( .not. any(KeyRight == BondKeys) ) call error_message(i,angs,flag,instance="ang")
If( KeyLeft == KeyRight ) call error_message(i,angs,flag,instance="ang")
end do
! checking diheds topology ...
allocate( AngKeys(Nangs) )
do i = 1 , Nangs
x = angs(i,1) ; y = angs(i,2) ; z = angs(i,3)
AngKeys(i) = CantorPairing( x , y , z )
end do
do i = 1 , Ndiheds
flag = .false.
x = diheds(i,1) ; y = diheds(i,2) ; z = diheds(i,3)
KeyLeft = CantorPairing( x , y , z )
If( .not. any(KeyLeft == AngKeys) ) call error_message(i,diheds,flag,instance="dihed")
x = diheds(i,2) ; y = diheds(i,3) ; z = diheds(i,4)
KeyRight = CantorPairing( x , y , z )
If( .not. any(KeyRight == AngKeys) ) call error_message(i,diheds,flag,instance="dihed")
end do
! prepare to leave ...
if( done ) then
TorF = .true. ! <== error detected
close(10)
else
TorF = .false. ! <== NO error detected
end If
end function Checking_Topology
!
!
!
!
!========================================
function CantorPairing(i,j,k) result(R)
! 3-tupling Cantor Function ...
! f(i,j,k) = f(k,j,i)
!========================================
implicit none
integer , intent(in) :: i,j,k
! local variables ...
integer :: R , L , a , b
! Symmetric Pairing for (i,k)-tuple ...
a = max(i,k) ; b = min(i,k)
L = a*(a+1)/2 + b
! Cantor pairing with the center pairing ...
R = (L+j)*(L+j+1)/2 + L
end function CantorPairing
!
!
!
!===============================================
function PairingFunction(i,j,verbose) result(k)
!===============================================
implicit none
integer , intent(in) :: i,j
logical , optional , intent(in) :: verbose
! local variables ...
integer :: k , a , b
If( (i == j) .and. present(verbose) ) then
Print 232, i , j
stop
end If
! the symmetric pairing satisfies f(i,j)=f(j,i) ...
! Symmetric Cantor Pairing ...
!k = (i+j)*(i+j+1)/2 + (i*j)
! Symmetric Pairing ...
a = max(i,j) ; b = min(i,j)
k = a*(a+1)/2 + b
include 'formats.h'
end function PairingFunction
!
!
!
!==================================================
subroutine error_message(i , a , flag , instance )
!==================================================
implicit none
integer , intent(in) :: i
integer , intent(in) :: a(:,:)
logical , intent(inout) :: flag
character(len=*) , intent(in) :: instance
If( .not. done ) open (10, file='log.trunk/Topology.test.log', status='unknown')
done = .true.
If( flag == .true. ) return
select case (instance)
case("ang")
write(10,231) a(i,1) , a(i,2) , a(i,3)
case("dihed")
write(10,233) a(i,1) , a(i,2) , a(i,3) , a(i,4)
end select
flag = .true.
include 'formats.h'
end subroutine error_message
!
!
!
!
end MODULE setup_checklist