ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/calc_LJ_FF.F90
(Generate patch)

Comparing trunk/OOPSE_old/src/mdtools/libmdCode/calc_LJ_FF.F90 (file contents):
Revision 320 by chuckv, Wed Mar 12 14:55:29 2003 UTC vs.
Revision 358 by gezelter, Mon Mar 17 21:07:50 2003 UTC

# Line 2 | Line 2
2   !! Corresponds to the force field defined in lj_FF.cpp
3   !! @author Charles F. Vardeman II
4   !! @author Matthew Meineke
5 < !! @version $Id: calc_LJ_FF.F90,v 1.5 2003-03-12 14:55:29 chuckv Exp $, $Date: 2003-03-12 14:55:29 $, $Name: not supported by cvs2svn $, $Revision: 1.5 $
5 > !! @version $Id: calc_LJ_FF.F90,v 1.11 2003-03-17 21:07:50 gezelter Exp $, $Date: 2003-03-17 21:07:50 $, $Name: not supported by cvs2svn $, $Revision: 1.11 $
6  
7
8
7   module lj
8    use simulation
9    use definitions
10 <  use forceGlobals
13 <  use atype_typedefs
10 >  use atype_module
11    use vector_class
12   #ifdef IS_MPI
13    use mpiSimulation
14   #endif
15    implicit none
16    PRIVATE
17 +
18 + #define __FORTRAN90
19 + #include "fForceField.h"
20 +
21 +  integer, save :: LJ_Mixing_Policy
22    
23    !! Logical has lj force field module been initialized?
22  logical, save :: isljFFinit = .false.
24    
25 +  logical, save :: LJ_FF_initialized = .false.
26    
27    !! Public methods and data
28 <  public :: init_ljFF
28 >  public :: init_LJ_FF
29    public :: do_lj_pair
30    
31    type :: lj_mixed_params
# Line 45 | Line 47 | contains
47    
48   contains
49  
50 <  subroutine init_ljFF(status)
50 >  subroutine init_LJ_FF(mix_Policy, status)
51 >    integer, intent(in) :: mix_Policy
52      integer, intent(out) :: status
53      integer :: myStatus
54      
55 +    if (mix_Policy == LB_MIXING_RULE) then
56 +       LJ_Mixing_Policy = LB_MIXING_RULE
57 +    else
58 +       if (mix_Policy == EXPLICIT_MIXING_RULE) then
59 +          LJ_Mixing_Policy = EXPLICIT_MIXING_RULE
60 +       else
61 +          write(*,*) 'Unknown Mixing Policy!'
62 +          status = -1
63 +          return
64 +       endif
65 +    endif
66 +    
67      status = 0
68      call createMixingList(myStatus)
69      if (myStatus /= 0) then
# Line 56 | Line 71 | contains
71         return
72      end if
73      
74 <  end subroutine init_ljFF
74 >    LJ_FF_initialized = .true.
75 >    
76 >  end subroutine init_LJ_FF
77    
78    subroutine createMixingList(status)
79      integer :: nAtypes
# Line 68 | Line 85 | contains
85      real ( kind = dp ) :: rcut, rcut6
86      status = 0
87      
88 <    nAtypes = getSize(atype)
89 <    if (listSize == 0) then
88 >    nAtypes = getSize(atypes)
89 >    if (nAtypes == 0) then
90         status = -1
91         return
92      end if
93 <    
77 <    
93 >        
94      if (.not. associated(ljMixed)) then
95 <       allocate(ljMixed(listSize,listSize))
95 >       allocate(ljMixed(nAtypes, nAtypes))
96      else
97         status = -1
98         return
99      end if
100 <    call getRcut(rcut, rcut6=rcut6)
100 >    call getRcut(rcut, rc6=rcut6)
101      do i = 1, nAtypes
102  
103         call getElementProperty(atypes,i,"lj_epsilon",myEpsilon_i)
# Line 133 | Line 149 | contains
149            
150         end do
151      end do
136
152      
153    end subroutine createMixingList
154    
155  
156 <  subroutine do_lj_pair(atom1, atom2, d, rij, pot, f)
156 >  subroutine do_lj_pair(atom1, atom2, d, rij, r2, pot, f, do_pot, do_stress)
157  
158      integer, intent(in) ::  atom1, atom2
159 <    real( kind = dp ), intent(in) :: rij
159 >    real( kind = dp ), intent(in) :: rij, r2
160      real( kind = dp ) :: pot
161      real( kind = dp ), dimension(3, getNlocal()) :: f    
162      real( kind = dp ), intent(in), dimension(3) :: d
163 +    logical, intent(in) :: do_pot, do_stress
164  
165      ! local Variables
166      real( kind = dp ) :: drdx, drdy, drdz
167      real( kind = dp ) :: fx, fy, fz
168      real( kind = dp ) :: pot_temp, dudr
153    real( kind = dp ) :: sigma
154    real( kind = dp ) :: sigma2
169      real( kind = dp ) :: sigma6
170      real( kind = dp ) :: epsilon
157
171      real( kind = dp ) :: rcut
159    real( kind = dp ) :: rcut2
160    real( kind = dp ) :: rcut6
161    real( kind = dp ) :: r2
172      real( kind = dp ) :: r6
163
173      real( kind = dp ) :: t6
174      real( kind = dp ) :: t12
166    real( kind = dp ) :: tp6
167    real( kind = dp ) :: tp12
175      real( kind = dp ) :: delta
176  
177      ! Look up the correct parameters in the mixing matrix
178   #ifdef IS_MPI
172    sigma    = ljMixed(atid_Row(atom1),atid_Col(atom2))%sigma
179      sigma6   = ljMixed(atid_Row(atom1),atid_Col(atom2))%sigma6
174    tp6      = ljMixed(atid_Row(atom1),atid_col(atom2))%tp6
175    tp12     = ljMixed(atid_Row(atom1),atid_Col(atom2))%tp12
180      epsilon  = ljMixed(atid_Row(atom1),atid_Col(atom2))%epsilon
181      delta    = ljMixed(atid_Row(atom1),atid_Col(atom2))%delta
182   #else
179    sigma    = ljMixed(atid(atom1),atid(atom2))%sigma
183      sigma6   = ljMixed(atid(atom1),atid(atom2))%sigma6
181    tp6      = ljMixed(atid(atom1),atid(atom2))%tp6
182    tp12     = ljMixed(atid(atom1),atid(atom2))%tp12
184      epsilon  = ljMixed(atid(atom1),atid(atom2))%epsilon
185      delta    = ljMixed(atid(atom1),atid(atom2))%delta
186   #endif
186
187    
188      call getRcut(rcut)
189      
190    r2 = rij * rij
190      r6 = r2 * r2 * r2
191  
192      t6  = sigma6/ r6
# Line 208 | Line 207 | contains
207         fz = dudr * drdz
208      
209   #ifdef IS_MPI
210 <       pot_Row(atom1) = pot_Row(atom1) + pot_temp*0.5
211 <       pot_Col(atom2) = pot_Col(atom2) + pot_temp*0.5
210 >       if (do_pot) then
211 >          pot_Row(atom1) = pot_Row(atom1) + pot_temp*0.5
212 >          pot_Col(atom2) = pot_Col(atom2) + pot_temp*0.5
213 >       endif
214  
215         f_Row(1,atom1) = f_Row(1,atom1) + fx
216         f_Row(2,atom1) = f_Row(2,atom1) + fy
# Line 220 | Line 221 | contains
221         f_Col(3,atom2) = f_Col(3,atom2) - fz      
222  
223   #else
224 <       pot = pot + pot_temp
224 >       if (do_pot) pot = pot + pot_temp
225  
226         f(1,atom1) = f(1,atom1) + fx
227         f(2,atom1) = f(2,atom1) + fy
# Line 231 | Line 232 | contains
232         f(3,atom2) = f(3,atom2) - fz
233   #endif
234        
235 <       if (doStress()) then
235 >       if (do_stress) then
236            tau_Temp(1) = tau_Temp(1) + fx * d(1)
237            tau_Temp(2) = tau_Temp(2) + fx * d(2)
238            tau_Temp(3) = tau_Temp(3) + fx * d(3)
# Line 243 | Line 244 | contains
244            tau_Temp(9) = tau_Temp(9) + fz * d(3)
245            virial_Temp = virial_Temp + (tau_Temp(1) + tau_Temp(5) + tau_Temp(9))
246         endif
247 <
247 >      
248      endif
249      return          
250    end subroutine do_lj_pair
251  
252  
253 <  !! Calculates the mixing for sigma or epslon based on character
254 <  !! string for initialzition of mixing array.
253 >  !! Calculates the mixing for sigma or epslon
254 >
255    function calcLJMix(thisParam,param1,param2,status) result(myMixParam)
256      character(len=*) :: thisParam
257      real(kind = dp)  :: param1
258      real(kind = dp)  :: param2
259      real(kind = dp ) :: myMixParam
260 <    character(len = getStringLen()) :: thisMixingRule
261 <    integer, optional :: status
262 <    
262 <    !! get the mixing rules from the simulation
263 <    thisMixingRule = returnMixingRules()
260 >
261 >    integer, optional :: status  
262 >
263      myMixParam = 0.0_dp
264      
265      if (present(status)) status = 0
266 <    select case (thisMixingRule)
267 <    case ("standard")
266 >    select case (LJ_Mixing_Policy)
267 >    case (LB_MIXING_RULE)
268         select case (thisParam)
269         case ("sigma")
270            myMixParam = 0.5_dp * (param1 + param2)
# Line 274 | Line 273 | contains
273         case default
274            status = -1
275         end select
277    case("LJglass")
276      case default
277         status = -1
278      end select

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines