Commit 25e2bbda authored by Daniel Wortmann's avatar Daniel Wortmann

Fixed linear mixing of LDA+U density matrix in parallel case. Should fix #303

parent 2ed4eaf7
......@@ -7,10 +7,10 @@ MODULE m_mix
!------------------------------------------------------------------------
! mixing of charge densities or potentials:
! IMIX = 0 : linear mixing
! IMIX = 3 : Broyden's First method
! IMIX = 5 : Broyden's Second method
! IMIX = 7 : Generalized Anderson method
! IMIX = 0 : linear mixing
! IMIX = 3 : Broyden's First method
! IMIX = 5 : Broyden's Second method
! IMIX = 7 : Generalized Anderson method
!------------------------------------------------------------------------
contains
......@@ -46,7 +46,7 @@ contains
type(t_field), intent(inout) :: field
type(t_dimension), intent(in) :: dimension
type(t_mpi), intent(in) :: mpi
TYPE(t_atoms),TARGET,INTENT(in) :: atoms
TYPE(t_atoms),TARGET,INTENT(in) :: atoms
class(t_xcpot), intent(in) :: xcpot
type(t_potden), intent(inout) :: outDen
type(t_results), intent(inout) :: results
......@@ -70,9 +70,9 @@ contains
IF (ALL(inDen%mmpMat==0.0)) THEN
l_densitymatrix=.FALSE.
inDen%mmpMat=outDen%mmpMat
if (mpi%irank.ne.0) inden%mmpmat=0.0
ENDIF
ENDIF
print *,"A:",mpi%irank,maxval(abs(inden%mmpmat))
CALL timestart("Reading of distances")
CALL mixvector_init(mpi%mpi_comm,l_densitymatrix,oneD,input,vacuum,noco,sym,stars,cell,sphhar,atoms)
......@@ -84,9 +84,9 @@ contains
CALL distance(mpi%irank,cell%vol,input%jspins,fsm(it),inDen,outDen,results,fsm_Mag)
CALL timestop("Reading of distances")
! KERKER PRECONDITIONER
IF( input%preconditioning_param /= 0 ) THEN
IF( input%preconditioning_param /= 0 ) THEN
CALL timestart("Preconditioner")
CALL kerker( field, DIMENSION, mpi, &
stars, atoms, sphhar, vacuum, input, sym, cell, noco, &
......@@ -95,7 +95,8 @@ contains
CALL mixing_history_store(fsm(it))
CALL timestop("Preconditioner")
END IF
if (atoms%n_u>0.and.mpi%irank.ne.0.and.input%ldaulinmix) inden%mmpMat=0.0
print *,"A2:",mpi%irank,maxval(abs(inden%mmpmat))
CALL timestart("Mixing")
!mixing of the densities
SELECT CASE(input%imix)
......@@ -121,7 +122,7 @@ contains
IF (mpi%irank==0) WRITE( 6, fmt='(a,f10.5,a,i0,a,i0)' ) &
'RESTARTED PULAY MIXING: alpha=',input%alpha," History-length=",it-1,"/",input%maxiter
CALL pulay(input%alpha,fsm,sm,0)
IF (it==input%maxiter) CALL mixing_history_limit(0) !Restarting Pulay
IF (it==input%maxiter) CALL mixing_history_limit(0) !Restarting Pulay
CASE(15)
IF (mpi%irank==0) WRITE( 6, fmt='(a,f10.5,a,i0,a,i0)' ) &
'ADAPTED PULAY MIXING: alpha=',input%alpha," History-length=",it-1,"/",input%maxiter
......@@ -130,24 +131,25 @@ contains
CALL judft_error("Unknown Mixing schema")
END SELECT
CALL timestop("Mixing")
print *,"B:",mpi%irank,maxval(abs(inden%mmpmat))
CALL timestart("Postprocessing")
!extracte mixed density
!extracte mixed density
inDen%pw=0.0;inDen%mt=0.0
IF (ALLOCATED(inDen%vacz)) inden%vacz=0.0
IF (ALLOCATED(inDen%vacxy)) inden%vacxy=0.0
IF (ALLOCATED(inDen%mmpMat).AND.l_densitymatrix) inden%mmpMat=0.0
CALL sm(it)%to_density(inDen)
IF (atoms%n_u>0.AND..NOT.l_densitymatrix.AND..NOT.input%ldaulinmix) THEN
!No density matrix was present
!No density matrix was present
!but is now created...
inden%mmpMAT=outden%mmpMat
CALL mixing_history_reset(mpi)
CALL mixvector_reset()
ENDIF
if(iteration == 1 .and. xcpot%vx_is_MetaGGA()) then
if(iteration == 1 .and. xcpot%vx_is_MetaGGA()) then
CALL mixing_history_reset(mpi)
CALL mixvector_reset()
endif
......@@ -185,8 +187,9 @@ contains
IF (l_writehistory.AND.input%imix.NE.0) CALL mixing_history_close(mpi)
CALL timestop("Postprocessing")
print *,"C:",mpi%irank,maxval(abs(inden%mmpmat))
CALL timestop("Charge Density Mixing")
END SUBROUTINE mix_charge
END MODULE m_mix
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