LCOV - code coverage report
Current view: top level - force - force_w.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 41 42 97.6 %
Date: 2019-09-08 04:53:50 Functions: 1 2 50.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2019 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : MODULE m_forcew
       7             :   ! ************************************************************
       8             :   ! Printing force components
       9             :   ! ************************************************************
      10             : CONTAINS
      11         324 :   SUBROUTINE force_w(mpi,input,atoms,sym,results,cell,oneD,vacuum)
      12             :     USE m_types
      13             :     USE m_xmlOutput
      14             :     USE m_relaxation
      15             :     IMPLICIT NONE
      16             :     TYPE(t_mpi),INTENT(IN)       :: mpi
      17             :     TYPE(t_results),INTENT(INOUT):: results
      18             :     TYPE(t_oneD),INTENT(IN)      :: oneD
      19             :     TYPE(t_input),INTENT(IN)     :: input
      20             :     TYPE(t_sym),INTENT(IN)       :: sym
      21             :     TYPE(t_cell),INTENT(IN)      :: cell
      22             :     TYPE(t_atoms),INTENT(IN)     :: atoms
      23             :     TYPE(t_vacuum),INTENT(IN)    :: vacuum
      24             :     !     ..
      25             :     !     .. Local Scalars ..
      26             :     REAL sum
      27             :     INTEGER i,jsp,n,nat1,ierr
      28             :     REAL eps_force
      29             :     LOGICAL :: l_new,l_relax
      30             :     !     ..
      31             :     !     .. Local Arrays ..
      32         646 :     REAL forcetot(3,atoms%ntype)
      33             :     CHARACTER(LEN=20) :: attributes(7)
      34             : #ifdef CPP_MPI
      35             :     include 'mpif.h'
      36             : #endif
      37             :     !
      38             :     !     write spin-dependent forces
      39             :     !
      40         324 :     IF (mpi%irank==0) THEN
      41         162 :        nat1 = 1
      42         474 :        DO n = 1,atoms%ntype
      43         312 :           IF (atoms%l_geo(n)) THEN
      44         312 :              IF (input%jspins.EQ.2) THEN
      45         753 :                 DO jsp = 1,input%jspins
      46        2510 :                    WRITE (6,FMT=8000) jsp,n, (atoms%pos(i,nat1),i=1,3),&
      47        4769 :                         &           (results%force(i,n,jsp),i=1,3)
      48             :                 END DO
      49             :              END IF
      50             : 8000         FORMAT ('SPIN-',i1,1x,'FORCE FOR ATOM TYPE=',i3,2x,'X=',f7.3,&
      51             :                   &          3x,'Y=',f7.3,3x,'Z=',f7.3,5x,' FX_SP =',f9.6,' FY_SP =',&
      52             :                   &          f9.6,' FZ_SP =',f9.6)
      53             :           ENDIF
      54         474 :           nat1 = nat1 + atoms%neq(n)
      55             :        END DO
      56             :        !
      57             :        !     write total forces
      58             :        !
      59         162 :        WRITE  (6,8005)
      60             : 8005   FORMAT (/,' ***** TOTAL FORCES ON ATOMS ***** ',/)
      61         162 :        IF (input%l_f) CALL openXMLElement('totalForcesOnRepresentativeAtoms',(/'units'/),(/'Htr/bohr'/))
      62             :        nat1 = 1
      63         474 :        forcetot = 0.0
      64         474 :        DO n = 1,atoms%ntype
      65         312 :           IF (atoms%l_geo(n)) THEN
      66         875 :              DO jsp = 1,input%jspins
      67        4253 :                 DO i = 1,3
      68        2252 :                    forcetot(i,n) = forcetot(i,n) + results%force(i,n,jsp)
      69             :                 END DO
      70             :              END DO
      71             : 
      72        1560 :              WRITE (6,FMT=8010) n, (atoms%pos(i,nat1),i=1,3),&
      73        2808 :                   &        (forcetot(i,n),i=1,3)
      74             : 8010         FORMAT (' TOTAL FORCE FOR ATOM TYPE=',i3,2x,'X=',f7.3,3x,'Y=',&
      75             :                   &              f7.3,3x,'Z=',f7.3,/,22x,' FX_TOT=',f9.6,&
      76             :                   &              ' FY_TOT=',f9.6,' FZ_TOT=',f9.6)
      77             : 
      78         312 :              WRITE(attributes(1),'(i0)') n
      79         312 :              WRITE(attributes(2),'(f12.6)') atoms%pos(1,nat1)
      80         312 :              WRITE(attributes(3),'(f12.6)') atoms%pos(2,nat1)
      81         312 :              WRITE(attributes(4),'(f12.6)') atoms%pos(3,nat1)
      82         312 :              WRITE(attributes(5),'(f12.8)') forcetot(1,n)
      83         312 :              WRITE(attributes(6),'(f12.8)') forcetot(2,n)
      84         312 :              WRITE(attributes(7),'(f12.8)') forcetot(3,n)
      85         312 :              IF (input%l_f) THEN
      86             :                 CALL writeXMLElementFormPoly('forceTotal',(/'atomType','x       ','y       ','z       ',&
      87             :                      'F_x     ','F_y     ','F_z     '/),attributes,&
      88           4 :                      RESHAPE((/8,1,1,1,3,3,3,6,12,12,12,12,12,12/),(/7,2/)))
      89             :              END IF
      90             :           END IF
      91         474 :           nat1 = nat1 + atoms%neq(n)
      92             :        END DO
      93         162 :        IF (input%l_f) CALL closeXMLElement('totalForcesOnRepresentativeAtoms')
      94             : 
      95             : 
      96             :        !Check convergence of force by comparing force with old_force
      97         162 :        sum=MAXVAL(ABS(forcetot - results%force_old))
      98         474 :        results%force_old(:,:)=forcetot !Store for next iteration
      99         162 :        results%force=0.0
     100         162 :        l_relax=sum<input%force_converged
     101         162 :        IF (.NOT.l_relax) THEN
     102          27 :           WRITE (6,8020) input%force_converged,sum
     103             : 8020      FORMAT ('No new postions, force convergence required=',f8.5,'; max force distance=',f8.5)
     104             :        END IF
     105             :     ENDIF
     106             : #ifdef CPP_MPI
     107         324 :     CALL MPI_BCAST(l_relax,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
     108             : #endif
     109         324 :     IF (l_relax.AND.input%l_f) CALL relaxation(mpi,input,atoms,cell,sym,forcetot,results%tote)
     110             : 
     111         322 :   END SUBROUTINE force_w
     112           0 : END MODULE m_forcew

Generated by: LCOV version 1.13