ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/UseTheForce/DarkSide/gb.F90
(Generate patch)

Comparing trunk/OOPSE-4/src/UseTheForce/DarkSide/gb.F90 (file contents):
Revision 2367 by kdaily, Fri Oct 14 15:44:37 2005 UTC vs.
Revision 2788 by gezelter, Mon Jun 5 18:44:05 2006 UTC

# Line 40 | Line 40 | module gb_pair
40   !!
41  
42  
43 < module gb_pair
43 > module gayberne
44    use force_globals
45    use definitions
46    use simulation
47    use atype_module
48    use vector_class
49 +  use linearalgebra
50    use status
51    use lj
52 +  use fForceOptions
53   #ifdef IS_MPI
54    use mpiSimulation
55   #endif
# Line 56 | Line 58 | module gb_pair
58  
59    private
60  
61 <  logical, save :: haveGayBerneLJMap = .false.
62 <  logical, save :: gb_pair_initialized = .false.
61 <  logical, save :: gb_lj_pair_initialized = .false.
62 <  real(kind=dp), save :: gb_sigma
63 <  real(kind=dp), save :: gb_l2b_ratio
64 <  real(kind=dp), save :: gb_eps
65 <  real(kind=dp), save :: gb_eps_ratio
66 <  real(kind=dp), save :: gb_mu
67 <  real(kind=dp), save :: gb_nu
68 <  real(kind=dp), save :: lj_sigma
69 <  real(kind=dp), save :: lj_eps
70 <  real(kind=dp), save :: gb_sigma_l
71 <  real(kind=dp), save :: gb_eps_l
61 > #define __FORTRAN90
62 > #include "UseTheForce/DarkSide/fInteractionMap.h"
63  
64 <  public :: check_gb_pair_FF
65 <  public :: set_gb_pair_params
64 >  logical, save :: haveGBMap = .false.
65 >  logical, save :: haveMixingMap = .false.
66 >  real(kind=dp), save :: mu = 2.0_dp
67 >  real(kind=dp), save :: nu = 1.0_dp
68 >
69 >
70 >  public :: newGBtype
71 >  public :: complete_GB_FF
72    public :: do_gb_pair
73    public :: getGayBerneCut
74 < !!$  public :: check_gb_lj_pair_FF
78 < !!$  public :: set_gb_lj_pair_params
79 <  public :: do_gb_lj_pair
80 <  public :: createGayBerneLJMap
81 <  public :: destroyGayBerneTypes
82 <  public :: complete_GayBerne_FF
83 < !!may not need
84 <  type, private :: LJtype
85 <     integer  :: atid
86 <     real(kind=dp) :: sigma
87 <     real(kind=dp) :: epsilon
88 <  end type LJtype
89 < !!may not need
90 <  type, private :: LJList
91 <     integer       :: Nljtypes =0
92 <     integer       :: currentLJtype= 0
93 <     type(LJtype), pointer :: LJtype(:) =>  null()
94 <     integer, pointer      :: atidToLJtype(:) =>null()
95 <  end type LJList
74 >  public :: destroyGBtypes
75  
76 <  type(LJList), save :: LJMap
77 <  
78 <  type :: GayBerneLJ
79 < !!$     integer :: atid
80 < !!$     real(kind = dp ),pointer, dimension(:) ::  epsil_GB      =>null()
102 < !!$     real(kind = dp ),pointer, dimension(:) ::  sigma_GB        =>null()
103 < !!$     real(kind = dp ),pointer, dimension(:) ::  epsilon_ratio   =>null()
104 < !!$     real(kind = dp ),pointer, dimension(:) ::  sigma_ratio     =>null()
105 < !!$     real(kind = dp ),pointer, dimension(:) ::  mu              =>null()
106 <    
107 <     real(kind = dp ) :: sigma_l
108 <     real(kind = dp ) :: sigma_s
109 <     real(kind = dp ) :: sigma_ratio
110 <     real(kind = dp ) :: eps_s
111 <     real(kind = dp ) :: eps_l
76 >  type :: GBtype
77 >     integer          :: atid
78 >     real(kind = dp ) :: d
79 >     real(kind = dp ) :: l
80 >     real(kind = dp ) :: eps
81       real(kind = dp ) :: eps_ratio
82 <     integer          :: c_ident
83 <     integer          :: status
84 <  end type GayBerneLJ
85 <
86 < !!$  type, private :: gayberneLJlist
87 < !!$     integer:: n_gaybernelj = 0
88 < !!$     integer:: currentgayberneLJ = 0
89 < !!$     type(GayBerneLJ),pointer :: GayBerneLJ(:) => null()
90 < !!$     integer, pointer         :: atidToGayBerneLJ(:) => null()
91 < !!$  end type gayberneLJlist
92 <
93 <  type(gayberneLJ), dimension(:), allocatable :: gayBerneLJMap
94 <
82 >     real(kind = dp ) :: dw
83 >     logical          :: isLJ
84 >  end type GBtype
85 >  
86 >  type, private :: GBList
87 >     integer               :: nGBtypes = 0
88 >     integer               :: currentGBtype = 0
89 >     type(GBtype), pointer :: GBtypes(:)      => null()
90 >     integer, pointer      :: atidToGBtype(:) => null()
91 >  end type GBList
92 >  
93 >  type(GBList), save :: GBMap
94 >  
95 >  type :: GBMixParameters
96 >     real(kind=DP) :: sigma0
97 >     real(kind=DP) :: eps0
98 >     real(kind=DP) :: dw
99 >     real(kind=DP) :: x2
100 >     real(kind=DP) :: xa2
101 >     real(kind=DP) :: xai2
102 >     real(kind=DP) :: xp2
103 >     real(kind=DP) :: xpap2
104 >     real(kind=DP) :: xpapi2
105 >  end type GBMixParameters
106 >  
107 >  type(GBMixParameters), dimension(:,:), allocatable :: GBMixingMap
108 >  
109   contains
110 <
111 <  subroutine check_gb_pair_FF(status)
112 <    integer :: status
113 <    status = -1
114 <    if (gb_pair_initialized) status = 0
115 <    return
116 <  end subroutine check_gb_pair_FF
117 <
118 < !!$  subroutine check_gb_lj_pair_FF(status)
119 < !!$    integer :: status
137 < !!$    status = -1
138 < !!$    if (gb_lj_pair_initialized) status = 0
139 < !!$    return
140 < !!$  end subroutine check_gb_lj_pair_FF
141 <
142 <  subroutine set_gb_pair_params(sigma, l2b_ratio, eps, eps_ratio, mu, nu)
143 <    real( kind = dp ), intent(in) :: sigma, l2b_ratio, eps, eps_ratio
144 <    real( kind = dp ), intent(in) :: mu, nu
145 <    integer :: ntypes, nljtypes
146 < !!    integer, intent(in) :: c_ident
147 <    integer, pointer :: MatchList(:) => null ()
148 <    integer :: status
149 <    gb_sigma = sigma
150 <    gb_l2b_ratio = l2b_ratio
151 <    gb_eps = eps
152 <    gb_eps_ratio = eps_ratio
153 <    gb_mu = mu
154 <    gb_nu = nu
155 <    gb_sigma_l = gb_sigma*l2b_ratio
156 <    gb_eps_l = gb_eps*gb_eps_ratio
110 >  
111 >  subroutine newGBtype(c_ident, d, l, eps, eps_ratio, dw, status)
112 >    
113 >    integer, intent(in) :: c_ident
114 >    real( kind = dp ), intent(in) :: d, l, eps, eps_ratio, dw
115 >    integer, intent(out) :: status
116 >    
117 >    integer :: nGBTypes, nLJTypes, ntypes, myATID
118 >    integer, pointer :: MatchList(:) => null()
119 >    integer :: current, i
120      status = 0
121 <
122 <
123 <      
124 <
121 >    
122 >    if (.not.associated(GBMap%GBtypes)) then
123 >      
124 >       call getMatchingElementList(atypes, "is_GayBerne", .true., &
125 >            nGBtypes, MatchList)
126 >      
127 >       call getMatchingElementList(atypes, "is_LennardJones", .true., &
128 >            nLJTypes, MatchList)
129 >      
130 >       GBMap%nGBtypes = nGBtypes + nLJTypes
131 >      
132 >       allocate(GBMap%GBtypes(nGBtypes + nLJTypes))
133 >      
134 >       ntypes = getSize(atypes)
135 >      
136 >       allocate(GBMap%atidToGBtype(ntypes))      
137 >    endif
138 >    
139 >    GBMap%currentGBtype = GBMap%currentGBtype + 1
140 >    current = GBMap%currentGBtype
141 >    
142 >    myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
143 >    
144 >    GBMap%atidToGBtype(myATID)       = current
145 >    GBMap%GBtypes(current)%atid      = myATID
146 >    GBMap%GBtypes(current)%d         = d
147 >    GBMap%GBtypes(current)%l         = l
148 >    GBMap%GBtypes(current)%eps       = eps
149 >    GBMap%GBtypes(current)%eps_ratio = eps_ratio
150 >    GBMap%GBtypes(current)%dw        = dw
151 >    GBMap%GBtypes(current)%isLJ      = .false.
152 >    
153      return
154 <  end subroutine set_gb_pair_params
154 >  end subroutine newGBtype
155    
156 < !!$  subroutine set_gb_lj_pair_params(sigma_gb, l2b_ratio, eps_gb, eps_ratio, mu, nu, sigma_lj, eps_lj, c_ident, status)
157 < !!$    real( kind = dp ), intent(in) :: sigma_gb, l2b_ratio, eps_gb, eps_ratio, mu, nu
158 < !!$    real( kind = dp ), intent(in) :: sigma_lj, eps_lj
159 < !!$    integer, intent(in) :: c_ident
160 < !!$    integer :: nLJTYPES, nGayBerneTypes, ntypes, current, status
161 < !!$
171 < !!$    integer :: myATID
172 < !!$    logical :: thisProperty
173 < !!$    real(kind=dp):: fake
174 < !!$    
175 < !!$    status = 0
176 < !!$
177 < !!$    if(.not.associated(LJMap%Ljtype)) then
178 <
179 < !!$       call getMatchingElementList(atypes, "is_GayBerne", .true., &
180 < !!$            nGayBerneTypes, MatchList)
181 < !!$      
182 < !!$       call getMatchingElementList(atypes, "is_LennardJones", .true., &
183 < !!$            nLJTypes, MatchList)
184 < !!$
185 < !!$       LJMap%nLJtypes = nLJTypes
186 < !!$
187 < !!$       allocate(LJMap% LJtype(nLJTypes))
188 < !!$
189 < !!$       ntypes = getSize(atypes)
190 < !!$
191 < !!$       allocate(LJMap%atidToLJtype(ntypes))
192 < !!$
193 < !!$   endif
194 < !!$
195 < !!$   LJmap%currentLJtype =  LJMap%currentLJtype + 1
196 < !!$
197 < !!$   current = LJMap%currentLJtype
198 < !!$   LJMap%atidToLJtype(myATID)    = current
199 < !!$   myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
200 < !!$   call getElementProperty(atypes, myATID, "is_LennardJones",thisProperty)
201 < !!$   if(thisProperty) then
202 < !!$
203 < !!$      LJMap%LJtype(current)%atid    = myatid
204 < !!$!!for testing
205 < !!$      fake = getSigma(myATID)
206 < !!$      LJMap%LJtype(current)%sigma   = getSigma(myATID)
207 < !!$      LJMap%LJtype(current)%epsilon = getEpsilon(myATID)
208 < !!$   end if
209 <
210 < !!$    gb_sigma = sigma_gb
211 < !!$    gb_l2b_ratio = l2b_ratio
212 < !!$    gb_eps = eps_gb
213 < !!$    gb_eps_ratio = eps_ratio
214 < !!    gb_mu = mu
215 < !!    gb_nu = nu
216 < !!$    
217 < !!$    lj_sigma = sigma_lj
218 < !!$    lj_eps = eps_lj
219 <
220 < !!    gb_lj_pair_initialized = .true.
221 < !!$  endsubroutine set_gb_lj_pair_params
222 <
223 <  subroutine createGayBerneLJMap
224 <    integer :: ntypes, i, j
225 <    real(kind=dp) :: s1, s2, e1, e2
226 <    real(kind=dp) :: sigma_s,sigma_l,eps_s, eps_l
156 >  subroutine complete_GB_FF(status)
157 >    integer :: status
158 >    integer :: i, j, l, m, lm, function_type
159 >    real(kind=dp) :: thisDP, sigma
160 >    integer :: alloc_stat, iTheta, iPhi, nSteps, nAtypes, myATID, current
161 >    logical :: thisProperty
162      
163 <    if(LJMap%currentLJtype == 0)then
164 <       call handleError("gayberneLJ", "no members in gayberneLJMap")
163 >    status = 0
164 >    if (GBMap%currentGBtype == 0) then
165 >       call handleError("complete_GB_FF", "No members in GBMap")
166 >       status = -1
167         return
168      end if
169 +    
170 +    nAtypes = getSize(atypes)
171 +    
172 +    if (nAtypes == 0) then
173 +       status = -1
174 +       return
175 +    end if
176 +    
177 +    ! atypes comes from c side
178 +    do i = 1, nAtypes
179 +      
180 +       myATID = getFirstMatchingElement(atypes, 'c_ident', i)
181 +       call getElementProperty(atypes, myATID, "is_LennardJones", thisProperty)
182 +      
183 +       if (thisProperty) then
184 +          GBMap%currentGBtype = GBMap%currentGBtype + 1
185 +          current = GBMap%currentGBtype
186 +          
187 +          GBMap%atidToGBtype(myATID) = current
188 +          GBMap%GBtypes(current)%atid      = myATID      
189 +          GBMap%GBtypes(current)%isLJ      = .true.          
190 +          GBMap%GBtypes(current)%d         = getSigma(myATID)
191 +          GBMap%GBtypes(current)%l         = GBMap%GBtypes(current)%d
192 +          GBMap%GBtypes(current)%eps       = getEpsilon(myATID)
193 +          GBMap%GBtypes(current)%eps_ratio = 1.0_dp
194 +          GBMap%GBtypes(current)%dw        = 1.0_dp
195 +          
196 +       endif
197 +      
198 +    end do
199 +    
200 +    haveGBMap = .true.
201  
202 <    ntypes = getSize(atypes)
202 >    mu = getGayBerneMu()
203 >    nu = getGayBerneNu()
204 >
205      
206 <    if(.not.allocated(gayBerneLJMap))then
207 <       allocate(gayBerneLJMap(ntypes))
208 <    endif
206 >  end subroutine complete_GB_FF
207 >
208 >  subroutine createGBMixingMap()
209 >    integer :: nGBtypes, i, j
210 >    real (kind = dp) :: d1, l1, e1, er1, dw1
211 >    real (kind = dp) :: d2, l2, e2, er2, dw2
212 >    real (kind = dp) :: er, ermu, xp, ap2
213 >
214 >    if (GBMap%currentGBtype == 0) then
215 >       call handleError("GB", "No members in GBMap")
216 >       return
217 >    end if
218      
219 <    do i = 1, ntypes
220 <       s1 = LJMap%LJtype(i)%sigma
221 <       e1 = LJMap%LJtype(i)%epsilon
222 <    
223 < !!$       sigma_s = 0.5d0 *(s1+gb_sigma)
224 < !!$       sigma_l = 0.5d0 *(s1+gb_sigma*gb_l2b_ratio)
225 <       sigma_s = gb_sigma
226 <       sigma_l = gb_sigma*gb_l2b_ratio
227 <       gayBerneLJMap(i)%sigma_s = sigma_s
228 <       gayBerneLJMap(i)%sigma_l = sigma_l
229 <       gayBerneLJMap(i)%sigma_ratio = sigma_l/sigma_s
230 <       eps_s = dsqrt(e1*gb_eps)
231 <       eps_l = dsqrt(e1*gb_eps_l)
232 <       gayBerneLJMap(i)%eps_s = eps_s
233 <       gayBerneLJMap(i)%eps_l = eps_l
234 <       gayBerneLJMap(i)%eps_ratio = eps_l/eps_s
219 >    nGBtypes = GBMap%nGBtypes
220 >
221 >    if (.not. allocated(GBMixingMap)) then
222 >       allocate(GBMixingMap(nGBtypes, nGBtypes))
223 >    endif
224 >
225 >    do i = 1, nGBtypes
226 >
227 >       d1 = GBMap%GBtypes(i)%d
228 >       l1 = GBMap%GBtypes(i)%l
229 >       e1 = GBMap%GBtypes(i)%eps
230 >       er1 = GBMap%GBtypes(i)%eps_ratio
231 >       dw1 = GBMap%GBtypes(i)%dw
232 >
233 >       do j = i, nGBtypes
234 >
235 >          d2 = GBMap%GBtypes(j)%d
236 >          l2 = GBMap%GBtypes(j)%l
237 >          e2 = GBMap%GBtypes(j)%eps
238 >          er2 = GBMap%GBtypes(j)%eps_ratio
239 >          dw2 = GBMap%GBtypes(j)%dw
240 >
241 >          GBMixingMap(i,j)%sigma0 = sqrt(d1*d1 + d2*d2)
242 >          GBMixingMap(i,j)%xa2 = (l1*l1 - d1*d1)/(l1*l1 + d2*d2)
243 >          GBMixingMap(i,j)%xai2 = (l2*l2 - d2*d2)/(l2*l2 + d1*d1)
244 >          GBMixingMap(i,j)%x2 = (l1*l1 - d1*d1) * (l2*l2 - d2*d2) / &
245 >               ((l2*l2 + d1*d1) * (l1*l1 + d2*d2))
246 >
247 >          ! assumed LB mixing rules for now:
248 >
249 >          GBMixingMap(i,j)%dw = 0.5_dp * (dw1 + dw2)
250 >          GBMixingMap(i,j)%eps0 = sqrt(e1 * e2)
251 >
252 >          er = sqrt(er1 * er2)
253 >          ermu = er**(1.0_dp / mu)
254 >          xp = (1.0_dp - ermu) / (1.0_dp + ermu)
255 >          ap2 = 1.0_dp / (1.0_dp + ermu)
256 >
257 >          GBMixingMap(i,j)%xp2 = xp*xp
258 >          GBMixingMap(i,j)%xpap2 = xp*ap2
259 >          GBMixingMap(i,j)%xpapi2 = xp/ap2
260 >          
261 >          if (i.ne.j) then
262 >             GBMixingMap(j,i)%sigma0 = GBMixingMap(i,j)%sigma0
263 >             GBMixingMap(j,i)%dw     = GBMixingMap(i,j)%dw    
264 >             GBMixingMap(j,i)%eps0   = GBMixingMap(i,j)%eps0  
265 >             GBMixingMap(j,i)%x2     = GBMixingMap(i,j)%x2    
266 >             GBMixingMap(j,i)%xa2    = GBMixingMap(i,j)%xa2  
267 >             GBMixingMap(j,i)%xai2   = GBMixingMap(i,j)%xai2  
268 >             GBMixingMap(j,i)%xp2    = GBMixingMap(i,j)%xp2  
269 >             GBMixingMap(j,i)%xpap2  = GBMixingMap(i,j)%xpap2
270 >             GBMixingMap(j,i)%xpapi2 = GBMixingMap(i,j)%xpapi2
271 >          endif
272 >       enddo
273      enddo
274 <    haveGayBerneLJMap = .true.
275 <    gb_lj_pair_initialized = .true.
276 <  endsubroutine createGayBerneLJMap
274 >    haveMixingMap = .true.
275 >    
276 >  end subroutine createGBMixingMap
277 >  
278 >
279    !! gay berne cutoff should be a parameter in globals, this is a temporary
280    !! work around - this should be fixed when gay berne is up and running
281 +
282    function getGayBerneCut(atomID) result(cutValue)
283 <    integer, intent(in) :: atomID !! nah... we don't need to use this...
284 <    real(kind=dp) :: cutValue
283 >    integer, intent(in) :: atomID
284 >    integer :: gbt1
285 >    real(kind=dp) :: cutValue, l, d
286  
287 <    cutValue = gb_l2b_ratio*gb_sigma*2.5_dp
287 >    if (GBMap%currentGBtype == 0) then
288 >       call handleError("GB", "No members in GBMap")
289 >       return
290 >    end if
291 >
292 >    gbt1 = GBMap%atidToGBtype(atomID)
293 >    l = GBMap%GBtypes(gbt1)%l
294 >    d = GBMap%GBtypes(gbt1)%d  
295 >    cutValue = 2.5_dp*max(l,d)
296 >
297    end function getGayBerneCut
298  
299    subroutine do_gb_pair(atom1, atom2, d, r, r2, sw, vpair, fpair, &
300 <       pot, A, f, t, do_pot)
300 >       pot, Amat, f, t, do_pot)
301      
302      integer, intent(in) :: atom1, atom2
303 <    integer :: id1, id2
303 >    integer :: atid1, atid2, gbt1, gbt2, id1, id2
304      real (kind=dp), intent(inout) :: r, r2
305      real (kind=dp), dimension(3), intent(in) :: d
306      real (kind=dp), dimension(3), intent(inout) :: fpair
307      real (kind=dp) :: pot, sw, vpair
308 <    real (kind=dp), dimension(9,nLocal) :: A
308 >    real (kind=dp), dimension(9,nLocal) :: Amat
309      real (kind=dp), dimension(3,nLocal) :: f
310      real (kind=dp), dimension(3,nLocal) :: t
311      logical, intent(in) :: do_pot
312 <    real (kind = dp), dimension(3) :: ul1
282 <    real (kind = dp), dimension(3) :: ul2
312 >    real (kind = dp), dimension(3) :: ul1, ul2, rxu1, rxu2, uxu, rhat
313  
314 <    real(kind=dp) :: chi, chiprime, emu, s2
315 <    real(kind=dp) :: r4, rdotu1, rdotu2, u1dotu2, g, gp, gpi, gmu, gmum
316 <    real(kind=dp) :: curlyE, enu, enum, eps, dotsum, dotdiff, ds2, dd2
317 <    real(kind=dp) :: opXdot, omXdot, opXpdot, omXpdot, pref, gfact
318 <    real(kind=dp) :: BigR, Ri, Ri2, Ri6, Ri7, Ri12, Ri13, R126, R137
289 <    real(kind=dp) :: dru1dx, dru1dy, dru1dz
290 <    real(kind=dp) :: dru2dx, dru2dy, dru2dz
291 <    real(kind=dp) :: dBigRdx, dBigRdy, dBigRdz
292 <    real(kind=dp) :: dBigRdu1x, dBigRdu1y, dBigRdu1z
293 <    real(kind=dp) :: dBigRdu2x, dBigRdu2y, dBigRdu2z
294 <    real(kind=dp) :: dUdx, dUdy, dUdz
295 <    real(kind=dp) :: dUdu1x, dUdu1y, dUdu1z, dUdu2x, dUdu2y, dUdu2z
296 <    real(kind=dp) :: dcE, dcEdu1x, dcEdu1y, dcEdu1z, dcEdu2x, dcEdu2y, dcEdu2z
297 <    real(kind=dp) :: depsdu1x, depsdu1y, depsdu1z, depsdu2x, depsdu2y, depsdu2z
298 <    real(kind=dp) :: drdx, drdy, drdz
299 <    real(kind=dp) :: dgdx, dgdy, dgdz
300 <    real(kind=dp) :: dgdu1x, dgdu1y, dgdu1z, dgdu2x, dgdu2y, dgdu2z
301 <    real(kind=dp) :: dgpdx, dgpdy, dgpdz
302 <    real(kind=dp) :: dgpdu1x, dgpdu1y, dgpdu1z, dgpdu2x, dgpdu2y, dgpdu2z
303 <    real(kind=dp) :: line1a, line1bx, line1by, line1bz
304 <    real(kind=dp) :: line2a, line2bx, line2by, line2bz
305 <    real(kind=dp) :: line3a, line3b, line3, line3x, line3y, line3z
306 <    real(kind=dp) :: term1x, term1y, term1z, term1u1x, term1u1y, term1u1z
307 <    real(kind=dp) :: term1u2x, term1u2y, term1u2z
308 <    real(kind=dp) :: term2a, term2b, term2u1x, term2u1y, term2u1z
309 <    real(kind=dp) :: term2u2x, term2u2y, term2u2z
310 <    real(kind=dp) :: yick1, yick2, mess1, mess2
311 <    
312 <    s2 = (gb_l2b_ratio)**2
313 <    emu = (gb_eps_ratio)**(1.0d0/gb_mu)
314 >    real (kind = dp) :: sigma0, dw, eps0, x2, xa2, xai2, xp2, xpap2, xpapi2
315 >    real (kind = dp) :: e1, e2, eps, sigma, s3, s03, au, bu, a, b, g, g2
316 >    real (kind = dp) :: U, BigR, R3, R6, R7, R12, R13, H, Hp, fx, fy, fz
317 >    real (kind = dp) :: dUdr, dUda, dUdb, dUdg, pref1, pref2
318 >    logical :: i_is_lj, j_is_lj
319  
320 <    chi = (s2 - 1.0d0)/(s2 + 1.0d0)
321 <    chiprime = (1.0d0 - emu)/(1.0d0 + emu)
320 >    if (.not.haveMixingMap) then
321 >       call createGBMixingMap()
322 >    endif
323  
324 <    r4 = r2*r2
324 > #ifdef IS_MPI
325 >    atid1 = atid_Row(atom1)
326 >    atid2 = atid_Col(atom2)
327 > #else
328 >    atid1 = atid(atom1)
329 >    atid2 = atid(atom2)
330 > #endif
331  
332 +    gbt1 = GBMap%atidToGBtype(atid1)
333 +    gbt2 = GBMap%atidToGBtype(atid2)    
334 +
335 +    i_is_LJ = GBMap%GBTypes(gbt1)%isLJ
336 +    j_is_LJ = GBMap%GBTypes(gbt2)%isLJ
337 +
338 +    sigma0 = GBMixingMap(gbt1, gbt2)%sigma0
339 +    dw     = GBMixingMap(gbt1, gbt2)%dw    
340 +    eps0   = GBMixingMap(gbt1, gbt2)%eps0  
341 +    x2     = GBMixingMap(gbt1, gbt2)%x2    
342 +    xa2    = GBMixingMap(gbt1, gbt2)%xa2  
343 +    xai2   = GBMixingMap(gbt1, gbt2)%xai2  
344 +    xp2    = GBMixingMap(gbt1, gbt2)%xp2  
345 +    xpap2  = GBMixingMap(gbt1, gbt2)%xpap2
346 +    xpapi2 = GBMixingMap(gbt1, gbt2)%xpapi2
347 +    
348   #ifdef IS_MPI
349 <    ul1(1) = A_Row(3,atom1)
350 <    ul1(2) = A_Row(6,atom1)
349 >    ul1(1) = A_Row(7,atom1)
350 >    ul1(2) = A_Row(8,atom1)
351      ul1(3) = A_Row(9,atom1)
352  
353 <    ul2(1) = A_Col(3,atom2)
354 <    ul2(2) = A_Col(6,atom2)
353 >    ul2(1) = A_Col(7,atom2)
354 >    ul2(2) = A_Col(8,atom2)
355      ul2(3) = A_Col(9,atom2)
356   #else
357 <    ul1(1) = A(3,atom1)
358 <    ul1(2) = A(6,atom1)
359 <    ul1(3) = A(9,atom1)
357 >    ul1(1) = Amat(7,atom1)
358 >    ul1(2) = Amat(8,atom1)
359 >    ul1(3) = Amat(9,atom1)
360  
361 <    ul2(1) = A(3,atom2)
362 <    ul2(2) = A(6,atom2)
363 <    ul2(3) = A(9,atom2)
336 <
361 >    ul2(1) = Amat(7,atom2)
362 >    ul2(2) = Amat(8,atom2)
363 >    ul2(3) = Amat(9,atom2)
364   #endif
365      
366 <    dru1dx = ul1(1)
367 <    dru2dx = ul2(1)
368 <    dru1dy = ul1(2)
369 <    dru2dy = ul2(2)
370 <    dru1dz = ul1(3)
371 <    dru2dz = ul2(3)
345 <        
366 >    if (i_is_LJ) then
367 >       a = 0.0_dp
368 >       ul1 = 0.0_dp
369 >    else
370 >       a = d(1)*ul1(1)   + d(2)*ul1(2)   + d(3)*ul1(3)
371 >    endif
372  
373 +    if (j_is_LJ) then
374 +       b = 0.0_dp
375 +       ul2 = 0.0_dp
376 +    else      
377 +       b = d(1)*ul2(1)   + d(2)*ul2(2)   + d(3)*ul2(3)
378 +    endif
379  
380 <    drdx = d(1) / r
381 <    drdy = d(2) / r
382 <    drdz = d(3) / r
380 >    if (i_is_LJ.or.j_is_LJ) then
381 >       g = 0.0_dp
382 >    else
383 >       g = ul1(1)*ul2(1) + ul1(2)*ul2(2) + ul1(3)*ul2(3)
384 >    endif
385 >
386 >    au = a / r
387 >    bu = b / r
388 >    g2 = g*g
389 >
390 >    H  = (xa2 * au + xai2 * bu - 2.0_dp*x2*au*bu*g)  / (1.0_dp - x2*g2)
391 >    Hp = (xpap2*au + xpapi2*bu - 2.0_dp*xp2*au*bu*g) / (1.0_dp - xp2*g2)
392 >    sigma = sigma0 / sqrt(1.0_dp - H)
393 >    e1 = 1.0_dp / sqrt(1.0_dp - x2*g2)
394 >    e2 = 1.0_dp - Hp
395 >    eps = eps0 * (e1**nu) * (e2**mu)
396 >    BigR = dw*sigma0 / (r - sigma + dw*sigma0)
397      
398 <    ! do some dot products:
399 <    ! NB the r in these dot products is the actual intermolecular vector,
400 <    ! and is not the unit vector in that direction.
401 <    
402 <    rdotu1 = d(1)*ul1(1) + d(2)*ul1(2) + d(3)*ul1(3)
357 <    rdotu2 = d(1)*ul2(1) + d(2)*ul2(2) + d(3)*ul2(3)
358 <    u1dotu2 = ul1(1)*ul2(1) + ul1(2)*ul2(2) +  ul1(3)*ul2(3)
398 >    R3 = BigR*BigR*BigR
399 >    R6 = R3*R3
400 >    R7 = R6 * BigR
401 >    R12 = R6*R6
402 >    R13 = R6*R7
403  
404 <    ! This stuff is all for the calculation of g(Chi) and dgdx
405 <    ! Line numbers roughly follow the lines in equation A25 of Luckhurst
406 <    !   et al. Liquid Crystals 8, 451-464 (1990).
407 <    ! We note however, that there are some major typos in that Appendix
408 <    ! of the Luckhurst paper, particularly in equations A23, A29 and A31
409 <    ! We have attempted to correct them below.
404 >    U = 4.0_dp * eps * (R12 - R6)
405 >
406 >    s3 = sigma*sigma*sigma
407 >    s03 = sigma0*sigma0*sigma0
408 >
409 >    pref1 = - 8.0_dp * eps * mu * (R12 - R6) / (e2 * r)
410 >    pref2 = 8.0_dp * eps * s3 * (6.0_dp*R13 - 3.0_dp*R7) / (dw*r*s03)
411 >
412 >    dUdr = - (pref1 * Hp + pref2 * (sigma0*sigma0*r/s3 - H))
413      
414 <    dotsum = rdotu1+rdotu2
415 <    dotdiff = rdotu1-rdotu2
369 <    ds2 = dotsum*dotsum
370 <    dd2 = dotdiff*dotdiff
371 <  
372 <    opXdot = 1.0d0 + Chi*u1dotu2
373 <    omXdot = 1.0d0 - Chi*u1dotu2
374 <    opXpdot = 1.0d0 + ChiPrime*u1dotu2
375 <    omXpdot = 1.0d0 - ChiPrime*u1dotu2
376 <  
377 <    line1a = dotsum/opXdot
378 <    line1bx = dru1dx + dru2dx
379 <    line1by = dru1dy + dru2dy
380 <    line1bz = dru1dz + dru2dz
414 >    dUda = pref1 * (xpap2*au - xp2*bu*g) / (1.0_dp - xp2 * g2) &
415 >         + pref2 * (xa2 * au - x2 *bu*g) / (1.0_dp - x2 * g2)
416      
417 <    line2a = dotdiff/omXdot
418 <    line2bx = dru1dx - dru2dx
384 <    line2by = dru1dy - dru2dy
385 <    line2bz = dru1dz - dru2dz
386 <    
387 <    term1x = -Chi*(line1a*line1bx + line2a*line2bx)/r2
388 <    term1y = -Chi*(line1a*line1by + line2a*line2by)/r2
389 <    term1z = -Chi*(line1a*line1bz + line2a*line2bz)/r2
390 <    
391 <    line3a = ds2/opXdot
392 <    line3b = dd2/omXdot
393 <    line3 = Chi*(line3a + line3b)/r4
394 <    line3x = d(1)*line3
395 <    line3y = d(2)*line3
396 <    line3z = d(3)*line3
397 <    
398 <    dgdx = term1x + line3x
399 <    dgdy = term1y + line3y
400 <    dgdz = term1z + line3z
417 >    dUdb = pref1 * (xpapi2*bu - xp2*au*g) / (1.0_dp - xp2 * g2) &
418 >         + pref2 * (xai2 * bu - x2 *au*g) / (1.0_dp - x2 * g2)
419  
420 <    term1u1x = 2.0d0*(line1a+line2a)*d(1)
421 <    term1u1y = 2.0d0*(line1a+line2a)*d(2)
422 <    term1u1z = 2.0d0*(line1a+line2a)*d(3)
423 <    term1u2x = 2.0d0*(line1a-line2a)*d(1)
424 <    term1u2y = 2.0d0*(line1a-line2a)*d(2)
425 <    term1u2z = 2.0d0*(line1a-line2a)*d(3)
426 <    
409 <    term2a = -line3a/opXdot
410 <    term2b =  line3b/omXdot
411 <    
412 <    term2u1x = Chi*ul2(1)*(term2a + term2b)
413 <    term2u1y = Chi*ul2(2)*(term2a + term2b)
414 <    term2u1z = Chi*ul2(3)*(term2a + term2b)
415 <    term2u2x = Chi*ul1(1)*(term2a + term2b)
416 <    term2u2y = Chi*ul1(2)*(term2a + term2b)
417 <    term2u2z = Chi*ul1(3)*(term2a + term2b)
418 <    
419 <    pref = -Chi*0.5d0/r2
420 >    dUdg = 4.0_dp * eps * nu * (R12 - R6) * x2 * g / (1.0_dp - x2*g2) &
421 >         + 8.0_dp * eps * mu * (R12 - R6) * (xp2*au*bu - Hp*xp2*g) / &
422 >         (1.0_dp - xp2 * g2) / e2 &
423 >         + 8.0_dp * eps * s3 * (3.0_dp * R7 - 6.0_dp * R13) * &
424 >         (x2 * au * bu - H * x2 * g) / (1.0_dp - x2 * g2) / (dw * s03)
425 >            
426 >    rhat = d / r
427  
428 <    dgdu1x = pref*(term1u1x+term2u1x)
429 <    dgdu1y = pref*(term1u1y+term2u1y)
430 <    dgdu1z = pref*(term1u1z+term2u1z)
424 <    dgdu2x = pref*(term1u2x+term2u2x)
425 <    dgdu2y = pref*(term1u2y+term2u2y)
426 <    dgdu2z = pref*(term1u2z+term2u2z)
428 >    fx = -dUdr * rhat(1) - dUda * ul1(1) - dUdb * ul2(1)
429 >    fy = -dUdr * rhat(2) - dUda * ul1(2) - dUdb * ul2(2)
430 >    fx = -dUdr * rhat(3) - dUda * ul1(3) - dUdb * ul2(3)
431  
432 <    g = 1.0d0 - Chi*(line3a + line3b)/(2.0d0*r2)
433 <  
434 <    BigR = (r - gb_sigma*(g**(-0.5d0)) + gb_sigma)/gb_sigma
435 <    Ri = 1.0d0/BigR
432 <    Ri2 = Ri*Ri
433 <    Ri6 = Ri2*Ri2*Ri2
434 <    Ri7 = Ri6*Ri
435 <    Ri12 = Ri6*Ri6
436 <    Ri13 = Ri6*Ri7
437 <
438 <    gfact = (g**(-1.5d0))*0.5d0
439 <
440 <    dBigRdx = drdx/gb_sigma + dgdx*gfact
441 <    dBigRdy = drdy/gb_sigma + dgdy*gfact
442 <    dBigRdz = drdz/gb_sigma + dgdz*gfact
443 <
444 <    dBigRdu1x = dgdu1x*gfact
445 <    dBigRdu1y = dgdu1y*gfact
446 <    dBigRdu1z = dgdu1z*gfact
447 <    dBigRdu2x = dgdu2x*gfact
448 <    dBigRdu2y = dgdu2y*gfact
449 <    dBigRdu2z = dgdu2z*gfact
450 <
451 <    ! Now, we must do it again for g(ChiPrime) and dgpdx
452 <
453 <    line1a = dotsum/opXpdot
454 <    line2a = dotdiff/omXpdot
455 <    term1x = -ChiPrime*(line1a*line1bx + line2a*line2bx)/r2
456 <    term1y = -ChiPrime*(line1a*line1by + line2a*line2by)/r2
457 <    term1z = -ChiPrime*(line1a*line1bz + line2a*line2bz)/r2
458 <    line3a = ds2/opXpdot
459 <    line3b = dd2/omXpdot
460 <    line3 = ChiPrime*(line3a + line3b)/r4
461 <    line3x = d(1)*line3
462 <    line3y = d(2)*line3
463 <    line3z = d(3)*line3
464 <    
465 <    dgpdx = term1x + line3x
466 <    dgpdy = term1y + line3y
467 <    dgpdz = term1z + line3z
468 <    
469 <    term1u1x = 2.00d0*(line1a+line2a)*d(1)
470 <    term1u1y = 2.00d0*(line1a+line2a)*d(2)
471 <    term1u1z = 2.00d0*(line1a+line2a)*d(3)
472 <    term1u2x = 2.0d0*(line1a-line2a)*d(1)
473 <    term1u2y = 2.0d0*(line1a-line2a)*d(2)
474 <    term1u2z = 2.0d0*(line1a-line2a)*d(3)
475 <
476 <    term2a = -line3a/opXpdot
477 <    term2b =  line3b/omXpdot
478 <    
479 <    term2u1x = ChiPrime*ul2(1)*(term2a + term2b)
480 <    term2u1y = ChiPrime*ul2(2)*(term2a + term2b)
481 <    term2u1z = ChiPrime*ul2(3)*(term2a + term2b)
482 <    term2u2x = ChiPrime*ul1(1)*(term2a + term2b)
483 <    term2u2y = ChiPrime*ul1(2)*(term2a + term2b)
484 <    term2u2z = ChiPrime*ul1(3)*(term2a + term2b)
485 <  
486 <    pref = -ChiPrime*0.5d0/r2
487 <    
488 <    dgpdu1x = pref*(term1u1x+term2u1x)
489 <    dgpdu1y = pref*(term1u1y+term2u1y)
490 <    dgpdu1z = pref*(term1u1z+term2u1z)
491 <    dgpdu2x = pref*(term1u2x+term2u2x)
492 <    dgpdu2y = pref*(term1u2y+term2u2y)
493 <    dgpdu2z = pref*(term1u2z+term2u2z)
494 <    
495 <    gp = 1.0d0 - ChiPrime*(line3a + line3b)/(2.0d0*r2)
496 <    gmu = gp**gb_mu
497 <    gpi = 1.0d0 / gp
498 <    gmum = gmu*gpi
499 <
500 <    curlyE = 1.0d0/dsqrt(1.0d0 - Chi*Chi*u1dotu2*u1dotu2)
501 < !!$
502 < !!$    dcE = -(curlyE**3)*Chi*Chi*u1dotu2
503 <    dcE = (curlyE**3)*Chi*Chi*u1dotu2
504 <
505 <    dcEdu1x = dcE*ul2(1)
506 <    dcEdu1y = dcE*ul2(2)
507 <    dcEdu1z = dcE*ul2(3)
508 <    dcEdu2x = dcE*ul1(1)
509 <    dcEdu2y = dcE*ul1(2)
510 <    dcEdu2z = dcE*ul1(3)
511 <    
512 <    enu = curlyE**gb_nu
513 <    enum = enu/curlyE
514 <  
515 <    eps = gb_eps*enu*gmu
516 <
517 <    yick1 = gb_eps*enu*gb_mu*gmum
518 <    yick2 = gb_eps*gmu*gb_nu*enum
519 <
520 <    depsdu1x = yick1*dgpdu1x + yick2*dcEdu1x
521 <    depsdu1y = yick1*dgpdu1y + yick2*dcEdu1y
522 <    depsdu1z = yick1*dgpdu1z + yick2*dcEdu1z
523 <    depsdu2x = yick1*dgpdu2x + yick2*dcEdu2x
524 <    depsdu2y = yick1*dgpdu2y + yick2*dcEdu2y
525 <    depsdu2z = yick1*dgpdu2z + yick2*dcEdu2z
526 <    
527 <    R126 = Ri12 - Ri6
528 <    R137 = 6.0d0*Ri7 - 12.0d0*Ri13
529 <    
530 <    mess1 = gmu*R137
531 <    mess2 = R126*gb_mu*gmum
532 <    
533 <    dUdx = 4.0d0*gb_eps*enu*(mess1*dBigRdx + mess2*dgpdx)*sw
534 <    dUdy = 4.0d0*gb_eps*enu*(mess1*dBigRdy + mess2*dgpdy)*sw
535 <    dUdz = 4.0d0*gb_eps*enu*(mess1*dBigRdz + mess2*dgpdz)*sw
536 <    
537 <    dUdu1x = 4.0d0*(R126*depsdu1x + eps*R137*dBigRdu1x)*sw
538 <    dUdu1y = 4.0d0*(R126*depsdu1y + eps*R137*dBigRdu1y)*sw
539 <    dUdu1z = 4.0d0*(R126*depsdu1z + eps*R137*dBigRdu1z)*sw
540 <    dUdu2x = 4.0d0*(R126*depsdu2x + eps*R137*dBigRdu2x)*sw
541 <    dUdu2y = 4.0d0*(R126*depsdu2y + eps*R137*dBigRdu2y)*sw
542 <    dUdu2z = 4.0d0*(R126*depsdu2z + eps*R137*dBigRdu2z)*sw
543 <      
432 >    rxu1 = cross_product(d, ul1)
433 >    rxu2 = cross_product(d, ul2)    
434 >    uxu = cross_product(ul1, ul2)
435 >          
436   #ifdef IS_MPI
437 <    f_Row(1,atom1) = f_Row(1,atom1) + dUdx
438 <    f_Row(2,atom1) = f_Row(2,atom1) + dUdy
439 <    f_Row(3,atom1) = f_Row(3,atom1) + dUdz
437 >    f_Row(1,atom1) = f_Row(1,atom1) + fx
438 >    f_Row(2,atom1) = f_Row(2,atom1) + fy
439 >    f_Row(3,atom1) = f_Row(3,atom1) + fz
440      
441 <    f_Col(1,atom2) = f_Col(1,atom2) - dUdx
442 <    f_Col(2,atom2) = f_Col(2,atom2) - dUdy
443 <    f_Col(3,atom2) = f_Col(3,atom2) - dUdz
441 >    f_Col(1,atom2) = f_Col(1,atom2) - fx
442 >    f_Col(2,atom2) = f_Col(2,atom2) - fy
443 >    f_Col(3,atom2) = f_Col(3,atom2) - fz
444      
445 <    t_Row(1,atom1) = t_Row(1,atom1)- ul1(3)*dUdu1y + ul1(2)*dUdu1z
446 <    t_Row(2,atom1) = t_Row(2,atom1)- ul1(1)*dUdu1z + ul1(3)*dUdu1x
447 <    t_Row(3,atom1) = t_Row(3,atom1)- ul1(2)*dUdu1x + ul1(1)*dUdu1y
448 <    
449 <    t_Col(1,atom2) = t_Col(1,atom2) - ul2(3)*dUdu2y + ul2(2)*dUdu2z
450 <    t_Col(2,atom2) = t_Col(2,atom2) - ul2(1)*dUdu2z + ul2(3)*dUdu2x
451 <    t_Col(3,atom2) = t_Col(3,atom2) - ul2(2)*dUdu2x + ul2(1)*dUdu2y
445 >    t_Row(1,atom1) = t_Row(1,atom1) + dUda*rxu1(1) - dUdg*uxu(1)
446 >    t_Row(2,atom1) = t_Row(2,atom1) + dUda*rxu1(2) - dUdg*uxu(2)
447 >    t_Row(3,atom1) = t_Row(3,atom1) + dUda*rxu1(3) - dUdg*uxu(3)
448 >                                                                
449 >    t_Col(1,atom2) = t_Col(1,atom2) + dUdb*rxu2(1) + dUdg*uxu(1)
450 >    t_Col(2,atom2) = t_Col(2,atom2) + dUdb*rxu2(2) + dUdg*uxu(2)
451 >    t_Col(3,atom2) = t_Col(3,atom2) + dUdb*rxu2(3) + dUdg*uxu(3)
452   #else
453 <    f(1,atom1) = f(1,atom1) + dUdx
454 <    f(2,atom1) = f(2,atom1) + dUdy
455 <    f(3,atom1) = f(3,atom1) + dUdz
453 >    f(1,atom1) = f(1,atom1) + fx
454 >    f(2,atom1) = f(2,atom1) + fy
455 >    f(3,atom1) = f(3,atom1) + fz
456      
457 <    f(1,atom2) = f(1,atom2) - dUdx
458 <    f(2,atom2) = f(2,atom2) - dUdy
459 <    f(3,atom2) = f(3,atom2) - dUdz
457 >    f(1,atom2) = f(1,atom2) - fx
458 >    f(2,atom2) = f(2,atom2) - fy
459 >    f(3,atom2) = f(3,atom2) - fz
460      
461 <    t(1,atom1) = t(1,atom1)- ul1(3)*dUdu1y + ul1(2)*dUdu1z
462 <    t(2,atom1) = t(2,atom1)- ul1(1)*dUdu1z + ul1(3)*dUdu1x
463 <    t(3,atom1) = t(3,atom1)- ul1(2)*dUdu1x + ul1(1)*dUdu1y
464 <    
465 <    t(1,atom2) = t(1,atom2)- ul2(3)*dUdu2y + ul2(2)*dUdu2z
466 <    t(2,atom2) = t(2,atom2)- ul2(1)*dUdu2z + ul2(3)*dUdu2x
467 <    t(3,atom2) = t(3,atom2)- ul2(2)*dUdu2x + ul2(1)*dUdu2y
461 >    t(1,atom1) = t(1,atom1) +  dUda*rxu1(1) - dUdg*uxu(1)
462 >    t(2,atom1) = t(2,atom1) +  dUda*rxu1(2) - dUdg*uxu(2)
463 >    t(3,atom1) = t(3,atom1) +  dUda*rxu1(3) - dUdg*uxu(3)
464 >                                                        
465 >    t(1,atom2) = t(1,atom2) +  dUdb*rxu2(1) + dUdg*uxu(1)
466 >    t(2,atom2) = t(2,atom2) +  dUdb*rxu2(2) + dUdg*uxu(2)
467 >    t(3,atom2) = t(3,atom2) +  dUdb*rxu2(3) + dUdg*uxu(3)
468   #endif
469    
470      if (do_pot) then
471   #ifdef IS_MPI
472 <       pot_row(atom1) = pot_row(atom1) + 2.0d0*eps*R126*sw
473 <       pot_col(atom2) = pot_col(atom2) + 2.0d0*eps*R126*sw
472 >       pot_row(VDW_POT,atom1) = pot_row(VDW_POT,atom1) + 0.5d0*U*sw
473 >       pot_col(VDW_POT,atom2) = pot_col(VDW_POT,atom2) + 0.5d0*U*sw
474   #else
475 <       pot = pot + 4.0*eps*R126*sw
475 >       pot = pot + U*sw
476   #endif
477      endif
478 <
479 <    vpair = vpair + 4.0*eps*R126
478 >    
479 >    vpair = vpair + U*sw
480   #ifdef IS_MPI
481      id1 = AtomRowToGlobal(atom1)
482      id2 = AtomColToGlobal(atom2)
# Line 595 | Line 487 | contains
487      
488      if (molMembershipList(id1) .ne. molMembershipList(id2)) then
489        
490 <       fpair(1) = fpair(1) + dUdx
491 <       fpair(2) = fpair(2) + dUdy
492 <       fpair(3) = fpair(3) + dUdz
490 >       fpair(1) = fpair(1) + fx
491 >       fpair(2) = fpair(2) + fy
492 >       fpair(3) = fpair(3) + fz
493        
494      endif
495      
496      return
497    end subroutine do_gb_pair
498 +  
499 +  subroutine destroyGBTypes()
500  
501 <  subroutine do_gb_lj_pair(atom1, atom2, d, r, r2, sw, vpair, fpair, &
502 <       pot, A, f, t, do_pot)
501 >    GBMap%nGBtypes = 0
502 >    GBMap%currentGBtype = 0
503      
504 <    integer, intent(in) :: atom1, atom2
505 <    integer :: id1, id2
506 <    real (kind=dp), intent(inout) :: r, r2
507 <    real (kind=dp), dimension(3), intent(in) :: d
614 <    real (kind=dp), dimension(3), intent(inout) :: fpair
615 <    real (kind=dp) :: pot, sw, vpair
616 <    real (kind=dp), dimension(9,nLocal) :: A
617 <    real (kind=dp), dimension(3,nLocal) :: f
618 <    real (kind=dp), dimension(3,nLocal) :: t
619 <    logical, intent(in) :: do_pot
620 <    real (kind = dp), dimension(3) :: ul
621 <
622 < !!  real(kind=dp) :: lj2, s_lj2pperp2,s_perpppar2,eabnu, epspar
623 <    real(kind=dp) :: spar, sperp, slj, par2, perp2, sc, slj2
624 <    real(kind=dp) :: s_par2mperp2, s_lj2ppar2
625 <    real(kind=dp) :: enot, eperp, epar, eab, eabf,moom, mum1
626 < !!    real(kind=dp) :: e_ljpperp, e_perpmpar, e_ljppar
627 <    real(kind=dp) :: dx, dy, dz, drdx,drdy,drdz, rdotu
628 < !!    real(kind=dp) :: ct, dctdx, dctdy, dctdz, dctdux, dctduy, dctduz
629 <    real(kind=dp) :: mess, sab, dsabdct, eprime, deprimedct, depmudct
630 <    real(kind=dp) :: epmu, depmudx, depmudy, depmudz
631 <    real(kind=dp) :: depmudux, depmuduy, depmuduz
632 <    real(kind=dp) :: BigR, dBigRdx, dBigRdy, dBigRdz
633 <    real(kind=dp) :: dBigRdux, dBigRduy, dBigRduz
634 <    real(kind=dp) :: dUdx, dUdy, dUdz, dUdux, dUduy, dUduz, e0
635 <    real(kind=dp) :: Ri, Ri3, Ri6, Ri7, Ril2, Ri13, Rl26, R137, prefactor
636 <    real(kind=dp) :: chipoalphap2, chioalpha2, ec, epsnot
637 <    real(kind=dp) :: drdotudx, drdotudy, drdotudz    
638 <    real(kind=dp) :: ljeps, ljsigma, sigmaratio, sigmaratioi
639 <    integer :: ljt1, ljt2, atid1, atid2
640 <    logical :: thisProperty
641 < #ifdef IS_MPI
642 <    atid1 = atid_Row(atom1)
643 <    atid2 = atid_Col(atom2)
644 < #else
645 <    atid1 = atid(atom1)
646 <    atid2 = atid(atom2)
647 < #endif
648 <    ri =1/r
504 >    if (associated(GBMap%GBtypes)) then
505 >       deallocate(GBMap%GBtypes)
506 >       GBMap%GBtypes => null()
507 >    end if
508      
509 <    dx = d(1)
510 <    dy = d(2)
511 <    dz = d(3)
653 <    
654 <    drdx = dx *ri
655 <    drdy = dy *ri
656 <    drdz = dz *ri
657 <  
658 <  
659 <
660 <    if(.not.haveGayBerneLJMap) then
661 <       call createGayBerneLJMap()
662 <    endif
663 < !!$   write(*,*) "in gbljpair"
664 <    call getElementProperty(atypes, atid1, "is_LennardJones",thisProperty)
665 < !!$    write(*,*) thisProperty
666 <    if(thisProperty.eqv..true.)then
667 < #ifdef IS_MPI
668 <       ul(1) = A_Row(3,atom2)
669 <       ul(2) = A_Row(6,atom2)
670 <       ul(3) = A_Row(9,atom2)
671 <
672 < #else
673 <       ul(1) = A(3,atom2)
674 <       ul(2) = A(6,atom2)
675 <       ul(3) = A(9,atom2)
676 < #endif
677 <
678 <       rdotu = (dx*ul(1)+dy*ul(2)+dz*ul(3))*ri
679 <
680 <       ljt1 = LJMap%atidtoLJtype(atid1)
681 <       ljt2 = LJMap%atidtoLJtype(atid2)
682 <      
683 <       ljeps =  LJMap%LJtype(ljt1)%epsilon
684 < !!$       write(*,*) "ljeps"
685 < !!$       write(*,*) ljeps
686 <       drdotudx = ul(1)*ri-rdotu*dx*ri*ri
687 <       drdotudy = ul(2)*ri-rdotu*dy*ri*ri
688 <       drdotudz = ul(3)*ri-rdotu*dz*ri*ri
689 <
690 <    
691 <       moom =  1.0d0 / gb_mu
692 <       mum1 = gb_mu-1
693 <
694 <       sperp = GayBerneLJMap(ljt1)%sigma_s
695 <       spar =  GayBerneLJMap(ljt1)%sigma_l
696 <       slj = LJMap%LJtype(ljt1)%sigma
697 <       slj2 = slj*slj
698 < !!$       write(*,*) "spar"
699 < !!$       write(*,*) sperp
700 < !!$       write(*,*) spar
701 < !!    chioalpha2 = s_par2mperp2/s_lj2ppar2
702 <       chioalpha2 =1-((sperp+slj)*(sperp+slj))/((spar+slj)*(spar+slj))
703 <       sc = (sperp+slj)/2.0d0
704 <  
705 <       par2 = spar*spar
706 <       perp2 = sperp*sperp
707 <       s_par2mperp2 = par2 - perp2
708 <       s_lj2ppar2 = slj2 + par2
709 <
710 <
711 < !! check these ! left from old code
712 < !! kdaily e0 may need to be (gb_eps + lj_eps)/2
713 <    
714 <       eperp = dsqrt(gb_eps*ljeps)
715 <       epar = eperp*gb_eps_ratio
716 <       enot = dsqrt(ljeps*eperp)
717 <       chipoalphap2 = 1+(dsqrt(epar*ljeps)/enot)**moom
718 < !! to so mess matchs cleaver (eq 20)
719 <    
720 <       mess = 1-rdotu*rdotu*chioalpha2
721 <       sab = 1.0d0/dsqrt(mess)
722 <       dsabdct = sc*sab*sab*sab*rdotu*chioalpha2
723 <      
724 <       eab = 1-chipoalphap2*rdotu*rdotu
725 <       eabf = enot*eab**gb_mu
726 <       depmudct = -2*enot*chipoalphap2*gb_mu*rdotu*eab**mum1
727 <      
728 <      
729 <       BigR = (r - sab*sc + sc)/sc
730 <       dBigRdx = (drdx -dsabdct*drdotudx)/sc
731 <       dBigRdy = (drdy -dsabdct*drdotudy)/sc
732 <       dBigRdz = (drdz -dsabdct*drdotudz)/sc
733 <       dBigRdux = (-dsabdct*drdx)/sc
734 <       dBigRduy = (-dsabdct*drdy)/sc
735 <       dBigRduz = (-dsabdct*drdz)/sc
736 <      
737 <       depmudx = depmudct*drdotudx
738 <       depmudy = depmudct*drdotudy
739 <       depmudz = depmudct*drdotudz
740 <       depmudux = depmudct*drdx
741 <       depmuduy = depmudct*drdy
742 <       depmuduz = depmudct*drdz
743 <      
744 <       Ri = 1.0d0/BigR
745 <       Ri3 = Ri*Ri*Ri
746 <       Ri6 = Ri3*Ri3
747 <       Ri7 = Ri6*Ri
748 <       Ril2 = Ri6*Ri6
749 <       Ri13 = Ri6*Ri7
750 <       Rl26 = Ril2 - Ri6
751 <       R137 = 6.0d0*Ri7 - 12.0d0*Ri13
752 <      
753 <       prefactor = 4.0d0
754 <      
755 <       dUdx = prefactor*(eabf*R137*dBigRdx + Rl26*depmudx)
756 <       dUdy = prefactor*(eabf*R137*dBigRdy + Rl26*depmudy)
757 <       dUdz = prefactor*(eabf*R137*dBigRdz + Rl26*depmudz)
758 <       dUdux = prefactor*(eabf*R137*dBigRdux + Rl26*depmudux)
759 <       dUduy = prefactor*(eabf*R137*dBigRduy + Rl26*depmuduy)
760 <       dUduz = prefactor*(eabf*R137*dBigRduz + Rl26*depmuduz)
761 <      
762 < #ifdef IS_MPI
763 <       f_Row(1,atom1) = f_Row(1,atom1) - dUdx
764 <       f_Row(2,atom1) = f_Row(2,atom1) - dUdy
765 <       f_Row(3,atom1) = f_Row(3,atom1) - dUdz
766 <    
767 <       f_Col(1,atom2) = f_Col(1,atom2) + dUdx
768 <       f_Col(2,atom2) = f_Col(2,atom2) + dUdy
769 <       f_Col(3,atom2) = f_Col(3,atom2) + dUdz
770 <      
771 <       t_Row(1,atom2) = t_Row(1,atom1) + ul(2)*dUdu1z - ul(3)*dUdu1y
772 <       t_Row(2,atom2) = t_Row(2,atom1) + ul(3)*dUdu1x - ul(1)*dUdu1z
773 <       t_Row(3,atom2) = t_Row(3,atom1) + ul(1)*dUdu1y - ul(2)*dUdu1x
774 <  
775 < #else
776 <      
777 <       !!kdaily changed flx(gbatom) to f(1,atom1)
778 <       f(1,atom1) = f(1,atom1) + dUdx
779 <       f(2,atom1) = f(2,atom1) + dUdy
780 <       f(3,atom1) = f(3,atom1) + dUdz
781 <      
782 <       !!kdaily changed flx(ljatom) to f(2,atom2)
783 <       f(1,atom2) = f(1,atom2) - dUdx
784 <       f(2,atom2) = f(2,atom2) - dUdy
785 <       f(3,atom2) = f(3,atom2) - dUdz
786 <      
787 <       ! torques are cross products:
788 <       !!kdaily tlx(gbatom) to t(1, atom1)and ulx(gbatom) to u11(atom1)need mpi
789 <       t(1,atom2) = t(1,atom2) + ul(2)*dUduz - ul(3)*dUduy
790 <       t(2,atom2) = t(2,atom2) + ul(3)*dUdux - ul(1)*dUduz
791 <       t(3,atom2) = t(3,atom2) + ul(1)*dUduy - ul(2)*dUdux
792 <      
793 < #endif
794 <      
795 <       if (do_pot) then
796 < #ifdef IS_MPI
797 <          pot_row(atom1) = pot_row(atom1) + 2.0d0*eps*Rl26*sw
798 <          pot_col(atom2) = pot_col(atom2) + 2.0d0*eps*Rl26*sw
799 < #else
800 <          pot = pot + prefactor*eabf*Rl26*sw
801 < #endif
802 <       endif
803 <      
804 <       vpair = vpair + 4.0*epmu*Rl26
805 < #ifdef IS_MPI
806 <       id1 = AtomRowToGlobal(atom1)
807 <       id2 = AtomColToGlobal(atom2)
808 < #else
809 <       id1 = atom1
810 <       id2 = atom2
811 < #endif
812 <      
813 <       If (Molmembershiplist(Id1) .Ne. Molmembershiplist(Id2)) Then
814 <          
815 <          Fpair(1) = Fpair(1) + Dudx
816 <          Fpair(2) = Fpair(2) + Dudy
817 <          Fpair(3) = Fpair(3) + Dudz
818 <          
819 <       Endif
820 <      
821 <    else
822 <       !!need to do this all over but switch the gb and lj
823 <    endif
824 <    return
825 <
826 <  end subroutine do_gb_lj_pair
827 <
828 <  subroutine complete_GayBerne_FF(status)
829 <    integer :: nLJTYPES, nGayBerneTypes, ntypes, current, status, natypes
830 <    integer, pointer :: MatchList(:) => null ()
831 <    integer :: i
832 <    integer :: myATID
833 <    logical :: thisProperty
834 <    
835 <    if(.not.associated(LJMap%Ljtype)) then
836 <      
837 <       natypes = getSize(atypes)
838 <      
839 <       if(nAtypes == 0) then
840 <          status = -1
841 <          return
842 <       end if
843 <      
844 <       call getMatchingElementList(atypes, "is_LennardJones", .true., &
845 <            nLJTypes, MatchList)
846 <      
847 <       LJMap%nLJtypes = nLJTypes
848 <      
849 <       if(nLJTypes ==0) then
850 <          write(*,*)" you broke this thing kyle"
851 <          return
852 <       endif
853 <       allocate(LJMap%LJtype(nLJTypes))
854 <      
855 <       ntypes = getSize(atypes)
856 <      
857 <       allocate(LJMap%atidToLJtype(ntypes))
509 >    if (associated(GBMap%atidToGBtype)) then
510 >       deallocate(GBMap%atidToGBtype)
511 >       GBMap%atidToGBtype => null()
512      end if
513      
514 <    do i =1, ntypes
861 <      
862 <       myATID = getFirstMatchingElement(atypes, 'c_ident', i)
863 <       call getElementProperty(atypes, myATID, "is_LennardJones",thisProperty)
864 <      
865 <       if(thisProperty) then
866 <          current =  LJMap%currentLJtype+1      
867 <          LJMap%currentLJtype =  current          
868 <          
869 <          LJMap%atidToLJtype(myATID)    = current
870 <          LJMap%LJtype(current)%atid    = myATid
871 <          
872 <          LJMap%LJtype(current)%sigma   = getSigma(myATID)
873 <          LJMap%LJtype(current)%epsilon = getEpsilon(myATID)
874 <       endif
875 <      
876 <    enddo
877 <    gb_pair_initialized = .true.
514 >    haveMixingMap = .false.
515      
516 <  end subroutine complete_GayBerne_FF
516 >  end subroutine destroyGBTypes
517  
518 <  subroutine destroyGayBerneTypes()
882 <
883 <    LJMap%Nljtypes =0
884 <    LJMap%currentLJtype=0
885 <    if(associated(LJMap%LJtype))then
886 <       deallocate(LJMap%LJtype)
887 <       LJMap%LJtype => null()
888 <    end if
889 <      
890 <    if(associated(LJMap%atidToLJType))then
891 <       deallocate(LJMap%atidToLJType)
892 <       LJMap%atidToLJType => null()
893 <    end if
894 <
895 < !!       deallocate(gayBerneLJMap)
896 <  
897 <    haveGayBerneLJMap = .false.
898 <  end subroutine destroyGayBerneTypes
899 <
900 <
901 <
902 < end module gb_pair
518 > end module gayberne
519      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines