-
Notifications
You must be signed in to change notification settings - Fork 0
/
qm2_load_params_and_allocate.F90
2435 lines (2231 loc) · 123 KB
/
qm2_load_params_and_allocate.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
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
! <compile=optimized>
#include "copyright.h"
#include "../include/assert.fh"
#include "../include/dprec.fh"
subroutine qm2_load_params_and_allocate(silence)
! Written by: Ross Walker (TSRI, 2005)
! Updates by: Andreas Goetz (SDSC, 2009, 2010, 2011)
! Updates by: Taisung Lee (Rutgers, 2011)
! This routine should be called before running any qm2 routine calculations.
! It is responsible for filling the parameter arrays with the designated
! parameters for the method chosen.
! All parameters are loaded into qm2_params structure.
! Note, allocation is done in this routine for all pointers in the qm2_params structure.
! Deallocation is done by deallocate qmmm routine.
! Parameter definitions:
! Common params for all methods:
! core(nquant_nlink) - The core charge on each atom
! natomic_orbs(nquant_nlink) - Number of atomic orbitals on each atom.
! orb_loc(2,nquant_nlink) - (1,x) = position of first orbital on atom x. 2,x = last orbital on x.
! heat_of_form(nquant_nlink) - Gas Phase heat of formation for atom.
use constants, only : half, EV_TO_KCAL, AU_TO_EV
use ElementOrbitalIndex, only: MaxValenceOrbitals, &
SPPrincipalQuantumNumber, DPrincipalQuantumNumber
use QM2_parameters
use qm2_params_module, only : new
use qmmm_module, only : qmmm_nml,qmmm_struct, qm2_struct, qm2_params, &
qmmm_mpi, qmmm_scratch, qmmm_opnq
use MNDOChargeSeparation, only : GetDDAndPho
use qm2_diagonalizer_module, only : qm2_diagonalizer_setup
implicit none
logical, intent(in) :: silence
!Locals
_REAL_ :: pdiag_guess1, pdiag_guess2, pddg_zaf, pddg_zbf
_REAL_ :: gssc, gspc, gppc, gp2c, hspc, elec_eng
_REAL_ :: exponent_temp1, base_temp1, exponent_temp2, base_temp2
_REAL_ :: HSP1_temp, HSP2_temp, DD1_temp, DD2_temp, DD_diff, DD3_temp, hpp
_REAL_ :: temp
integer :: iostmp, ioptmp
integer :: i, j, k, iat, jat, itmp, iqm_atomic, n_atomic_orb, first_orb, last_orb
integer :: ns_atoms, nsp_atoms, nspd_atoms, nelectrons, nopen
integer :: ier=0
_REAL_::DD(6), PO(9)
#ifdef MPI
include 'mpif.h'
integer :: jstart, jend, ia, ib, ja, jb, inum, jnum
integer :: loop_count
integer, dimension(:), allocatable :: gather_array !Allocated and deallocated in this routine.
#endif
logical :: test
! Initialize the parameter module
call InitializeParameter(qmmm_nml%qmtheory)
call new(qm2_params, qmmm_struct%qm_ntypes, qmmm_struct%nquant_nlink, &
qmmm_nml%qmtheory, qmmm_struct%PM3MMX_INTERFACE, qmmm_opnq%useOPNQ)
!Zero the total heat of formation before calculating it.
qm2_params%tot_heat_form = 0.0D0
! We start by loading in the parameters that are common to all the semi-empirical methods.
!---------- COMMON PARAMS ---------------
qm2_struct%norbs=0
ns_atoms=0
nsp_atoms=0
nspd_atoms=0
nelectrons=-qmmm_nml%qmcharge
!
! define the parameters for each type--most of parameters should be in this way
! TL Work
do i=1,qmmm_struct%qm_ntypes
qm2_params%sp_quantum_number(i)=SPPrincipalQuantumNumber(qmmm_struct%qm_type_id(i))
qm2_params%d_quantum_number(i)=DPrincipalQuantumNumber(qmmm_struct%qm_type_id(i))
end do
do i=1,qmmm_struct%nquant_nlink
iqm_atomic=qmmm_struct%iqm_atomic_numbers(i)
qm2_params%core_chg(i)=dble(core_chg(iqm_atomic))
nelectrons=nelectrons+core_chg(iqm_atomic)
n_atomic_orb=natomic_orbs(iqm_atomic)
if (n_atomic_orb==1) ns_atoms=ns_atoms+1
if (n_atomic_orb==4) nsp_atoms=nsp_atoms+1
if (n_atomic_orb==9) nspd_atoms=nspd_atoms+1
! Check we don't bust any static arrays
! DFTB is independent of this and checks are done in qm2_dftb_load_params
if ( .not. qmmm_nml%qmtheory%DFTB ) then
if (n_atomic_orb > MaxValenceOrbitals) then
write (6,*) 'n_atomic_orb of ', n_atomic_orb, ' exceeds MaxValenceOrbitals of MaxValenceOrbitals'
call sander_bomb('qm2_load_params_and_allocate', &
'exceeded max', &
'Check qmmm_module.f and parameters.h')
end if
end if
qm2_params%natomic_orbs(i)=n_atomic_orb
qm2_params%orb_loc(1,i)=qm2_struct%norbs+1
qm2_params%orb_loc(2,i)=qm2_struct%norbs+n_atomic_orb
qm2_struct%norbs = qm2_struct%norbs+n_atomic_orb
qm2_params%tot_heat_form=qm2_params%tot_heat_form+heat_of_form(iqm_atomic)
end do !i=1,qmmm_struct%nquant_nlink
!Work out how many 2 electron integrals there will be
!! old code
!!ns_atoms=qmmm_struct%nquant_nlink-nsp_atoms
!!qm2_struct%n2el=50*nsp_atoms*(nsp_atoms-1)+10*nsp_atoms*ns_atoms+ &
!! ishft((ns_atoms*(ns_atoms-1)),-1)
!! TL_Work
qm2_struct%n2el= max(ns_atoms*(ns_atoms-1)/2,0) &
+10*nsp_atoms*ns_atoms + 45 *nspd_atoms*ns_atoms &
+max(100*nsp_atoms*(nsp_atoms-1)/2,0) + 450*nspd_atoms*nsp_atoms &
+max(2025*nspd_atoms*(nspd_atoms-1)/2,0)
!QMMM e-repul memory depends on QM-MM pair list size so is
!allocated later on and checked on every call.
call qm2_allocate_qmqm_e_repul(qm2_struct%n2el)
!Protect DUMB users from STUPID errors
if (nelectrons > 2*qm2_struct%norbs) then
if (qmmm_mpi%commqmmm_master.and.qmmm_struct%qm_mm_first_call) then
write(6,'(''QMMM: ERROR-number of electrons: '',i5,'' is more'')') nelectrons
write(6,'(''QMMM: than 2xnorbs of: '',i5)') qm2_struct%norbs
write(6,'(''QMMM: Check qmcharge in qmmm namelist and rerun'')')
write(6,'(''QMMM: the calculation.'')')
end if
call mexit(6,1)
end if
!Now we know the number of electrons work out how many closed and open shells there are.
if(qmmm_nml%spin==1 .OR. qmmm_nml%spin==3 .OR.qmmm_nml%spin==5)then
! Make sure we have an even number of electrons
if((nelectrons/2)*2 /= nelectrons) then
if (qmmm_mpi%commqmmm_master.and.qmmm_struct%qm_mm_first_call) then
write(6,'(''QMMM: System specified with odd number of electrons ('',i5,'')'')') nelectrons
write(6,'(''QMMM: but odd spin ('',i3,''). You most likely have the charge of'')') qmmm_nml%spin
write(6,'(''QMMM: QM region (qmcharge) set incorrectly. Correct error and re-run calculation.'')')
end if
call mexit(6,1)
end if
else if (qmmm_nml%spin==2 .OR. qmmm_nml%spin==4 .OR. qmmm_nml%spin==6) then
! Make sure we have an odd number of electrons.
! Note spins other than 1 are not currently allowed because UHF is not implemented.
if((nelectrons/2)*2 == nelectrons) then
if (qmmm_mpi%commqmmm_master.and.qmmm_struct%qm_mm_first_call) then
write(6,'(''QMMM: System specified with even number of electrons ('',i5,'')'')') nelectrons
write(6,'(''QMMM: but even spin ('',i3,''). You most likely have the charge of'')') qmmm_nml%spin
write(6,'(''QMMM: QM region (qmcharge) set incorrectly. Correct error and re-run calculation.'')')
end if
call mexit(6,1)
end if
end if
if (qmmm_nml%spin == 1) then
nopen = 0
else if (qmmm_nml%spin == 2) then
nopen = 1
else if (qmmm_nml%spin == 3) then
nopen = 2
else if (qmmm_nml%spin == 4) then
nopen = 3
else if (qmmm_nml%spin == 5) then
nopen = 4
else if (qmmm_nml%spin == 6) then
nopen = 5
end if
qm2_struct%nclosed = nelectrons/2
if( nopen > 0 ) then
qm2_struct%nclosed = qm2_struct%nclosed - nopen/2
if ((qm2_struct%nclosed + nopen) > qm2_struct%norbs) then
if (qmmm_mpi%commqmmm_master .and. qmmm_struct%qm_mm_first_call) then
write(6,'(''QMMM: Number of doubly filled ('',i3,'') plus'')') qm2_struct%nclosed
write(6,'(''QMMM: number of partly filled ('',i3,'') levels'')') nopen
write(6,'(''QMMM: is greater than the total number of orbitals ('',i5,'').'')') qm2_struct%norbs
write(6,'(''QMMM: Fix problem and re-run calculation.'')')
end if
call mexit(6,1)
end if
end if
qm2_struct%nopenclosed=nopen+qm2_struct%nclosed
!Allocate things that depend on norbs:
allocate (qm2_params%pascal_tri1(qm2_struct%norbs), stat=ier )
REQUIRE(ier == 0)
allocate (qm2_params%pascal_tri2(qm2_struct%norbs), stat=ier )
REQUIRE(ier == 0)
qm2_struct%matsize = ishft(qm2_struct%norbs*(qm2_struct%norbs+1),-1) !ishift(x,-1) = integer divide by 2
allocate ( qm2_struct%den_matrix(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
allocate ( qm2_struct%old_den_matrix(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
!zero the entire density matrix on the first call
qm2_struct%den_matrix = 0.0d0; qm2_struct%old_den_matrix = 0.0d0;
allocate ( qm2_struct%old2_density(qm2_struct%norbs), stat=ier )
REQUIRE ( ier == 0 ) !Used by qm2_cnvg as workspace.
if (qmmm_nml%density_predict == 1) then
!We are using Niklasson et al. density matrix prediction.
allocate ( qm2_struct%md_den_mat_guess1(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
allocate ( qm2_struct%md_den_mat_guess2(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
end if
if (qmmm_nml%fock_predict == 1) then
!We are using Pulay et al. Fock matrix prediction.
allocate ( qm2_struct%fock_mat_final1(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
allocate ( qm2_struct%fock_mat_final2(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
allocate ( qm2_struct%fock_mat_final3(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
allocate ( qm2_struct%fock_mat_final4(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
end if
allocate ( qm2_struct%fock_matrix(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
allocate ( qm2_struct%hmatrix(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
!+TJG 01/26/2010
allocate ( qm2_struct%diis_fock(qm2_struct%matsize,qmmm_nml%ndiis_matrices), stat=ier )
REQUIRE ( ier == 0 )
qm2_struct%diis_fock = 0.d0
! this could be done in packed form because the error matrix is an antisymmetric matrix,
! but I'd rather go for clarity than for speed. -TJG
allocate ( qm2_struct%diis_errmat(qm2_struct%norbs*qm2_struct%norbs,qmmm_nml%ndiis_matrices), stat=ier )
REQUIRE ( ier == 0 )
qm2_struct%diis_errmat = 0.d0
allocate ( qm2_struct%diis_mat(qmmm_nml%ndiis_matrices+1,qmmm_nml%ndiis_matrices+1), stat=ier )
REQUIRE ( ier == 0 )
qm2_struct%diis_mat = 0.d0
!-TJG 01/26/2010
#ifdef MPI
# ifndef USE_MPI_IN_PLACE
!Allocate a temporary array for doing the reduce of P and F etc. Only needed if
!we can't do things using MPI_IN_PLACE
allocate ( qmmm_scratch%matsize_red_scratch(qm2_struct%matsize), stat=ier )
REQUIRE ( ier == 0 )
# endif
#endif
allocate (qm2_struct%fock2_ptot2(MaxValenceOrbitals**2,qmmm_struct%nquant_nlink),stat=ier)
REQUIRE(ier==0)
!set up array of lower half triangle indicies (Pascal's triangle)
do I=1,qm2_struct%norbs
qm2_params%pascal_tri1(I)=ishft((I*(I-1)),-1)
qm2_params%pascal_tri2(I)=qm2_params%pascal_tri1(I)+I
end do
!Fill the diagonal of the density matrix with the first guess:
pdiag_guess1=dble(qmmm_nml%qmcharge)/(qm2_struct%norbs+1.D-10)
do j=1, qm2_struct%norbs
qm2_struct%den_matrix(qm2_params%pascal_tri2(j))=-pdiag_guess1
qm2_struct%old_den_matrix(qm2_params%pascal_tri2(j))=-pdiag_guess1
end do
do i=1,qmmm_struct%nquant_nlink
first_orb=qm2_params%orb_loc(1,i)
last_orb=qm2_params%orb_loc(2,i)
k=4 ! default number of orbitals to be populated
! S only
if ((qm2_params%core_chg(i).le.2) .and. &
(qm2_params%natomic_orbs(i)==1)) then
k=1
end if
! when the atom has d electrons
if ((qm2_params%core_chg(i).gt.8) .and. &
(qm2_params%natomic_orbs(i).gt.4)) then
k= qm2_params%natomic_orbs(i)
end if
pdiag_guess2=dble(qm2_params%core_chg(i))/dble(k)
do j=first_orb,first_orb+k-1
qm2_struct%den_matrix(qm2_params%pascal_tri2(j))= pdiag_guess2 + &
qm2_struct%den_matrix(qm2_params%pascal_tri2(j))
qm2_struct%old_den_matrix(qm2_params%pascal_tri2(j))= pdiag_guess2 +&
qm2_struct%old_den_matrix(qm2_params%pascal_tri2(j))
end do
end do
if ( qmmm_nml%density_predict == 1) then
!We are using Pguess(t) = 2Pconv(t-1) - Pguess(t-2)
!in this case for an initial start we set
!den_matrix = 0.5 initial guess
!md_den_mat_guess1 = initial guess
!md_den_mat_guess2 = 0.0d0
! then
! on step 1 we get: den_matrix = 2.0d0 * den_matrix - md_den_mat_guess2 (0,0d0)
! = initial guess
! on step 2 we get: md_den_mat_guess2 = md_den_mat_guess1 = initial_guess
! den_matrix = 2.0d0 * den_matrix - md_den_mat_guess2 (initial_guess)
qm2_struct%md_den_mat_guess2(1:qm2_struct%matsize) = 0.0d0
qm2_struct%md_den_mat_guess1(1:qm2_struct%matsize) = 0.0d0
qm2_struct%den_matrix(1:qm2_struct%matsize) = qm2_struct%den_matrix(1:qm2_struct%matsize) * 0.5d0
end if
!! qxd_s, qxd_z0, qxd_zq, qxd_d0, qxd_dq, qxd_q0, qxd_qq, qxd_neff
!----------------------------------------
!
! OPNQ parameter loding
!
!--------------------------------------
if (qmmm_opnq%useOPNQ) then
do i=1,qmmm_struct%qm_ntypes
qm2_params%qxd_supported(i) = qxd_supported(qmmm_struct%qm_type_id(i))
if (qm2_params%qxd_supported(i)) then
qm2_params%qxd_s(i) = qxd_s(qmmm_struct%qm_type_id(i))
qm2_params%qxd_z0(i) = qxd_z0(qmmm_struct%qm_type_id(i))
qm2_params%qxd_zq(i) = qxd_zq(qmmm_struct%qm_type_id(i))
qm2_params%qxd_d0(i) = qxd_d0(qmmm_struct%qm_type_id(i))
qm2_params%qxd_dq(i) = qxd_dq(qmmm_struct%qm_type_id(i))
qm2_params%qxd_q0(i) = qxd_q0(qmmm_struct%qm_type_id(i))
qm2_params%qxd_qq(i) = qxd_qq(qmmm_struct%qm_type_id(i))
qm2_params%qxd_neff(i) = qxd_neff(qmmm_struct%qm_type_id(i))
end if
end do
end if ! (qmmm_opnq%useOPNQ)
!----------------------------------------
!
! Now we fill up the data depending on the method we are using
!
!--------------------------------------
! MNDO PARAMS *
!--------------------------------------
if (qmmm_nml%qmtheory%MNDO) then
do i = 1,qmmm_struct%nquant_nlink
iqm_atomic=qmmm_struct%iqm_atomic_numbers(i)
! Check that parameters exist for this element in MNDO
if (.NOT. element_supported_mndo(iqm_atomic)) then
write(6,'("QMMM: Atom number: ",i6," has atomic number ",i4,".")') i, iqm_atomic
write(6,'("QMMM: There are no MNDO parameters for this element. Sorry.")')
call sander_bomb('qm2_load_params_and_allocate', &
'UNSUPPORTED ELEMENT', &
'QM MNDO NOT AVAILABLE FOR THIS ATOM')
end if
!----------------------------------------
! Calculate parameters that are actually
! derived from other parameters.
!----------------------------------------
!1) Electronic Energy (EISOL)
! elec_eng = USS*IOS + UPP*IOP + UDD*IOD + GSS*GSSC + GPP*GPPC + GSP*GSPC + GP2*GP2C
! + HSP*HSPC
iostmp = ios(iqm_atomic)
ioptmp = iop(iqm_atomic)
gssc = dble(max(iostmp-1,0))
gspc = dble(iostmp * ioptmp)
gp2c = dble((ioptmp * (ioptmp - 1))/2) &
+ 0.5d0*dble(min(ioptmp,6-ioptmp)*(min(ioptmp,6-ioptmp)-1)/2)
gppc = -0.5d0*dble(min(ioptmp,6-ioptmp)*(min(ioptmp,6-ioptmp)-1)/2)
hspc = dble(-ioptmp)
elec_eng = uss_mndo(iqm_atomic)*iostmp + upp_mndo(iqm_atomic)*ioptmp &
+ gss_mndo(iqm_atomic)*gssc + gsp_mndo(iqm_atomic)*gspc &
+ gpp_mndo(iqm_atomic)*gppc + gp2_mndo(iqm_atomic)*gp2c &
+ hsp_mndo(iqm_atomic)*hspc
!2) multip_2c_elec_params(1-5,i) (DD,QQ,AM,AD,AQ)
! DD = (( (4.0d0*s_orb_exp*p_orb_exp)**(nsshell+0.5d0) ) * (2.0d0*nsshell + 1)) &
! / (( (s_orb_exp + p_orb_exp)**(2.0d0*nsshell + 2.0d0) ) * sqrt(3.0d0))
!
! QQ = sqrt((4.0d0*nsshell**2+6.0d0*nsshell+2.0d0)/20.0d0)/p_orb_exp
! AM = GSS/AU_TO_EV
if (p_orb_exp_mndo(iqm_atomic) .ne. 0.0d0 .or. &
s_orb_exp_mndo(iqm_atomic) .ne. 0.0d0) then
exponent_temp1 = nsshell(iqm_atomic)+0.5d0
base_temp1 = 4.0d0*s_orb_exp_mndo(iqm_atomic)*p_orb_exp_mndo(iqm_atomic)
exponent_temp2 = 2.0d0*nsshell(iqm_atomic) + 2.0d0
base_temp2 = s_orb_exp_mndo(iqm_atomic) + p_orb_exp_mndo(iqm_atomic)
qm2_params%multip_2c_elec_params(1,i) = ((base_temp1**exponent_temp1)*(2.0d0*nsshell(iqm_atomic) + 1.0d0)) &
/ ((base_temp2**exponent_temp2) * sqrt(3.0d0))
qm2_params%multip_2c_elec_params(2,i) = &
sqrt((4.0d0*nsshell(iqm_atomic)**2+6.0d0*nsshell(iqm_atomic) &
+2.0d0)/20.0d0)/p_orb_exp_mndo(iqm_atomic)
else
qm2_params%multip_2c_elec_params(1,i)= 0.0d0
qm2_params%multip_2c_elec_params(2,i)= 0.0d0
end if
if (GSS_mndo(iqm_atomic) .ne. 0.0d0 ) then
qm2_params%multip_2c_elec_params(3,i) = (0.5d0*AU_TO_EV)/GSS_mndo(iqm_atomic) !AM
else
qm2_params%multip_2c_elec_params(3,i) = 0.0d0
end if
! Calculation of AD and AQ
if (iqm_atomic == 1) then
qm2_params%multip_2c_elec_params(4,i) = qm2_params%multip_2c_elec_params(3,i) !AD for H
qm2_params%multip_2c_elec_params(5,i) = qm2_params%multip_2c_elec_params(3,i) !AQ for H
else
!AD
dd1_temp = (HSP_mndo(iqm_atomic) &
/(AU_TO_EV*qm2_params%multip_2c_elec_params(1,i)**2))**(1.D0/3.D0)
dd2_temp = dd1_temp + 0.04d0
do j = 1, 5
dd_diff = dd2_temp - dd1_temp
hsp1_temp = 0.5D0*dd1_temp &
- 0.5D0/sqrt(4.D0*qm2_params%multip_2c_elec_params(1,i)**2+1.0d0/dd1_temp**2)
hsp2_temp = 0.5D0*dd2_temp &
- 0.5D0/sqrt(4.D0*qm2_params%multip_2c_elec_params(1,i)**2+1.0d0/dd2_temp**2)
if (abs(hsp2_temp - hsp1_temp) < 1.0d-25) exit
dd3_temp = dd1_temp + dd_diff*(HSP_mndo(iqm_atomic)/AU_TO_EV-hsp1_temp) &
/ (hsp2_temp - hsp1_temp)
dd1_temp = dd2_temp
dd2_temp = dd3_temp
end do
qm2_params%multip_2c_elec_params(4,i) = 0.5d0/dd2_temp
!end AD
!AQ
hpp = 0.5D0*(gpp_mndo(iqm_atomic)-gp2_mndo(iqm_atomic))
hpp = max(0.1d0,hpp) !I have no idea where this max comes from but it is required to
!match mopac results for Chlorine and potentially other elements.
dd1_temp = (16.0d0*hpp &
/(AU_TO_EV*48.0d0*qm2_params%multip_2c_elec_params(2,i)**4))**(1.0d0/5.0d0)
dd2_temp = dd1_temp + 0.04d0
do j = 1, 5
dd_diff = dd2_temp - dd1_temp
hsp1_temp = 0.25d0*dd1_temp - 0.5d0/sqrt(4.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd1_temp**2) + 0.25d0/sqrt(8.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd1_temp**2)
hsp2_temp = 0.25d0*dd2_temp - 0.5d0/sqrt(4.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd2_temp**2) + 0.25d0/sqrt(8.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd2_temp**2)
if (abs(hsp2_temp - hsp1_temp) < 1.0d-25) exit
dd3_temp = dd1_temp + dd_diff*(hpp/AU_TO_EV-hsp1_temp) &
/ (hsp2_temp - hsp1_temp)
dd1_temp = dd2_temp
dd2_temp = dd3_temp
end do
qm2_params%multip_2c_elec_params(5,i) = 0.5d0/dd2_temp
!end AQ
end if
!----------------------------------------
! End calculation of derived parameters.
!----------------------------------------
qm2_params%tot_heat_form = qm2_params%tot_heat_form-(elec_eng*EV_TO_KCAL)
qm2_params%onec2elec_params(1,i) = 0.5D0*GSS_mndo(iqm_atomic)
qm2_params%onec2elec_params(2,i) = GSP_mndo(iqm_atomic)
qm2_params%onec2elec_params(3,i) = 0.5d0*GPP_mndo(iqm_atomic)
qm2_params%onec2elec_params(4,i) = 1.25d0*GP2_mndo(iqm_atomic)
qm2_params%onec2elec_params(5,i) = 0.5d0*HSP_mndo(iqm_atomic)
qm2_params%cc_exp_params(i) = alp_mndo(iqm_atomic)
qm2_params%orb_elec_ke(1,i) = uss_mndo(iqm_atomic)
qm2_params%orb_elec_ke(2,i) = upp_mndo(iqm_atomic)
end do
! Precompute some parameters to save time later
! RCW: By rebasing the atomic numbers of each atoms as types we reduce the overall
! size of the arrays. While this does not save us much memory it greatly increases
! the chance of cache hits.
do i=1,qmmm_struct%qm_ntypes
qm2_params%s_orb_exp_by_type(i) = s_orb_exp_mndo(qmmm_struct%qm_type_id(i))
qm2_params%p_orb_exp_by_type(i) = p_orb_exp_mndo(qmmm_struct%qm_type_id(i))
do j = 1,qmmm_struct%qm_ntypes
qm2_params%betasas(i,j) = betas_mndo(qmmm_struct%qm_type_id(i))+betas_mndo(qmmm_struct%qm_type_id(j))
qm2_params%betasap(i,j) = betas_mndo(qmmm_struct%qm_type_id(i))+betap_mndo(qmmm_struct%qm_type_id(j))
qm2_params%betapap(i,j) = betap_mndo(qmmm_struct%qm_type_id(i))+betap_mndo(qmmm_struct%qm_type_id(j))
end do
end do
!--------------------------------------
! end MNDO PARAMS *
!--------------------------------------
!----------------------------------------
!
! Now we fill up the data depending on the method we are using
!
!--------------------------------------
! MNDOD PARAMS *
!--------------------------------------
else if (qmmm_nml%qmtheory%MNDOD) then
do i = 1,qmmm_struct%nquant_nlink
iqm_atomic=qmmm_struct%iqm_atomic_numbers(i)
! Check that parameters exist for this element in MNDOD
if (.NOT. element_supported_MNDOD(iqm_atomic)) then
write(6,'("QMMM: Atom number: ",i6," has atomic number ",i4,".")') i, iqm_atomic
write(6,'("QMMM: There are no MNDOD parameters for this element. Sorry.")')
call sander_bomb('qm2_load_params_and_allocate', &
'UNSUPPORTED ELEMENT', &
'QM MNDOD NOT AVAILABLE FOR THIS ATOM')
end if
!----------------------------------------
! Calculate parameters that are actually
! derived from other parameters.
!----------------------------------------
!1) Electronic Energy (EISOL)
! elec_eng = USS*IOS + UPP*IOP + UDD*IOD + GSS*GSSC + GPP*GPPC + GSP*GSPC + GP2*GP2C
! + HSP*HSPC
iostmp = ios(iqm_atomic)
ioptmp = iop(iqm_atomic)
gssc = dble(max(iostmp-1,0))
gspc = dble(iostmp * ioptmp)
gp2c = dble((ioptmp * (ioptmp - 1))/2) &
+ 0.5d0*dble(min(ioptmp,6-ioptmp)*(min(ioptmp,6-ioptmp)-1)/2)
gppc = -0.5d0*dble(min(ioptmp,6-ioptmp)*(min(ioptmp,6-ioptmp)-1)/2)
hspc = dble(-ioptmp)
elec_eng = uss_MNDOD(iqm_atomic)*iostmp + upp_MNDOD(iqm_atomic)*ioptmp &
+ gss_MNDOD(iqm_atomic)*gssc + gsp_MNDOD(iqm_atomic)*gspc &
+ gpp_MNDOD(iqm_atomic)*gppc + gp2_MNDOD(iqm_atomic)*gp2c &
+ hsp_MNDOD(iqm_atomic)*hspc
!2) multip_2c_elec_params(1-5,i) (DD,QQ,AM,AD,AQ)
! DD = (( (4.0d0*s_orb_exp*p_orb_exp)**(nsshell+0.5d0) ) * (2.0d0*nsshell + 1)) &
! / (( (s_orb_exp + p_orb_exp)**(2.0d0*nsshell + 2.0d0) ) * sqrt(3.0d0))
!
! QQ = sqrt((4.0d0*nsshell**2+6.0d0*nsshell+2.0d0)/20.0d0)/p_orb_exp
! AM = GSS/AU_TO_EV
if (p_orb_exp_MNDOD(iqm_atomic) .ne. 0.0d0 .or. &
s_orb_exp_MNDOD(iqm_atomic) .ne. 0.0d0) then
exponent_temp1 = nsshell(iqm_atomic)+0.5d0
base_temp1 = 4.0d0*s_orb_exp_MNDOD(iqm_atomic)*p_orb_exp_MNDOD(iqm_atomic)
exponent_temp2 = 2.0d0*nsshell(iqm_atomic) + 2.0d0
base_temp2 = s_orb_exp_MNDOD(iqm_atomic) + p_orb_exp_MNDOD(iqm_atomic)
qm2_params%multip_2c_elec_params(1,i) = ((base_temp1**exponent_temp1)*(2.0d0*nsshell(iqm_atomic) + 1.0d0)) &
/ ((base_temp2**exponent_temp2) * sqrt(3.0d0))
qm2_params%multip_2c_elec_params(2,i) = &
sqrt((4.0d0*nsshell(iqm_atomic)**2+6.0d0*nsshell(iqm_atomic) &
+2.0d0)/20.0d0)/p_orb_exp_MNDOD(iqm_atomic)
else
qm2_params%multip_2c_elec_params(1,i)= 0.0d0
qm2_params%multip_2c_elec_params(2,i)= 0.0d0
end if
if (GSS_MNDOD(iqm_atomic) .ne. 0.0d0 ) then
qm2_params%multip_2c_elec_params(3,i) = (0.5d0*AU_TO_EV)/GSS_MNDOD(iqm_atomic) !AM
else
qm2_params%multip_2c_elec_params(3,i) = 0.0d0
end if
! Calculation of AD and AQ
if (iqm_atomic == 1) then
qm2_params%multip_2c_elec_params(4,i) = qm2_params%multip_2c_elec_params(3,i) !AD for H
qm2_params%multip_2c_elec_params(5,i) = qm2_params%multip_2c_elec_params(3,i) !AQ for H
else
!AD
dd1_temp = (HSP_MNDOD(iqm_atomic) &
/(AU_TO_EV*qm2_params%multip_2c_elec_params(1,i)**2))**(1.D0/3.D0)
dd2_temp = dd1_temp + 0.04d0
do j = 1, 5
dd_diff = dd2_temp - dd1_temp
hsp1_temp = 0.5D0*dd1_temp &
- 0.5D0/sqrt(4.D0*qm2_params%multip_2c_elec_params(1,i)**2+1.0d0/dd1_temp**2)
hsp2_temp = 0.5D0*dd2_temp &
- 0.5D0/sqrt(4.D0*qm2_params%multip_2c_elec_params(1,i)**2+1.0d0/dd2_temp**2)
if (abs(hsp2_temp - hsp1_temp) < 1.0d-25) exit
dd3_temp = dd1_temp + dd_diff*(HSP_MNDOD(iqm_atomic)/AU_TO_EV-hsp1_temp) &
/ (hsp2_temp - hsp1_temp)
dd1_temp = dd2_temp
dd2_temp = dd3_temp
end do
qm2_params%multip_2c_elec_params(4,i) = 0.5d0/dd2_temp
!end AD
!AQ
hpp = 0.5D0*(gpp_MNDOD(iqm_atomic)-gp2_MNDOD(iqm_atomic))
hpp = max(0.1d0,hpp) !I have no idea where this max comes from but it is required to
!match mopac results for Chlorine and potentially other elements.
dd1_temp = (16.0d0*hpp &
/(AU_TO_EV*48.0d0*qm2_params%multip_2c_elec_params(2,i)**4))**(1.0d0/5.0d0)
dd2_temp = dd1_temp + 0.04d0
do j = 1, 5
dd_diff = dd2_temp - dd1_temp
hsp1_temp = 0.25d0*dd1_temp - 0.5d0/sqrt(4.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd1_temp**2) + 0.25d0/sqrt(8.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd1_temp**2)
hsp2_temp = 0.25d0*dd2_temp - 0.5d0/sqrt(4.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd2_temp**2) + 0.25d0/sqrt(8.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd2_temp**2)
if (abs(hsp2_temp - hsp1_temp) < 1.0d-25) exit
dd3_temp = dd1_temp + dd_diff*(hpp/AU_TO_EV-hsp1_temp) &
/ (hsp2_temp - hsp1_temp)
dd1_temp = dd2_temp
dd2_temp = dd3_temp
end do
qm2_params%multip_2c_elec_params(5,i) = 0.5d0/dd2_temp
!end AQ
end if
!----------------------------------------
! End calculation of derived parameters.
!----------------------------------------
qm2_params%tot_heat_form = qm2_params%tot_heat_form-(elec_eng*EV_TO_KCAL)
qm2_params%onec2elec_params(1,i) = 0.5D0*GSS_MNDOD(iqm_atomic)
qm2_params%onec2elec_params(2,i) = GSP_MNDOD(iqm_atomic)
qm2_params%onec2elec_params(3,i) = 0.5d0*GPP_MNDOD(iqm_atomic)
qm2_params%onec2elec_params(4,i) = 1.25d0*GP2_MNDOD(iqm_atomic)
qm2_params%onec2elec_params(5,i) = 0.5d0*HSP_MNDOD(iqm_atomic)
qm2_params%cc_exp_params(i) = alp_MNDOD(iqm_atomic)
qm2_params%orb_elec_ke(1,i) = uss_MNDOD(iqm_atomic)
qm2_params%orb_elec_ke(2,i) = upp_MNDOD(iqm_atomic)
qm2_params%orb_elec_ke(3,i) = udd_MNDOD(iqm_atomic)
end do
! move the zeta loading to here so that the derived dd and rho_0 can be calculated
do i=1,qmmm_struct%qm_ntypes
qm2_params%s_orb_exp_by_type(i) = s_orb_exp_MNDOD(qmmm_struct%qm_type_id(i))
qm2_params%p_orb_exp_by_type(i) = p_orb_exp_MNDOD(qmmm_struct%qm_type_id(i))
qm2_params%d_orb_exp_by_type(i) = d_orb_exp_MNDOD(qmmm_struct%qm_type_id(i))
qm2_params%s_orb_exp_tail_by_type(i) = s_orb_exp_tail_MNDOD(qmmm_struct%qm_type_id(i))
qm2_params%p_orb_exp_tail_by_type(i) = p_orb_exp_tail_MNDOD(qmmm_struct%qm_type_id(i))
qm2_params%d_orb_exp_tail_by_type(i) = d_orb_exp_tail_MNDOD(qmmm_struct%qm_type_id(i))
qm2_params%gss(i) = gss_MNDOD(qmmm_struct%qm_type_id(i))
qm2_params%hsp(i) = hsp_MNDOD(qmmm_struct%qm_type_id(i))
qm2_params%hpp(i) = (gpp_MNDOD(qmmm_struct%qm_type_id(i))-gp2_MNDOD(qmmm_struct%qm_type_id(i)))*half
DD=0.0D0
PO=0.0D0
call GetDDAndPho(i, DD, PO)
qm2_params%dd(1:6,i)=DD
qm2_params%po(1:9,i)=PO
temp=rho_core_mndod(qmmm_struct%qm_type_id(i))
if (abs(temp) > 1.0d-5 ) then
qm2_params%po(9,i)=temp
end if
do j = 1,qmmm_struct%qm_ntypes
qm2_params%betasas(i,j) = betas_MNDOD(qmmm_struct%qm_type_id(i))+betas_MNDOD(qmmm_struct%qm_type_id(j))
qm2_params%betasap(i,j) = betas_MNDOD(qmmm_struct%qm_type_id(i))+betap_MNDOD(qmmm_struct%qm_type_id(j))
qm2_params%betasad(i,j) = betas_MNDOD(qmmm_struct%qm_type_id(i))+betad_MNDOD(qmmm_struct%qm_type_id(j))
qm2_params%betapap(i,j) = betap_MNDOD(qmmm_struct%qm_type_id(i))+betap_MNDOD(qmmm_struct%qm_type_id(j))
qm2_params%betapad(i,j) = betap_MNDOD(qmmm_struct%qm_type_id(i))+betad_MNDOD(qmmm_struct%qm_type_id(j))
qm2_params%betadad(i,j) = betad_MNDOD(qmmm_struct%qm_type_id(i))+betad_MNDOD(qmmm_struct%qm_type_id(j))
end do
end do
!--------------------------------------
! end MNDOD PARAMS *
!--------------------------------------
!--------------------------------------
! AM1 PARAMS *
!--------------------------------------
else if (qmmm_nml%qmtheory%AM1) then
do i = 1,qmmm_struct%nquant_nlink
iqm_atomic=qmmm_struct%iqm_atomic_numbers(i)
! Check that parameters exist for this element in AM1
if (.NOT. element_supported_am1(iqm_atomic)) then
write(6,'("QMMM: Atom number: ",i6," has atomic number ",i4,".")') i, iqm_atomic
write(6,'("QMMM: There are no AM1 parameters for this element. Sorry.")')
call sander_bomb('qm2_load_params_and_allocate', &
'UNSUPPORTED ELEMENT', &
'QM AM1 NOT AVAILABLE FOR THIS ATOM')
end if
!----------------------------------------
! Calculate parameters that are actually
! derived from other parameters.
!----------------------------------------
!1) Electronic Energy (EISOL)
! elec_eng = USS*IOS + UPP*IOP + UDD*IOD + GSS*GSSC + GPP*GPPC + GSP*GSPC + GP2*GP2C
! + HSP*HSPC
iostmp = ios(iqm_atomic)
ioptmp = iop(iqm_atomic)
gssc = dble(max(iostmp-1,0))
gspc = dble(iostmp * ioptmp)
gp2c = dble((ioptmp * (ioptmp - 1))/2) &
+ 0.5d0*dble(min(ioptmp,6-ioptmp)*(min(ioptmp,6-ioptmp)-1)/2)
gppc = -0.5d0*dble(min(ioptmp,6-ioptmp)*(min(ioptmp,6-ioptmp)-1)/2)
hspc = dble(-ioptmp)
elec_eng = uss_am1(iqm_atomic)*iostmp + upp_am1(iqm_atomic)*ioptmp &
+ gss_am1(iqm_atomic)*gssc + gsp_am1(iqm_atomic)*gspc &
+ gpp_am1(iqm_atomic)*gppc + gp2_am1(iqm_atomic)*gp2c &
+ hsp_am1(iqm_atomic)*hspc
!2) multip_2c_elec_params(1-5,i) (DD,QQ,AM,AD,AQ)
! DD = (( (4.0d0*s_orb_exp*p_orb_exp)**(nsshell+0.5d0) ) * (2.0d0*nsshell + 1)) &
! / (( (s_orb_exp + p_orb_exp)**(2.0d0*nsshell + 2.0d0) ) * sqrt(3.0d0))
!
! QQ = sqrt((4.0d0*nsshell**2+6.0d0*nsshell+2.0d0)/20.0d0)/p_orb_exp
! AM = GSS/AU_TO_EV
if (p_orb_exp_am1(iqm_atomic) .ne. 0.0d0 .or. &
s_orb_exp_am1(iqm_atomic) .ne. 0.0d0) then
exponent_temp1 = nsshell(iqm_atomic)+0.5d0
base_temp1 = 4.0d0*s_orb_exp_am1(iqm_atomic)*p_orb_exp_am1(iqm_atomic)
exponent_temp2 = 2.0d0*nsshell(iqm_atomic) + 2.0d0
base_temp2 = s_orb_exp_am1(iqm_atomic) + p_orb_exp_am1(iqm_atomic)
qm2_params%multip_2c_elec_params(1,i) = ((base_temp1**exponent_temp1)*(2.0d0*nsshell(iqm_atomic) + 1.0d0)) &
/ ((base_temp2**exponent_temp2) * sqrt(3.0d0))
qm2_params%multip_2c_elec_params(2,i) = &
sqrt((4.0d0*nsshell(iqm_atomic)**2+6.0d0*nsshell(iqm_atomic) &
+2.0d0)/20.0d0)/p_orb_exp_am1(iqm_atomic)
else
qm2_params%multip_2c_elec_params(1,i)= 0.0d0
qm2_params%multip_2c_elec_params(2,i)= 0.0d0
end if
if (GSS_am1(iqm_atomic) .ne. 0.0d0 ) then
qm2_params%multip_2c_elec_params(3,i) = (0.5d0*AU_TO_EV)/GSS_am1(iqm_atomic) !AM
else
qm2_params%multip_2c_elec_params(3,i) = 0.0d0
end if
! Calculation of AD and AQ
if (iqm_atomic == 1) then
qm2_params%multip_2c_elec_params(4,i) = qm2_params%multip_2c_elec_params(3,i) !AD for H
qm2_params%multip_2c_elec_params(5,i) = qm2_params%multip_2c_elec_params(3,i) !AQ for H
else
dd1_temp = (HSP_am1(iqm_atomic) &
/(AU_TO_EV*qm2_params%multip_2c_elec_params(1,i)**2))**(1.D0/3.D0)
dd2_temp = dd1_temp + 0.04d0
do j = 1, 5
dd_diff = dd2_temp - dd1_temp
hsp1_temp = 0.5D0*dd1_temp &
- 0.5D0/sqrt(4.D0*qm2_params%multip_2c_elec_params(1,i)**2+1.0d0/dd1_temp**2)
hsp2_temp = 0.5D0*dd2_temp &
- 0.5D0/sqrt(4.D0*qm2_params%multip_2c_elec_params(1,i)**2+1.0d0/dd2_temp**2)
if (abs(hsp2_temp - hsp1_temp) < 1.0d-25) exit
dd3_temp = dd1_temp + dd_diff*(HSP_am1(iqm_atomic)/AU_TO_EV-hsp1_temp) &
/ (hsp2_temp - hsp1_temp)
dd1_temp = dd2_temp
dd2_temp = dd3_temp
end do
qm2_params%multip_2c_elec_params(4,i) = 0.5d0/dd2_temp
!end AD
!AQ
hpp = 0.5D0*(gpp_am1(iqm_atomic)-gp2_am1(iqm_atomic))
hpp = max(0.1d0,hpp) !I have no idea where this max comes from but it is required to
!match mopac results for Chlorine and potentially other elements.
dd1_temp = (16.0d0*hpp &
/(AU_TO_EV*48.0d0*qm2_params%multip_2c_elec_params(2,i)**4))**(1.0d0/5.0d0)
dd2_temp = dd1_temp + 0.04d0
do j = 1, 5
dd_diff = dd2_temp - dd1_temp
hsp1_temp = 0.25d0*dd1_temp - 0.5d0/sqrt(4.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd1_temp**2) + 0.25d0/sqrt(8.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd1_temp**2)
hsp2_temp = 0.25d0*dd2_temp - 0.5d0/sqrt(4.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd2_temp**2) + 0.25d0/sqrt(8.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd2_temp**2)
if (abs(hsp2_temp - hsp1_temp) < 1.0d-25) exit
dd3_temp = dd1_temp + dd_diff*(hpp/AU_TO_EV-hsp1_temp) &
/ (hsp2_temp - hsp1_temp)
dd1_temp = dd2_temp
dd2_temp = dd3_temp
end do
qm2_params%multip_2c_elec_params(5,i) = 0.5d0/dd2_temp
!end AQ
end if
!----------------------------------------
! End calculation of derived parameters.
!----------------------------------------
! Next do the electronic energy - add it to the total heat of formation energy.
qm2_params%tot_heat_form = qm2_params%tot_heat_form-(elec_eng*EV_TO_KCAL)
qm2_params%onec2elec_params(1,i) = 0.5D0*GSS_am1(iqm_atomic)
qm2_params%onec2elec_params(2,i) = GSP_am1(iqm_atomic)
qm2_params%onec2elec_params(3,i) = 0.5d0*GPP_am1(iqm_atomic)
qm2_params%onec2elec_params(4,i) = 1.25d0*GP2_am1(iqm_atomic)
qm2_params%onec2elec_params(5,i) = 0.5d0*HSP_am1(iqm_atomic)
qm2_params%cc_exp_params(i) = alp_am1(iqm_atomic)
qm2_params%orb_elec_ke(1,i) = uss_am1(iqm_atomic)
qm2_params%orb_elec_ke(2,i) = upp_am1(iqm_atomic)
end do
! Precompute some parameters to save time later
! RCW: By rebasing the atomic numbers of each atoms as types we reduce the overall
! size of the arrays. While this does not save us much memory it greatly increases
! the chance of cache hits.
do i=1,qmmm_struct%qm_ntypes
! get the Slater orbital expansion coefficients
qm2_params%s_orb_exp_by_type(i) = s_orb_exp_am1(qmmm_struct%qm_type_id(i))
qm2_params%p_orb_exp_by_type(i) = p_orb_exp_am1(qmmm_struct%qm_type_id(i))
qm2_params%NUM_FN(i) = NUM_FN_am1(qmmm_struct%qm_type_id(i))
do j=1,4
qm2_params%FN1(j,i) = FN1_am1(j,qmmm_struct%qm_type_id(i))
qm2_params%FN2(j,i) = FN2_am1(j,qmmm_struct%qm_type_id(i))
qm2_params%FN3(j,i) = FN3_am1(j,qmmm_struct%qm_type_id(i))
end do
end do
do i=1,qmmm_struct%qm_ntypes
do j = 1,qmmm_struct%qm_ntypes
qm2_params%betasas(i,j) = betas_am1(qmmm_struct%qm_type_id(i))+betas_am1(qmmm_struct%qm_type_id(j))
qm2_params%betasap(i,j) = betas_am1(qmmm_struct%qm_type_id(i))+betap_am1(qmmm_struct%qm_type_id(j))
qm2_params%betapap(i,j) = betap_am1(qmmm_struct%qm_type_id(i))+betap_am1(qmmm_struct%qm_type_id(j))
end do
end do
!--------------------------------------
! end AM1 PARAMS *
!--------------------------------------
!--------------------------------------
! AM1/DHFR PARAMS *
!--------------------------------------
else if (qmmm_nml%qmtheory%AM1DHFR) then
do i = 1,qmmm_struct%nquant_nlink
iqm_atomic=qmmm_struct%iqm_atomic_numbers(i)
! Check that parameters exist for this element in AM1/DHFR
if (.NOT. element_supported_am1dhfr(iqm_atomic)) then
write(6,'("QMMM: Atom number: ",i6," has atomic number ",i4,".")') i, iqm_atomic
write(6,'("QMMM: There are no AM1/DHFR parameters for this element. Sorry.")')
call sander_bomb('qm2_load_params_and_allocate', &
'UNSUPPORTED ELEMENT', &
'QM AM1/DHFR NOT AVAILABLE FOR THIS ATOM')
end if
!----------------------------------------
! Calculate parameters that are actually
! derived from other parameters.
!----------------------------------------
!1) Electronic Energy (EISOL)
! elec_eng = USS*IOS + UPP*IOP + UDD*IOD + GSS*GSSC + GPP*GPPC + GSP*GSPC + GP2*GP2C
! + HSP*HSPC
iostmp = ios(iqm_atomic)
ioptmp = iop(iqm_atomic)
gssc = dble(max(iostmp-1,0))
gspc = dble(iostmp * ioptmp)
gp2c = dble((ioptmp * (ioptmp - 1))/2) &
+ 0.5d0*dble(min(ioptmp,6-ioptmp)*(min(ioptmp,6-ioptmp)-1)/2)
gppc = -0.5d0*dble(min(ioptmp,6-ioptmp)*(min(ioptmp,6-ioptmp)-1)/2)
hspc = dble(-ioptmp)
elec_eng = uss_am1dhfr(iqm_atomic)*iostmp + upp_am1dhfr(iqm_atomic)*ioptmp &
+ gss_am1dhfr(iqm_atomic)*gssc + gsp_am1dhfr(iqm_atomic)*gspc &
+ gpp_am1dhfr(iqm_atomic)*gppc + gp2_am1dhfr(iqm_atomic)*gp2c &
+ hsp_am1dhfr(iqm_atomic)*hspc
!2) multip_2c_elec_params(1-5,i) (DD,QQ,AM,AD,AQ)
! DD = (( (4.0d0*s_orb_exp*p_orb_exp)**(nsshell+0.5d0) ) * (2.0d0*nsshell + 1)) &
! / (( (s_orb_exp + p_orb_exp)**(2.0d0*nsshell + 2.0d0) ) * sqrt(3.0d0))
!
! QQ = sqrt((4.0d0*nsshell**2+6.0d0*nsshell+2.0d0)/20.0d0)/p_orb_exp
! AM = GSS/AU_TO_EV
if (p_orb_exp_am1dhfr(iqm_atomic) .ne. 0.0d0 .or. &
s_orb_exp_am1dhfr(iqm_atomic) .ne. 0.0d0) then
exponent_temp1 = nsshell(iqm_atomic)+0.5d0
base_temp1 = 4.0d0*s_orb_exp_am1dhfr(iqm_atomic)*p_orb_exp_am1dhfr(iqm_atomic)
exponent_temp2 = 2.0d0*nsshell(iqm_atomic) + 2.0d0
base_temp2 = s_orb_exp_am1dhfr(iqm_atomic) + p_orb_exp_am1dhfr(iqm_atomic)
qm2_params%multip_2c_elec_params(1,i) = ((base_temp1**exponent_temp1)*(2.0d0*nsshell(iqm_atomic) + 1.0d0)) &
/ ((base_temp2**exponent_temp2) * sqrt(3.0d0))
qm2_params%multip_2c_elec_params(2,i) = &
sqrt((4.0d0*nsshell(iqm_atomic)**2+6.0d0*nsshell(iqm_atomic) &
+2.0d0)/20.0d0)/p_orb_exp_am1dhfr(iqm_atomic)
else
qm2_params%multip_2c_elec_params(1,i)= 0.0d0
qm2_params%multip_2c_elec_params(2,i)= 0.0d0
end if
if (GSS_am1dhfr(iqm_atomic) .ne. 0.0d0 ) then
qm2_params%multip_2c_elec_params(3,i) = (0.5d0*AU_TO_EV)/GSS_am1dhfr(iqm_atomic) !AM
else
qm2_params%multip_2c_elec_params(3,i) = 0.0d0
end if
! Calculation of AD and AQ
if (iqm_atomic == 1) then
qm2_params%multip_2c_elec_params(4,i) = qm2_params%multip_2c_elec_params(3,i) !AD for H
qm2_params%multip_2c_elec_params(5,i) = qm2_params%multip_2c_elec_params(3,i) !AQ for H
else
dd1_temp = (HSP_am1dhfr(iqm_atomic) &
/(AU_TO_EV*qm2_params%multip_2c_elec_params(1,i)**2))**(1.D0/3.D0)
dd2_temp = dd1_temp + 0.04d0
do j = 1, 5
dd_diff = dd2_temp - dd1_temp
hsp1_temp = 0.5D0*dd1_temp &
- 0.5D0/sqrt(4.D0*qm2_params%multip_2c_elec_params(1,i)**2+1.0d0/dd1_temp**2)
hsp2_temp = 0.5D0*dd2_temp &
- 0.5D0/sqrt(4.D0*qm2_params%multip_2c_elec_params(1,i)**2+1.0d0/dd2_temp**2)
if (abs(hsp2_temp - hsp1_temp) < 1.0d-25) exit
dd3_temp = dd1_temp + dd_diff*(HSP_am1dhfr(iqm_atomic)/AU_TO_EV-hsp1_temp) &
/ (hsp2_temp - hsp1_temp)
dd1_temp = dd2_temp
dd2_temp = dd3_temp
end do
qm2_params%multip_2c_elec_params(4,i) = 0.5d0/dd2_temp
!end AD
!AQ
hpp = 0.5D0*(gpp_am1dhfr(iqm_atomic)-gp2_am1dhfr(iqm_atomic))
hpp = max(0.1d0,hpp) !I have no idea where this max comes from but it is required to
!match mopac results for Chlorine and potentially other elements.
dd1_temp = (16.0d0*hpp &
/(AU_TO_EV*48.0d0*qm2_params%multip_2c_elec_params(2,i)**4))**(1.0d0/5.0d0)
dd2_temp = dd1_temp + 0.04d0
do j = 1, 5
dd_diff = dd2_temp - dd1_temp
hsp1_temp = 0.25d0*dd1_temp - 0.5d0/sqrt(4.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd1_temp**2) + 0.25d0/sqrt(8.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd1_temp**2)
hsp2_temp = 0.25d0*dd2_temp - 0.5d0/sqrt(4.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd2_temp**2) + 0.25d0/sqrt(8.0d0*qm2_params%multip_2c_elec_params(2,i)**2 &
+ 1.0d0/dd2_temp**2)
if (abs(hsp2_temp - hsp1_temp) < 1.0d-25) exit
dd3_temp = dd1_temp + dd_diff*(hpp/AU_TO_EV-hsp1_temp) &
/ (hsp2_temp - hsp1_temp)
dd1_temp = dd2_temp
dd2_temp = dd3_temp
end do
qm2_params%multip_2c_elec_params(5,i) = 0.5d0/dd2_temp
!end AQ
end if
!----------------------------------------
! End calculation of derived parameters.
!----------------------------------------
! Next do the electronic energy - add it to the total heat of formation energy.
qm2_params%tot_heat_form = qm2_params%tot_heat_form-(elec_eng*EV_TO_KCAL)
qm2_params%onec2elec_params(1,i) = 0.5D0*GSS_am1dhfr(iqm_atomic)
qm2_params%onec2elec_params(2,i) = GSP_am1dhfr(iqm_atomic)
qm2_params%onec2elec_params(3,i) = 0.5d0*GPP_am1dhfr(iqm_atomic)
qm2_params%onec2elec_params(4,i) = 1.25d0*GP2_am1dhfr(iqm_atomic)
qm2_params%onec2elec_params(5,i) = 0.5d0*HSP_am1dhfr(iqm_atomic)
qm2_params%cc_exp_params(i) = alp_am1dhfr(iqm_atomic)
qm2_params%orb_elec_ke(1,i) = uss_am1dhfr(iqm_atomic)
qm2_params%orb_elec_ke(2,i) = upp_am1dhfr(iqm_atomic)
end do
! Precompute some parameters to save time later
! RCW: By rebasing the atomic numbers of each atoms as types we reduce the overall
! size of the arrays. While this does not save us much memory it greatly increases
! the chance of cache hits.
do i=1,qmmm_struct%qm_ntypes
! get the Slater orbital expansion coefficients
qm2_params%s_orb_exp_by_type(i) = s_orb_exp_am1dhfr(qmmm_struct%qm_type_id(i))
qm2_params%p_orb_exp_by_type(i) = p_orb_exp_am1dhfr(qmmm_struct%qm_type_id(i))
qm2_params%NUM_FN(i) = NUM_FN_am1dhfr(qmmm_struct%qm_type_id(i))
do j=1,4
qm2_params%FN1(j,i) = FN1_am1dhfr(j,qmmm_struct%qm_type_id(i))
qm2_params%FN2(j,i) = FN2_am1dhfr(j,qmmm_struct%qm_type_id(i))
qm2_params%FN3(j,i) = FN3_am1dhfr(j,qmmm_struct%qm_type_id(i))
end do
end do
do i=1,qmmm_struct%qm_ntypes
do j = 1,qmmm_struct%qm_ntypes
qm2_params%betasas(i,j) = betas_am1dhfr(qmmm_struct%qm_type_id(i))+betas_am1dhfr(qmmm_struct%qm_type_id(j))
qm2_params%betasap(i,j) = betas_am1dhfr(qmmm_struct%qm_type_id(i))+betap_am1dhfr(qmmm_struct%qm_type_id(j))
qm2_params%betapap(i,j) = betap_am1dhfr(qmmm_struct%qm_type_id(i))+betap_am1dhfr(qmmm_struct%qm_type_id(j))
end do
end do
!--------------------------------------
! end AM1/DHFR PARAMS *
!--------------------------------------
!--------------------------------------
! AM1D PARAMS *
!--------------------------------------
else if (qmmm_nml%qmtheory%AM1D) then
do i = 1,qmmm_struct%nquant_nlink
iqm_atomic=qmmm_struct%iqm_atomic_numbers(i)
! Check that parameters exist for this element in AM1D
if (.NOT. element_supported_AM1D(iqm_atomic)) then
write(6,'("QMMM: Atom number: ",i6," has atomic number ",i4,".")') i, iqm_atomic
write(6,'("QMMM: There are no AM1D parameters for this element. Sorry.")')
call sander_bomb('qm2_load_params_and_allocate','UNSUPPORTED ELEMENT','QM AM1D NOT AVAILABLE FOR THIS ATOM')
end if
!----------------------------------------
! Calculate parameters that are actually
! derived from other parameters.
!----------------------------------------
!1) Electronic Energy (EISOL)
! elec_eng = USS*IOS + UPP*IOP + UDD*IOD + GSS*GSSC + GPP*GPPC + GSP*GSPC + GP2*GP2C
! + HSP*HSPC
iostmp = ios(iqm_atomic)
ioptmp = iop(iqm_atomic)
gssc = dble(max(iostmp-1,0))