Commit 5b0c1379 authored by Gregor Michalicek's avatar Gregor Michalicek

Move output of density matrix next to output of density

parent ac51edc4
......@@ -264,29 +264,33 @@ SUBROUTINE mix(stars,atoms,sphhar,vacuum,input,sym,cell,noco,oneD,&
CALL qfix(stars,atoms,sym,vacuum, sphhar,input,cell,oneD,&
inDen%pw,inDen%vacxy,inDen%mt,inDen%vacz,.FALSE.,.false., fix)
IF(atoms%n_u.NE.n_u_keep) THEN
inDen%mmpMat = n_mmpTemp
END IF
atoms%n_u=n_u_keep
!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,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)') inDen%mmpMat(:,:,:,:)
IF (input%ldauLinMix) THEN
WRITE (69,'(2(a6,f5.3))') 'alpha=',input%ldauMixParam,'spinf=',input%ldauSpinf
END IF
CLOSE (69)
ENDIF
inDen%iter = inDen%iter + 1
IF (input%imix.GT.0) THEN
CLOSE (57)
CLOSE (59)
END IF
IF(atoms%n_u.NE.n_u_keep) THEN
inDen%mmpMat = n_mmpTemp
END IF
atoms%n_u=n_u_keep
7900 FORMAT (/,'----> distance of charge densities for spin ',i2,' it=',i5,':',f13.6,' me/bohr**3')
7901 FORMAT (/,'----> HF distance of charge densities for spin ',i2,' it=',i5,':',f13.6,' me/bohr**3')
8000 FORMAT (/,'----> distance of charge densities for it=',i5,':', f13.6,' me/bohr**3')
......
......@@ -79,104 +79,92 @@ CONTAINS
END DO
CALL closeXMLElement('ldaUDensityMatrix')
! Check whether density matrix is present and open density-matrix - file
n_exist = isDensityMatrixPresent()
OPEN (69,file='n_mmp_mat',status='unknown',form='formatted')
! exit subroutine if density matrix does nbot exist
IF(.NOT.isDensityMatrixPresent()) THEN
n_mmp_in = n_mmp_out
RETURN
END IF
IF (n_exist) THEN
IF (input%ldauLinMix) THEN
IF (input%ldauLinMix) THEN
! mix here straight with given mixing factors
! mix here straight with given mixing factors
ALLOCATE (n_mmp(-3:3,-3:3,atoms%n_u,input%jspins))
ALLOCATE (n_mmp(-3:3,-3:3,atoms%n_u,input%jspins))
alpha = input%ldauMixParam
spinf = input%ldauSpinf
alpha = input%ldauMixParam
spinf = input%ldauSpinf
sum1 = 0.0
IF (input%jspins.EQ.1) THEN
DO i_u = 1, atoms%n_u
DO j = -3,3
DO k = -3,3
sum1 = sum1 + ABS(n_mmp_out(k,j,i_u,1) - n_mmp_in(k,j,i_u,1))
n_mmp(k,j,i_u,1) = alpha * n_mmp_out(k,j,i_u,1) + (1.0-alpha) * n_mmp_in(k,j,i_u,1)
END DO
END DO
END DO
WRITE (6,'(a16,f12.6)') 'n_mmp distance =',sum1
ELSE
sum2 = 0.0
gam = 0.5 * alpha * (1.0 + spinf)
del = 0.5 * alpha * (1.0 - spinf)
DO i_u = 1,atoms%n_u
DO j = -3,3
DO k = -3,3
sum1 = sum1 + ABS(n_mmp_out(k,j,i_u,1) - n_mmp_in(k,j,i_u,1))
sum2 = sum2 + ABS(n_mmp_out(k,j,i_u,2) - n_mmp_in(k,j,i_u,2))
n_mmp(k,j,i_u,1) = gam * n_mmp_out(k,j,i_u,1) + &
(1.0-gam) * n_mmp_in (k,j,i_u,1) + &
del * n_mmp_out(k,j,i_u,2) - &
del * n_mmp_in (k,j,i_u,2)
n_mmp(k,j,i_u,2) = gam * n_mmp_out(k,j,i_u,2) + &
(1.0-gam) * n_mmp_in (k,j,i_u,2) + &
del * n_mmp_out(k,j,i_u,1) - &
del * n_mmp_in (k,j,i_u,1)
END DO
END DO
END DO
WRITE (6,'(a23,f12.6)') 'n_mmp distance spin 1 =',sum1
WRITE (6,'(a23,f12.6)') 'n_mmp distance spin 2 =',sum2
ENDIF
WRITE (69,9000) n_mmp
WRITE (69,'(2(a6,f5.3))') 'alpha=',alpha,'spinf=',spinf
n_mmp_in = n_mmp
DEALLOCATE (n_mmp)
ELSE ! input%ldauLinMix
! calculate distance and write new n_mmp to mix in broyden.F
sum1 = 0.0
sum1 = 0.0
IF (input%jspins.EQ.1) THEN
DO i_u = 1, atoms%n_u
DO j = -3,3
DO k = -3,3
sum1 = sum1 + ABS(n_mmp_out(k,j,i_u,1) - n_mmp_in(k,j,i_u,1))
n_mmp(k,j,i_u,1) = alpha * n_mmp_out(k,j,i_u,1) + (1.0-alpha) * n_mmp_in(k,j,i_u,1)
END DO
END DO
END DO
IF (input%jspins.EQ.1) THEN
WRITE (6,'(a16,f12.6)') 'n_mmp distance =',sum1
ELSE
sum2 = 0.0
WRITE (6,'(a23,f12.6)') 'n_mmp distance spin 1 =',sum1
DO i_u = 1, atoms%n_u
DO j = -3,3
DO k = -3,3
sum2 = sum2 + ABS(n_mmp_out(k,j,i_u,2) - n_mmp_in(k,j,i_u,2))
END DO
WRITE (6,'(a16,f12.6)') 'n_mmp distance =',sum1
ELSE
sum2 = 0.0
gam = 0.5 * alpha * (1.0 + spinf)
del = 0.5 * alpha * (1.0 - spinf)
DO i_u = 1,atoms%n_u
DO j = -3,3
DO k = -3,3
sum1 = sum1 + ABS(n_mmp_out(k,j,i_u,1) - n_mmp_in(k,j,i_u,1))
sum2 = sum2 + ABS(n_mmp_out(k,j,i_u,2) - n_mmp_in(k,j,i_u,2))
n_mmp(k,j,i_u,1) = gam * n_mmp_out(k,j,i_u,1) + &
(1.0-gam) * n_mmp_in (k,j,i_u,1) + &
del * n_mmp_out(k,j,i_u,2) - &
del * n_mmp_in (k,j,i_u,2)
n_mmp(k,j,i_u,2) = gam * n_mmp_out(k,j,i_u,2) + &
(1.0-gam) * n_mmp_in (k,j,i_u,2) + &
del * n_mmp_out(k,j,i_u,1) - &
del * n_mmp_in (k,j,i_u,1)
END DO
END DO
DO j=-3,3
WRITE(6,'(14f12.6)') (n_mmp_in(k,j,1,2),k=-3,3)
END DO
WRITE (6,'(a23,f12.6)') 'n_mmp distance spin 1 =',sum1
WRITE (6,'(a23,f12.6)') 'n_mmp distance spin 2 =',sum2
ENDIF
n_mmp_in = n_mmp
DEALLOCATE (n_mmp)
ELSE ! input%ldauLinMix
! only calculate distance
sum1 = 0.0
DO i_u = 1, atoms%n_u
DO j = -3,3
DO k = -3,3
sum1 = sum1 + ABS(n_mmp_out(k,j,i_u,1) - n_mmp_in(k,j,i_u,1))
END DO
WRITE (6,'(a23,f12.6)') 'n_mmp distance spin 2 =',sum2
DO j=-3,3
WRITE(6,'(14f12.6)') (n_mmp_out(k,j,1,2),k=-3,3)
END DO
END DO
IF (input%jspins.EQ.1) THEN
WRITE (6,'(a16,f12.6)') 'n_mmp distance =',sum1
ELSE
sum2 = 0.0
WRITE (6,'(a23,f12.6)') 'n_mmp distance spin 1 =',sum1
DO i_u = 1, atoms%n_u
DO j = -3,3
DO k = -3,3
sum2 = sum2 + ABS(n_mmp_out(k,j,i_u,2) - n_mmp_in(k,j,i_u,2))
END DO
END DO
END IF
WRITE (69,9000) n_mmp_in
WRITE (69,9000) n_mmp_out
END IF ! input%ldauLinMix
ELSE ! isDensityMatrixPresent()
! first time with lda+u; write new n_mmp
WRITE (69,9000) n_mmp_out
WRITE (69,'(2(a6,f5.3))') 'alpha=',input%ldauMixParam,'spinf=',input%ldauSpinf
n_mmp_in = n_mmp_out
END IF ! isDensityMatrixPresent()
9000 FORMAT(7f20.13)
END DO
DO j=-3,3
WRITE(6,'(14f12.6)') (n_mmp_in(k,j,1,2),k=-3,3)
END DO
WRITE (6,'(a23,f12.6)') 'n_mmp distance spin 2 =',sum2
DO j=-3,3
WRITE(6,'(14f12.6)') (n_mmp_out(k,j,1,2),k=-3,3)
END DO
END IF
END IF ! input%ldauLinMix
CLOSE (69)
END SUBROUTINE u_mix
END MODULE m_umix
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