Commit 41570f84 authored by Daniel Wortmann's avatar Daniel Wortmann

Input for Pulay added

parent 7ffd7fed
......@@ -329,6 +329,8 @@ CONTAINS
input%imix = 5
CASE ('Anderson')
input%imix = 7
CASE ("Pulay")
input%imix = 9
CASE DEFAULT
STOP 'Error: unknown mixing scheme selected!'
END SELECT
......
......@@ -879,6 +879,7 @@
<xsd:enumeration value="Broyden1"/>
<xsd:enumeration value="Broyden2"/>
<xsd:enumeration value="Anderson"/>
<xsd:enumeration value="Pulay"/>
</xsd:restriction>
</xsd:simpleType>
......
......@@ -78,8 +78,10 @@ contains
write( 6, fmt='(a,f10.5)' ) 'BROYDEN SECOND MIXING',input%alpha
case( 7 )
write( 6, fmt='(a,f10.5)' ) 'ANDERSON GENERALIZED',input%alpha
case ( 9 )
write( 6, fmt='(a,f10.5)' ) 'PULAY MIXING',input%alpha
case default
call juDFT_error( "mix: input%imix =/= 0,3,5,7 ", calledby ="mix" )
call juDFT_error( "mix: input%imix =/= 0,3,5,7,9 ", calledby ="mix" )
end select
if ( input%jspins == 2 .and. input%imix /= 0 ) then
......@@ -119,8 +121,10 @@ contains
!if(it>1.and.input%imix==9) CALL pulay(input%alpha,fsm,sm)
if(it>1.and.(input%imix==3.or.input%imix==5.or.input%imix==7)) Call broyden(input%alpha,fsm,sm)
!PRINT *,"ATTENTION Broyden replaced by Pulay"
IF (it>1.and.input%imix==9) CALL pulay(input%alpha,fsm,sm)
IF (it>1.and.input%imix==9) THEN
CALL pulay(input%alpha,fsm,sm)
if (it==input%maxiter) call mixing_history_limit(1)
endif
!extracte mixed density
inDen%pw=0.0;inDen%mt=0.0
IF (ALLOCATED(inDen%vacz)) inden%vacz=0.0
......
......@@ -10,7 +10,7 @@ MODULE m_mixing_history
INTEGER:: iter_stored=0
TYPE(t_mixvector),ALLOCATABLE::sm_store(:),fsm_store(:)
PUBLIC :: mixing_history,mixing_history_reset,mixing_history_store
PUBLIC :: mixing_history_open,mixing_history_close
PUBLIC :: mixing_history_open,mixing_history_close,mixing_history_limit
CONTAINS
SUBROUTINE mixing_history_open(mpi,maxiter)
......@@ -82,7 +82,7 @@ CONTAINS
endif
IF (iter_stored+1==maxiter.AND.imix.NE.9) iter_stored=0 !This is a broyden method which has to
!be reset as soon as maxiter is reached
it=MIN(iter_stored+1,maxiter+1)
it=iter_stored+1
allocate(sm(it),fsm(it))
CALL sm(it)%alloc()
CALL fsm(it)%alloc()
......@@ -90,17 +90,17 @@ CONTAINS
CALL fsm(it)%from_density(outDen)
!store the difference fsm - sm in fsm
fsm(it) = fsm(it) - sm(it)
do n=it-1,1,-1 !Copy from storage
do n=1,it-1 !Copy from storage
sm(n)=sm_store(n)
fsm(n)=fsm_store(n)
ENDDO
if(iter_stored<maxiter) THEN
iter_stored=iter_stored+1
sm_store(:iter_stored)=sm(:iter_stored)
fsm_store(:iter_stored)=fsm(:iter_stored)
sm_store(iter_stored)=sm(iter_stored)
fsm_store(iter_stored)=fsm(iter_stored)
else
sm_store(:maxiter-1)=sm(2:maxiter)
fsm_store(:maxiter-1)=fsm(2:maxiter)
sm_store(:maxiter)=sm(2:maxiter+1)
fsm_store(:maxiter)=fsm(2:maxiter+1)
endif
end subroutine mixing_history
......@@ -112,6 +112,17 @@ CONTAINS
PRINT *, "Reset of history"
IF (mpi%irank==0) CALL system('rm mixing_history*')
END SUBROUTINE mixing_history_reset
subroutine mixing_history_limit(len)
IMPLICIT NONE
INTEGER,INTENT(in)::len
if (iter_stored>len) then
fsm_store(:len)=fsm_store(iter_stored-len+1:iter_stored)
sm_store(:len)=sm_store(iter_stored-len+1:iter_stored)
iter_stored=len
end if
end subroutine mixing_history_limit
SUBROUTINE mixing_history_store(fsm)
IMPLICIT NONE
......
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