Commit 62285e99 authored by Gregor Michalicek's avatar Gregor Michalicek

Eliminate mixDen and introduce vTemp

parent 2cf89a49
......@@ -233,18 +233,13 @@ CONTAINS
!---> loop over spins
nspins = input%jspins
IF (noco%l_noco) nspins = 1
!
! ..
! LDA+U
! LDA+U
IF ((atoms%n_u.GT.0)) THEN
ALLOCATE( vTot%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,input%jspins) )
CALL u_setup(sym,atoms,sphhar,input,enpara%el0(0:,:,:),inDen,vTot,mpi,results)
ELSE
ALLOCATE( vTot%mmpMat(-lmaxU_const:-lmaxU_const,-lmaxU_const:-lmaxU_const,1,2) )
ENDIF
!
!---> loop over k-points: each can be a separate task
END IF
!---> loop over k-points: each can be a separate task
DO jsp = 1,nspins
......@@ -411,7 +406,6 @@ ENDIF
DEALLOCATE (td%ind,td%tuulo,td%tdulo)
DEALLOCATE (td%tuloulo)
END DO ! spin loop ends
DEALLOCATE(vTot%mmpMat)
DEALLOCATE (matind)
IF (l_real) THEN
DEALLOCATE(hamOvlp%a_r,hamOvlp%b_r)
......
......@@ -102,8 +102,8 @@ CONTAINS
TYPE(t_mpi) :: mpi
TYPE(t_coreSpecInput) :: coreSpecInput
TYPE(t_wann) :: wann
TYPE(t_potden) :: vTot,vx,vCoul
TYPE(t_potden) :: inDen, outDen, mixDen
TYPE(t_potden) :: vTot,vx,vCoul,vTemp
TYPE(t_potden) :: inDen, outDen
! .. Local Scalars ..
INTEGER:: eig_id, archiveType
......@@ -196,18 +196,19 @@ CONTAINS
ALLOCATE (inDen%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
! Initialize and load inDen density without density matrix(end)
! Initialize mixDen density (start)
CALL mixDen%init(stars,atoms,sphhar,vacuum,oneD,input%jspins,.FALSE.)
IF (noco%l_noco) THEN
ALLOCATE (mixDen%cdom(stars%ng3),mixDen%cdomvz(vacuum%nmzd,2))
ALLOCATE (mixDen%cdomvxy(vacuum%nmzxyd,oneD%odi%n2d-1,2))
archiveType = CDN_ARCHIVE_TYPE_NOCO_const
! Initialize potentials (start)
CALL vTot%init(stars,atoms,sphhar,vacuum,oneD,DIMENSION%jspd,noco%l_noco)
CALL vCoul%init(stars,atoms,sphhar,vacuum,oneD,DIMENSION%jspd,noco%l_noco)
CALL vx%init(stars%ng3,atoms%jmtd,sphhar%nlhd,atoms%ntype,DIMENSION%jspd,.FALSE.)
CALL vTemp%init(stars,atoms,sphhar,vacuum,oneD,DIMENSION%jspd,noco%l_noco)
IF ((atoms%n_u.GT.0)) THEN
ALLOCATE(vTot%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,input%jspins))
ALLOCATE(vTemp%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,input%jspins))
ELSE
ALLOCATE (mixDen%cdom(1),mixDen%cdomvz(1,1),mixDen%cdomvxy(1,1,1))
archiveType = CDN_ARCHIVE_TYPE_CDN1_const
ALLOCATE(vTot%mmpMat(-lmaxU_const:-lmaxU_const,-lmaxU_const:-lmaxU_const,1,2))
ALLOCATE(vTemp%mmpMat(-lmaxU_const:-lmaxU_const,-lmaxU_const:-lmaxU_const,1,2))
ENDIF
ALLOCATE (mixDen%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
! Initialize mixDen density (end)
! Initialize potentials (end)
DO WHILE (l_cont)
......@@ -393,9 +394,11 @@ CONTAINS
! WRITE(6,fmt='(A)') 'Starting 1st variation ...'
CALL timestart("eigen")
IF (mpi%irank==0) WRITE(*,"(a)",advance="no") "* Eigenvalue problem "
vTemp = vTot
CALL eigen(mpi,stars,sphhar,atoms,obsolete,xcpot,&
sym,kpts,DIMENSION,vacuum,input,cell,enpara,banddos,noco,jij,oneD,hybrid,&
it,eig_id,inDen,results,vTot,vx)
it,eig_id,inDen,results,vTemp,vx)
vTot%mmpMat = vTemp%mmpMat
eig_idList(pc) = eig_id
CALL timestop("eigen")
!
......@@ -675,8 +678,7 @@ CONTAINS
!
CALL timestart("mixing")
IF (mpi%irank==0) WRITE(*,"(a)",advance="no") "* Mixing distance: "
CALL mix(stars,atoms,sphhar,vacuum,input,sym,cell,noco,oneD,hybrid,archiveType,inDen,outDen,results,mixDen)
inDen = mixDen
CALL mix(stars,atoms,sphhar,vacuum,input,sym,cell,noco,oneD,hybrid,archiveType,inDen,outDen,results)
CALL timestop("mixing")
WRITE (6,FMT=8130) it
......
......@@ -16,7 +16,7 @@ MODULE m_mix
CONTAINS
SUBROUTINE mix(stars,atoms,sphhar,vacuum,input,sym,cell,noco,oneD,&
hybrid,archiveType,inDen,outDen,results,mixDen)
hybrid,archiveType,inDen,outDen,results)
#include"cpp_double.h"
......@@ -44,9 +44,9 @@ SUBROUTINE mix(stars,atoms,sphhar,vacuum,input,sym,cell,noco,oneD,&
TYPE(t_cell),INTENT(IN) :: cell
TYPE(t_sphhar),INTENT(IN) :: sphhar
TYPE(t_atoms),INTENT(INOUT) :: atoms !n_u is modified temporarily
TYPE(t_potden),INTENT(IN) :: inDen, outDen
TYPE(t_potden),INTENT(IN) :: outDen
TYPE(t_results),INTENT(INOUT) :: results
TYPE(t_potden),INTENT(INOUT) :: mixDen
TYPE(t_potden),INTENT(INOUT) :: inDen
INTEGER, INTENT(IN) :: archiveType
!Local Scalars
......@@ -199,14 +199,14 @@ SUBROUTINE mix(stars,atoms,sphhar,vacuum,input,sym,cell,noco,oneD,&
END IF
!initiatlize mixed density and extract it with brysh2 call
mixDen%cdom = CMPLX(0.0,0.0)
mixDen%cdomvz = CMPLX(0.0,0.0)
mixDen%cdomvxy = CMPLX(0.0,0.0)
mixDen%mmpMat = CMPLX(0.0,0.0)
inDen%cdom = CMPLX(0.0,0.0)
inDen%cdomvz = CMPLX(0.0,0.0)
inDen%cdomvxy = CMPLX(0.0,0.0)
inDen%mmpMat = CMPLX(0.0,0.0)
CALL brysh2(input,stars,atoms,sphhar,noco,vacuum,sym,sm,mixDen%mmpMat,oneD,&
mixDen%pw,mixDen%mt,mixDen%vacz,mixDen%vacxy,mixDen%cdom,&
mixDen%cdomvz,mixDen%cdomvxy)
CALL brysh2(input,stars,atoms,sphhar,noco,vacuum,sym,sm,inDen%mmpMat,oneD,&
inDen%pw,inDen%mt,inDen%vacz,inDen%vacxy,inDen%cdom,&
inDen%cdomvz,inDen%cdomvxy)
!calculate the distance of charge densities...
......@@ -272,17 +272,17 @@ SUBROUTINE mix(stars,atoms,sphhar,vacuum,input,sym,cell,noco,oneD,&
!fix charge of the new density
CALL qfix(stars,atoms,sym,vacuum, sphhar,input,cell,oneD,&
mixDen%pw,mixDen%vacxy,mixDen%mt,mixDen%vacz,.FALSE.,.false., fix)
inDen%pw,inDen%vacxy,inDen%mt,inDen%vacz,.FALSE.,.false., fix)
!write out mixed density
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
1,results%last_distance,results%ef,.TRUE.,iter,mixDen%mt,mixDen%pw,mixDen%vacz,&
mixDen%vacxy,mixDen%cdom,mixDen%cdomvz,mixDen%cdomvxy)
mixDen%iter = inDen%iter + 1
1,results%last_distance,results%ef,.TRUE.,iter,inDen%mt,inDen%pw,inDen%vacz,&
inDen%vacxy,inDen%cdom,inDen%cdomvz,inDen%cdomvxy)
inDen%iter = inDen%iter + 1
IF (atoms%n_u > 0) THEN
OPEN (69,file='n_mmp_mat',status='replace',form='formatted')
WRITE (69,'(7f20.13)') mixDen%mmpMat(:,:,:,:)
WRITE (69,'(7f20.13)') inDen%mmpMat(:,:,:,:)
CLOSE (69)
ENDIF
......
......@@ -69,7 +69,7 @@ CONTAINS
TYPE(t_sphhar),INTENT(IN) :: sphhar
TYPE(t_atoms),INTENT(INOUT) :: atoms !vr0 is updated
TYPE(t_potden), INTENT(IN) :: den
TYPE(t_potden),INTENT(OUT) :: vTot,vx,vCoul
TYPE(t_potden),INTENT(INOUT) :: vTot,vx,vCoul
! ..
! .. Scalar Arguments ..
LOGICAL, INTENT (IN) :: reap
......@@ -122,14 +122,12 @@ CONTAINS
! ivac=1: upper (positive z) vacuum
! units: hartrees
!
CALL vTot%init(stars,atoms,sphhar,vacuum,oneD,DIMENSION%jspd,noco%l_noco)
CALL vCoul%init(stars,atoms,sphhar,vacuum,oneD,DIMENSION%jspd,noco%l_noco)
ALLOCATE ( alphm(stars%ng2,2),excpw(stars%ng3),excxy(vacuum%nmzxyd,oneD%odi%n2d-1,2),&
vbar(dimension%jspd),af1(3*stars%mx3),bf1(3*stars%mx3),xp(3,dimension%nspd),&
vpw_exx(stars%ng3,dimension%jspd),vpw_wexx(stars%ng3,dimension%jspd),&
excz(vacuum%nmzd,2),excr(atoms%jmtd,0:sphhar%nlhd,atoms%ntype),&
vpw_w(stars%ng3,dimension%jspd),vxpw_w(stars%ng3,dimension%jspd),psq(stars%ng3) )
CALL vx%init(stars%ng3,atoms%jmtd,sphhar%nlhd,atoms%ntype,DIMENSION%jspd,.FALSE.)
vTot%iter = den%iter
CALL workDen%init(stars,atoms,sphhar,vacuum,oneD,DIMENSION%jspd,.FALSE.)
......
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