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,17 +319,27 @@ let make
xt_o_x (Mat.sub fps spf) m_X
in
let diis, m_F_diis =
let diis =
DIIS.append ~p:(Mat.as_vec m_F_ortho) ~e:(Mat.as_vec error_fock) diis
in
try
let m_F_diis =
let x =
Bigarray.genarray_of_array1 (DIIS.next diis)
in
Bigarray.reshape_2 x (Mat.dim1 m_F_ortho) (Mat.dim2 m_F_ortho)
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
let m_F_diis =
let x =
Bigarray.genarray_of_array1 (DIIS.next diis)
in
Bigarray.reshape_2 x (Mat.dim1 m_F_ortho) (Mat.dim2 m_F_ortho)
in
(* MOs in orthogonal MO basis *)
let m_C', _ =
@ -515,15 +525,22 @@ let make
xt_o_x (Mat.sub fps spf) m_X
in
let diis =
DIIS.append ~p:(Mat.as_vec m_F_ortho) ~e:(Mat.as_vec error_fock) diis
in
let m_F_diis =
let x =
Bigarray.genarray_of_array1 (DIIS.next diis)
let diis, m_F_diis =
let diis =
DIIS.append ~p:(Mat.as_vec m_F_ortho) ~e:(Mat.as_vec error_fock) diis
in
Bigarray.reshape_2 x (Mat.dim1 m_F_ortho) (Mat.dim2 m_F_ortho)
try
let m_F_diis =
let x =
Bigarray.genarray_of_array1 (DIIS.next diis)
in
Bigarray.reshape_2 x (Mat.dim1 m_F_ortho) (Mat.dim2 m_F_ortho)
in
diis, m_F_diis
with Failure _ -> (* Failure in DIIS.next *)
DIIS.make (), m_F_ortho
in

View File

@ -9,7 +9,7 @@ The DIIS approximate solution for iteration {% $m+1$ %} is given by
{% \begin{align*}
\mathbf{p}_{m+1} & = \sum_{i=1}^m c_i (\mathbf{p}^f + \mathbf{e}_i) \\
& = \sum_{i=1}^m c_i \mathbf{p}^f + \sum_i c_i \mathbf{e}_i
& = \sum_{i=1}^m c_i \mathbf{p}^f + \sum_i c_i \mathbf{e}_i
\end{align*} %}
where {% $\mathbf{p}^f$ %} is the exact solution. One wants to minimize the