diff --git a/source/KKRnano/source/bfield/bfield.f90 b/source/KKRnano/source/bfield/bfield.f90 index 24df00425489efdd9e16848e1e0a7d6c65aa1fa5..732d339cc0fc8cf73fd21af43ce9667eb6bbd9d6 100644 --- a/source/KKRnano/source/bfield/bfield.f90 +++ b/source/KKRnano/source/bfield/bfield.f90 @@ -29,11 +29,16 @@ module mod_bfield !> Summary: A type storing information on magnetic fields for a single atom !------------------------------------------------------------------------------- type :: bfield_data + ! Noncollinear magnetic fields double precision, dimension(3) :: bfield_ext !! external magnetic field in cartesian coordinates double precision, dimension(3) :: bfield_constr !! constraining field in cartesian coordinates - double precision, dimension(3) :: mag_torque !! Magnetic torque - double precision, dimension(3) :: mag_mom !! Magnetic moment + ! Torque and other information used to update the constraints fields + double precision, dimension(3) :: mag_torque !! Magnetic torque + double precision, dimension(3) :: mag_mom !! Magnetic moment + double precision :: mean_xc_bfield !! Mean magnitude of xc bfield + + ! Precalculated intermediate results double precision, dimension(:,:,:), allocatable :: thetallmat !! shapefun in the ll' expansion end type diff --git a/source/KKRnano/source/bfield/torque.f90 b/source/KKRnano/source/bfield/torque.f90 index 660bf8ef6f4407876c109877dbaffed603807b3d..d6117435012a37f7d83414b8fcaaba3469fdeca3 100644 --- a/source/KKRnano/source/bfield/torque.f90 +++ b/source/KKRnano/source/bfield/torque.f90 @@ -77,6 +77,9 @@ contains ! potential. bxc(:,:) = (vpot(:,:,1) - vpot(:,:,2)) / 2. + ! Calculate and save mean xc bfield strength + bfield%mean_xc_bfield = sum(abs(bxc(:,1))) / irmd + ! Get magnetization density (in the global frame). For each angular momentum ! and radial index, rotate to the global frame. do ilm = 1, lmpotd @@ -184,7 +187,8 @@ contains else if (constr_mode == 2) then old_b_constr = bfield%bfield_constr(:) bfield%bfield_constr(:) = old_b_constr - dot_product(old_b_constr,dir)*dir - & - (mag_mom_dir - dot_product(mag_mom_dir,dir)*dir)*constr_bfield_mixing + ( (mag_mom_dir - dot_product(mag_mom_dir,dir)*dir) * & + bfield%mean_xc_bfield * constr_bfield_mixing ) else ! There might be other modes that are calculated somewhere else ! (e.g. mode 1, which only fixes the direction by not changing the local diff --git a/source/KKRnano/source/datastructures/InputParamsNew.txt b/source/KKRnano/source/datastructures/InputParamsNew.txt index c204040f0e5a8b0430510f5533443ae93f554a46..270644bc175e16ef8dd968a0d4961f5e09a8ba2d 100644 --- a/source/KKRnano/source/datastructures/InputParamsNew.txt +++ b/source/KKRnano/source/datastructures/InputParamsNew.txt @@ -133,7 +133,7 @@ l trans_bfield .FALSE. ### [bfields] apply magnetic field only in the muffin-tin (called lbfield_mt in KKRhost code) l mt_bfield .FALSE. ### [bfields] mixing parameter for the selfconsistency of the constraint magnetic fields -d constr_bfield_mixing 0.03 +d constr_bfield_mixing 0.9 ### [bfields] start applying magnetic field at iteration (called ibfield_itscf0 in KKRhost code) i itbfield0 0 ### [bfields] stop applying magnetic field after iteration itscf1 (called ibfield_itscf1 in KKRhost code) diff --git a/source/KKRnano/source/datastructures/InputParams_mod.F90 b/source/KKRnano/source/datastructures/InputParams_mod.F90 index 84abbf7d367655115e96e72228e168ff8fb88f13..1cf06ab5e2cdbdf78ffdd487bbc9248f76444045 100644 --- a/source/KKRnano/source/datastructures/InputParams_mod.F90 +++ b/source/KKRnano/source/datastructures/InputParams_mod.F90 @@ -682,9 +682,9 @@ integer function getValues(filename, self) result(ierror) destroy_and_return endif - ierror = getValue(cr, "constr_bfield_mixing", self%constr_bfield_mixing , def=0.03) + ierror = getValue(cr, "constr_bfield_mixing", self%constr_bfield_mixing , def=0.9) if (ierror == use_default) then - write(*,*) "WARNING: Bad/no value given for constr_bfield_mixing. Set constr_bfield_mixing to 0.03" + write(*,*) "WARNING: Bad/no value given for constr_bfield_mixing. Set constr_bfield_mixing to 0.9" ierror = 0 ! ok, no error elseif (ierror /= 0) then write(*,*) "Bad/no value given for constr_bfield_mixing."