!--------------------------------------------------------------------------------! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany! This file is part of FLEUR and available as free software under the conditions! of the MIT license as expressed in the LICENSE file in more detail.!--------------------------------------------------------------------------------

!This routine uses the current force,energies and atomic positions to !generate a displacement in a relaxation step. !The history is taken into account by read_relax from m_relaxio!After generating new positions the code stops

! add history CALLread_relax(pos,force,energies)!determine new positionsIF(SIZE(energies)==1.OR.input%forcemix==0)THEN!no history present simple step! choose a reasonable first guess for scaling! this choice is based on a Debye temperature of 330K;! modify as needed!alpha = (250.0/(MAXVAL(atoms%zatom)*input%xa))*((330./input%thetad)**2)CALLsimple_step(input%forcealpha,force,displace)ELSEIF(input%forcemix==1)THENCALLsimple_cg(pos,force,displace)ELSECALLsimple_bfgs(pos,force,displace)ENDIF!Check for convergence of forces/displacementsl_conv=.TRUE.DOn=1,atoms%ntypeIF(DOT_PRODUCT(force(:,n,SIZE(force,3)),force(:,n,SIZE(force,3)))>input%epsforce**2)l_conv=.FALSE.IF(DOT_PRODUCT(displace(:,n),displace(:,n))>input%epsforce**2)l_conv=.FALSE.ENDDO!New displacements relative to positions in inp.xmlCALLread_displacements(atoms,old_displace)displace=displace+old_displace!Write fileCALLwrite_relax(pos,force,energies,displace)

SUBROUTINEsimple_bfgs(pos,force,shift)!-----------------------------------------------! Simple BFGS method to calculate shift out of old positions and forces!-----------------------------------------------IMPLICITNONEREAL,INTENT(in)::pos(:,:,:),force(:,:,:)