Commit bd43f992 authored by Daniel Wortmann's avatar Daniel Wortmann

Bugfixes

parent 22f412d2
......@@ -96,7 +96,7 @@ contains
ENDIF
CALL mixvector_init(mpi%mpi_comm,l_densitymatrix,oneD,input,vacuum,noco,sym,stars,cell,sphhar,atoms)
maxiter=merge(1,input%maxiter,input%imix==0)
CALL mixing_history(maxiter,inden,outden,sm,fsm,it)
CALL mixing_history(input%imix,maxiter,inden,outden,sm,fsm,it)
CALL distance(mpi%irank,cell%vol,input%jspins,fsm(it),sm(it),inDen%iter,outDen,results,fsm_Mag)
......
......@@ -22,19 +22,18 @@ CONTAINS
! Locals
INTEGER :: n,it,hlen
REAL :: dfivi,fmvm,vmnorm
REAL,ALLOCATABLE :: am(:)
REAL :: fmvm,vmnorm
REAL,ALLOCATABLE :: am(:),dfivi(:)
TYPE(t_mixvector) :: fm1,sm1,ui,um,vi,vm
TYPE(t_mixvector),allocatable :: u_store(:),v_store(:)
hlen=size(fm)
ALLOCATE(u_store(hlen-1),v_store(hlen-1))
do it=1,hlen-1
ALLOCATE(u_store(hlen-2),v_store(hlen-2))
do it=1,hlen-2
call u_store(it)%alloc()
call v_store(it)%alloc()
enddo
dfivi = 0.0
CALL fm1%alloc()
CALL sm1%alloc()
CALL ui%alloc()
......@@ -42,7 +41,8 @@ CONTAINS
CALL vi%alloc()
CALL vm%alloc()
ALLOCATE (am(hlen-1))
ALLOCATE (am(hlen-1),dfivi(hlen-1))
dfivi = 0.0
am = 0.0
DO n=2,hlen
sm1 = sm(n) - sm(n-1)
......@@ -55,7 +55,7 @@ CONTAINS
ui=u_store(it)
vi=v_store(it)
am(it) = vi.dot.fm(n)
am(it) = vi.dot.fm1
! calculate um(:) = -am(it)*ui(:) + um(:)
um=um-am(it)*ui
WRITE(6,FMT='(5x,"<vi|w|Fm> for it",i2,5x,f10.6)')it,am(it)
......@@ -67,7 +67,7 @@ CONTAINS
DO it = n-2,1,-1
vi=v_store(it)
! calculate vm(:) = -am(it)*dfivi*vi(:) + vm
vm=vm-am(it)*dfivi*vi
vm=vm-am(it)*dfivi(it)*vi
END DO
vmnorm=fm1.dot.vm
......@@ -77,9 +77,9 @@ CONTAINS
vm=(1.0/vmnorm)*vm
! save dfivi(mit) for next iteration
dfivi = vmnorm
if (n<hlen) u_store(n)=um
if (n<hlen) v_store(n)=vm
dfivi(n-1) = vmnorm
IF (n<hlen) u_store(n-1)=um
IF (n<hlen) v_store(n-1)=vm
enddo
! update rho(m+1)
! calculate <fm|w|vm>
......
......@@ -10,10 +10,10 @@ MODULE m_mixing_history
type(t_mixvector),allocatable::sm_store(:),fsm_store(:)
contains
subroutine mixing_history(maxiter,inden,outden,sm,fsm,it)
SUBROUTINE mixing_history(imix,maxiter,inden,outden,sm,fsm,it)
use m_types
implicit none
integer,intent(in)::maxiter
INTEGER,INTENT(in)::imix,maxiter
type(t_potden),intent(in)::inden,outden
type(t_mixvector),ALLOCATABLE::sm(:),fsm(:)
INTEGER,INTENT(out)::it
......@@ -23,7 +23,9 @@ contains
if (.not.allocated(sm_store)) THEN
allocate(sm_store(maxiter),fsm_store(maxiter))
endif
it=min(iter_stored+1,maxiter)
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)
allocate(sm(it),fsm(it))
CALL sm(it)%alloc()
CALL fsm(it)%alloc()
......
......@@ -160,11 +160,11 @@ CONTAINS
den%vacz(:,iv,js)=vec%vec_vac(ii+1:ii+SIZE(den%vacz,1))
ii=ii+SIZE(den%vacz,1)
IF (invs2)THEN
den%vacxy(:,:,iv,js)=RESHAPE(vec%vec_vac(ii+1:ii+SIZE(den%vacxy(:,:,iv,js))),SHAPE(den%vacxy(:,:,iv,js)))
den%vacxy(:,:,iv,js)=RESHAPE(vec%vec_vac(ii:ii+SIZE(den%vacxy(:,:,iv,js))-1),SHAPE(den%vacxy(:,:,iv,js)))
ii=ii+SIZE(den%vacxy(:,:,iv,js))
ELSE
den%vacxy(:,:,iv,js)=RESHAPE(CMPLX(vec%vec_vac(ii+1:ii+SIZE(den%vacxy(:,:,iv,js))),&
vec%vec_vac(ii+SIZE(den%vacxy(:,:,iv,js))+1:ii+2*SIZE(den%vacxy(:,:,iv,js)))),&
den%vacxy(:,:,iv,js)=RESHAPE(CMPLX(vec%vec_vac(ii:ii+SIZE(den%vacxy(:,:,iv,js))-1),&
vec%vec_vac(ii+SIZE(den%vacxy(:,:,iv,js)):ii+2*SIZE(den%vacxy(:,:,iv,js)))-1),&
SHAPE(den%vacxy(:,:,iv,js)))
ii=ii+2*SIZE(den%vacxy(:,:,iv,js))
ENDIF
......
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