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

Comparing trunk/OOPSE-4/src/UseTheForce/doForces.F90 (file contents):
Revision 2717 by gezelter, Mon Apr 17 21:49:12 2006 UTC vs.
Revision 2722 by gezelter, Thu Apr 20 18:24:24 2006 UTC

# Line 45 | Line 45
45  
46   !! @author Charles F. Vardeman II
47   !! @author Matthew Meineke
48 < !! @version $Id: doForces.F90,v 1.78 2006-04-17 21:49:12 gezelter Exp $, $Date: 2006-04-17 21:49:12 $, $Name: not supported by cvs2svn $, $Revision: 1.78 $
48 > !! @version $Id: doForces.F90,v 1.79 2006-04-20 18:24:24 gezelter Exp $, $Date: 2006-04-20 18:24:24 $, $Name: not supported by cvs2svn $, $Revision: 1.79 $
49  
50  
51   module doForces
# Line 73 | Line 73 | module doForces
73    PRIVATE
74  
75   #define __FORTRAN90
76 #include "UseTheForce/fSwitchingFunction.h"
76   #include "UseTheForce/fCutoffPolicy.h"
77   #include "UseTheForce/DarkSide/fInteractionMap.h"
78   #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h"
79  
81
80    INTEGER, PARAMETER:: PREPAIR_LOOP = 1
81    INTEGER, PARAMETER:: PAIR_LOOP    = 2
82 +  INTEGER, PARAMETER:: np = 500
83  
84    logical, save :: haveNeighborList = .false.
85    logical, save :: haveSIMvariables = .false.
# Line 92 | Line 91 | module doForces
91    logical, save :: haveElectrostaticSummationMethod = .false.
92    logical, save :: haveCutoffPolicy = .false.
93    logical, save :: VisitCutoffsAfterComputing = .false.
94 +  logical, save :: haveSplineSqrt = .false.
95  
96    logical, save :: FF_uses_DirectionalAtoms
97    logical, save :: FF_uses_Dipoles
# Line 150 | Line 150 | contains
150    end type gtypeCutoffs
151    type(gtypeCutoffs), dimension(:,:), allocatable :: gtypeCutoffMap
152  
153 +  ! variables for the spline of the sqrt
154 +  type(cubicSpline), save :: splineSqrt
155 +  logical, save :: useSpline = .true.
156 +  
157 +
158   contains
159  
160    subroutine createInteractionHash()
# Line 581 | Line 586 | contains
586          defaultDoShift = .true.
587          
588       endif
589 <
589 >    
590       localError = 0
591       call setLJDefaultCutoff( defaultRcut, defaultDoShift )
592       call setElectrostaticCutoffRadius( defaultRcut, defaultRsw )
593       call setCutoffEAM( defaultRcut )
594       call setCutoffSC( defaultRcut )
595 <     call set_switch(GROUP_SWITCH, defaultRsw, defaultRcut)
595 >     call set_switch(defaultRsw, defaultRcut)
596       call setHmatDangerousRcutValue(defaultRcut)
597 <
597 >     call setupSplineSqrt(defaultRcut)
598 >        
599       haveDefaultCutoffs = .true.
600       haveGtypeCutoffMap = .false.
601 +
602     end subroutine setCutoffs
603  
604     subroutine cWasLame()
# Line 645 | Line 652 | contains
652  
653    subroutine doReadyCheck(error)
654      integer, intent(out) :: error
648
655      integer :: myStatus
656  
657      error = 0
# Line 658 | Line 664 | contains
664         call createGtypeCutoffMap()      
665      endif
666  
661
667      if (VisitCutoffsAfterComputing) then
668 <       call set_switch(GROUP_SWITCH, largestRcut, largestRcut)      
668 >       call set_switch(largestRcut, largestRcut)      
669         call setHmatDangerousRcutValue(largestRcut)
670         call setLJsplineRmax(largestRcut)
671         call setCutoffEAM(largestRcut)
# Line 668 | Line 673 | contains
673         VisitCutoffsAfterComputing = .false.
674      endif
675  
676 +    if (.not. haveSplineSqrt) then
677 +       call setupSplineSqrt(largestRcut)
678 +    endif
679  
680      if (.not. haveSIMvariables) then
681         call setSimVariables()
682      endif
675
676  !  if (.not. haveRlist) then
677  !     write(default_error, *) 'rList has not been set in doForces!'
678  !     error = -1
679  !     return
680  !  endif
683  
684      if (.not. haveNeighborList) then
685         write(default_error, *) 'neighbor list has not been initialized in doForces!'
686         error = -1
687         return
688      end if
689 <
689 >    
690      if (.not. haveSaneForceField) then
691         write(default_error, *) 'Force Field is not sane in doForces!'
692         error = -1
693         return
694      end if
695 <
695 >    
696   #ifdef IS_MPI
697      if (.not. isMPISimSet()) then
698         write(default_error,*) "ERROR: mpiSimulation has not been initialized!"
# Line 968 | Line 970 | contains
970  
971                     list(nlist) = j
972                  endif
973 <
972 <
973 <                
973 >                
974                  if (rgrpsq < gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCutsq) then
975  
976                     rCut = gtypeCutoffMap(groupToGtypeRow(i),groupToGtypeCol(j))%rCut
# Line 981 | Line 981 | contains
981                        fij(3) = 0.0_dp
982                     endif
983                    
984 <                   call get_switch(rgrpsq, sw, dswdr, rgrp, &
985 <                        group_switch, in_switching_region)
984 >                   call get_switch(rgrpsq, sw, dswdr,rgrp, in_switching_region)
985                    
986                     n_in_j = groupStartCol(j+1) - groupStartCol(j)
987                    
# Line 1195 | Line 1194 | contains
1194                  
1195                  ! prevent overcounting of the skips
1196                  if (i.lt.j) then
1197 <                   call get_interatomic_vector(q(:,i), &
1199 <                        q(:,j), d_atm, ratmsq)
1197 >                   call get_interatomic_vector(q(:,i), q(:,j), d_atm, ratmsq)
1198                     rVal = dsqrt(ratmsq)
1199 <                   call get_switch(ratmsq, sw, dswdr, rVal, group_switch, &
1202 <                        in_switching_region)
1199 >                   call get_switch(ratmsq, sw, dswdr, rVal,in_switching_region)
1200   #ifdef IS_MPI
1201                     call rf_self_excludes(i, j, sw, eFrame, d_atm, rVal, &
1202                          vpair, pot_local(ELECTROSTATIC_POT), f, t, do_pot)
# Line 1258 | Line 1255 | contains
1255      real ( kind = dp ), intent(inout) :: d_grp(3)
1256      real ( kind = dp ), intent(inout) :: rCut
1257      real ( kind = dp ) :: r
1258 +    real ( kind = dp ) :: a_k, b_k, c_k, d_k, dx
1259      integer :: me_i, me_j
1260 +    integer :: k
1261  
1262      integer :: iHash
1263  
1264 <    r = sqrt(rijsq)
1264 >    if (useSpline) then
1265 >       call lookupUniformSpline(splineSqrt, rijsq, r)
1266 >    else
1267 >       r = sqrt(rijsq)
1268 >    endif
1269 >
1270      vpair = 0.0d0
1271      fpair(1:3) = 0.0d0
1272  
# Line 1325 | Line 1329 | contains
1329         call do_SC_pair(i, j, d, r, rijsq, rcut, sw, vpair, fpair, &
1330              pot(METALLIC_POT), f, do_pot)
1331      endif
1328
1329    
1332      
1333    end subroutine do_pair
1334  
# Line 1348 | Line 1350 | contains
1350  
1351      integer :: me_i, me_j, iHash
1352  
1353 <    r = sqrt(rijsq)
1353 >    if (useSpline) then
1354 >       call lookupUniformSpline(splineSqrt, rijsq, r)
1355 >    else
1356 >       r = sqrt(rijsq)
1357 >    endif
1358  
1359   #ifdef IS_MPI  
1360      me_i = atid_row(i)
# Line 1381 | Line 1387 | contains
1387      if (FF_uses_SC .and. SIM_uses_SC) then
1388         call calc_SC_preforce_Frho(nlocal,pot(METALLIC_POT))
1389      endif
1384
1385
1390    end subroutine do_preforce
1391  
1392  
# Line 1403 | Line 1407 | contains
1407  
1408         if( .not.boxIsOrthorhombic ) then
1409            ! calc the scaled coordinates.
1410 +          ! scaled = matmul(HmatInv, d)
1411  
1412 <          scaled = matmul(HmatInv, d)
1413 <
1412 >          scaled(1) = HmatInv(1,1)*d(1) + HmatInv(1,2)*d(2) + HmatInv(1,3)*d(3)
1413 >          scaled(2) = HmatInv(2,1)*d(1) + HmatInv(2,2)*d(2) + HmatInv(2,3)*d(3)
1414 >          scaled(3) = HmatInv(3,1)*d(1) + HmatInv(3,2)*d(2) + HmatInv(3,3)*d(3)
1415 >          
1416            ! wrap the scaled coordinates
1417  
1418 <          scaled = scaled  - anint(scaled)
1418 >          scaled(1) = scaled(1) - dnint(scaled(1))
1419 >          scaled(2) = scaled(2) - dnint(scaled(2))
1420 >          scaled(3) = scaled(3) - dnint(scaled(3))
1421  
1413
1422            ! calc the wrapped real coordinates from the wrapped scaled
1423            ! coordinates
1424 +          ! d = matmul(Hmat,scaled)
1425 +          d(1)= Hmat(1,1)*scaled(1) + Hmat(1,2)*scaled(2) + Hmat(1,3)*scaled(3)
1426 +          d(2)= Hmat(2,1)*scaled(1) + Hmat(2,2)*scaled(2) + Hmat(2,3)*scaled(3)
1427 +          d(3)= Hmat(3,1)*scaled(1) + Hmat(3,2)*scaled(2) + Hmat(3,3)*scaled(3)
1428  
1417          d = matmul(Hmat,scaled)
1418
1429         else
1430            ! calc the scaled coordinates.
1421
1431  
1432            scaled(1) = d(1) * HmatInv(1,1)
1433            scaled(2) = d(2) * HmatInv(2,2)
# Line 1608 | Line 1617 | end module doForces
1617  
1618    end subroutine add_stress_tensor
1619  
1620 +  subroutine setupSplineSqrt(rmax)
1621 +    real(kind=dp), intent(in) :: rmax
1622 +    real(kind=dp), dimension(np) :: xvals, yvals
1623 +    real(kind=dp) :: r2_1, r2_n, dx, r2
1624 +    integer :: i
1625 +
1626 +    r2_1 = 0.5d0
1627 +    r2_n = rmax*rmax
1628 +
1629 +    dx = (r2_n-r2_1) / dble(np-1)
1630 +    
1631 +    do i = 1, np
1632 +       r2 = r2_1 + dble(i-1)*dx
1633 +       xvals(i) = r2
1634 +       yvals(i) = dsqrt(r2)
1635 +    enddo
1636 +
1637 +    call newSpline(splineSqrt, xvals, yvals, .true.)
1638 +    
1639 +    haveSplineSqrt = .true.
1640 +    return
1641 +  end subroutine setupSplineSqrt
1642 +
1643 +  subroutine deleteSplineSqrt()
1644 +    call deleteSpline(splineSqrt)
1645 +    haveSplineSqrt = .false.
1646 +    return
1647 +  end subroutine deleteSplineSqrt
1648 +
1649   end module doForces

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines