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

Comparing trunk/OOPSE-4/src/UseTheForce/DarkSide/simulation.F90 (file contents):
Revision 2204 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 2592 by gezelter, Thu Feb 16 21:40:20 2006 UTC

# Line 43 | Line 43 | module simulation
43  
44   module simulation
45    use definitions
46 +  use status
47 +  use linearAlgebra
48    use neighborLists
49    use force_globals
50    use vector_class
# Line 58 | Line 60 | module simulation
60   #define __FORTRAN90
61   #include "brains/fSimulation.h"
62   #include "UseTheForce/fSwitchingFunction.h"
63 + #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h"
64  
65    type (simtype), public, save :: thisSim
66  
# Line 82 | Line 85 | module simulation
85    real(kind=dp), allocatable, dimension(:), public :: mfactCol
86    real(kind=dp), allocatable, dimension(:), public :: mfactLocal
87  
88 +  logical, allocatable, dimension(:) :: simHasAtypeMap
89 + #ifdef IS_MPI
90 +  logical, allocatable, dimension(:) :: simHasAtypeMapTemp
91 + #endif
92 +
93    real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv
94 +  real(kind=dp), save :: DangerRcut
95    logical, public, save :: boxIsOrthorhombic
96  
97    public :: SimulationSetup
98    public :: getNlocal
99    public :: setBox
100 +  public :: checkBox
101    public :: getDielect
102    public :: SimUsesPBC
103  
# Line 97 | Line 107 | module simulation
107    public :: SimUsesCharges
108    public :: SimUsesDipoles
109    public :: SimUsesSticky
110 +  public :: SimUsesStickyPower
111    public :: SimUsesGayBerne
112    public :: SimUsesEAM
113    public :: SimUsesShapes
114    public :: SimUsesFLARB
115    public :: SimUsesRF
116 +  public :: SimUsesSF
117    public :: SimRequiresPrepairCalc
118    public :: SimRequiresPostpairCalc
119 <
119 >  public :: SimHasAtype
120 >  public :: SimUsesSC
121 >  public :: SimUsesMEAM
122 >  public :: setHmatDangerousRcutValue
123  
124   contains
125  
# Line 456 | Line 471 | contains
471               molMemberShipList(i) = CmolMembership(i)
472            enddo
473  
474 <          if (status == 0) simulation_setup_complete = .true.
474 >         call createSimHasAtype(alloc_stat)
475 >         if (alloc_stat /= 0) then
476 >            status = -1
477 >         end if
478 >        
479 >         if (status == 0) simulation_setup_complete = .true.
480  
481          end subroutine SimulationSetup
482  
483          subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
484            real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
485            integer :: cBoxIsOrthorhombic
486 <          integer :: smallest, status, i
486 >          integer :: smallest, status
487  
488            Hmat = cHmat
489            HmatInv = cHmatInv
# Line 473 | Line 493 | contains
493               boxIsOrthorhombic = .true.
494            endif
495  
496 <          return    
496 >          call checkBox()
497 >          return
498          end subroutine setBox
499 +
500 +        subroutine checkBox()
501 +
502 +          integer :: i
503 +          real(kind=dp), dimension(3) :: hx, hy, hz, ax, ay, az, piped
504 +          character(len = statusMsgSize) :: errMsg
505 +
506 +          hx = Hmat(1,:)
507 +          hy = Hmat(2,:)
508 +          hz = Hmat(3,:)
509 +
510 +          ax = cross_product(hy, hz)
511 +          ay = cross_product(hx, hz)
512 +          az = cross_product(hx, hy)
513  
514 +          ax = ax / length(ax)
515 +          ay = ay / length(ay)
516 +          az = az / length(az)
517 +
518 +          piped(1) = abs(dot_product(ax, hx))
519 +          piped(2) = abs(dot_product(ay, hy))
520 +          piped(3) = abs(dot_product(az, hz))
521 +          
522 +          do i = 1, 3
523 +             if ((0.5_dp * piped(i)).lt.DangerRcut) then                
524 +                write(errMsg, '(a94,f9.4,a1)') 'One of the dimensions of the Periodic ' &
525 +                     // 'Box is smaller than ' // newline // tab // &
526 +                     'the largest cutoff radius' // &
527 +                     ' (rCut = ', DangerRcut, ')'
528 +                call handleError("checkBox", errMsg)
529 +             end if
530 +          enddo        
531 +          return    
532 +        end subroutine checkBox
533 +
534          function getDielect() result(dielect)
535            real( kind = dp ) :: dielect
536            dielect = thisSim%dielect
# Line 488 | Line 543 | contains
543  
544          function SimUsesDirectionalAtoms() result(doesit)
545            logical :: doesit
546 <          doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_sticky .or. &
546 >          doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_Sticky .or. &
547 >               thisSim%SIM_uses_StickyPower .or. &
548                 thisSim%SIM_uses_GayBerne .or. thisSim%SIM_uses_Shapes
549          end function SimUsesDirectionalAtoms
550  
# Line 517 | Line 573 | contains
573            doesit = thisSim%SIM_uses_Sticky
574          end function SimUsesSticky
575  
576 +        function SimUsesStickyPower() result(doesit)
577 +          logical :: doesit
578 +          doesit = thisSim%SIM_uses_StickyPower
579 +        end function SimUsesStickyPower
580 +
581          function SimUsesGayBerne() result(doesit)
582            logical :: doesit
583            doesit = thisSim%SIM_uses_GayBerne
# Line 527 | Line 588 | contains
588            doesit = thisSim%SIM_uses_EAM
589          end function SimUsesEAM
590  
591 +
592 +        function SimUsesSC() result(doesit)
593 +          logical :: doesit
594 +          doesit = thisSim%SIM_uses_SC
595 +        end function SimUsesSC
596 +
597 +        function SimUsesMEAM() result(doesit)
598 +          logical :: doesit
599 +          doesit = thisSim%SIM_uses_MEAM
600 +        end function SimUsesMEAM
601 +
602 +
603          function SimUsesShapes() result(doesit)
604            logical :: doesit
605            doesit = thisSim%SIM_uses_Shapes
# Line 542 | Line 615 | contains
615            doesit = thisSim%SIM_uses_RF
616          end function SimUsesRF
617  
618 +        function SimUsesSF() result(doesit)
619 +          logical :: doesit
620 +          doesit = thisSim%SIM_uses_SF
621 +        end function SimUsesSF
622 +
623          function SimRequiresPrepairCalc() result(doesit)
624            logical :: doesit
625 <          doesit = thisSim%SIM_uses_EAM
625 >          doesit = thisSim%SIM_uses_EAM .or. thisSim%SIM_uses_SC &
626 >               .or. thisSim%SIM_uses_MEAM
627          end function SimRequiresPrepairCalc
628 <
628 >        
629          function SimRequiresPostpairCalc() result(doesit)
630            logical :: doesit
631 <          doesit = thisSim%SIM_uses_RF
631 >          doesit = thisSim%SIM_uses_RF .or. thisSim%SIM_uses_SF
632          end function SimRequiresPostpairCalc
633  
634 <        subroutine InitializeSimGlobals(thisStat)
634 >        ! Function returns true if the simulation has this atype
635 >        function SimHasAtype(thisAtype) result(doesit)
636 >          logical :: doesit
637 >          integer :: thisAtype
638 >          doesit = .false.
639 >          if(.not.allocated(SimHasAtypeMap)) return
640 >
641 >          doesit = SimHasAtypeMap(thisAtype)
642 >            
643 >        end function SimHasAtype
644 >
645 >        subroutine createSimHasAtype(status)
646 >          integer, intent(out) :: status
647 >          integer :: alloc_stat
648 >          integer :: me_i
649 >          integer :: mpiErrors
650 >          integer :: nAtypes
651 >          status = 0
652 >
653 >          nAtypes = getSize(atypes)
654 >          ! Setup logical map for atypes in simulation
655 >          if (.not.allocated(SimHasAtypeMap)) then
656 >             allocate(SimHasAtypeMap(nAtypes),stat=alloc_stat)
657 >             if (alloc_stat /= 0 ) then
658 >                status = -1
659 >                return
660 >             end if
661 >             SimHasAtypeMap = .false.
662 >          end if
663 >          
664 >          ! Loop through the local atoms and grab the atypes present        
665 >          do me_i = 1,nLocal
666 >             SimHasAtypeMap(atid(me_i)) = .true.
667 >          end do
668 >          ! For MPI, we need to know all possible atypes present in
669 >          ! simulation on all processors. Use LOR operation to set map.
670 > #ifdef IS_MPI
671 >          if (.not.allocated(SimHasAtypeMapTemp)) then
672 >             allocate(SimHasAtypeMapTemp(nAtypes),stat=alloc_stat)
673 >             if (alloc_stat /= 0 ) then
674 >                status = -1
675 >                return
676 >             end if
677 >          end if
678 >          call mpi_allreduce(SimHasAtypeMap, SimHasAtypeMaptemp, nAtypes, &
679 >               mpi_logical, MPI_LOR, mpi_comm_world, mpiErrors)
680 >          simHasAtypeMap = simHasAtypeMapTemp
681 >          deallocate(simHasAtypeMapTemp)
682 > #endif          
683 >        end subroutine createSimHasAtype
684 >        
685 >       subroutine InitializeSimGlobals(thisStat)
686            integer, intent(out) :: thisStat
687            integer :: alloc_stat
688  
# Line 604 | Line 734 | contains
734            n = nLocal
735          end function getNlocal
736  
737 +        subroutine setHmatDangerousRcutValue(dangerWillRobinson)
738 +          real(kind=dp), intent(in) :: dangerWillRobinson
739 +          DangerRcut = dangerWillRobinson
740 +
741 +          call checkBox()
742 +
743 +          return
744 +        end subroutine setHmatDangerousRcutValue
745 +
746 +
747 +
748        end module simulation

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines