1 |
|
!! Calculates Long Range forces. |
2 |
|
!! @author Charles F. Vardeman II |
3 |
|
!! @author Matthew Meineke |
4 |
< |
!! @version $Id: do_Forces.F90,v 1.2 2003-03-06 16:07:55 mmeineke Exp $, $Date: 2003-03-06 16:07:55 $, $Name: not supported by cvs2svn $, $Revision: 1.2 $ |
4 |
> |
!! @version $Id: do_Forces.F90,v 1.3 2003-03-06 19:57:03 chuckv Exp $, $Date: 2003-03-06 19:57:03 $, $Name: not supported by cvs2svn $, $Revision: 1.3 $ |
5 |
|
|
6 |
|
|
7 |
|
|
30 |
|
type (atype), pointer :: ListTail => null() |
31 |
|
|
32 |
|
|
33 |
– |
!! LJ mixing array |
34 |
– |
! type (lj_atype), dimension(:,:), pointer :: ljMixed => null() |
33 |
|
|
34 |
|
|
35 |
|
logical, save :: firstTime = .True. |
48 |
|
!! Logical has lj force field module been initialized? |
49 |
|
logical, save :: isFFinit = .false. |
50 |
|
|
51 |
+ |
!! Use periodic boundry conditions |
52 |
+ |
logical :: wrap = .false. |
53 |
|
|
54 |
+ |
!! Potential energy global module variables |
55 |
+ |
#ifdef IS_MPI |
56 |
+ |
real(kind = dp), dimension(3,getNrow(plan_row)) :: qRow = 0.0_dp |
57 |
+ |
real(kind = dp), dimension(3,getNcol(plan_col)) :: qCol = 0.0_dp |
58 |
+ |
|
59 |
+ |
real(kind = dp), dimension(3,getNrow(plan_row)) :: muRow = 0.0_dp |
60 |
+ |
real(kind = dp), dimension(3,getNcol(plan_col)) :: muCol = 0.0_dp |
61 |
+ |
|
62 |
+ |
real(kind = dp), dimension(3,getNrow(plan_row)) :: u_lRow = 0.0_dp |
63 |
+ |
real(kind = dp), dimension(3,getNcol(plan_col)) :: u_lCol = 0.0_dp |
64 |
+ |
|
65 |
+ |
real(kind = dp), dimension(3,getNrow(plan_row)) :: ARow = 0.0_dp |
66 |
+ |
real(kind = dp), dimension(3,getNcol(plan_col)) :: ACol = 0.0_dp |
67 |
+ |
|
68 |
+ |
|
69 |
+ |
|
70 |
+ |
real(kind = dp), dimension(3,getNrow(plan_row)) :: fRow = 0.0_dp |
71 |
+ |
real(kind = dp), dimension(3,getNcol(plan_col)) :: fCol = 0.0_dp |
72 |
+ |
|
73 |
+ |
|
74 |
+ |
real(kind = dp), dimension(3,getNrow(plan_row)) :: tRow = 0.0_dp |
75 |
+ |
real(kind = dp), dimension(3,getNcol(plan_col)) :: tCol = 0.0_dp |
76 |
+ |
|
77 |
+ |
|
78 |
+ |
|
79 |
+ |
real(kind = dp), dimension(getNrow(plan_row)) :: eRow = 0.0_dp |
80 |
+ |
real(kind = dp), dimension(getNcol(plan_col)) :: eCol = 0.0_dp |
81 |
+ |
|
82 |
+ |
real(kind = dp), dimension(getNlocal()) :: eTemp = 0.0_dp |
83 |
+ |
#endif |
84 |
+ |
real(kind = dp) :: pe = 0.0_dp |
85 |
+ |
real(kind = dp), dimension(3,getNlocal()) :: fTemp = 0.0_dp |
86 |
+ |
real(kind = dp), dimension(3,getNlocal()) :: tTemp = 0.0_dp |
87 |
+ |
real(kind = dp), dimension(9) :: tauTemp = 0.0_dp |
88 |
+ |
|
89 |
+ |
logical :: do_preForce = .false. |
90 |
+ |
logical :: do_postForce = .false. |
91 |
+ |
|
92 |
+ |
|
93 |
+ |
|
94 |
|
!! Public methods and data |
95 |
|
public :: new_atype |
96 |
|
public :: do_forceLoop |
57 |
– |
public :: getLjPot |
97 |
|
public :: init_FF |
98 |
|
|
99 |
|
|
314 |
|
|
315 |
|
!! Stress Tensor |
316 |
|
real( kind = dp), dimension(9) :: tau |
317 |
< |
real( kind = dp), dimension(9) :: tauTemp |
317 |
> |
|
318 |
|
real ( kind = dp ) :: potE |
319 |
|
logical ( kind = 2) :: do_pot |
320 |
|
integer :: FFerror |
332 |
|
real( kind = DP ) :: pot_local |
333 |
|
|
334 |
|
!! Local arrays needed for MPI |
296 |
– |
real(kind = dp), dimension(3,getNrow(plan_row)) :: qRow = 0.0_dp |
297 |
– |
real(kind = dp), dimension(3,getNcol(plan_col)) :: qCol = 0.0_dp |
335 |
|
|
299 |
– |
real(kind = dp), dimension(3,getNrow(plan_row)) :: muRow = 0.0_dp |
300 |
– |
real(kind = dp), dimension(3,getNcol(plan_col)) :: muCol = 0.0_dp |
301 |
– |
|
302 |
– |
real(kind = dp), dimension(3,getNrow(plan_row)) :: u_lRow = 0.0_dp |
303 |
– |
real(kind = dp), dimension(3,getNcol(plan_col)) :: u_lCol = 0.0_dp |
304 |
– |
|
305 |
– |
real(kind = dp), dimension(3,getNrow(plan_row)) :: ARow = 0.0_dp |
306 |
– |
real(kind = dp), dimension(3,getNcol(plan_col)) :: ACol = 0.0_dp |
307 |
– |
|
308 |
– |
|
309 |
– |
|
310 |
– |
real(kind = dp), dimension(3,getNrow(plan_row)) :: fRow = 0.0_dp |
311 |
– |
real(kind = dp), dimension(3,getNcol(plan_col)) :: fCol = 0.0_dp |
312 |
– |
real(kind = dp), dimension(3,getNlocal()) :: fMPITemp = 0.0_dp |
313 |
– |
|
314 |
– |
real(kind = dp), dimension(3,getNrow(plan_row)) :: tRow = 0.0_dp |
315 |
– |
real(kind = dp), dimension(3,getNcol(plan_col)) :: tCol = 0.0_dp |
316 |
– |
real(kind = dp), dimension(3,getNlocal()) :: tMPITemp = 0.0_dp |
317 |
– |
|
318 |
– |
|
319 |
– |
real(kind = dp), dimension(getNrow(plan_row)) :: eRow = 0.0_dp |
320 |
– |
real(kind = dp), dimension(getNcol(plan_col)) :: eCol = 0.0_dp |
321 |
– |
|
322 |
– |
real(kind = dp), dimension(getNlocal()) :: eTemp = 0.0_dp |
323 |
– |
|
336 |
|
#endif |
337 |
|
|
338 |
|
|
344 |
|
integer :: i, j, jbeg, jend, jnab, idim, jdim, idim2, jdim2, dim, dim2 |
345 |
|
integer :: nlist |
346 |
|
integer :: j_start |
347 |
< |
integer :: tag_i,tag_j |
348 |
< |
real( kind = DP ) :: r, pot, ftmp, dudr, d2, drdx1, kt1, kt2, kt3, ktmp |
349 |
< |
real( kind = dp ) :: fx,fy,fz |
350 |
< |
real( kind = DP ) :: drdx, drdy, drdz |
339 |
< |
real( kind = DP ) :: rxi, ryi, rzi, rxij, ryij, rzij, rijsq |
347 |
> |
|
348 |
> |
real( kind = DP ) :: r_ij, pot, ftmp, dudr, d2, drdx1, kt1, kt2, kt3, ktmp |
349 |
> |
|
350 |
> |
real( kind = DP ) :: rx_ij, ry_ij, rz_ij, rijsq |
351 |
|
real( kind = DP ) :: rlistsq, rcutsq,rlist,rcut |
352 |
|
|
353 |
|
real( kind = DP ) :: dielectric = 0.0_dp |
354 |
|
|
355 |
|
! a rig that need to be fixed. |
356 |
|
#ifdef IS_MPI |
346 |
– |
logical :: newtons_thrd = .true. |
357 |
|
real( kind = dp ) :: pe_local |
358 |
|
integer :: nlocal |
359 |
|
#endif |
386 |
|
natoms = getNlocal() |
387 |
|
call getRcut(rcut,rcut2=rcutsq) |
388 |
|
call getRlist(rlist,rlistsq) |
389 |
+ |
|
390 |
|
!! Find ensemble |
391 |
|
if (isEnsemble("NPT")) do_stress = .true. |
392 |
+ |
!! set to wrap |
393 |
+ |
if (isPBC()) wrap = .true. |
394 |
|
|
395 |
+ |
|
396 |
|
#ifndef IS_MPI |
397 |
|
nrow = natoms - 1 |
398 |
|
ncol = natoms |
406 |
|
|
407 |
|
!! See if we need to update neighbor lists |
408 |
|
call check(q,update_nlist) |
395 |
– |
! if (firstTime) then |
396 |
– |
! update_nlist = .true. |
397 |
– |
! firstTime = .false. |
398 |
– |
! endif |
409 |
|
|
410 |
|
!--------------WARNING........................... |
411 |
|
! Zero variables, NOTE:::: Forces are zeroed in C |
412 |
|
! Zeroing them here could delete previously computed |
413 |
|
! Forces. |
414 |
|
!------------------------------------------------ |
415 |
< |
#ifndef IS_MPI |
406 |
< |
! nloops = nloops + 1 |
407 |
< |
pe = 0.0E0_DP |
408 |
< |
|
409 |
< |
#else |
410 |
< |
fRow = 0.0E0_DP |
411 |
< |
fCol = 0.0E0_DP |
415 |
> |
call zero_module_variables() |
416 |
|
|
413 |
– |
pe_local = 0.0E0_DP |
417 |
|
|
415 |
– |
eRow = 0.0E0_DP |
416 |
– |
eCol = 0.0E0_DP |
417 |
– |
eTemp = 0.0E0_DP |
418 |
– |
#endif |
419 |
– |
|
418 |
|
! communicate MPI positions |
419 |
|
#ifdef IS_MPI |
420 |
|
call gather(q,qRow,plan_row3d) |
428 |
|
|
429 |
|
call gather(A,ARow,plan_row_rotation) |
430 |
|
call gather(A,ACol,plan_col_rotation) |
433 |
– |
|
431 |
|
#endif |
432 |
|
|
433 |
|
|
445 |
|
do i = 1, nrow |
446 |
|
point(i) = nlist + 1 |
447 |
|
#ifdef IS_MPI |
448 |
< |
ljAtype_i => identPtrListRow(i)%this |
448 |
> |
Atype_i => identPtrListRow(i)%this |
449 |
|
tag_i = tagRow(i) |
453 |
– |
rxi = qRow(1,i) |
454 |
– |
ryi = qRow(2,i) |
455 |
– |
rzi = qRow(3,i) |
450 |
|
#else |
451 |
< |
ljAtype_i => identPtrList(i)%this |
451 |
> |
Atype_i => identPtrList(i)%this |
452 |
|
j_start = i + 1 |
459 |
– |
rxi = q(1,i) |
460 |
– |
ryi = q(2,i) |
461 |
– |
rzi = q(3,i) |
453 |
|
#endif |
454 |
|
|
455 |
|
inner: do j = j_start, ncol |
465 |
– |
#ifdef IS_MPI |
456 |
|
! Assign identity pointers and tags |
457 |
< |
ljAtype_j => identPtrListColumn(j)%this |
458 |
< |
tag_j = tagColumn(j) |
459 |
< |
if (newtons_thrd) then |
460 |
< |
if (tag_i <= tag_j) then |
461 |
< |
if (mod(tag_i + tag_j,2) == 0) cycle inner |
462 |
< |
else |
463 |
< |
if (mod(tag_i + tag_j,2) == 1) cycle inner |
464 |
< |
endif |
475 |
< |
endif |
457 |
> |
#ifdef IS_MPI |
458 |
> |
Atype_j => identPtrListColumn(j)%this |
459 |
> |
|
460 |
> |
call get_interatomic_vector(i,j,qRow(:,i),qCol(:,j),& |
461 |
> |
rxij,ryij,rzij,rijsq,r) |
462 |
> |
!! For mpi, use newtons 3rd law when building neigbor list |
463 |
> |
!! Also check to see the particle i != j. |
464 |
> |
if (mpi_cycle_jLoop(i,j)) cycle inner: |
465 |
|
|
477 |
– |
rxij = wrap(rxi - qCol(1,j), 1) |
478 |
– |
ryij = wrap(ryi - qCol(2,j), 2) |
479 |
– |
rzij = wrap(rzi - qCol(3,j), 3) |
466 |
|
#else |
467 |
< |
ljAtype_j => identPtrList(j)%this |
468 |
< |
rxij = wrap(rxi - q(1,j), 1) |
469 |
< |
ryij = wrap(ryi - q(2,j), 2) |
484 |
< |
rzij = wrap(rzi - q(3,j), 3) |
467 |
> |
Atype_j => identPtrList(j)%this |
468 |
> |
call get_interatomic_vector(i,j,q(:,i),q(:,j),& |
469 |
> |
rxij,ryij,rzij,rijsq,r) |
470 |
|
|
471 |
|
#endif |
472 |
< |
rijsq = rxij*rxij + ryij*ryij + rzij*rzij |
473 |
< |
|
474 |
< |
#ifdef IS_MPI |
490 |
< |
if (rijsq <= rlistsq .AND. & |
491 |
< |
tag_j /= tag_i) then |
492 |
< |
#else |
493 |
< |
|
494 |
< |
if (rijsq < rlistsq) then |
495 |
< |
#endif |
496 |
< |
|
472 |
> |
|
473 |
> |
if (rijsq < rlistsq) then |
474 |
> |
|
475 |
|
nlist = nlist + 1 |
476 |
+ |
|
477 |
|
if (nlist > neighborListSize) then |
478 |
|
call expandList(listerror) |
479 |
|
if (listerror /= 0) then |
482 |
|
return |
483 |
|
end if |
484 |
|
endif |
485 |
+ |
|
486 |
|
list(nlist) = j |
487 |
|
|
488 |
|
|
489 |
|
if (rijsq < rcutsq) then |
490 |
< |
|
491 |
< |
r = dsqrt(rijsq) |
512 |
< |
|
513 |
< |
call getLJPot(r,pot,dudr,ljAtype_i,ljAtype_j) |
514 |
< |
|
515 |
< |
#ifdef IS_MPI |
516 |
< |
eRow(i) = eRow(i) + pot*0.5 |
517 |
< |
eCol(i) = eCol(i) + pot*0.5 |
518 |
< |
#else |
519 |
< |
pe = pe + pot |
520 |
< |
#endif |
521 |
< |
|
522 |
< |
drdx = -rxij / r |
523 |
< |
drdy = -ryij / r |
524 |
< |
drdz = -rzij / r |
525 |
< |
|
526 |
< |
fx = dudr * drdx |
527 |
< |
fy = dudr * drdy |
528 |
< |
fz = dudr * drdz |
529 |
< |
|
530 |
< |
#ifdef IS_MPI |
531 |
< |
fCol(1,j) = fCol(1,j) - fx |
532 |
< |
fCol(2,j) = fCol(2,j) - fy |
533 |
< |
fCol(3,j) = fCol(3,j) - fz |
534 |
< |
|
535 |
< |
fRow(1,j) = fRow(1,j) + fx |
536 |
< |
fRow(2,j) = fRow(2,j) + fy |
537 |
< |
fRow(3,j) = fRow(3,j) + fz |
538 |
< |
#else |
539 |
< |
f(1,j) = f(1,j) - fx |
540 |
< |
f(2,j) = f(2,j) - fy |
541 |
< |
f(3,j) = f(3,j) - fz |
542 |
< |
f(1,i) = f(1,i) + fx |
543 |
< |
f(2,i) = f(2,i) + fy |
544 |
< |
f(3,i) = f(3,i) + fz |
545 |
< |
#endif |
546 |
< |
|
547 |
< |
if (do_stress) then |
548 |
< |
tauTemp(1) = tauTemp(1) + fx * rxij |
549 |
< |
tauTemp(2) = tauTemp(2) + fx * ryij |
550 |
< |
tauTemp(3) = tauTemp(3) + fx * rzij |
551 |
< |
tauTemp(4) = tauTemp(4) + fy * rxij |
552 |
< |
tauTemp(5) = tauTemp(5) + fy * ryij |
553 |
< |
tauTemp(6) = tauTemp(6) + fy * rzij |
554 |
< |
tauTemp(7) = tauTemp(7) + fz * rxij |
555 |
< |
tauTemp(8) = tauTemp(8) + fz * ryij |
556 |
< |
tauTemp(9) = tauTemp(9) + fz * rzij |
557 |
< |
endif |
558 |
< |
endif |
490 |
> |
call do_pair(Atype_i,Atype_j,i,j,r,rxij,ryij,rzij) |
491 |
> |
endif |
492 |
|
enddo inner |
493 |
|
enddo |
494 |
|
|
498 |
|
point(natoms) = nlist + 1 |
499 |
|
#endif |
500 |
|
|
501 |
< |
else |
501 |
> |
else !! (update) |
502 |
|
|
503 |
|
! use the list to find the neighbors |
504 |
|
do i = 1, nrow |
506 |
|
JEND = POINT(i+1) - 1 |
507 |
|
! check thiat molecule i has neighbors |
508 |
|
if (jbeg .le. jend) then |
509 |
+ |
|
510 |
|
#ifdef IS_MPI |
511 |
|
ljAtype_i => identPtrListRow(i)%this |
578 |
– |
rxi = qRow(1,i) |
579 |
– |
ryi = qRow(2,i) |
580 |
– |
rzi = qRow(3,i) |
512 |
|
#else |
513 |
< |
ljAtype_i => identPtrList(i)%this |
583 |
< |
rxi = q(1,i) |
584 |
< |
ryi = q(2,i) |
585 |
< |
rzi = q(3,i) |
513 |
> |
ljAtype_i => identPtrList(i)%this |
514 |
|
#endif |
515 |
|
do jnab = jbeg, jend |
516 |
|
j = list(jnab) |
517 |
|
#ifdef IS_MPI |
518 |
|
ljAtype_j = identPtrListColumn(j)%this |
519 |
< |
rxij = wrap(rxi - qCol(1,j), 1) |
520 |
< |
ryij = wrap(ryi - qCol(2,j), 2) |
521 |
< |
rzij = wrap(rzi - qCol(3,j), 3) |
519 |
> |
call get_interatomic_vector(i,j,qRow(:,i),qCol(:,j),& |
520 |
> |
rxij,ryij,rzij,rijsq,r) |
521 |
> |
|
522 |
|
#else |
523 |
|
ljAtype_j = identPtrList(j)%this |
524 |
< |
rxij = wrap(rxi - q(1,j), 1) |
525 |
< |
ryij = wrap(ryi - q(2,j), 2) |
598 |
< |
rzij = wrap(rzi - q(3,j), 3) |
524 |
> |
call get_interatomic_vector(i,j,q(:,i),q(:,j),& |
525 |
> |
rxij,ryij,rzij,rijsq,r) |
526 |
|
#endif |
527 |
< |
rijsq = rxij*rxij + ryij*ryij + rzij*rzij |
601 |
< |
|
602 |
< |
if (rijsq < rcutsq) then |
603 |
< |
|
604 |
< |
r = dsqrt(rijsq) |
605 |
< |
|
606 |
< |
call getLJPot(r,pot,dudr,ljAtype_i,ljAtype_j) |
607 |
< |
#ifdef IS_MPI |
608 |
< |
eRow(i) = eRow(i) + pot*0.5 |
609 |
< |
eCol(i) = eCol(i) + pot*0.5 |
610 |
< |
#else |
611 |
< |
pe = pe + pot |
612 |
< |
#endif |
613 |
< |
|
614 |
< |
drdx = -rxij / r |
615 |
< |
drdy = -ryij / r |
616 |
< |
drdz = -rzij / r |
617 |
< |
|
618 |
< |
fx = dudr * drdx |
619 |
< |
fy = dudr * drdy |
620 |
< |
fz = dudr * drdz |
621 |
< |
|
622 |
< |
#ifdef IS_MPI |
623 |
< |
fCol(1,j) = fCol(1,j) - fx |
624 |
< |
fCol(2,j) = fCol(2,j) - fy |
625 |
< |
fCol(3,j) = fCol(3,j) - fz |
626 |
< |
|
627 |
< |
fRow(1,j) = fRow(1,j) + fx |
628 |
< |
fRow(2,j) = fRow(2,j) + fy |
629 |
< |
fRow(3,j) = fRow(3,j) + fz |
630 |
< |
#else |
631 |
< |
f(1,j) = f(1,j) - fx |
632 |
< |
f(2,j) = f(2,j) - fy |
633 |
< |
f(3,j) = f(3,j) - fz |
634 |
< |
f(1,i) = f(1,i) + fx |
635 |
< |
f(2,i) = f(2,i) + fy |
636 |
< |
f(3,i) = f(3,i) + fz |
637 |
< |
#endif |
638 |
< |
|
639 |
< |
if (do_stress) then |
640 |
< |
tauTemp(1) = tauTemp(1) + fx * rxij |
641 |
< |
tauTemp(2) = tauTemp(2) + fx * ryij |
642 |
< |
tauTemp(3) = tauTemp(3) + fx * rzij |
643 |
< |
tauTemp(4) = tauTemp(4) + fy * rxij |
644 |
< |
tauTemp(5) = tauTemp(5) + fy * ryij |
645 |
< |
tauTemp(6) = tauTemp(6) + fy * rzij |
646 |
< |
tauTemp(7) = tauTemp(7) + fz * rxij |
647 |
< |
tauTemp(8) = tauTemp(8) + fz * ryij |
648 |
< |
tauTemp(9) = tauTemp(9) + fz * rzij |
649 |
< |
endif |
650 |
< |
|
651 |
< |
|
652 |
< |
endif |
527 |
> |
call do_pair(i,j,r,rxij,ryij,rzij) |
528 |
|
enddo |
529 |
|
endif |
530 |
|
enddo |
536 |
|
!!distribute forces |
537 |
|
|
538 |
|
call scatter(fRow,f,plan_row3d) |
539 |
< |
call scatter(fCol,fMPITemp,plan_col3d) |
539 |
> |
call scatter(fCol,fTemp,plan_col3d) |
540 |
|
|
541 |
|
do i = 1,nlocal |
542 |
< |
f(1:3,i) = f(1:3,i) + fMPITemp(1:3,i) |
542 |
> |
f(1:3,i) = f(1:3,i) + fTemp(1:3,i) |
543 |
|
end do |
544 |
|
|
545 |
< |
|
546 |
< |
call scatter(tRow,t,plan_row3d) |
547 |
< |
call scatter(tCol,tMPITemp,plan_col3d) |
545 |
> |
if (do_torque) then |
546 |
> |
call scatter(tRow,t,plan_row3d) |
547 |
> |
call scatter(tCol,tTemp,plan_col3d) |
548 |
|
|
549 |
< |
do i = 1,nlocal |
550 |
< |
t(1:3,i) = t(1:3,i) + tMPITemp(1:3,i) |
551 |
< |
end do |
549 |
> |
do i = 1,nlocal |
550 |
> |
t(1:3,i) = t(1:3,i) + tTemp(1:3,i) |
551 |
> |
end do |
552 |
> |
endif |
553 |
|
|
678 |
– |
|
554 |
|
if (do_pot) then |
555 |
|
! scatter/gather pot_row into the members of my column |
556 |
|
call scatter(eRow,eTemp,plan_row) |
560 |
|
do i = 1, nlocal |
561 |
|
pe_local = pe_local + eTemp(i) |
562 |
|
enddo |
563 |
< |
if (newtons_thrd) then |
564 |
< |
eTemp = 0.0E0_DP |
565 |
< |
call scatter(eCol,eTemp,plan_col) |
566 |
< |
do i = 1, nlocal |
567 |
< |
pe_local = pe_local + eTemp(i) |
568 |
< |
enddo |
569 |
< |
endif |
563 |
> |
|
564 |
> |
eTemp = 0.0E0_DP |
565 |
> |
call scatter(eCol,eTemp,plan_col) |
566 |
> |
do i = 1, nlocal |
567 |
> |
pe_local = pe_local + eTemp(i) |
568 |
> |
enddo |
569 |
> |
|
570 |
|
pe = pe_local |
571 |
|
endif |
572 |
< |
|
572 |
> |
#else |
573 |
> |
! Copy local array into return array for c |
574 |
> |
f = fTemp |
575 |
> |
t = tTemp |
576 |
|
#endif |
577 |
|
|
578 |
|
potE = pe |
587 |
|
#endif |
588 |
|
endif |
589 |
|
|
712 |
– |
|
590 |
|
end subroutine do_force_loop |
591 |
|
|
592 |
|
|
593 |
|
|
594 |
+ |
|
595 |
+ |
|
596 |
+ |
|
597 |
+ |
|
598 |
+ |
|
599 |
+ |
|
600 |
+ |
|
601 |
+ |
!! Calculate any pre-force loop components and update nlist if necessary. |
602 |
+ |
subroutine do_preForce(updateNlist) |
603 |
+ |
logical, intent(inout) :: updateNlist |
604 |
+ |
|
605 |
+ |
|
606 |
+ |
|
607 |
+ |
end subroutine do_preForce |
608 |
+ |
|
609 |
+ |
|
610 |
+ |
|
611 |
+ |
|
612 |
+ |
|
613 |
+ |
|
614 |
+ |
|
615 |
+ |
|
616 |
+ |
|
617 |
+ |
|
618 |
+ |
|
619 |
+ |
|
620 |
+ |
|
621 |
+ |
!! Calculate any post force loop components, i.e. reaction field, etc. |
622 |
+ |
subroutine do_postForce() |
623 |
+ |
|
624 |
+ |
|
625 |
+ |
|
626 |
+ |
end subroutine do_postForce |
627 |
+ |
|
628 |
+ |
|
629 |
+ |
|
630 |
+ |
|
631 |
+ |
|
632 |
+ |
|
633 |
+ |
|
634 |
+ |
|
635 |
+ |
|
636 |
+ |
|
637 |
+ |
|
638 |
+ |
|
639 |
+ |
|
640 |
+ |
|
641 |
+ |
|
642 |
+ |
|
643 |
+ |
|
644 |
+ |
subroutine do_pair(atype_i,atype_j,i,j,r_ij,rx_ij,ry_ij,rz_ij) |
645 |
+ |
type (atype ), pointer, intent(inout) :: atype_i |
646 |
+ |
type (atype ), pointer, intent(inout) :: atype_j |
647 |
+ |
integer :: i |
648 |
+ |
integer :: j |
649 |
+ |
real ( kind = dp ), intent(inout) :: rx_ij |
650 |
+ |
real ( kind = dp ), intent(inout) :: ry_ij |
651 |
+ |
real ( kind = dp ), intent(inout) :: rz_ij |
652 |
+ |
|
653 |
+ |
|
654 |
+ |
real( kind = dp ) :: fx = 0.0_dp |
655 |
+ |
real( kind = dp ) :: fy = 0.0_dp |
656 |
+ |
real( kind = dp ) :: fz = 0.0_dp |
657 |
+ |
|
658 |
+ |
real( kind = dp ) :: drdx = 0.0_dp |
659 |
+ |
real( kind = dp ) :: drdy = 0.0_dp |
660 |
+ |
real( kind = dp ) :: drdz = 0.0_dp |
661 |
+ |
|
662 |
+ |
|
663 |
+ |
|
664 |
+ |
|
665 |
+ |
|
666 |
+ |
|
667 |
+ |
call getLJForce(r,pot,dudr,ljAtype_i,ljAtype_j) |
668 |
+ |
|
669 |
+ |
#ifdef IS_MPI |
670 |
+ |
eRow(i) = eRow(i) + pot*0.5 |
671 |
+ |
eCol(i) = eCol(i) + pot*0.5 |
672 |
+ |
#else |
673 |
+ |
pe = pe + pot |
674 |
+ |
#endif |
675 |
+ |
|
676 |
+ |
drdx = -rxij / r |
677 |
+ |
drdy = -ryij / r |
678 |
+ |
drdz = -rzij / r |
679 |
+ |
|
680 |
+ |
fx = dudr * drdx |
681 |
+ |
fy = dudr * drdy |
682 |
+ |
fz = dudr * drdz |
683 |
+ |
|
684 |
+ |
|
685 |
+ |
|
686 |
+ |
|
687 |
+ |
|
688 |
+ |
|
689 |
+ |
|
690 |
+ |
#ifdef IS_MPI |
691 |
+ |
fCol(1,j) = fCol(1,j) - fx |
692 |
+ |
fCol(2,j) = fCol(2,j) - fy |
693 |
+ |
fCol(3,j) = fCol(3,j) - fz |
694 |
+ |
|
695 |
+ |
fRow(1,j) = fRow(1,j) + fx |
696 |
+ |
fRow(2,j) = fRow(2,j) + fy |
697 |
+ |
fRow(3,j) = fRow(3,j) + fz |
698 |
+ |
#else |
699 |
+ |
fTemp(1,j) = fTemp(1,j) - fx |
700 |
+ |
fTemp(2,j) = fTemp(2,j) - fy |
701 |
+ |
fTemp(3,j) = fTemp(3,j) - fz |
702 |
+ |
fTemp(1,i) = fTemp(1,i) + fx |
703 |
+ |
fTemp(2,i) = fTemp(2,i) + fy |
704 |
+ |
fTemp(3,i) = fTemp(3,i) + fz |
705 |
+ |
#endif |
706 |
+ |
|
707 |
+ |
if (do_stress) then |
708 |
+ |
tauTemp(1) = tauTemp(1) + fx * rxij |
709 |
+ |
tauTemp(2) = tauTemp(2) + fx * ryij |
710 |
+ |
tauTemp(3) = tauTemp(3) + fx * rzij |
711 |
+ |
tauTemp(4) = tauTemp(4) + fy * rxij |
712 |
+ |
tauTemp(5) = tauTemp(5) + fy * ryij |
713 |
+ |
tauTemp(6) = tauTemp(6) + fy * rzij |
714 |
+ |
tauTemp(7) = tauTemp(7) + fz * rxij |
715 |
+ |
tauTemp(8) = tauTemp(8) + fz * ryij |
716 |
+ |
tauTemp(9) = tauTemp(9) + fz * rzij |
717 |
+ |
endif |
718 |
+ |
|
719 |
+ |
|
720 |
+ |
|
721 |
+ |
end subroutine do_pair |
722 |
+ |
|
723 |
+ |
|
724 |
+ |
|
725 |
+ |
|
726 |
+ |
|
727 |
+ |
|
728 |
+ |
|
729 |
+ |
|
730 |
+ |
|
731 |
+ |
|
732 |
+ |
|
733 |
+ |
|
734 |
+ |
|
735 |
+ |
|
736 |
+ |
|
737 |
+ |
|
738 |
+ |
subroutine get_interatomic_vector(q_i,q_j,rx_ij,ry_ij,rz_ij,r_sq,r_ij) |
739 |
+ |
!---------------- Arguments------------------------------- |
740 |
+ |
!! index i |
741 |
+ |
|
742 |
+ |
!! Position array |
743 |
+ |
real (kind = dp), dimension(3) :: q_i |
744 |
+ |
real (kind = dp), dimension(3) :: q_j |
745 |
+ |
!! x component of vector between i and j |
746 |
+ |
real ( kind = dp ), intent(out) :: rx_ij |
747 |
+ |
!! y component of vector between i and j |
748 |
+ |
real ( kind = dp ), intent(out) :: ry_ij |
749 |
+ |
!! z component of vector between i and j |
750 |
+ |
real ( kind = dp ), intent(out) :: rz_ij |
751 |
+ |
!! magnitude of r squared |
752 |
+ |
real ( kind = dp ), intent(out) :: r_sq |
753 |
+ |
!! magnitude of vector r between atoms i and j. |
754 |
+ |
real ( kind = dp ), intent(out) :: r_ij |
755 |
+ |
!! wrap into periodic box. |
756 |
+ |
logical, intent(in) :: wrap |
757 |
+ |
|
758 |
+ |
!--------------- Local Variables--------------------------- |
759 |
+ |
!! Distance between i and j |
760 |
+ |
real( kind = dp ) :: d(3) |
761 |
+ |
!---------------- END DECLARATIONS------------------------- |
762 |
+ |
|
763 |
+ |
|
764 |
+ |
! Find distance between i and j |
765 |
+ |
d(1:3) = q_i(1:3) - q_j(1:3) |
766 |
+ |
|
767 |
+ |
! Wrap back into periodic box if necessary |
768 |
+ |
if ( wrap ) then |
769 |
+ |
d(1:3) = d(1:3) - thisSim%box(1:3) * sign(1.0_dp,thisSim%box(1:3)) * & |
770 |
+ |
int(abs(d(1:3)/thisSim%box(1:3) + 0.5_dp) |
771 |
+ |
end if |
772 |
+ |
|
773 |
+ |
! Find Magnitude of the vector |
774 |
+ |
r_sq = dot_product(d,d) |
775 |
+ |
r_ij = sqrt(r_sq) |
776 |
+ |
|
777 |
+ |
! Set each component for force calculation |
778 |
+ |
rx_ij = d(1) |
779 |
+ |
ry_ij = d(2) |
780 |
+ |
rz_ij = d(3) |
781 |
+ |
|
782 |
+ |
|
783 |
+ |
end subroutine get_interatomic_vector |
784 |
+ |
|
785 |
+ |
subroutine zero_module_variables() |
786 |
+ |
|
787 |
+ |
#ifndef IS_MPI |
788 |
+ |
|
789 |
+ |
pe = 0.0E0_DP |
790 |
+ |
tauTemp = 0.0_dp |
791 |
+ |
fTemp = 0.0_dp |
792 |
+ |
tTemp = 0.0_dp |
793 |
+ |
#else |
794 |
+ |
qRow = 0.0_dp |
795 |
+ |
qCol = 0.0_dp |
796 |
+ |
|
797 |
+ |
muRow = 0.0_dp |
798 |
+ |
muCol = 0.0_dp |
799 |
+ |
|
800 |
+ |
u_lRow = 0.0_dp |
801 |
+ |
u_lCol = 0.0_dp |
802 |
+ |
|
803 |
+ |
ARow = 0.0_dp |
804 |
+ |
ACol = 0.0_dp |
805 |
+ |
|
806 |
+ |
fRow = 0.0_dp |
807 |
+ |
fCol = 0.0_dp |
808 |
+ |
|
809 |
+ |
|
810 |
+ |
tRow = 0.0_dp |
811 |
+ |
tCol = 0.0_dp |
812 |
+ |
|
813 |
+ |
|
814 |
+ |
|
815 |
+ |
eRow = 0.0_dp |
816 |
+ |
eCol = 0.0_dp |
817 |
+ |
eTemp = 0.0_dp |
818 |
+ |
#endif |
819 |
+ |
|
820 |
+ |
end subroutine zero_module_variables |
821 |
+ |
|
822 |
+ |
#ifdef IS_MPI |
823 |
+ |
!! Function to properly build neighbor lists in MPI using newtons 3rd law. |
824 |
+ |
!! We don't want 2 processors doing the same i j pair twice. |
825 |
+ |
!! Also checks to see if i and j are the same particle. |
826 |
+ |
function mpi_cycle_jLoop(i,j) result(do_cycle) |
827 |
+ |
!--------------- Arguments-------------------------- |
828 |
+ |
! Index i |
829 |
+ |
integer,intent(in) :: i |
830 |
+ |
! Index j |
831 |
+ |
integer,intent(in) :: j |
832 |
+ |
! Result do_cycle |
833 |
+ |
logical :: do_cycle |
834 |
+ |
!--------------- Local variables-------------------- |
835 |
+ |
integer :: tag_i |
836 |
+ |
integer :: tag_j |
837 |
+ |
!--------------- END DECLARATIONS------------------ |
838 |
+ |
tag_i = tagRow(i) |
839 |
+ |
tag_j = tagColumn(j) |
840 |
+ |
|
841 |
+ |
do_cycle = .false. |
842 |
+ |
|
843 |
+ |
if (tag_i == tag_j) then |
844 |
+ |
do_cycle = .true. |
845 |
+ |
return |
846 |
+ |
end if |
847 |
+ |
|
848 |
+ |
if (tag_i < tag_j) then |
849 |
+ |
if (mod(tag_i + tag_j,2) == 0) do_cycle = .true. |
850 |
+ |
return |
851 |
+ |
else |
852 |
+ |
if (mod(tag_i + tag_j,2) == 1) do_cycle = .true. |
853 |
+ |
endif |
854 |
+ |
end function mpi_cycle_jLoop |
855 |
+ |
#endif |
856 |
+ |
|
857 |
|
end module do_Forces |