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

Eliminate mixDen and introduce vTemp

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