Commit 42ce8d6b authored by Yingzhou Li's avatar Yingzhou Li

Added preconditioner

parent 45b29a8e
......@@ -293,18 +293,33 @@ contains
end if
call rci_op_null(task)
if (iter > 0) then
ijob = ijob + 1
else
ijob = ijob + 2
end if
return
end if
! - G = Psi'*HPsi
if (ijob == SID_LOCK + 2) then
call rci_op_gemm(iS, task, 'C', 'N', n, n, &
m, 1.0_r8, &
MID_Psi, m, MID_HPsi, m, 0.0_r8, &
MID_G, max_n)
ijob = ijob + 1
return
end if
! G = G(not conv, not conv)
if (ijob == SID_LOCK + 2) then
if (ijob == SID_LOCK + 3) then
call rci_op_subcol(iS, task, n, n, &
MID_G, MID_WORK)
ijob = ijob + 1
return
end if
if (ijob == SID_LOCK + 3) then
if (ijob == SID_LOCK + 4) then
call rci_op_subrow(iS, task, n, nact, &
MID_WORK, MID_G)
ijob = ijob + 1
......@@ -312,16 +327,21 @@ contains
end if
! - trG = trace(G)
if (ijob == SID_LOCK + 4) then
if (ijob == SID_LOCK + 5) then
call rci_op_trace(iS, task, nact, MID_G, max_n)
ijob = ijob + 1
return
end if
! - check conv
if (ijob == SID_LOCK + 5) then
if (ijob == SID_LOCK + 6) then
trG = resvec(1)
trdiff = abs(trG-trG_old)
trG_old = trG
print *, trG
if (r_h%verbose > 0) write(*,'(a,i5,a,es15.7e3)') &
'Iter ', iter, ', Rel Err: ', trdiff/trG
if ((nact == 0) .or. (iter == max_iter)) then
ijob = SID_FINISH
call rci_op_null(task)
......@@ -334,7 +354,7 @@ contains
end if
! Psi_lock = Psi(:, conv)
if (ijob == SID_LOCK + 6) then
if (ijob == SID_LOCK + 7) then
resvec = 1.0_r8 - act_idx
call rci_op_subcol(iS, task, m, n, MID_Psi, MID_Psi_lock)
ijob = ijob + 1
......@@ -342,63 +362,63 @@ contains
end if
! HPsi_lock = HPsi(:, conv)
if (ijob == SID_LOCK + 7) then
if (ijob == SID_LOCK + 8) then
call rci_op_subcol(iS, task, m, n, MID_HPsi, MID_HPsi_lock)
ijob = ijob + 1
return
end if
! SPsi_lock = SPsi_lock
if (ijob == SID_LOCK + 8) then
if (ijob == SID_LOCK + 9) then
call rci_op_subcol(iS, task, m, n, MID_SPsi, MID_SPsi_lock)
ijob = ijob + 1
return
end if
! Psi = Psi(:, not conv)]
if (ijob == SID_LOCK + 9) then
if (ijob == SID_LOCK + 10) then
resvec = act_idx
call rci_op_subcol(iS, task, m, n, MID_Psi, MID_PWORK)
ijob = ijob + 1
return
end if
if (ijob == SID_LOCK + 10) then
if (ijob == SID_LOCK + 11) then
call rci_op_copy(iS, task, 'N', MID_PWORK, MID_Psi)
ijob = ijob + 1
return
end if
! W = W(:, not conv)]
if (ijob == SID_LOCK + 11) then
if (ijob == SID_LOCK + 12) then
call rci_op_subcol(iS, task, m, n, MID_W, MID_PWORK)
ijob = ijob + 1
return
end if
if (ijob == SID_LOCK + 12) then
if (ijob == SID_LOCK + 13) then
call rci_op_copy(iS, task, 'N', MID_PWORK, MID_W)
ijob = ijob + 1
return
end if
! HPsi = HPsi(:, not conv)]
if (ijob == SID_LOCK + 13) then
if (ijob == SID_LOCK + 14) then
call rci_op_subcol(iS, task, m, n, MID_HPsi, MID_PWORK)
ijob = ijob + 1
return
end if
if (ijob == SID_LOCK + 14) then
if (ijob == SID_LOCK + 15) then
call rci_op_copy(iS, task, 'N', MID_PWORK, MID_HPsi)
ijob = ijob + 1
return
end if
! SPsi = SPsi(:, not conv)]
if (ijob == SID_LOCK + 15) then
if (ijob == SID_LOCK + 16) then
call rci_op_subcol(iS, task, m, n, MID_SPsi, MID_PWORK)
ijob = ijob + 1
return
end if
if (ijob == SID_LOCK + 16) then
if (ijob == SID_LOCK + 17) then
call rci_op_copy(iS, task, 'N', MID_PWORK, MID_SPsi)
ijob = SID_ITER
return
......@@ -1313,8 +1333,10 @@ contains
trdiff = abs(trG-trG_old)
trG_old = trG
print *, trG
if (r_h%verbose > 0) write(*,'(a,i5,a,es15.7e3)') &
'Iter ', iter, ', Rel Err: ', trdiff
'Iter ', iter, ', Rel Err: ', trdiff/trG
if ((trdiff < tol_iter*sqrt(dble(nact))) &
.or. (iter == max_iter)) then
call rci_op_null(task)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment