! ! Copyright (C) 2015-2017 M. Govoni ! This file is distributed under the terms of the ! GNU General Public License. See the file `License' ! in the root directory of the present distribution, ! or http://www.gnu.org/copyleft/gpl.txt . ! ! This file is part of WEST. ! ! Contributors to this file: ! Marco Govoni ! !----------------------------------------------------------------------- SUBROUTINE store_sqvc(sqvc_tmp,numg,singularity_removal_mode,div) !----------------------------------------------------------------------- ! ! This routine computes results of applying sqVc to a potential ! associated with vector q. Coulomb cutoff technique can be used ! USE kinds, ONLY : DP USE io_global, ONLY : stdout USE constants, ONLY : fpi, e2, tpi, pi USE cell_base, ONLY : tpiba2, tpiba,omega,at,alat,bg USE gvect, ONLY : g, gstart USE coulomb_vcut_module, ONLY : vcut_init, vcut_type, vcut_info, & vcut_get, vcut_spheric_get, vcut_destroy USE mp, ONLY : mp_sum USE mp_global, ONLY : intra_bgrp_comm USE mp_world, ONLY : mpime,world_comm,nproc USE gvecw, ONLY : ecutwfc USE control_flags, ONLY : gamma_only USE random_numbers, ONLY : randy ! IMPLICIT NONE ! ! I/O ! INTEGER,INTENT(IN) :: numg REAL(DP),INTENT(OUT) :: sqvc_tmp(numg) INTEGER,INTENT(IN) :: singularity_removal_mode REAL(DP),INTENT(OUT) :: div ! ! Workspace ! REAL(DP) :: gnorm2,q(3),x,nq(3),ecutvcut,atws(3,3),dq(3),xq(3),alpha INTEGER :: ig, ipol, iq1, iq2, iq3, i1, i2, i3 LOGICAL :: on_double_grid REAL(DP),PARAMETER :: eps=1.d-6 REAL(DP) :: grid_factor = 8.d0/7.d0 TYPE(vcut_type) :: vcut LOGICAL :: try_ort_div=.TRUE.,i_am_ort REAL(DP) :: prod(3,3), qhelp, edge(3), qbz(3), rand, qmo, vbz, vhelp REAL(DP) :: intcounter ! CALL start_clock('storesqvc') ! ! ====== ! BODY ! ====== ! SELECT CASE(singularity_removal_mode) ! CASE(1) ! ! In this case we use the spherical region ! sqvc_tmp(1)=0._DP DO ig = gstart,numg gnorm2 = ( g(1,ig)*g(1,ig) + g(2,ig)*g(2,ig) + g(3,ig)*g(3,ig) ) * tpiba2 sqvc_tmp(ig) = SQRT(e2*fpi/gnorm2) ENDDO ! CASE(2) ! ! In this case we use Gygi-Baldereschi method ! nq(1)=1._DP nq(2)=1._DP nq(3)=1._DP ! sqvc_tmp(1)=0._DP DO ig = gstart,numg q(:) = g(:,ig) gnorm2 = SUM(q(:)**2) * tpiba2 on_double_grid = .TRUE. DO ipol = 1,3 x = 0.5_DP*( q(1)*at(1,ipol)+q(2)*at(2,ipol)+q(3)*at(3,ipol) )*nq(ipol) on_double_grid = on_double_grid .AND. (ABS(x-NINT(x))