| 1 |
mmeineke |
10 |
|
| 2 |
|
|
subroutine force_lj ( i, j, rcutsq, rijsq, sigma, epslon, v, & |
| 3 |
|
|
fx, fy, fz, rxij, ryij, rzij, natoms ) |
| 4 |
|
|
implicit none |
| 5 |
|
|
|
| 6 |
|
|
|
| 7 |
|
|
! Passed parameters |
| 8 |
|
|
|
| 9 |
|
|
integer :: natoms ! the number of atoms |
| 10 |
|
|
integer :: i, j ! the index of the two atoms |
| 11 |
|
|
|
| 12 |
|
|
double precision rcutsq ! the square of rcut (needed for the shift potential) |
| 13 |
|
|
double precision rijsq ! the square of the distance twixt i and j |
| 14 |
|
|
double precision v ! the potential energy |
| 15 |
|
|
double precision rxij, ryij, rzij ! vector components of the distance |
| 16 |
|
|
|
| 17 |
|
|
! Passed arrays |
| 18 |
|
|
|
| 19 |
|
|
double precision, dimension(natoms) :: sigma ! the distance parameters |
| 20 |
|
|
double precision, dimension(natoms) :: epslon ! the wel depth parameters |
| 21 |
|
|
double precision, dimension(natoms) :: fx, fy, fz ! the force arrays |
| 22 |
|
|
|
| 23 |
|
|
! local variables |
| 24 |
|
|
|
| 25 |
|
|
double precision sr2, sr6, vij, vsij, fij |
| 26 |
|
|
double precision sigm, sigsq, epsl |
| 27 |
|
|
double precision fxij, fyij, fzij |
| 28 |
|
|
|
| 29 |
|
|
!******************************************************* |
| 30 |
|
|
|
| 31 |
|
|
epsl = dsqrt( epslon(i) * epslon(j) ) |
| 32 |
|
|
sigm = ( sigma(i) + sigma(j) ) / 2.0d0 |
| 33 |
|
|
sigsq = sigm * sigm |
| 34 |
|
|
|
| 35 |
|
|
sr2 = sigsq / rijsq |
| 36 |
|
|
sr6 = sr2 * sr2 * sr2 |
| 37 |
|
|
|
| 38 |
|
|
vij = epsl * sr6 * ( sr6 - 1.0d0 ) |
| 39 |
|
|
|
| 40 |
|
|
fij = epsl * sr6 * ( sr6 - 0.5d0 ) |
| 41 |
|
|
fij = fij / rijsq |
| 42 |
|
|
|
| 43 |
|
|
fxij = rxij * fij * 48.0d0 |
| 44 |
|
|
fyij = ryij * fij * 48.0d0 |
| 45 |
|
|
fzij = rzij * fij * 48.0d0 |
| 46 |
|
|
|
| 47 |
|
|
fx(i) = fx(i) - fxij |
| 48 |
|
|
fy(i) = fy(i) - fyij |
| 49 |
|
|
fz(i) = fz(i) - fzij |
| 50 |
|
|
|
| 51 |
|
|
fx(j) = fx(j) + fxij |
| 52 |
|
|
fy(j) = fy(j) + fyij |
| 53 |
|
|
fz(j) = fz(j) + fzij |
| 54 |
|
|
|
| 55 |
|
|
! calculate the shifted potential |
| 56 |
|
|
|
| 57 |
|
|
sr2 = sigsq / rcutsq |
| 58 |
|
|
sr6 = sr2 * sr2 * sr2 |
| 59 |
|
|
|
| 60 |
|
|
vsij = epsl * sr6 * ( sr6 - 1.0d0 ) |
| 61 |
|
|
|
| 62 |
|
|
! calculate the continous potential |
| 63 |
|
|
|
| 64 |
|
|
v = v + 4.0d0 * ( vij - vsij ) |
| 65 |
|
|
|
| 66 |
|
|
end subroutine force_lj |