Skip to content

Commit

Permalink
Introduce a guard against overflow in the dense FOE
Browse files Browse the repository at this point in the history
  • Loading branch information
william-dawson committed Dec 16, 2024
1 parent 20f55fe commit 0252acb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Source/Fortran/FermiOperatorModule.F90
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ SUBROUTINE ComputeDenseFOE(H, ISQ, trace, K, inv_temp_in, &
chemical_potential = left + (right - left) / 2
DO II = 1, num_eigs
sval = eigs(II) - chemical_potential
! occ(II) = 0.5_NTREAL * (1.0_NTREAL - ERF(inv_temp * sval))
occ(II) = 1.0_NTREAL / (1.0_NTREAL + EXP(inv_temp * sval))
! Guard against overflow
IF (inv_temp * sval .GT. 30) THEN
occ(II) = 0.5_NTREAL * (1.0_NTREAL - ERF(inv_temp * sval))
ELSE
occ(II) = 1.0_NTREAL / (1.0_NTREAL + EXP(inv_temp * sval))
END IF
END DO
sv = SUM(occ)
IF (ABS(trace - sv) .LT. 1E-8_NTREAL) THEN
Expand Down

0 comments on commit 0252acb

Please sign in to comment.