8 #ifndef mpqc_interfaces_tiledarray_tests_dmm_scf_hpp
9 #define mpqc_interfaces_tiledarray_tests_dmm_scf_hpp
12 #include "tiledarray_fock.hpp"
13 #include <TiledArray/algebra/diis.h>
14 #include "curvy_steps.hpp"
19 using Array2 = TA::Array<double,2>;
20 using Array3 = TA::Array<double,3>;
21 using Array4 = TA::Array<double,4>;
26 Density_Update(Array2 &R,
const Array2 &S,
const Array2 &F,
27 const std::size_t iter,
28 const std::size_t rot_order = 4){
29 curvy_steps::Density_Update(R, S, F, iter, rot_order);
32 double DF_DMM(Array2 &D,
const Array2 &S,
const Array2 &H,
33 Array2 &F, Array2 &G,
const Array3 &Eri3,
34 const Array2 &Inv_Eri2,
double nuc_repl){
37 TA::DIIS<Array2> diis;
42 double error_norminf = 1.0;
45 while(error_norminf > 4e-6){
46 double iter0 = madness::wall_time();
49 double mad_conj0 = madness::wall_time();
50 Density_Update(D, S, F, scf_iter);
51 double mad_conjf = madness::wall_time();
54 double Fock0 = madness::wall_time();
56 (Eri3(
"i,j,X") * Inv_Eri2(
"X,Y") * (Eri3(
"n,m,Y") * D(
"m,n"))) -
57 (Eri3(
"i,n,X") * Inv_Eri2(
"X,Y") * (Eri3(
"j,m,Y") * D(
"m,n")));
58 F(
"i,j") = H(
"i,j") + G(
"i,j");
59 S.world().gop.fence();
62 Array2 gradient = 8 * ( S(
"i,q") * D(
"q,x") * F(
"x,j") -
63 F(
"i,q") * D(
"q,x") * S(
"x,j") );
66 error_norminf = TA::expressions::norminf(gradient(
"i,j"));
67 diis.extrapolate(F, gradient);
70 energy = TA::expressions::dot( 2.0 * H(
"i,j") + G(
"i,j"), D(
"i,j") );
72 S.world().gop.fence();
73 double iterf = madness::wall_time();
78 return energy + nuc_repl;