-
Notifications
You must be signed in to change notification settings - Fork 5
/
CoulInt_QMMM.f
153 lines (117 loc) · 4.54 KB
/
CoulInt_QMMM.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
module QMMM_m
use constants_m
use parameters_m , only : PBC
use for_force , only : pot_total
use MD_read_m , only : atom , molecule , MM
use polarizability_m , only : Induced_DP
use Semi_Empirical_Parms , only : chemical_element => atom
public :: QMMM_FORCE
private
! module parameters ...
real*8 :: D_2_eAngs = 0.20819434d0
real*8 :: beta_QQ = 1.0
real*8 :: mu_QQ = 6.0
real*8 :: beta_QP = 0.8
real*8 :: mu_QP = 10.0
! module variables ...
real*8 , allocatable :: dq(:)
contains
!
!
!
!==================================
subroutine QMMM_FORCE( NetCharge )
!==================================
implicit none
real*8 , intent(in) :: NetCharge(:)
! local variables ...
real*8 :: FourVector(4) , U_Coul
integer :: i , ati , atj
return
print*,"QMMM_FORCE"
if( .NOT. allocated(dq) ) allocate( dq(size(atom)) )
dq = NetCharge
forall( i=1:size(atom) ) atom(i) % fcoupling(:) = D_zero
U_Coul = D_zero
!================================================================================================
do ati = 1 , MM % N_of_atoms
do atj = ati+1 , MM % N_of_atoms
if( atom(atj)% flex .OR. atom(ati)% flex ) then
FourVector(1:4) = CoulFourVector( ati , atj )
atom(ati)% fcoupling(1:3) = atom(ati)% fcoupling(1:3) + FourVector(1:3)
atom(atj)% fcoupling(1:3) = atom(atj)% fcoupling(1:3) - FourVector(1:3)
U_Coul = U_Coul + FourVector(4)
end if
end do
end do
!================================================================================================
! Append total force with Excited State Coulombic terms; force units = J/mts = Newtons ...
forall( i=1:MM % N_of_atoms ) atom(i)% ftotal(:) = atom(i)% ftotal(:) + atom(i)% fcoupling(:) * Angs_2_mts
pot_total = pot_total + U_Coul * mol*micro*factor3/MM%N_of_molecules
end subroutine QMMM_FORCE
!
!
!
!=========================================================
pure function CoulFourVector( i , j ) result(FourVector)
!=========================================================
implicit none
integer , intent(in) :: i
integer , intent(in) :: j
! local variables ...
real*8 , dimension (4) :: FourVector
real*8 , dimension (3) :: rij , a , QiPj , QjPi , F_QQ , F_QP
real*8 :: rijq , rijsq , Q_i, Q_j , QQ_ij , U_QQ , U_QP
real*8 :: g , step , barrier
rij(:) = atom(i) % xyz(:) - atom(j) % xyz(:)
rij(:) = rij(:) - MM % box(:) * DINT( rij(:) * MM % ibox(:) )
rijq = sum( rij(:) * rij(:) )
rijsq = sqrt( rijq )
! charge/charge interaction ...
!================================================================================================
QQ_ij = dq(i)*dq(j) + atom(i)%charge*dq(j) + atom(j)%charge*dq(i)
! force ...
F_QQ = QQ_ij * rij(1:3) / (rijq * rijsq)
! energy ...
U_QQ = QQ_ij / rijsq
!================================================================================================
! charge/induced-dipole interaction ...
!================================================================================================
Q_i = atom(i)%charge + dq(i)
! a = (p.r)r ...
a(1:3) = dot_product(Induced_DP(j,1:3),rij(1:3)) * rij(1:3)
! a = 3*(p.r)*r / ( |r|^2 ) - p ...
QiPj(1:3) = Q_i * (THREE * a(1:3) * ( D_ONE / rijq ) - Induced_DP(j,1:3) )
Q_j = atom(j)%charge + dq(j)
! a = (p.r)r ...
a(1:3) = dot_product(Induced_DP(i,1:3),rij(1:3)) * rij(1:3)
! a = 3*(p.r)*r / ( |r|^2 ) - p ...
QjPi(1:3) = Q_j * (THREE * a(1:3) * ( D_ONE / rijq ) - Induced_DP(i,1:3) )
! force ...
F_QP = (QiPj - QjPi) / (rijq * rijsq)
! energy ...
a(:) = Q_i*Induced_DP(j,:) - Q_j*Induced_DP(i,:)
U_QP = dot_product( a(:) , rij(:) ) / ( rijq * rijsq )
!================================================================================================
! applying smooth cutoffs ...
!================================================================================================
! charge-charge ...
g = exp(beta_QQ*(rijsq - mu_QQ))
step = g / (g + D_one)
barrier = beta_QQ*step - beta_QQ*step*step
U_QQ = U_QQ * step
F_QQ = F_QQ * step - U_QQ * barrier * rij(1:3)/rijsq
! charge-dipole ...
g = exp(beta_QP*(rijsq - mu_QP))
step = g / (g + D_one)
barrier = beta_QP*step - beta_QP*step*step
U_QP = U_QP * step
F_QP = F_QP * step - U_QP * barrier * rij(1:3)/rijsq
!================================================================================================
FourVector(1:3) = Coulomb*F_QQ + Coulomb*D_2_eAngs*F_QP
FourVector(4) = Coulomb*U_QQ + Coulomb*D_2_eAngs*U_QP
end function CoulFourVector
!
!
!
end module QMMM_m