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

Comparing trunk/OOPSE-4/src/UseTheForce/DarkSide/LJ.F90 (file contents):
Revision 1624 by chuckv, Thu Oct 21 15:25:30 2004 UTC vs.
Revision 2733 by gezelter, Tue Apr 25 02:09:01 2006 UTC

# Line 1 | Line 1
1 + !!
2 + !! Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 + !!
4 + !! The University of Notre Dame grants you ("Licensee") a
5 + !! non-exclusive, royalty free, license to use, modify and
6 + !! redistribute this software in source and binary code form, provided
7 + !! that the following conditions are met:
8 + !!
9 + !! 1. Acknowledgement of the program authors must be made in any
10 + !!    publication of scientific results based in part on use of the
11 + !!    program.  An acceptable form of acknowledgement is citation of
12 + !!    the article in which the program was described (Matthew
13 + !!    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 + !!    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 + !!    Parallel Simulation Engine for Molecular Dynamics,"
16 + !!    J. Comput. Chem. 26, pp. 252-271 (2005))
17 + !!
18 + !! 2. Redistributions of source code must retain the above copyright
19 + !!    notice, this list of conditions and the following disclaimer.
20 + !!
21 + !! 3. Redistributions in binary form must reproduce the above copyright
22 + !!    notice, this list of conditions and the following disclaimer in the
23 + !!    documentation and/or other materials provided with the
24 + !!    distribution.
25 + !!
26 + !! This software is provided "AS IS," without a warranty of any
27 + !! kind. All express or implied conditions, representations and
28 + !! warranties, including any implied warranty of merchantability,
29 + !! fitness for a particular purpose or non-infringement, are hereby
30 + !! excluded.  The University of Notre Dame and its licensors shall not
31 + !! be liable for any damages suffered by licensee as a result of
32 + !! using, modifying or distributing the software or its
33 + !! derivatives. In no event will the University of Notre Dame or its
34 + !! licensors be liable for any lost revenue, profit or data, or for
35 + !! direct, indirect, special, consequential, incidental or punitive
36 + !! damages, however caused and regardless of the theory of liability,
37 + !! arising out of the use of or inability to use software, even if the
38 + !! University of Notre Dame has been advised of the possibility of
39 + !! such damages.
40 + !!
41 +
42 +
43   !! Calculates Long Range forces Lennard-Jones interactions.
2 !! Corresponds to the force field defined in lj_FF.cpp
44   !! @author Charles F. Vardeman II
45   !! @author Matthew Meineke
46 < !! @version $Id: LJ.F90,v 1.2 2004-10-21 15:25:30 chuckv Exp $, $Date: 2004-10-21 15:25:30 $, $Name: not supported by cvs2svn $, $Revision: 1.2 $
46 > !! @version $Id: LJ.F90,v 1.24 2006-04-25 02:09:01 gezelter Exp $, $Date: 2006-04-25 02:09:01 $, $Name: not supported by cvs2svn $, $Revision: 1.24 $
47  
48 +
49   module lj
50    use atype_module
9  use switcheroo
51    use vector_class
52    use simulation
53 +  use status
54 +  use fForceOptions
55   #ifdef IS_MPI
56    use mpiSimulation
57   #endif
# Line 16 | Line 59 | module lj
59  
60    implicit none
61    PRIVATE
62 <  
62 > #define __FORTRAN90
63 > #include "UseTheForce/DarkSide/fInteractionMap.h"
64 >
65    integer, parameter :: DP = selected_real_kind(15)
66  
67 < #define __FORTRAN90
68 < #include "UseTheForce/fForceField.h"
67 >  logical, save :: useGeometricDistanceMixing = .false.
68 >  logical, save :: haveMixingMap = .false.
69  
70 <  integer, save :: LJ_Mixing_Policy
71 <  real(kind=DP), save :: LJ_rcut
72 <  logical, save :: havePolicy = .false.
73 <  logical, save :: haveCut = .false.
74 <  logical, save :: LJ_do_shift = .false.
75 <  
76 <  !! Logical has lj force field module been initialized?
77 <  
78 <  logical, save :: LJ_FF_initialized = .false.
79 <  
80 <  !! Public methods and data
81 <  public :: init_LJ_FF
82 <  public :: setCutoffLJ
83 <  public :: do_lj_pair
70 >  real(kind=DP), save :: defaultCutoff = 0.0_DP
71 >  logical, save :: defaultShift = .false.
72 >  logical, save :: haveDefaultCutoff = .false.
73 >
74 >  type, private :: LJtype
75 >     integer       :: atid
76 >     real(kind=dp) :: sigma
77 >     real(kind=dp) :: epsilon
78 >     logical       :: isSoftCore = .false.
79 >  end type LJtype
80 >
81 >  type, private :: LJList
82 >     integer               :: Nljtypes = 0
83 >     integer               :: currentLJtype = 0
84 >     type(LJtype), pointer :: LJtypes(:)      => null()
85 >     integer, pointer      :: atidToLJtype(:) => null()
86 >  end type LJList
87 >
88 >  type(LJList), save :: LJMap
89 >
90 >  type :: MixParameters
91 >     real(kind=DP) :: sigma
92 >     real(kind=DP) :: epsilon
93 >     real(kind=dp) :: sigmai
94 >     real(kind=dp) :: rCut
95 >     logical       :: rCutWasSet = .false.
96 >     logical       :: shiftedPot
97 >     logical       :: isSoftCore = .false.
98 >  end type MixParameters
99 >
100 >  type(MixParameters), dimension(:,:), allocatable :: MixingMap
101 >
102    public :: newLJtype
103 <  
104 <  !! structure for lj type parameters
105 <  type, private :: ljType
106 <    integer :: lj_ident
107 <    real(kind=dp) :: lj_sigma
108 <    real(kind=dp) :: lj_epsilon
46 <  end type ljType
47 <  
48 <  !! List of lj type parameters
49 <  type, private :: ljTypeList
50 <    integer  :: n_lj_types = 0
51 <    integer  :: currentAddition = 0
52 <    type(ljType), pointer :: ljParams(:) => null()
53 <  end type ljTypeList
54 <  
55 <  !! The list of lj Parameters
56 <  type (ljTypeList), save :: ljParameterList
57 <  
58 <  
59 <  type :: lj_mixed_params
60 <     !! Lennard-Jones epsilon
61 <     real ( kind = dp )  :: epsilon = 0.0_dp
62 <     !! Lennard-Jones Sigma
63 <     real ( kind = dp )  :: sigma = 0.0_dp
64 <     !! Lennard-Jones Sigma to sixth
65 <     real ( kind = dp )  :: sigma6 = 0.0_dp
66 <     !!
67 <     real ( kind = dp )  :: tp6
68 <     real ( kind = dp )  :: tp12
69 <     real ( kind = dp )  :: delta  = 0.0_dp
70 <  end type lj_mixed_params
71 <  
72 <  type (lj_mixed_params), dimension(:,:), pointer :: ljMixed
73 <  
74 <  
75 <  
103 >  public :: setLJDefaultCutoff
104 >  public :: getSigma
105 >  public :: getEpsilon
106 >  public :: do_lj_pair
107 >  public :: destroyLJtypes
108 >
109   contains
110  
111 <  subroutine newLJtype(ident,lj_sigma,lj_epsilon,status)
112 <    integer,intent(in) :: ident
113 <    real(kind=dp),intent(in) :: lj_sigma
114 <    real(kind=dp),intent(in) :: lj_epsilon
111 >  subroutine newLJtype(c_ident, sigma, epsilon, isSoftCore, status)
112 >    integer,intent(in) :: c_ident
113 >    real(kind=dp),intent(in) :: sigma
114 >    real(kind=dp),intent(in) :: epsilon
115 >    integer, intent(in) :: isSoftCore
116      integer,intent(out) :: status
117 <    
118 <    integer,pointer                        :: Matchlist(:) => null()
117 >    integer :: nLJTypes, ntypes, myATID
118 >    integer, pointer :: MatchList(:) => null()
119      integer :: current
120 <    integer :: nAtypes
120 >
121      status = 0
122 <    
123 <        !! Assume that atypes has already been set and get the total number of types in atypes
90 <  
91 <  
122 >    ! check to see if this is the first time into this routine...
123 >    if (.not.associated(LJMap%LJtypes)) then
124  
125 <    ! check to see if this is the first time into
126 <    if (.not.associated(ljParameterList%ljParams)) then
127 <       call getMatchingElementList(atypes, "is_lj", .true., nAtypes, MatchList)
128 <       ljParameterList%n_lj_types = nAtypes
129 <       if (nAtypes == 0) then
130 <         status = -1
131 <         return
132 <       end if
133 <       allocate(ljParameterList%ljParams(nAtypes))
125 >       call getMatchingElementList(atypes, "is_LennardJones", .true., &
126 >            nLJTypes, MatchList)
127 >      
128 >       LJMap%nLJtypes =  nLJTypes
129 >
130 >       allocate(LJMap%LJtypes(nLJTypes))
131 >
132 >       ntypes = getSize(atypes)
133 >
134 >       allocate(LJMap%atidToLJtype(ntypes))
135      end if
136  
137 <    ljParameterList%currentAddition = ljParameterList%currentAddition + 1
138 <    current = ljParameterList%currentAddition
139 <    
140 <    ! set the values for ljParameterList
141 <    ljParameterList%ljParams(current)%lj_ident = ident
142 <    ljParameterList%ljParams(current)%lj_epsilon = lj_epsilon
143 <    ljParameterList%ljParams(current)%lj_sigma = lj_sigma
144 <    
145 <  end subroutine newLJtype
146 <  
114 <  subroutine init_LJ_FF(mix_Policy, status)
115 <    integer, intent(in) :: mix_Policy
116 <    integer, intent(out) :: status
117 <    integer :: myStatus
118 <    
119 <    if (mix_Policy == LB_MIXING_RULE) then
120 <       LJ_Mixing_Policy = LB_MIXING_RULE
137 >    LJMap%currentLJtype = LJMap%currentLJtype + 1
138 >    current = LJMap%currentLJtype
139 >
140 >    myATID = getFirstMatchingElement(atypes, "c_ident", c_ident)
141 >    LJMap%atidToLJtype(myATID)        = current
142 >    LJMap%LJtypes(current)%atid       = myATID
143 >    LJMap%LJtypes(current)%sigma      = sigma
144 >    LJMap%LJtypes(current)%epsilon    = epsilon
145 >    if (isSoftCore .eq. 1) then
146 >       LJMap%LJtypes(current)%isSoftCore = .true.
147      else
148 <       if (mix_Policy == EXPLICIT_MIXING_RULE) then
123 <          LJ_Mixing_Policy = EXPLICIT_MIXING_RULE
124 <       else
125 <          write(*,*) 'Unknown Mixing Policy!'
126 <          status = -1
127 <          return
128 <       endif
148 >       LJMap%LJtypes(current)%isSoftCore = .false.
149      endif
150 +  end subroutine newLJtype
151  
152 <    havePolicy = .true.
152 >  subroutine setLJDefaultCutoff(thisRcut, shiftedPot)
153 >    real(kind=dp), intent(in) :: thisRcut
154 >    logical, intent(in) :: shiftedPot
155 >    defaultCutoff = thisRcut
156 >    defaultShift = shiftedPot
157 >    haveDefaultCutoff = .true.
158 >    !we only want to build LJ Mixing map if LJ is being used.
159 >    if(LJMap%nLJTypes /= 0) then
160 >       call createMixingMap()
161 >    end if
162  
163 <    if (haveCut) then
164 <       status = 0
165 <       call createMixingList(myStatus)
166 <       if (myStatus /= 0) then
167 <          status = -1
168 <          return
169 <       end if
170 <      
171 <       LJ_FF_initialized = .true.
163 >  end subroutine setLJDefaultCutoff
164 >
165 >  function getSigma(atid) result (s)
166 >    integer, intent(in) :: atid
167 >    integer :: ljt1
168 >    real(kind=dp) :: s
169 >
170 >    if (LJMap%currentLJtype == 0) then
171 >       call handleError("LJ", "No members in LJMap")
172 >       return
173      end if
143  
144  end subroutine init_LJ_FF
145  
146  subroutine setCutoffLJ(rcut, do_shift, status)
147    logical, intent(in):: do_shift
148    integer :: status, myStatus
149    real(kind=dp) :: rcut
174  
175 < #define __FORTRAN90
176 < #include "UseTheForce/fSwitchingFunction.h"
175 >    ljt1 = LJMap%atidToLJtype(atid)
176 >    s = LJMap%LJtypes(ljt1)%sigma
177  
178 <    status = 0
178 >  end function getSigma
179  
180 <    LJ_rcut = rcut
181 <    LJ_do_shift = do_shift
182 <    call set_switch(LJ_SWITCH, rcut, rcut)
183 <    haveCut = .true.
180 >  function getEpsilon(atid) result (e)
181 >    integer, intent(in) :: atid
182 >    integer :: ljt1
183 >    real(kind=dp) :: e
184  
185 <    if (havePolicy) then
186 <       status = 0
163 <       call createMixingList(myStatus)
164 <       if (myStatus /= 0) then
165 <          status = -1
166 <          return
167 <       end if
168 <      
169 <       LJ_FF_initialized = .true.
170 <    end if    
171 <    
172 <    return
173 <  end subroutine setCutoffLJ
174 <  
175 <  subroutine createMixingList(status)
176 <    integer :: nAtypes
177 <    integer :: status
178 <    integer :: i
179 <    integer :: j
180 <    real ( kind = dp ) :: mySigma_i,mySigma_j
181 <    real ( kind = dp ) :: myEpsilon_i,myEpsilon_j
182 <    real ( kind = dp ) :: rcut6
183 <    logical :: I_isLJ, J_isLJ
184 <    status = 0
185 <    
186 <    ! we only allocate this array to the number of lj_atypes
187 <    nAtypes = size(ljParameterList%ljParams)
188 <    if (nAtypes == 0) then
189 <       status = -1
185 >    if (LJMap%currentLJtype == 0) then
186 >       call handleError("LJ", "No members in LJMap")
187         return
188      end if
192        
193    if (.not. associated(ljMixed)) then
194       allocate(ljMixed(nAtypes, nAtypes))
195    endif
189  
190 <    rcut6 = LJ_rcut**6
190 >    ljt1 = LJMap%atidToLJtype(atid)
191 >    e = LJMap%LJtypes(ljt1)%epsilon
192  
193 < ! This loops through all atypes, even those that don't support LJ forces.
200 <    do i = 1, nAtypes
193 >  end function getEpsilon
194  
195 <          myEpsilon_i = ljParameterList%ljParams(i)%lj_epsilon
196 <          mySigma_i = ljParameterList%ljParams(i)%lj_sigma
197 <          
198 <          ! do self mixing rule
199 <          ljMixed(i,i)%sigma   = mySigma_i
200 <          
201 <          ljMixed(i,i)%sigma6  = (ljMixed(i,i)%sigma) ** 6
195 >  subroutine createMixingMap()
196 >    integer :: nLJtypes, i, j
197 >    real ( kind = dp ) :: s1, s2, e1, e2
198 >    real ( kind = dp ) :: rcut6, tp6, tp12
199 >    logical :: isSoftCore1, isSoftCore2, doShift
200 >
201 >    if (LJMap%currentLJtype == 0) then
202 >       call handleError("LJ", "No members in LJMap")
203 >       return
204 >    end if
205 >
206 >    nLJtypes = LJMap%nLJtypes
207 >
208 >    if (.not. allocated(MixingMap)) then
209 >       allocate(MixingMap(nLJtypes, nLJtypes))
210 >    endif
211 >
212 >    useGeometricDistanceMixing = usesGeometricDistanceMixing()
213 >    do i = 1, nLJtypes
214 >
215 >       s1 = LJMap%LJtypes(i)%sigma
216 >       e1 = LJMap%LJtypes(i)%epsilon
217 >       isSoftCore1 = LJMap%LJtypes(i)%isSoftCore
218 >
219 >       do j = i, nLJtypes
220            
221 <          ljMixed(i,i)%tp6     = (ljMixed(i,i)%sigma6)/rcut6
221 >          s2 = LJMap%LJtypes(j)%sigma
222 >          e2 = LJMap%LJtypes(j)%epsilon
223 >          isSoftCore2 = LJMap%LJtypes(j)%isSoftCore
224            
225 <          ljMixed(i,i)%tp12    = (ljMixed(i,i)%tp6) ** 2
225 >          MixingMap(i,j)%isSoftCore = isSoftCore1 .or. isSoftCore2
226 >
227 >          ! only the distance parameter uses different mixing policies
228 >          if (useGeometricDistanceMixing) then
229 >             MixingMap(i,j)%sigma = dsqrt(s1 * s2)
230 >          else
231 >             MixingMap(i,j)%sigma = 0.5_dp * (s1 + s2)
232 >          endif
233            
234 <          
215 <          ljMixed(i,i)%epsilon = myEpsilon_i
216 <          
217 <          ljMixed(i,i)%delta = -4.0_DP * ljMixed(i,i)%epsilon * &
218 <            (ljMixed(i,i)%tp12 - ljMixed(i,i)%tp6)
219 <          
220 <          do j = i + 1, nAtypes
234 >          MixingMap(i,j)%epsilon = dsqrt(e1 * e2)
235  
236 <                myEpsilon_j = ljParameterList%ljParams(j)%lj_epsilon
223 <                mySigma_j = ljParameterList%ljParams(j)%lj_sigma
236 >          MixingMap(i,j)%sigmai = 1.0_DP  / (MixingMap(i,j)%sigma)
237  
238 <                          
239 <                ljMixed(i,j)%sigma  =  &
240 <                     calcLJMix("sigma",mySigma_i, &
241 <                     mySigma_j)
242 <                
243 <                ljMixed(i,j)%sigma6 = &
244 <                     (ljMixed(i,j)%sigma)**6
245 <                
246 <                
247 <                ljMixed(i,j)%tp6     = ljMixed(i,j)%sigma6/rcut6
248 <                
249 <                ljMixed(i,j)%tp12    = (ljMixed(i,j)%tp6) ** 2
250 <                
251 <                
252 <                ljMixed(i,j)%epsilon = &
253 <                     calcLJMix("epsilon",myEpsilon_i, &
254 <                     myEpsilon_j)
255 <                
243 <                ljMixed(i,j)%delta = -4.0_DP * ljMixed(i,j)%epsilon * &
244 <                     (ljMixed(i,j)%tp12 - ljMixed(i,j)%tp6)
245 <                
246 <                
247 <                ljMixed(j,i)%sigma   = ljMixed(i,j)%sigma
248 <                ljMixed(j,i)%sigma6  = ljMixed(i,j)%sigma6
249 <                ljMixed(j,i)%tp6     = ljMixed(i,j)%tp6
250 <                ljMixed(j,i)%tp12    = ljMixed(i,j)%tp12
251 <                ljMixed(j,i)%epsilon = ljMixed(i,j)%epsilon
252 <                ljMixed(j,i)%delta   = ljMixed(i,j)%delta
253 <          
254 <          end do
255 <    end do
238 >          if (haveDefaultCutoff) then
239 >             MixingMap(i,j)%shiftedPot = defaultShift
240 >          else
241 >             MixingMap(i,j)%shiftedPot = defaultShift
242 >          endif          
243 >
244 >          if (i.ne.j) then
245 >             MixingMap(j,i)%sigma      = MixingMap(i,j)%sigma
246 >             MixingMap(j,i)%epsilon    = MixingMap(i,j)%epsilon
247 >             MixingMap(j,i)%sigmai     = MixingMap(i,j)%sigmai
248 >             MixingMap(j,i)%rCut       = MixingMap(i,j)%rCut
249 >             MixingMap(j,i)%rCutWasSet = MixingMap(i,j)%rCutWasSet
250 >             MixingMap(j,i)%shiftedPot = MixingMap(i,j)%shiftedPot
251 >             MixingMap(j,i)%isSoftCore = MixingMap(i,j)%isSoftCore
252 >          endif
253 >
254 >       enddo
255 >    enddo
256      
257 <  end subroutine createMixingList
258 <  
259 <  subroutine do_lj_pair(atom1, atom2, d, rij, r2, sw, vpair, fpair, &
257 >    haveMixingMap = .true.
258 >    
259 >  end subroutine createMixingMap
260 >          
261 >  subroutine do_lj_pair(atom1, atom2, d, rij, r2, rcut, sw, vpair, fpair, &
262         pot, f, do_pot)
263 <
263 >    
264      integer, intent(in) ::  atom1, atom2
265 <    real( kind = dp ), intent(in) :: rij, r2
265 >    integer :: atid1, atid2, ljt1, ljt2
266 >    real( kind = dp ), intent(in) :: rij, r2, rcut
267      real( kind = dp ) :: pot, sw, vpair
268      real( kind = dp ), dimension(3,nLocal) :: f    
269      real( kind = dp ), intent(in), dimension(3) :: d
# Line 270 | Line 273 | contains
273      ! local Variables
274      real( kind = dp ) :: drdx, drdy, drdz
275      real( kind = dp ) :: fx, fy, fz
276 +    real( kind = dp ) :: myPot, myPotC, myDeriv, myDerivC, ros, rcos
277      real( kind = dp ) :: pot_temp, dudr
278 <    real( kind = dp ) :: sigma6
278 >    real( kind = dp ) :: sigmai
279      real( kind = dp ) :: epsilon
280 <    real( kind = dp ) :: r6
281 <    real( kind = dp ) :: t6
278 <    real( kind = dp ) :: t12
279 <    real( kind = dp ) :: delta
280 <    integer :: id1, id2
280 >    logical :: isSoftCore, shiftedPot
281 >    integer :: id1, id2, localError
282  
283 +    if (.not.haveMixingMap) then
284 +       call createMixingMap()
285 +    endif
286 +
287      ! Look up the correct parameters in the mixing matrix
288   #ifdef IS_MPI
289 <    sigma6   = ljMixed(atid_Row(atom1),atid_Col(atom2))%sigma6
290 <    epsilon  = ljMixed(atid_Row(atom1),atid_Col(atom2))%epsilon
286 <    delta    = ljMixed(atid_Row(atom1),atid_Col(atom2))%delta
289 >    atid1 = atid_Row(atom1)
290 >    atid2 = atid_Col(atom2)
291   #else
292 <    sigma6   = ljMixed(atid(atom1),atid(atom2))%sigma6
293 <    epsilon  = ljMixed(atid(atom1),atid(atom2))%epsilon
290 <    delta    = ljMixed(atid(atom1),atid(atom2))%delta
292 >    atid1 = atid(atom1)
293 >    atid2 = atid(atom2)
294   #endif
295  
296 <    r6 = r2 * r2 * r2
297 <    
298 <    t6  = sigma6/ r6
299 <    t12 = t6 * t6    
300 <  
301 <    pot_temp = 4.0E0_DP * epsilon * (t12 - t6)
302 <    if (LJ_do_shift) then
303 <       pot_temp = pot_temp + delta
296 >    ljt1 = LJMap%atidToLJtype(atid1)
297 >    ljt2 = LJMap%atidToLJtype(atid2)
298 >
299 >    sigmai     = MixingMap(ljt1,ljt2)%sigmai
300 >    epsilon    = MixingMap(ljt1,ljt2)%epsilon
301 >    isSoftCore = MixingMap(ljt1,ljt2)%isSoftCore
302 >    shiftedPot = MixingMap(ljt1,ljt2)%shiftedPot
303 >
304 >    ros = rij * sigmai
305 >    myPotC = 0.0_DP
306 >
307 >    if (isSoftCore) then
308 >
309 >       call getSoftFunc(ros, myPot, myDeriv)
310 >
311 >       if (shiftedPot) then
312 >          rcos = rcut * sigmai
313 >          call getSoftFunc(rcos, myPotC, myDerivC)
314 >       endif
315 >              
316 >    else
317 >
318 >       call getLJfunc(ros, myPot, myDeriv)
319 >
320 >       if (shiftedPot) then
321 >          rcos = rcut * sigmai
322 >          call getLJfunc(rcos, myPotC, myDerivC)
323 >       endif
324 >      
325      endif
326  
327 +    pot_temp = epsilon * (myPot - myPotC)
328      vpair = vpair + pot_temp
329 <      
330 <    dudr = sw * 24.0E0_DP * epsilon * (t6 - 2.0E0_DP*t12) / rij
306 <      
329 >    dudr = sw * epsilon * myDeriv * sigmai
330 >
331      drdx = d(1) / rij
332      drdy = d(2) / rij
333      drdz = d(3) / rij
334 <      
334 >
335      fx = dudr * drdx
336      fy = dudr * drdy
337      fz = dudr * drdz
338 <    
315 <      
338 >
339   #ifdef IS_MPI
340      if (do_pot) then
341 <       pot_Row(atom1) = pot_Row(atom1) + sw*pot_temp*0.5
342 <       pot_Col(atom2) = pot_Col(atom2) + sw*pot_temp*0.5
341 >       pot_Row(VDW_POT,atom1) = pot_Row(VDW_POT,atom1) + sw*pot_temp*0.5
342 >       pot_Col(VDW_POT,atom2) = pot_Col(VDW_POT,atom2) + sw*pot_temp*0.5
343      endif
344 <    
344 >
345      f_Row(1,atom1) = f_Row(1,atom1) + fx
346      f_Row(2,atom1) = f_Row(2,atom1) + fy
347      f_Row(3,atom1) = f_Row(3,atom1) + fz
348 <    
348 >
349      f_Col(1,atom2) = f_Col(1,atom2) - fx
350      f_Col(2,atom2) = f_Col(2,atom2) - fy
351      f_Col(3,atom2) = f_Col(3,atom2) - fz      
352 <    
352 >
353   #else
354      if (do_pot) pot = pot + sw*pot_temp
355  
356      f(1,atom1) = f(1,atom1) + fx
357      f(2,atom1) = f(2,atom1) + fy
358      f(3,atom1) = f(3,atom1) + fz
359 <    
359 >
360      f(1,atom2) = f(1,atom2) - fx
361      f(2,atom2) = f(2,atom2) - fy
362      f(3,atom2) = f(3,atom2) - fz
363   #endif
364 <        
364 >
365   #ifdef IS_MPI
366      id1 = AtomRowToGlobal(atom1)
367      id2 = AtomColToGlobal(atom2)
# Line 348 | Line 371 | contains
371   #endif
372  
373      if (molMembershipList(id1) .ne. molMembershipList(id2)) then
374 <      
374 >
375         fpair(1) = fpair(1) + fx
376         fpair(2) = fpair(2) + fy
377         fpair(3) = fpair(3) + fz
# Line 356 | Line 379 | contains
379      endif
380  
381      return    
382 <    
382 >
383    end subroutine do_lj_pair
361  
362  
363  !! Calculates the mixing for sigma or epslon
364  
365  function calcLJMix(thisParam,param1,param2,status) result(myMixParam)
366    character(len=*) :: thisParam
367    real(kind = dp)  :: param1
368    real(kind = dp)  :: param2
369    real(kind = dp ) :: myMixParam
384  
385 <    integer, optional :: status  
385 >  subroutine destroyLJTypes()
386  
387 <    myMixParam = 0.0_dp
387 >    LJMap%nLJtypes = 0
388 >    LJMap%currentLJtype = 0
389      
390 <    if (present(status)) status = 0
391 <    select case (LJ_Mixing_Policy)
392 <    case (1)
393 <       select case (thisParam)
394 <       case ("sigma")
395 <          myMixParam = 0.5_dp * (param1 + param2)
396 <       case ("epsilon")
397 <          myMixParam = sqrt(param1 * param2)
398 <       case default
399 <          status = -1
400 <       end select
386 <    case default
387 <       status = -1
388 <    end select
389 <  end function calcLJMix
390 <  
391 < end module lj
390 >    if (associated(LJMap%LJtypes)) then
391 >       deallocate(LJMap%LJtypes)
392 >       LJMap%LJtypes => null()
393 >    end if
394 >    
395 >    if (associated(LJMap%atidToLJtype)) then
396 >       deallocate(LJMap%atidToLJtype)
397 >       LJMap%atidToLJtype => null()
398 >    end if
399 >    
400 >    haveMixingMap = .false.
401  
402 < subroutine newLJtype(ident,lj_sigma,lj_epsilon,status)
394 <    use lj, ONLY : module_newLJtype => newLJtype
395 <    integer, parameter :: DP = selected_real_kind(15)
396 <    integer,intent(inout) :: ident
397 <    real(kind=dp),intent(inout) :: lj_sigma
398 <    real(kind=dp),intent(inout) :: lj_epsilon
399 <    integer,intent(inout) :: status
402 >  end subroutine destroyLJTypes
403  
404 <    call module_newLJtype(ident,lj_sigma,lj_epsilon,status)
404 >  subroutine getLJfunc(r, myPot, myDeriv)
405  
406 < end subroutine newLJtype
406 >    real(kind=dp), intent(in) :: r
407 >    real(kind=dp), intent(inout) :: myPot, myDeriv
408 >    real(kind=dp) :: ri, ri2, ri6, ri7, ri12, ri13
409 >    real(kind=dp) :: a, b, c, d, dx
410 >    integer :: j
411  
412 +    ri = 1.0_DP / r
413 +    ri2 = ri*ri
414 +    ri6 = ri2*ri2*ri2
415 +    ri7 = ri6*ri
416 +    ri12 = ri6*ri6
417 +    ri13 = ri12*ri
418 +    
419 +    myPot = 4.0_DP * (ri12 - ri6)
420 +    myDeriv = 24.0_DP * (ri7 - 2.0_DP * ri13)
421 +    
422 +    return
423 +  end subroutine getLJfunc
424 +
425 +  subroutine getSoftFunc(r, myPot, myDeriv)
426 +    
427 +    real(kind=dp), intent(in) :: r
428 +    real(kind=dp), intent(inout) :: myPot, myDeriv
429 +    real(kind=dp) :: ri, ri2, ri6, ri7
430 +    real(kind=dp) :: a, b, c, d, dx
431 +    integer :: j
432 +    
433 +    ri = 1.0_DP / r    
434 +    ri2 = ri*ri
435 +    ri6 = ri2*ri2*ri2
436 +    ri7 = ri6*ri
437 +    myPot = 4.0_DP * (ri6)
438 +    myDeriv = - 24.0_DP * ri7
439 +    
440 +    return
441 +  end subroutine getSoftFunc
442 +
443 + end module lj

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines