From 753035ebddb07181ee1ea1357e886234eca57e76 Mon Sep 17 00:00:00 2001 From: Nicolas Essing <n.essing@fz-juelich.de> Date: Mon, 1 Nov 2021 18:19:36 +0100 Subject: [PATCH] Introduced an input parameter for the mixing strength used to converge the constraint magnetic fields. The mixing is used for modes 2 and 3, so also for the torque based method, different from KKRhost, which does not have a mixing parameter (different from 1) in that case. --- source/KKRnano/source/ProcessKKRresults_mod.F90 | 4 ++-- source/KKRnano/source/bfield/torque.f90 | 11 ++++++----- .../KKRnano/source/datastructures/InputParamsNew.txt | 2 ++ .../KKRnano/source/datastructures/InputParams_mod.F90 | 10 ++++++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/source/KKRnano/source/ProcessKKRresults_mod.F90 b/source/KKRnano/source/ProcessKKRresults_mod.F90 index bbcca6747..91a35435b 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 df2e77681..660bf8ef6 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 14f919210..c204040f0 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 a20d14824..84abbf7d3 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" -- GitLab