10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-07 06:33:39 +01:00

Fixed DIIS

This commit is contained in:
Anthony Scemama 2019-12-05 15:10:14 +01:00
parent 1db40e023f
commit be8b2d8b2b
2 changed files with 33 additions and 16 deletions

View File

@ -319,16 +319,26 @@ let make
xt_o_x (Mat.sub fps spf) m_X xt_o_x (Mat.sub fps spf) m_X
in in
let diis, m_F_diis =
let diis = let diis =
DIIS.append ~p:(Mat.as_vec m_F_ortho) ~e:(Mat.as_vec error_fock) diis DIIS.append ~p:(Mat.as_vec m_F_ortho) ~e:(Mat.as_vec error_fock) diis
in in
try
let m_F_diis = let m_F_diis =
let x = let x =
Bigarray.genarray_of_array1 (DIIS.next diis) Bigarray.genarray_of_array1 (DIIS.next diis)
in in
Bigarray.reshape_2 x (Mat.dim1 m_F_ortho) (Mat.dim2 m_F_ortho) Bigarray.reshape_2 x (Mat.dim1 m_F_ortho) (Mat.dim2 m_F_ortho)
in in
diis, m_F_diis
with Failure _ -> (* Failure in DIIS.next *)
DIIS.make (), m_F_ortho
in
let diis =
DIIS.append ~p:(Mat.as_vec m_F_ortho) ~e:(Mat.as_vec error_fock) diis
in
(* MOs in orthogonal MO basis *) (* MOs in orthogonal MO basis *)
@ -515,16 +525,23 @@ let make
xt_o_x (Mat.sub fps spf) m_X xt_o_x (Mat.sub fps spf) m_X
in in
let diis, m_F_diis =
let diis = let diis =
DIIS.append ~p:(Mat.as_vec m_F_ortho) ~e:(Mat.as_vec error_fock) diis DIIS.append ~p:(Mat.as_vec m_F_ortho) ~e:(Mat.as_vec error_fock) diis
in in
try
let m_F_diis = let m_F_diis =
let x = let x =
Bigarray.genarray_of_array1 (DIIS.next diis) Bigarray.genarray_of_array1 (DIIS.next diis)
in in
Bigarray.reshape_2 x (Mat.dim1 m_F_ortho) (Mat.dim2 m_F_ortho) Bigarray.reshape_2 x (Mat.dim1 m_F_ortho) (Mat.dim2 m_F_ortho)
in in
diis, m_F_diis
with Failure _ -> (* Failure in DIIS.next *)
DIIS.make (), m_F_ortho
in
(* MOs in orthogonal MO basis *) (* MOs in orthogonal MO basis *)