Commit db529bb9 authored by Robin Hilgers's avatar Robin Hilgers

Seems to work now. However still experimental.

parent 11908fe8
......@@ -39,7 +39,7 @@ SUBROUTINE rotateMagnetToSpinAxis(vacuum,sphhar,stars&
TYPE(t_potden) :: denTemp
LOGICAL :: l_firstIt,nonZeroAngles !Switch which is handed in by function calls which determines if we have to rotate cdn initially.
REAL :: moments(3,atoms%ntype),scalePhi,scaleTheta
REAL :: moments(3,atoms%ntype)
REAL :: phiTemp(atoms%ntype),thetaTemp(atoms%ntype)
REAL :: diffT(atoms%ntype),diffP(atoms%ntype),eps, zeros(atoms%ntype)
INTEGER :: ierr(2)
......@@ -51,11 +51,11 @@ SUBROUTINE rotateMagnetToSpinAxis(vacuum,sphhar,stars&
IF(noco%alph_inp(i).NE.0.0) nonZeroAngles=.TRUE.
IF(noco%beta_inp(i).NE.0.0) nonZeroAngles=.TRUE.
END DO
IF(l_firstIt.AND.nonZeroAngles) THEN
! Rotates cdn by given noco angles in first iteration. WARNING: If you want to continue/restart a calculation with MT relaxation set noco angles to 0!
IF (noco%l_RelaxBeta) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,nococonv%beta,den)
IF (noco%l_RelaxAlpha) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,nococonv%alph,zeros,den)
CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,noco%beta_inp,den)
CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,noco%alph_inp,zeros,den)
!Setting angles to zero since we want our spinQ Axis to remain the same when writing out the density.
nococonv%alph=zeros
nococonv%beta=zeros
......@@ -71,29 +71,41 @@ SUBROUTINE rotateMagnetToSpinAxis(vacuum,sphhar,stars&
END IF
phiTemp(:)=(-1)*phiTemp(:)
!Calculate angular rotation which has to be done.
IF (noco%l_RelaxBeta) diffT=thetaTemp-nococonv%beta
IF (noco%l_RelaxAlpha) diffP=phiTemp-nococonv%alph
diffT=thetaTemp-nococonv%beta
diffP=phiTemp-nococonv%alph
DO i=1, atoms%ntype
! Set angles to zero if too low. (Prevent numerical rubbish to appear)
IF (abs(diffT(i)).LE.eps) diffT(i)=0.0
IF (abs(diffP(i)).LE.eps) diffP(i)=0.0
END DO
!which angles to relax?
IF (noco%l_RelaxBeta) scaleTheta=1.0
IF (noco%l_RelaxAlpha) scalePhi=1.0
IF (.NOT.noco%l_RelaxBeta) scaleTheta=0.0
IF (.NOT.noco%l_RelaxAlpha) scalePhi=0.0
!IF(noco%mix_RelaxAngleAlpha.NE.1.0.OR.noco%mix_RelaxAngleBeta.NE.1.0) THEN
diffT=scaleTheta*diffT
diffP=scalePhi*diffP
!END IF
!Which angles to keep constant from input den
IF (.NOT.noco%l_RelaxAlpha) THEN
IF(l_firstIT) THEN
nococonv%alphRlx=diffP
CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,-diffP,zeros,den)
END IF
END IF
! Rotate cdn by direction of magnetization so it alings with spin quantization axis.
IF (noco%l_RelaxAlpha) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,-diffP,zeros,den)
IF (noco%l_RelaxBeta) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,-diffT,den)
IF (noco%l_RelaxAlpha.OR..NOT.l_firstIT) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,-diffP,zeros,den)
!Which angles to keep constant from input den
IF (.NOT.noco%l_RelaxBeta) THEN
IF(l_firstIT) THEN
nococonv%betaRlx=diffT
CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,-diffT,den)
END IF
END IF
IF (noco%l_RelaxBeta.OR..NOT.l_firstIT) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,-diffT,den)
!Store angles in nococonv
IF (noco%l_RelaxBeta) nococonv%beta=nococonv%beta+diffT
IF (noco%l_RelaxAlpha) nococonv%alph=nococonv%alph+diffP
IF (noco%l_RelaxBeta) nococonv%beta=nococonv%beta+diffT
IF (.NOT.noco%l_RelaxBeta) nococonv%beta=nococonv%betaRlx
IF (noco%l_RelaxAlpha) nococonv%alph=nococonv%alph+diffP
IF(.NOT.noco%l_RelaxAlpha) nococonv%alph=nococonv%alphRlx
! Set angles to zero if too low. (Prevent numerical rubbish to appear)
DO i=1, atoms%ntype
IF (abs(nococonv%beta(i)).LE.eps) nococonv%beta(i)=0.0
......@@ -127,15 +139,15 @@ SUBROUTINE rotateMagnetFromSpinAxis(noco,nococonv,vacuum,sphhar,stars&
zeros(:)=0.0
! Backwards rotation so SQA and magnetization don't align anymore. This is needed since you otherwise run into issues in the mixing since you mix cdn's which have been rotated
! in different directions.
IF (noco%l_RelaxBeta) CAlL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,nococonv%beta,inDen)
IF (noco%l_RelaxAlpha) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,nococonv%alph,zeros,inDen)
CAlL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,nococonv%beta,inDen)
CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,nococonv%alph,zeros,inDen)
IF (present(den)) THEN
IF (noco%l_RelaxBeta) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,nococonv%beta,den)
IF (noco%l_RelaxAlpha) CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,nococonv%alph,zeros,den)
CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,zeros,nococonv%beta,den)
CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,nococonv%alph,zeros,den)
END IF
! Nococonv is zero now since rotation has been reverted.
nococonv%alph=zeros
nococonv%beta=zeros
nococonv%alph=zeros
nococonv%beta=zeros
END SUBROUTINE rotateMagnetFromSpinAxis
......
......@@ -72,7 +72,6 @@ MODULE m_types_noco
CALL mpi_bc(this%l_spav,rank,mpi_comm)
CALL mpi_bc(this%theta_inp,rank,mpi_comm)
CALL mpi_bc(this%phi_inp,rank,mpi_comm)
CALL mpi_bc(this%l_relax,rank,mpi_comm)
CALL mpi_bc(this%alph_inp,rank,mpi_comm)
CALL mpi_bc(this%beta_inp,rank,mpi_comm)
......@@ -118,15 +117,11 @@ MODULE m_types_noco
this%l_scaleMag = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_scaleMag'))
this%mag_scale = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@mag_scale'))
this%mix_b = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@mix_b'))
this%l_alignMT = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_RelaxMT'))
this%l_RelaxBeta = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_RelaxBeta'))
this%l_RelaxAlpha = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_RelaxAlpha'))
this%mix_RelaxWeightOffD = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@mix_RelaxWeightOffD'))
valueString = TRIM(ADJUSTL(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/qss')))
IF (this%l_RelaxAlpha.OR.this%l_RelaxBeta) THEN
this%l_alignMT=.TRUE.
ELSE
this%l_alignMT=.FALSE.
END IF
READ(valueString,*) this%qss_inp
END IF
......
......@@ -113,6 +113,10 @@ MODULE m_nocoInputCheck
IF (noco%l_mtNocoPot.AND..NOT.noco%l_mperp) THEN
CALL juDFT_error("l_mperp='F' and l_mtNocoPot='T' makes no sense.",calledby='nocoInputCheck')
END IF
IF(noco%l_alignmt.AND..NOT.(noco%l_RelaxAlpha.OR.noco%l_RelaxBeta)) CALL juDFT_warn("No relaxation is performed if neither l_RelaxBeta nor l_RelaxAlpha is true.",calledby="nocoInputCheck")
IF(.NOT.noco%l_alignmt.AND.(noco%l_RelaxAlpha.OR.noco%l_RelaxBeta)) CALL juDFT_warn("No relaxation is performed with l_RelaxMT=F even if either l_RelaxBeta or l_RelaxAlpha is True.",calledby="nocoInputCheck")
END SUBROUTINE nocoInputCheck
END MODULE m_nocoInputCheck
......@@ -186,8 +186,8 @@ CONTAINS
IF (l_nocoOpt .OR. l_explicit) THEN
160 FORMAT(' <nocoParams l_ss="', l1, '" l_mperp="', l1,'" l_mtNocoPot="', l1,'" l_alignMT="', l1, '" l_constr="', l1, '" l_sourceFree="', l1, &
'" l_scaleMag="', l1, '" mag_scale="', f0.8, '" mix_b="', f0.8, '" l_RelaxAlpha="',l1, '" l_RelaxBeta="',l1,'" mix_RelaxWeightOffD="',f0.8,'">')
WRITE (fileNum, 160) noco%l_ss, noco%l_mperp, noco%l_mtNocoPot, noco%l_alignMT, noco%l_constr, noco%l_sourceFree, noco%l_scaleMag, noco%mag_scale, noco%mix_b, noco%l_RelaxAlpha,noco%l_RelaxBeta,noco%mix_RelaxWeightOffD
'" l_scaleMag="', l1, '" mag_scale="', f0.8, '" mix_b="', f0.8, '" l_RelaxMT="',l1,'" l_RelaxAlpha="',l1, '" l_RelaxBeta="',l1,'" mix_RelaxWeightOffD="',f0.8,'">')
WRITE (fileNum, 160) noco%l_ss, noco%l_mperp, noco%l_mtNocoPot, noco%l_alignMT, noco%l_constr, noco%l_sourceFree, noco%l_scaleMag, noco%mag_scale, noco%mix_b,noco%l_alignMT, noco%l_RelaxAlpha,noco%l_RelaxBeta,noco%mix_RelaxWeightOffD
162 FORMAT(' <qss>', f0.10, ' ', f0.10, ' ', f0.10, '</qss>')
WRITE (fileNum, 162) noco%qss_inp
WRITE (fileNum, '(a)') ' </nocoParams>'
......
......@@ -97,6 +97,7 @@
<xsd:attribute default="F" name="l_sourceFree" type="FleurBool" use="optional"/>
<xsd:attribute default="F" name="l_scaleMag" type="FleurBool" use="optional"/>
<xsd:attribute default="1.0" name="mag_scale" type="xsd:string" use="optional"/>
<xsd:attribute default="f" name="l_RelaxMT" type="FleurBool" use="optional"/>
<xsd:attribute default="f" name="l_RelaxAlpha" type="FleurBool" use="optional"/>
<xsd:attribute default="f" name="l_RelaxBeta" type="FleurBool" use="optional"/>
<xsd:attribute default="1.0" name="mix_RelaxWeightOffD" type="xsd:string" use="optional"/>
......
......@@ -9,7 +9,7 @@
<coreElectrons ctail="f" frcor="F" kcrel="0" coretail_lmax="0"/>
<magnetism jspins="2" l_noco="t" swsp="F" lflip="f"/>
<soc theta="0.0" phi="0.0000000" l_soc="t" spav="F"/>
<nocoParams l_ss="F" l_mperp="t" l_mtNocoPot="t" l_constr="F" l_RelaxBeta="T" l_RelaxAlpha="T" mix_b=".00000000">
<nocoParams l_ss="F" l_mperp="t" l_mtNocoPot="t" l_constr="F" l_RelaxMT="T" l_RelaxBeta="T" l_RelaxAlpha="T" mix_b=".00000000">
<qss>.0000000000 .0000000000 .0000000000</qss>
</nocoParams>
<expertModes gw="0" secvar="F"/>
......
......@@ -9,7 +9,7 @@
<coreElectrons ctail="f" frcor="F" kcrel="0" coretail_lmax="0"/>
<magnetism jspins="2" l_noco="t" swsp="F" lflip="f"/>
<soc theta=".00000000" phi=".00000000" l_soc="F" spav="F"/>
<nocoParams l_ss="F" l_mperp="t" l_mtNocoPot="t" l_constr="F" l_sourceFree="f" mix_b=".00000000" l_RelaxBeta="t" l_RelaxAlpha="t" mix_RelaxWeightOffD="1.0">
<nocoParams l_ss="F" l_mperp="t" l_mtNocoPot="t" l_constr="F" l_sourceFree="f" mix_b=".00000000" l_RelaxMT="T" l_RelaxBeta="t" l_RelaxAlpha="t" mix_RelaxWeightOffD="1.0">
<qss>.0000000000 .0000000000 .0000000000</qss>
</nocoParams>
<expertModes gw="0" secvar="F"/>
......
......@@ -13,6 +13,8 @@ MODULE m_types_nococonv
REAL :: qss(3)=[0.,0.,0.]
REAL, ALLOCATABLE :: alph(:)
REAL, ALLOCATABLE :: beta(:)
REAL, ALLOCATABLE :: alphRlx(:)
REAL, ALLOCATABLE :: betaRlx(:)
REAL, ALLOCATABLE :: b_con(:,:)
CONTAINS
procedure:: init=>t_nococonv_init
......@@ -29,6 +31,10 @@ CONTAINS
this%phi=noco%phi_inp
this%alph=noco%alph_inp
this%beta=noco%beta_inp
this%alphRlx=noco%alph_inp
this%betaRlx=noco%beta_inp
this%alphRlx=0.0
this%betaRlx=0.0
this%qss=noco%qss_inp
if (allocated(this%b_con)) deallocate(this%b_con)
allocate(this%b_con(2,size(this%alph)))
......
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