LCOV - code coverage report
Current view: top level - src/65_paw - m_paw_efield.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 95.2 % 21 20
Test Date: 2026-09-20 15:27:41 Functions: 100.0 % 1 1

            Line data    Source code
       1              : !!****m* ABINIT/m_paw_efield
       2              : !! NAME
       3              : !!  m_paw_efield
       4              : !!
       5              : !! FUNCTION
       6              : !!  This module contains routines related to the treatment of electric field in the PAW approach.
       7              : !!
       8              : !! COPYRIGHT
       9              : !! Copyright (C) 2018-2026 ABINIT group (FJ, PH)
      10              : !! This file is distributed under the terms of the
      11              : !! GNU General Public License, see ~abinit/COPYING
      12              : !! or http://www.gnu.org/copyleft/gpl.txt .
      13              : !!
      14              : !! SOURCE
      15              : 
      16              : #if defined HAVE_CONFIG_H
      17              : #include "config.h"
      18              : #endif
      19              : 
      20              : #include "abi_common.h"
      21              : 
      22              : MODULE m_paw_efield
      23              : 
      24              :  use defs_basis
      25              :  use m_abicore
      26              :  use m_errors
      27              :  use m_time, only : timab
      28              :  use m_xmpi, only : xmpi_sum
      29              : 
      30              :  use m_pawtab,   only : pawtab_type
      31              :  use m_pawrhoij, only : pawrhoij_type
      32              : 
      33              :  implicit none
      34              : 
      35              :  private
      36              : 
      37              : !public procedures.
      38              :  public :: pawpolev ! Compute the PAW on-site term for polarization
      39              : 
      40              : CONTAINS  !========================================================================================
      41              : !!***
      42              : 
      43              : !----------------------------------------------------------------------
      44              : 
      45              : !!****f* ABINIT/pawpolev
      46              : !! NAME
      47              : !! pawpolev
      48              : !!
      49              : !! FUNCTION
      50              : !! Compute the PAW term for polarization, named expected value term
      51              : !!
      52              : !! COPYRIGHT
      53              : !! Copyright (C) 1998-2026 ABINIT group (FJ, PH)
      54              : !! This file is distributed under the terms of the
      55              : !! GNU General Public License, see ~abinit/COPYING
      56              : !! or http://www.gnu.org/copyleft/gpl.txt .
      57              : !! For the initials of contributors, see ~abinit/doc/developers/contributors.txt.
      58              : !!
      59              : !! INPUTS
      60              : !!  comm_atom=--optional-- MPI communicator over atoms
      61              : !!  my_natom=number of atoms treated by current processor
      62              : !!  natom=number of atoms in cell.
      63              : !!  ntypat = number of atom types
      64              : !!  pawrhoij(natom) <type(pawrhoij_type)>= paw rhoij occupancies and related data
      65              : !!  pawtab(ntypat) <type(pawtab_type)>=paw tabulated starting data
      66              : !!
      67              : !! OUTPUT
      68              : !!  pelev(3)= electronic polarisation. expectation value term (PAW only)
      69              : !!
      70              : !! SOURCE
      71              : 
      72           99 : subroutine pawpolev(my_natom,natom,ntypat,pawrhoij,pawtab,pelev,&
      73              : &                   comm_atom) ! optional argument (parallelism)
      74              : 
      75              : !Arguments ---------------------------------------------
      76              : !scalars
      77              :  integer,intent(in) :: my_natom,natom,ntypat
      78              :  integer,optional,intent(in) :: comm_atom
      79              : !arrays
      80              :  real(dp),intent(out) :: pelev(3)
      81              :  type(pawrhoij_type),intent(in) :: pawrhoij(my_natom)
      82              :  type(pawtab_type),intent(in) :: pawtab(ntypat)
      83              : 
      84              : 
      85              : !Local variables ---------------------------------------
      86              : !scalars
      87              :  integer :: iatom,idir,ierr,irhoij,ispden,itypat,jrhoij,klmn
      88              :  logical :: paral_atom
      89              :  real(dp) :: c1,ro_dlt
      90              : !arrays
      91              :  integer,dimension(3) :: idirindx = (/4,2,3/)
      92              :  real(dp) :: tsec(2)
      93              : 
      94              : ! *************************************************************************
      95              : 
      96              :  DBG_ENTER("COLL")
      97              : 
      98           99 :  call timab(560,1,tsec)
      99              : 
     100           99 :  if (my_natom>0) then
     101           99 :    ABI_CHECK(pawrhoij(1)%qphase==1,'pawpolev not supposed to be called with qphase/=1!')
     102              :  end if
     103              : 
     104              : !Check for parallelism over atoms
     105           99 :  paral_atom=(present(comm_atom).and.(my_natom/=natom))
     106              : 
     107              : !note that when vector r is expanded in real spherical harmonics, the factor
     108              : !sqrt(four_pi/three) appears, as in the following
     109              : !x = sqrt(four_pi/three)*r*S_{1,1}
     110              : !y = sqrt(four_pi/three)*r*S_{1,-1}
     111              : !z = sqrt(four_pi/three)*r*S_{1,0}
     112              : !
     113              : !the moments pawtab()%qijl do not include such normalization factors
     114              : !see pawinit.F90 for their definition and computation
     115              : 
     116           99 :  c1=sqrt(four_pi/three)
     117              : 
     118           99 :  pelev=zero
     119          396 :  do idir=1,3
     120          990 :    do iatom=1,my_natom
     121          594 :      itypat=pawrhoij(iatom)%itypat
     122         1485 :      do ispden=1,pawrhoij(iatom)%nspden
     123          594 :        jrhoij=1
     124        18741 :        do irhoij=1,pawrhoij(iatom)%nrhoijsel
     125        17553 :          klmn=pawrhoij(iatom)%rhoijselect(irhoij)
     126        17553 :          ro_dlt=pawrhoij(iatom)%rhoijp(jrhoij,ispden)*pawtab(itypat)%dltij(klmn)
     127        17553 :          pelev(idir)=pelev(idir)+ro_dlt*c1*pawtab(itypat)%qijl(idirindx(idir),klmn)
     128        18147 :          jrhoij=jrhoij+pawrhoij(iatom)%cplex_rhoij
     129              :        end do
     130              :      end do
     131              :    end do
     132              :  end do
     133              : 
     134           99 :  if (paral_atom) then
     135            0 :    call xmpi_sum(pelev,comm_atom,ierr)
     136              :  end if
     137              : 
     138           99 :  call timab(560,2,tsec)
     139              : 
     140              :  DBG_EXIT("COLL")
     141              : 
     142           99 : end subroutine pawpolev
     143              : !!***
     144              : 
     145              : !----------------------------------------------------------------------
     146              : 
     147              : END MODULE m_paw_efield
     148              : !!***
        

Generated by: LCOV version 2.3-1