Commit d809e852 authored by Gregor Michalicek's avatar Gregor Michalicek

Move reading of density matrix to same location as reading of density

parent 5b87fe42
......@@ -9,7 +9,7 @@ MODULE m_eigen
CONTAINS
SUBROUTINE eigen(mpi,stars,sphhar,atoms,obsolete,xcpot,&
sym,kpts,DIMENSION, vacuum, input, cell, enpara_in,banddos, noco,jij, oneD,hybrid,&
it,eig_id,results,v,vx)
it,eig_id,inDen,results,v,vx)
!*********************************************************************
! sets up and solves the eigenvalue problem for a basis of lapws.
!
......@@ -61,8 +61,9 @@ CONTAINS
TYPE(t_cell),INTENT(IN) :: cell
TYPE(t_kpts),INTENT(IN) :: kpts
TYPE(t_sphhar),INTENT(IN) :: sphhar
TYPE(t_atoms),INTENT(INOUT) :: atoms!in u_setup n_u might be modified
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_potden),INTENT(INOUT) :: v,vx
TYPE(t_potden),INTENT(INOUT) :: inDen ! inDen%mmpMat is modified in u_setup
#ifdef CPP_MPI
INCLUDE 'mpif.h'
#endif
......@@ -250,7 +251,7 @@ CONTAINS
! LDA+U
IF ((atoms%n_u.GT.0)) THEN
ALLOCATE( v%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,input%jspins) )
CALL u_setup(sym,atoms,sphhar,input, enpara%el0(0:,:,:),v,mpi,results)
CALL u_setup(sym,atoms,sphhar,input,enpara%el0(0:,:,:),inDen,v,mpi,results)
ELSE
ALLOCATE( v%mmpMat(-lmaxU_const:-lmaxU_const,-lmaxU_const:-lmaxU_const,1,2) )
ENDIF
......
......@@ -17,7 +17,7 @@ MODULE m_usetup
! Extension to multiple U per atom type G.M. 2017 |
!-------------------------------------------------------------------+
CONTAINS
SUBROUTINE u_setup(sym,atoms,sphhar, input,el,pot,mpi,results)
SUBROUTINE u_setup(sym,atoms,sphhar, input,el,inDen,pot,mpi,results)
USE m_umtx
USE m_uj2f
USE m_nmat_rot
......@@ -31,7 +31,8 @@ CONTAINS
TYPE(t_mpi),INTENT(IN) :: mpi
TYPE(t_input),INTENT(IN) :: input
TYPE(t_sphhar),INTENT(IN) :: sphhar
TYPE(t_atoms),INTENT(INOUT) :: atoms !n_u might be modified if no density matrix is found
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_potden),INTENT(INOUT) :: inDen
TYPE(t_potden),INTENT(INOUT) :: pot
REAL, INTENT(IN) :: el(0:,:,:) !(0:atoms%lmaxd,ntype,jspd)
......@@ -39,13 +40,12 @@ CONTAINS
INTEGER itype,ispin,j,k,l,jspin,urec,i_u
INTEGER noded,nodeu,ios,lty(atoms%n_u)
REAL wronk
LOGICAL n_mmp_exist,n_exist, l_error
LOGICAL n_mmp_exist,n_exist
CHARACTER*8 l_type*2,l_form*9
CHARACTER*12 ::filename
REAL f(atoms%jmtd,2),g(atoms%jmtd,2),theta(atoms%n_u),phi(atoms%n_u),zero(atoms%n_u)
REAL f0(atoms%n_u,input%jspins),f2(atoms%n_u,input%jspins),f4(atoms%n_u,input%jspins),f6(atoms%n_u,input%jspins)
REAL, ALLOCATABLE :: u(:,:,:,:,:,:)
COMPLEX, ALLOCATABLE :: ns_mmp(:,:,:,:)
!
! look, whether density matrix exists already:
!
......@@ -70,12 +70,6 @@ CONTAINS
u(-lmaxU_const,-lmaxU_const,-lmaxU_const,-lmaxU_const,1,ispin) )
END DO
!
! read density matrix
!
ALLOCATE (ns_mmp(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,input%jspins))
CALL readDensityMatrix(input,atoms,ns_mmp,l_error)
IF(l_error) CALL juDFT_error('Error in reading density matrix!',calledby='u_setup')
!
! check for possible rotation of n_mmp
!
INQUIRE (file='n_mmp_rot',exist=n_exist)
......@@ -95,12 +89,12 @@ CONTAINS
END DO
CLOSE (68)
zero = 0.0
CALL nmat_rot(phi,theta,zero,3,atoms%n_u,input%jspins,lty,ns_mmp)
CALL nmat_rot(phi,theta,zero,3,atoms%n_u,input%jspins,lty,inDen%mmpMat)
ENDIF
!
! calculate potential matrix and total energy correction
!
CALL v_mmp(sym,atoms,input%jspins,ns_mmp,u,f0,f2,&
CALL v_mmp(sym,atoms,input%jspins,inDen%mmpMat,u,f0,f2,&
pot%mmpMat,results)
IF (mpi%irank.EQ.0) THEN
DO jspin = 1,input%jspins
......@@ -111,7 +105,7 @@ CONTAINS
WRITE (l_type,'(i2)') 2*(2*l+1)
l_form = '('//l_type//'f12.7)'
WRITE (6,'(a20,i3)') 'n-matrix for atom # ',itype
WRITE (6,l_form) ((ns_mmp(k,j,i_u,jspin),k=-l,l),j=-l,l)
WRITE (6,l_form) ((inDen%mmpMat(k,j,i_u,jspin),k=-l,l),j=-l,l)
WRITE (6,'(a20,i3)') 'V-matrix for atom # ',itype
IF (atoms%lda_u(i_u)%l_amf) THEN
WRITE (6,*) 'using the around-mean-field limit '
......@@ -123,7 +117,7 @@ CONTAINS
END DO
WRITE (6,*) results%e_ldau
ENDIF
DEALLOCATE ( u,ns_mmp )
DEALLOCATE (u)
ELSE
IF (mpi%irank.EQ.0) THEN
WRITE (*,*) 'no density matrix found ... skipping LDA+U'
......
......@@ -29,13 +29,13 @@ CONTAINS
TYPE(t_atoms),INTENT(IN) :: atoms
!
! .. Arguments ..
INTEGER, INTENT(IN) :: jspins
REAL, INTENT(IN) :: u(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,&
-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u)
REAL, INTENT(IN) :: f0(atoms%n_u),f2(atoms%n_u)
COMPLEX, INTENT(OUT) :: vs_mmp(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,jspins)
INTEGER, INTENT(IN) :: jspins
REAL, INTENT(IN) :: u(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,&
-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u)
REAL, INTENT(IN) :: f0(atoms%n_u),f2(atoms%n_u)
COMPLEX, INTENT(OUT) :: vs_mmp(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,jspins)
COMPLEX :: ns_mmp(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,jspins)
COMPLEX, INTENT(INOUT) :: ns_mmp(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,jspins)
! .. Local Variables ..
INTEGER ispin,jspin,l ,mp,p,q,itype,m,i_u
......
......@@ -108,7 +108,7 @@ CONTAINS
! .. Local Scalars ..
INTEGER:: eig_id, archiveType
INTEGER:: n,it,ithf,pc
LOGICAL:: stop80,reap,l_endit,l_opti,l_cont,l_qfix
LOGICAL:: stop80,reap,l_endit,l_opti,l_cont,l_qfix, l_error
REAL :: fermiEnergyTemp, fix
!--- J<
INTEGER :: phn
......@@ -249,6 +249,11 @@ CONTAINS
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
0,-1.0,0.0,.FALSE.,inDen%iter,inDen%mt,inDen%pw,inDen%vacz,inDen%vacxy,inDen%cdom,&
inDen%cdomvz,inDen%cdomvxy)
IF (isDensityMatrixPresent().AND.atoms%n_u>0) THEN
ALLOCATE (inDen%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u,input%jspins))
CALL readDensityMatrix(input,atoms,inDen%mmpMat,l_error)
IF(l_error) CALL juDFT_error('Error in reading density matrix!',calledby='fleur')
END IF
END IF
#ifdef CPP_MPI
CALL mpi_bc_potden(mpi,stars,sphhar,atoms,input,vacuum,oneD,noco,inDen)
......@@ -370,7 +375,7 @@ CONTAINS
IF (mpi%irank==0) WRITE(*,"(a)",advance="no") "* Eigenvalue problem "
CALL eigen(mpi,stars,sphhar,atoms,obsolete,xcpot,&
sym,kpts,DIMENSION,vacuum,input,cell,enpara,banddos,noco,jij,oneD,hybrid,&
it,eig_id, results,v,vx)
it,eig_id,inDen,results,v,vx)
eig_idList(pc) = eig_id
CALL timestop("eigen")
!
......
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