diff --git a/source/KKRnano/source/ProcessKKRresults_mod.F90 b/source/KKRnano/source/ProcessKKRresults_mod.F90 index bbcca67479cee345cc5a37611628a8102323fccb..91a35435b083e275e157577c3682915a4ab51d76 100644 --- a/source/KKRnano/source/ProcessKKRresults_mod.F90 +++ b/source/KKRnano/source/ProcessKKRresults_mod.F90 @@ -1042,8 +1042,8 @@ module ProcessKKRresults_mod theta = calc%noco_data%theta_noco(atom_id) phi = calc%noco_data%phi_noco(atom_id) call constraining_fields_scf_cycle(calc%bfields(ila), fix_angle_mode, & - theta, phi, params%itbfield0, params%itbfield1, & - iter) + theta, phi, params%constr_bfield_mixing, & + params%itbfield0, params%itbfield1, iter) end do end subroutine diff --git a/source/KKRnano/source/bfield/torque.f90 b/source/KKRnano/source/bfield/torque.f90 index df2e77681cd78a982c84f5b254927b72f7905b40..660bf8ef6f4407876c109877dbaffed603807b3d 100644 --- a/source/KKRnano/source/bfield/torque.f90 +++ b/source/KKRnano/source/bfield/torque.f90 @@ -150,15 +150,15 @@ contains !> Based on the torque and magnetic moment calculated together with the !> densities and saved in the bfield_data type. subroutine constraining_fields_scf_cycle(bfield, constr_mode, theta, phi, & - itscf0, itscf1, iteration) + constr_bfield_mixing, itscf0, itscf1, & + iteration) type(bfield_data), intent(inout) :: bfield !! Information on the magnetic field integer, intent(in) :: constr_mode !! Mode of the constraining field self-consistency double precision, intent(in) :: theta, phi !! Angles of the (old) magnetic moment + double precision, intent(in) :: constr_bfield_mixing !! Mixing param for the constr bfields integer, intent(in) :: itscf0, itscf1 !! Apply magnetic fields between these iterations integer, intent(in) :: iteration !! Current iteration - double precision, parameter :: constraint_bfields_mixing_parameter = 0.03 - double precision, dimension(3) :: dir, mag_mom_dir double precision, dimension(3) :: old_b_constr double precision :: mag_mom_len @@ -179,11 +179,12 @@ contains mag_mom_dir = bfield%mag_mom(:) / mag_mom_len if (constr_mode == 3) then - bfield%bfield_constr(:) = bfield%bfield_constr(:) - bfield%mag_torque(:) / mag_mom_len + bfield%bfield_constr(:) = bfield%bfield_constr(:) - & + (bfield%mag_torque(:) / mag_mom_len) * constr_bfield_mixing 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)*constraint_bfields_mixing_parameter + (mag_mom_dir - dot_product(mag_mom_dir,dir)*dir)*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 14f9192109ecc9b44d5bd4454f6ad5630a49a784..c204040f0e5a8b0430510f5533443ae93f554a46 100644 --- a/source/KKRnano/source/datastructures/InputParamsNew.txt +++ b/source/KKRnano/source/datastructures/InputParamsNew.txt @@ -132,6 +132,8 @@ l external_bfield .FALSE. 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 ### [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 a20d148244e721fd139264beef3e65d0af80f738..84abbf7d367655115e96e72228e168ff8fb88f13 100644 --- a/source/KKRnano/source/datastructures/InputParams_mod.F90 +++ b/source/KKRnano/source/datastructures/InputParams_mod.F90 @@ -82,6 +82,7 @@ module InputParams_mod logical :: external_bfield logical :: trans_bfield logical :: mt_bfield + double precision :: constr_bfield_mixing integer :: itbfield0 integer :: itbfield1 integer :: bfield_verbosity @@ -681,6 +682,15 @@ integer function getValues(filename, self) result(ierror) destroy_and_return endif + ierror = getValue(cr, "constr_bfield_mixing", self%constr_bfield_mixing , def=0.03) + if (ierror == use_default) then + write(*,*) "WARNING: Bad/no value given for constr_bfield_mixing. Set constr_bfield_mixing to 0.03" + ierror = 0 ! ok, no error + elseif (ierror /= 0) then + write(*,*) "Bad/no value given for constr_bfield_mixing." + destroy_and_return + endif + ierror = getValue(cr, "itbfield0", self%itbfield0 , def=0) if (ierror == use_default) then write(*,*) "WARNING: Bad/no value given for itbfield0. Set itbfield0 to 0"