Commit e31807ef authored by Gregor Michalicek's avatar Gregor Michalicek

Some cleanups in cdn/cdnval.F90 and related files

Note: This cleanup includes the inclusion of the qvlay array
into the t_regionCharges type. This breaks the program logic
for the noco%l_noco case as it is created inside a certain
spin loop but should be created outside this loop. It is not
yet clear how this will be solved. Probably the regCharges
type should just move to cdngen and the arrays in it should
have full spin dimensions.
parent be85e5a1
......@@ -2,8 +2,8 @@ MODULE m_cdnval
use m_juDFT
CONTAINS
SUBROUTINE cdnval(eig_id, mpi,kpts,jspin,sliceplot,noco, input,banddos,cell,atoms,enpara,stars,&
vacuum,dimension,sphhar,sym,obsolete,vTot,oneD,coreSpecInput,den,results,&
qvlay,qa21, chmom,clmom)
vacuum,dimension,sphhar,sym,obsolete,vTot,oneD,coreSpecInput,den,results,&
qa21,chmom,clmom)
!
! ***********************************************************
! this subroutin is a modified version of cdnval.F.
......@@ -114,7 +114,6 @@ CONTAINS
COMPLEX, INTENT(INOUT) :: qa21(atoms%ntype)
REAL, INTENT(OUT) :: chmom(atoms%ntype,dimension%jspd)
REAL, INTENT(OUT) :: clmom(3,atoms%ntype,dimension%jspd)
REAL, INTENT(INOUT) :: qvlay(dimension%neigd,vacuum%layerd,2,kpts%nkpt,dimension%jspd)
#ifdef CPP_MPI
INCLUDE 'mpif.h'
......@@ -129,7 +128,6 @@ CONTAINS
! ...Local Arrays ..
INTEGER :: n_bands(0:dimension%neigd)
REAL :: eig(dimension%neigd)
REAL :: vz0(2)
REAL, ALLOCATABLE :: orbcomp(:,:,:),qmtp(:,:) ! orbcomp
INTEGER, ALLOCATABLE :: gvac1d(:),gvac2d(:)
......@@ -186,7 +184,7 @@ CONTAINS
CALL denCoeffs%init(atoms,sphhar,jsp_start,jsp_end)
CALL denCoeffsOffdiag%init(atoms,noco,sphhar,l_fmpl)
CALL force%init1(input,atoms)
CALL regCharges%init(atoms,dimension,kpts,jsp_start,jsp_end)
CALL regCharges%init(atoms,dimension,kpts,vacuum,jsp_start,jsp_end)
CALL orb%init(atoms,noco,jsp_start,jsp_end)
CALL mcd%init1(banddos,dimension,input,atoms)
......@@ -247,8 +245,6 @@ CONTAINS
END DO
DEALLOCATE (f,g,flo)
IF (input%film) vz0(:) = vTot%vacz(vacuum%nmz,:,jspin)
CALL slab%init(banddos,dimension,atoms,cell)
IF ((banddos%ndir.EQ.-3).AND.banddos%dos) THEN
......@@ -352,11 +348,9 @@ CONTAINS
!ENDIF
!
IF (vacuum%nstm.EQ.3.AND.input%film) THEN
CALL nstm3(sym,atoms,vacuum,stars,ikpt,lapw%nv(jspin),&
input,jspin,kpts,&
CALL nstm3(sym,atoms,vacuum,stars,ikpt,lapw%nv(jspin),input,jspin,kpts,&
cell,kpts%wtkpt(ikpt),lapw%k1(:,jspin),lapw%k2(:,jspin),&
enpara%evac0(1,jspin),vTot%vacz(:,:,jspin),vz0,&
gvac1d,gvac2d)
enpara%evac0(1,jspin),vTot%vacz(:,:,jspin),gvac1d,gvac2d)
END IF
IF (noccbd.EQ.0) GO TO 199
......@@ -456,8 +450,8 @@ CONTAINS
IF (.NOT.((jspin.EQ.2) .AND. noco%l_noco)) THEN
CALL timestart("cdnval: vacden")
CALL vacden(vacuum,dimension,stars,oneD, kpts,input, cell,atoms,noco,banddos,&
gvac1d,gvac2d, we,ikpt,jspin,vTot%vacz(:,:,jspin),vz0, noccbd,lapw, enpara%evac0,eig,&
den,regCharges%qvac,qvlay, qstars,zMat)
gvac1d,gvac2d, we,ikpt,jspin,vTot%vacz(:,:,jspin),noccbd,lapw,enpara%evac0,eig,&
den,regCharges%qvac,regCharges%qvlay,qstars,zMat)
CALL timestop("cdnval: vacden")
END IF
!---> perform Brillouin zone integration and summation over the
......@@ -502,14 +496,12 @@ CONTAINS
skip_t,l_evp,eigVecCoeffs,usdus,regCharges,mcd,banddos%l_mcd)
IF (noco%l_mperp.AND.(ispin == jsp_end)) THEN
CALL qal_21(atoms,input,noccbd,we,noco,eigVecCoeffs,denCoeffsOffdiag,regCharges,qmat)
CALL qal_21(atoms,input,noccbd,noco,eigVecCoeffs,denCoeffsOffdiag,regCharges,qmat)
END IF
END IF
!
!+new
!---> layer charge of each valence state in this k-point of the SBZ
!---> from the mt-sphere region of the film
!
IF (banddos%dos.AND.(banddos%ndir.EQ.-3)) THEN
CALL q_mt_sl(ispin,atoms,noccbd,ikpt,noccbd,skip_t,noccbd,eigVecCoeffs,usdus,slab)
......@@ -581,7 +573,7 @@ CONTAINS
!--dw now write k-point data to tmp_dos
CALL write_dos(eig_id,ikpt,jspin,regCharges%qal(:,:,:,jspin),regCharges%qvac(:,:,ikpt,jspin),regCharges%qis(:,ikpt,jspin),&
qvlay(:,:,:,ikpt,jspin),qstars,ksym,jsym,mcd%mcd,slab%qintsl,&
regCharges%qvlay(:,:,:,ikpt,jspin),qstars,ksym,jsym,mcd%mcd,slab%qintsl,&
slab%qmtsl(:,:),qmtp(:,:),orbcomp)
CALL timestop("cdnval: write_info")
......
......@@ -5,7 +5,7 @@ MODULE m_qal21
!***********************************************************************
!
CONTAINS
SUBROUTINE qal_21(atoms,input,noccbd,we,noco,eigVecCoeffs,denCoeffsOffdiag,regCharges,qmat)
SUBROUTINE qal_21(atoms,input,noccbd,noco,eigVecCoeffs,denCoeffsOffdiag,regCharges,qmat)
USE m_rotdenmat
USE m_types
......@@ -16,14 +16,12 @@ CONTAINS
TYPE(t_eigVecCoeffs), INTENT(IN) :: eigVecCoeffs
TYPE (t_denCoeffsOffdiag), INTENT(IN) :: denCoeffsOffdiag
TYPE(t_regionCharges), INTENT(INOUT) :: regCharges
! ..
! .. Scalar Arguments ..
INTEGER, INTENT (IN) :: noccbd
! ..
INTEGER, INTENT (IN) :: noccbd
! .. Array Arguments ..
REAL, INTENT (INout) :: we(noccbd)
REAL, INTENT (OUT) :: qmat(0:,:,:,:)!(0:3,atoms%ntype,DIMENSION%neigd,4)
! ..
! .. Local Scalars ..
INTEGER i,l,lo,lop ,natom,nn,ntyp
......
......@@ -9,7 +9,7 @@ CONTAINS
vacuum,DIMENSION,stars,oneD,&
kpts,input,cell,atoms,noco,banddos,&
gvac1,gvac2,&
we,ikpt,jspin,vz,vz0,&
we,ikpt,jspin,vz,&
ne,lapw,&
evac,eig,den,qvac,qvlay,&
stcoeff,zMat)
......@@ -73,10 +73,11 @@ CONTAINS
INTEGER,PARAMETER :: n2max=13
REAL,PARAMETER :: emax=2.0/hartree_to_ev_const
! .. Array Arguments ..
REAL, INTENT (IN) :: evac(2,DIMENSION%jspd)
REAL, INTENT (OUT) :: qvlay(DIMENSION%neigd,vacuum%layerd,2,kpts%nkpt,DIMENSION%jspd)
REAL qvac(DIMENSION%neigd,2,kpts%nkpt,DIMENSION%jspd),we(DIMENSION%neigd),vz(vacuum%nmzd,2),vz0(2)
!
REAL, INTENT(IN) :: evac(2,DIMENSION%jspd)
REAL, INTENT(OUT) :: qvlay(DIMENSION%neigd,vacuum%layerd,2,kpts%nkpt,DIMENSION%jspd)
REAL, INTENT(INOUT) :: qvac(DIMENSION%neigd,2,kpts%nkpt,DIMENSION%jspd)
REAL, INTENT(IN) :: we(DIMENSION%neigd)
REAL :: vz(vacuum%nmzd,2) ! Note this breaks the INTENT(IN) from cdnval. It may be read from a file in this subroutine.
! STM-Arguments
REAL, INTENT (IN) :: eig(DIMENSION%neigd)
INTEGER, INTENT (IN) :: gvac1(DIMENSION%nv2d),gvac2(DIMENSION%nv2d)
......@@ -101,7 +102,7 @@ CONTAINS
& ind1,ind1p,irec2,irec3,m
!
! .. Local Arrays ..
REAL qssbti(3,2),qssbtii
REAL qssbti(3,2),qssbtii,vz0(2)
REAL bess(-oneD%odi%mb:oneD%odi%mb),dbss(-oneD%odi%mb:oneD%odi%mb)
COMPLEX, ALLOCATABLE :: ac(:,:,:),bc(:,:,:)
REAL, ALLOCATABLE :: dt(:),dte(:),du(:),ddu(:,:),due(:)
......@@ -165,6 +166,7 @@ CONTAINS
END IF ! oneD%odi%d1
!
vz0(:) = vz(vacuum%nmz,:)
eps=0.01
ic = CMPLX(0.,1.)
! ------------------
......
......@@ -13,7 +13,7 @@ CONTAINS
& sym,atoms,vacuum,stars,ikpt,nv,&
& input,jspin,kpts,&
& cell,wk,k1,k2,&
& evac,vz,vz0,&
& evac,vz,&
& gvac1d,gvac2d)
!
USE m_sort
......@@ -37,7 +37,6 @@ CONTAINS
INTEGER, INTENT (IN) :: k1(:),k2(:)
REAL, INTENT (IN) :: evac(2)
REAL, INTENT (IN) :: vz(:,:)!(vacuum%nmzd,2)
REAL, INTENT (IN) :: vz0(2)
INTEGER, INTENT (OUT) :: gvac1d(:),gvac2d(:) !(dimension%nv2d)
! ..
! .. Local Scalars
......@@ -103,7 +102,7 @@ CONTAINS
END IF
WRITE (87,'(i1,1x,i1)') jspin, vacuum%nvac
WRITE (87,'(2(e16.8,1x))') (evac(i), i=1,vacuum%nvac)
WRITE (87,'(2(e16.8,1x))') (vz0(i), i=1,vacuum%nvac)
WRITE (87,'(2(e16.8,1x))') (vz(vacuum%nmz,i), i=1,vacuum%nvac)
dz0=0.0
DO i=1, atoms%nat
IF (ABS(atoms%taual(3,i)).GT.dz0) dz0=ABS(atoms%taual(3,i))
......
......@@ -75,15 +75,12 @@ SUBROUTINE cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,&
!Local Arrays
REAL stdn(atoms%ntype,dimension%jspd),svdn(atoms%ntype,dimension%jspd)
REAL chmom(atoms%ntype,dimension%jspd),clmom(3,atoms%ntype,dimension%jspd)
REAL ,ALLOCATABLE :: qvlay(:,:,:,:,:)
COMPLEX,ALLOCATABLE :: qa21(:)
ALLOCATE (qa21(atoms%ntype))
ALLOCATE (qvlay(dimension%neigd,vacuum%layerd,2,kpts%nkpt,dimension%jspd))
!initialize density arrays with zero
qa21(:) = cmplx(0.0,0.0)
qvlay(:,:,:,:,:) = 0.0
IF (mpi%irank.EQ.0) CALL openXMLElementNoAttributes('valenceDensity')
......@@ -98,7 +95,7 @@ SUBROUTINE cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,&
CALL cdnval(eig_id,&
mpi,kpts,jspin,sliceplot,noco,input,banddos,cell,atoms,enpara,stars,vacuum,dimension,&
sphhar,sym,obsolete,vTot,oneD,coreSpecInput,&
outDen,results,qvlay,qa21,chmom,clmom)
outDen,results,qa21,chmom,clmom)
CALL timestop("cdngen: cdnval")
END DO
......@@ -143,7 +140,7 @@ SUBROUTINE cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,&
CALL mpi_bc_potden(mpi,stars,sphhar,atoms,input,vacuum,oneD,noco,outDen)
#endif
DEALLOCATE (qvlay,qa21)
DEALLOCATE (qa21)
END SUBROUTINE cdngen
......
......@@ -168,6 +168,7 @@ PRIVATE
REAL, ALLOCATABLE :: qvac(:,:,:,:)
REAL, ALLOCATABLE :: svac(:,:)
REAL, ALLOCATABLE :: pvac(:,:)
REAL, ALLOCATABLE :: qvlay(:,:,:,:,:)
CONTAINS
PROCEDURE,PASS :: init => regionCharges_init
......@@ -598,7 +599,7 @@ SUBROUTINE mcd_init1(thisMCD,banddos,dimension,input,atoms)
END SUBROUTINE mcd_init1
SUBROUTINE regionCharges_init(thisRegCharges,atoms,dimension,kpts,jsp_start,jsp_end)
SUBROUTINE regionCharges_init(thisRegCharges,atoms,dimension,kpts,vacuum,jsp_start,jsp_end)
USE m_types_setup
USE m_types_kpts
......@@ -609,6 +610,7 @@ SUBROUTINE regionCharges_init(thisRegCharges,atoms,dimension,kpts,jsp_start,jsp_
TYPE(t_atoms), INTENT(IN) :: atoms
TYPE(t_dimension), INTENT(IN) :: dimension
TYPE(t_kpts), INTENT(IN) :: kpts
TYPE(t_vacuum), INTENT(IN) :: vacuum
INTEGER, INTENT(IN) :: jsp_start
INTEGER, INTENT(IN) :: jsp_end
......@@ -624,6 +626,7 @@ SUBROUTINE regionCharges_init(thisRegCharges,atoms,dimension,kpts,jsp_start,jsp_
ALLOCATE(thisRegCharges%qvac(dimension%neigd,2,kpts%nkpt,dimension%jspd))
ALLOCATE(thisRegCharges%svac(2,jsp_start:jsp_end))
ALLOCATE(thisRegCharges%pvac(2,jsp_start:jsp_end))
ALLOCATE(thisRegCharges%qvlay(dimension%neigd,vacuum%layerd,2,kpts%nkpt,dimension%jspd))
thisRegCharges%qis = 0.0
......@@ -637,6 +640,7 @@ SUBROUTINE regionCharges_init(thisRegCharges,atoms,dimension,kpts,jsp_start,jsp_
thisRegCharges%qvac = 0.0
thisRegCharges%svac = 0.0
thisRegCharges%pvac = 0.0
thisRegCharges%qvlay = 0.0
END SUBROUTINE regionCharges_init
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment