Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Early exit feature for WOM #226

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Source/Fortran/FermiOperatorModule.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MODULE FermiOperatorModule
USE EigenSolversModule, ONLY : EigenDecomposition
USE LoadBalancerModule, ONLY : PermuteMatrix, UndoPermuteMatrix
USE LoggingModule, ONLY : WriteElement, WriteHeader, &
& EnterSubLog, ExitSubLog, WriteListElement
& EnterSubLog, ExitSubLog, WriteListElement, WriteComment
USE PSMatrixAlgebraModule, ONLY : MatrixMultiply, SimilarityTransform, &
& IncrementMatrix, MatrixNorm, ScaleMatrix, DotMatrix, MatrixTrace
USE PSMatrixModule, ONLY : Matrix_ps, ConstructEmptyMatrix, &
Expand Down Expand Up @@ -355,7 +355,7 @@ SUBROUTINE WOM_Implementation(H, ISQ, K, inv_temp, params, &
TYPE(Matrix_ps) :: Temp, W, A, X, KOrth
TYPE(MatrixMemoryPool_p) :: pool
INTEGER :: II
REAL(NTREAL) :: step, B_I, B_I_old, err, sparsity, energy
REAL(NTREAL) :: step, B_I, B_I_old, err, err2, sparsity, energy

GC = PRESENT(mu_in)

Expand Down Expand Up @@ -464,6 +464,16 @@ SUBROUTINE WOM_Implementation(H, ISQ, K, inv_temp, params, &
err = MatrixNorm(Temp)
END DO

!! Early Exit Criteria
CALL CopyMatrix(RK2, Temp)
CALL IncrementMatrix(W, Temp, alpha_in = -1.0_NTREAL, &
& threshold_in = params%threshold)
err2 = MatrixNorm(Temp)
IF (err2 .LT. params%converge_diff) THEN
CALL WriteComment("Early Exit Triggered")
EXIT
END IF

!! Update
CALL CopyMatrix(RK2, W)
B_I_old = B_I
Expand All @@ -478,6 +488,7 @@ SUBROUTINE WOM_Implementation(H, ISQ, K, inv_temp, params, &
CALL WriteElement("Beta", VALUE = B_I_old)
CALL WriteElement("Sparsity", VALUE = sparsity)
CALL WriteElement("Energy", VALUE = energy)
CALL WriteElement("Norm of Change", VALUE = err2)
CALL ExitSubLog
END IF
END DO
Expand Down