LCOV - code coverage report
Current view: top level - mix - kerker.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 23 28 82.1 %
Date: 2019-09-08 04:53:50 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2016 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_kerker
       7             : 
       8             : CONTAINS
       9             : 
      10           6 :   SUBROUTINE kerker( field, DIMENSION, mpi, &
      11             :        stars, atoms, sphhar, vacuum, input, sym, cell, noco, &
      12             :        oneD, inDen, outDen, precon_v  )
      13             : 
      14             :     !Implementation of the Kerker preconditioner by M.Hinzen
      15             : 
      16             :     USE m_vgen_coulomb
      17             :     USE m_VYukawaFilm
      18             :     USE m_juDFT
      19             :     USE m_qfix
      20             :     USE m_types
      21             :     USE m_types_mixvector
      22             :     USE m_constants
      23             : 
      24             : #ifdef CPP_MPI    
      25             :     USE m_mpi_bc_potden
      26             : #endif    
      27             :     IMPLICIT NONE
      28             : 
      29             :     TYPE(t_oneD),      INTENT(in)    :: oneD
      30             :     TYPE(t_input),     INTENT(in)    :: input
      31             :     TYPE(t_vacuum),    INTENT(in)    :: vacuum
      32             :     TYPE(t_noco),      INTENT(in)    :: noco
      33             :     TYPE(t_sym),       INTENT(in)    :: sym
      34             :     TYPE(t_stars),     INTENT(in)    :: stars
      35             :     TYPE(t_cell),      INTENT(in)    :: cell
      36             :     TYPE(t_sphhar),    INTENT(in)    :: sphhar
      37             :     TYPE(t_field),     INTENT(inout) :: field
      38             :     TYPE(t_dimension), INTENT(in)    :: DIMENSION
      39             :     TYPE(t_mpi),       INTENT(in)    :: mpi
      40             :     TYPE(t_atoms),     INTENT(in)    :: atoms 
      41             :     TYPE(t_potden),    INTENT(inout) :: outDen
      42             :     TYPE(t_potden),    INTENT(in)    :: inDen
      43             :     TYPE(t_mixvector), INTENT(INOUT) :: precon_v
      44             : 
      45           6 :     type(t_potden)                   :: resDen, vYukawa, resDenMod
      46             :     real                             :: fix
      47             :     integer                          :: lh,n
      48             : 
      49             : 
      50           6 :     CALL resDen%init( stars, atoms, sphhar, vacuum, noco, input%jspins, POTDEN_TYPE_DEN )
      51           6 :     CALL vYukawa%init( stars, atoms, sphhar, vacuum, noco, input%jspins, 4 )
      52           6 :     MPI0_b: IF( mpi%irank == 0 ) THEN 
      53           3 :        CALL resDen%subPotDen( outDen, inDen )
      54           3 :        IF( input%jspins == 2 ) CALL resDen%SpinsToChargeAndMagnetisation()
      55             :     END IF MPI0_b
      56             : #ifdef CPP_MPI
      57           6 :     CALL mpi_bc_potden( mpi, stars, sphhar, atoms, input, vacuum, oneD, noco, resDen )
      58             : #endif
      59           6 :     IF ( .NOT. input%film ) THEN
      60             :        CALL vgen_coulomb( 1, mpi, DIMENSION, oneD, input, field, vacuum, sym, stars, cell, &
      61           6 :             sphhar, atoms, resDen, vYukawa )
      62             :     ELSE
      63           0 :        if( mpi%irank == 0 ) then 
      64           0 :           call resDenMod%init( stars, atoms, sphhar, vacuum, noco, input%jspins, POTDEN_TYPE_DEN )
      65           0 :           call resDenMod%copyPotDen( resDen )
      66             :        end if
      67           0 :        vYukawa%iter = resDen%iter
      68             :        CALL VYukawaFilm( stars, vacuum, cell, sym, input, mpi, atoms, sphhar, oneD, noco, resDenMod, &
      69           0 :             vYukawa )
      70             :     END IF
      71             : 
      72           6 :     MPI0_c: IF( mpi%irank == 0 ) THEN
      73           3 :        resDen%pw(1:stars%ng3,1) = resDen%pw(1:stars%ng3,1) - input%preconditioning_param ** 2 / fpi_const * vYukawa%pw(1:stars%ng3,1)
      74          18 :        DO n = 1, atoms%ntype
      75         243 :           DO lh = 0, sphhar%nlhd
      76             :              resDen%mt(1:atoms%jri(n),lh,n,1) = resDen%mt(1:atoms%jri(n),lh,n,1) &
      77             :                   - input%preconditioning_param ** 2 / fpi_const &
      78         240 :                   * vYukawa%mt(1:atoms%jri(n),lh,n,1) * atoms%rmsh(1:atoms%jri(n),n) ** 2
      79             :           END DO
      80             :        END DO
      81           3 :        resDen%vacz  = resDen%vacz  - input%preconditioning_param ** 2 / fpi_const * vYukawa%vacz
      82           3 :        resDen%vacxy = resDen%vacxy - input%preconditioning_param ** 2 / fpi_const * vYukawa%vacxy
      83           3 :        IF( input%jspins == 2 ) CALL resDen%ChargeAndMagnetisationToSpins()
      84             :        ! fix the preconditioned density
      85           3 :        CALL outDen%addPotDen( resDen, inDen )
      86           3 :        CALL qfix(mpi,stars, atoms, sym, vacuum, sphhar, input, cell, oneD, outDen, noco%l_noco, .FALSE., .TRUE., fix )
      87           3 :        CALL resDen%subPotDen( outDen, inDen )
      88             :     END IF MPI0_c
      89           6 :     CALL precon_v%from_density(resden)
      90             : 
      91           6 :   END SUBROUTINE kerker
      92             : 
      93             : END MODULE m_kerker

Generated by: LCOV version 1.13