Skip to content
Snippets Groups Projects
Commit 397eb527 authored by Nicolas Essing's avatar Nicolas Essing
Browse files

Information on the convergence of the constraint fields.

Store the constraint fields from last iteration, write them to the
result file, and from that calculate the change of the fields.
Writes the maximum change and corresponding atom to output in each
iteration.
parent 3ef4db5c
No related branches found
No related tags found
No related merge requests found
...@@ -1131,10 +1131,10 @@ module ProcessKKRresults_mod ...@@ -1131,10 +1131,10 @@ module ProcessKKRresults_mod
reclen = max(reclen, 4*8 + 1*1 + 3*8) reclen = max(reclen, 4*8 + 1*1 + 3*8)
end if end if
if (noncobfield) then if (noncobfield) then
! The constraint bfields, torques, and moments before fixing directions ! The constraint bfields (from this and from last iteration), torques,
! (each double(3)) ! and moments before fixing directions (each double(3))
recnum = recnum + 1 recnum = recnum + 1
reclen = max(reclen, (3+3+3)*8) reclen = max(reclen, (3+3+3+3)*8)
end if end if
end subroutine end subroutine
...@@ -1206,8 +1206,11 @@ module ProcessKKRresults_mod ...@@ -1206,8 +1206,11 @@ module ProcessKKRresults_mod
irec = irec + 1 irec = irec + 1
endif endif
if (params%noncobfield) then if (params%noncobfield) then
write(unit=r1fu, rec=irec) calc%bfields(ila)%bfield_constr, & write(unit=r1fu, rec=irec) &
calc%bfields(ila)%mag_torque, calc%bfields(ila)%mag_mom calc%bfields(ila)%bfield_constr, &
calc%bfields(ila)%last_bfield_constr, &
calc%bfields(ila)%mag_torque, &
calc%bfields(ila)%mag_mom
irec = irec + 1 irec = irec + 1
end if end if
end do end do
...@@ -1658,13 +1661,15 @@ module ProcessKKRresults_mod ...@@ -1658,13 +1661,15 @@ module ProcessKKRresults_mod
double precision delta_angle !NOCO double precision delta_angle !NOCO
integer :: max_delta_atom !NOCO integer :: max_delta_atom !NOCO
double precision, dimension(3) :: dir ! NOCO, direction of local frame of reference double precision, dimension(3) :: dir ! NOCO, direction of local frame of reference
double precision, dimension(3) :: constr_field double precision, dimension(3) :: constr_field, last_constr_field
double precision, dimension(3) :: torque ! torque of the current atom double precision, dimension(3) :: torque ! torque of the current atom
double precision, dimension(3) :: newmoment ! magnetic moment before angle constraint double precision, dimension(3) :: newmoment ! magnetic moment before angle constraint
double precision :: max_torque_sqrd ! squared magnitude of largest torque so far double precision :: max_torque_sqrd ! squared magnitude of largest torque so far
integer :: max_torque_atom ! atom with largest torque so far integer :: max_torque_atom ! atom with largest torque so far
double precision :: constr_angle_change, max_constr_angle_change double precision :: constr_angle_change, max_constr_angle_change
integer :: max_constr_angle_change_atom integer :: max_constr_angle_change_atom
double precision :: constr_field_change, max_constr_field_change
integer :: max_constr_field_change_atom
integer :: reclen, recnum, irec, ie, lrecres2 integer :: reclen, recnum, irec, ie, lrecres2
integer :: lcoremax, i1, ispin, lpot integer :: lcoremax, i1, ispin, lpot
character(len=*), parameter :: & character(len=*), parameter :: &
...@@ -1680,6 +1685,8 @@ module ProcessKKRresults_mod ...@@ -1680,6 +1685,8 @@ module ProcessKKRresults_mod
F82="(' Largest torque magnitude [Ry] = ',E12.6)", & F82="(' Largest torque magnitude [Ry] = ',E12.6)", &
F83="(' Largest change of angle for constraint moment at atom = ', i5)", & F83="(' Largest change of angle for constraint moment at atom = ', i5)", &
F84="(' Largest change of angle for constraint moment (deg) = ', f10.6)", & F84="(' Largest change of angle for constraint moment (deg) = ', f10.6)", &
F85="(' Largest change in constraint field at atom = ', i5)", &
F80="(' Largest change in constraint field (Ry) = ', e10.4)", &
F94="(4X,'nuclear charge ',F10.6,9X,'core charge = ',F10.6)" F94="(4X,'nuclear charge ',F10.6,9X,'core charge = ',F10.6)"
integer :: npotd integer :: npotd
...@@ -1694,6 +1701,8 @@ module ProcessKKRresults_mod ...@@ -1694,6 +1701,8 @@ module ProcessKKRresults_mod
max_torque_atom = 0 max_torque_atom = 0
max_constr_angle_change = 0. max_constr_angle_change = 0.
max_constr_angle_change_atom = -1 ! Initially a flag that means "feature not used (yet)" max_constr_angle_change_atom = -1 ! Initially a flag that means "feature not used (yet)"
max_constr_field_change = 0.
max_constr_field_change_atom = 0
! Calculate size of data written per atom ! Calculate size of data written per atom
call calculateResults1FileShapes(reclen, recnum, compute_total_energy, & call calculateResults1FileShapes(reclen, recnum, compute_total_energy, &
...@@ -1776,7 +1785,7 @@ module ProcessKKRresults_mod ...@@ -1776,7 +1785,7 @@ module ProcessKKRresults_mod
irec = irec + 1 irec = irec + 1
if (noncobfield) then if (noncobfield) then
read(71, rec=irec) constr_field, torque, newmoment read(71, rec=irec) constr_field, last_constr_field, torque, newmoment
irec = irec + 1 irec = irec + 1
end if end if
...@@ -1831,6 +1840,17 @@ module ProcessKKRresults_mod ...@@ -1831,6 +1840,17 @@ module ProcessKKRresults_mod
max_constr_angle_change = constr_angle_change max_constr_angle_change = constr_angle_change
max_constr_angle_change_atom = i1 max_constr_angle_change_atom = i1
end if end if
! Look for largest change in constraining field
! Reuse variable for difference
last_constr_field = last_constr_field - constr_field
! Calculate the absolute value of the change (squared)
constr_field_change = dot_product(last_constr_field, last_constr_field)
if (constr_field_change > max_constr_field_change) then
! Update
max_constr_field_change = constr_field_change
max_constr_field_change_atom = i1
end if
end if end if
end if end if
...@@ -1882,6 +1902,8 @@ module ProcessKKRresults_mod ...@@ -1882,6 +1902,8 @@ module ProcessKKRresults_mod
if (max_constr_angle_change_atom >= 0) then if (max_constr_angle_change_atom >= 0) then
write(6, fmt=F83) max_constr_angle_change_atom write(6, fmt=F83) max_constr_angle_change_atom
write(6, fmt=F84) 180.0/PI*max_constr_angle_change write(6, fmt=F84) 180.0/PI*max_constr_angle_change
write(6, fmt=F85) max_constr_field_change_atom
write(6, fmt=F80) sqrt(max_constr_field_change)
end if end if
end if end if
write(6, '(79(1h+))') write(6, '(79(1h+))')
......
...@@ -32,6 +32,7 @@ module mod_bfield ...@@ -32,6 +32,7 @@ module mod_bfield
! Noncollinear magnetic fields ! Noncollinear magnetic fields
double precision, dimension(3) :: bfield_ext !! external magnetic field in cartesian coordinates 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) :: bfield_constr !! constraining field in cartesian coordinates
double precision, dimension(3) :: last_bfield_constr !! constraining field of last iteration
! Torque and other information used to update the constraints fields ! Torque and other information used to update the constraints fields
double precision, dimension(3) :: mag_torque !! Magnetic torque double precision, dimension(3) :: mag_torque !! Magnetic torque
......
...@@ -183,6 +183,9 @@ contains ...@@ -183,6 +183,9 @@ contains
mag_mom_dir = bfield%mag_mom(:) / mag_mom_len mag_mom_dir = bfield%mag_mom(:) / mag_mom_len
mag_mom_sign = sign(1., dot_product(mag_mom_dir, dir)) mag_mom_sign = sign(1., dot_product(mag_mom_dir, dir))
! Save previous iterations field
bfield%last_bfield_constr = bfield%bfield_constr
if (constr_mode == 3) then if (constr_mode == 3) then
bfield%bfield_constr(:) = bfield%bfield_constr(:) - & bfield%bfield_constr(:) = bfield%bfield_constr(:) - &
( mag_mom_sign * (bfield%mag_torque(:) / mag_mom_len) * & ( mag_mom_sign * (bfield%mag_torque(:) / mag_mom_len) * &
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment