28 #ifndef _mpqc_src_lib_chemistry_qc_mbptr12_srr12intermediatesVXBdiag_h
29 #define _mpqc_src_lib_chemistry_qc_mbptr12_srr12intermediatesVXBdiag_h
31 #include <tiledarray.h>
35 inline double get_element(
const TA::TArrayD& array,
const std::vector<std::size_t>& ele_idx)
37 const std::vector<std::size_t> tile_idx = array.trange().element_to_tile(ele_idx);
38 return (array.find(tile_idx).get()[ele_idx]);
43 SingleReference_R12Intermediates<T>::XaiAddToXam(
const TA::Array<double, 2 >& Xam,
44 const TA::Array<double, 2 >& Xai) {
65 X(
"a,m") = Xam(
"a,m") + Xai(
"a,i") * _2(
"<i|I|m>");
72 SingleReference_R12Intermediates<T>::BPk_Qk(
const char* p,
const char* q,
73 const double C_0,
const double C_1) {
75 const double B_C1 = 0.5 * C_0 * C_0 + 1.5 * C_1 * C_1;
76 const double B_C2 = 0.5 * C_0 * C_0 - 1.5 * C_1 * C_1;
78 std::string rTr_pkql = std::string(
"<") + p +
" k|rTr|" + q +
" l>";
79 std::string rTr_kpql = std::string(
"<k ") + p +
"|rTr|" + q +
" l>";
81 std::string r2_phJk_ql = std::string(
"<") + p +
"_hJ(p') k|r2|" + q +
" l>";
82 std::string r2_pkhJ_ql = std::string(
"<") + p +
" k_hJ(p')|r2|" + q +
" l>";
84 std::string r2_kphJ_ql = std::string(
"<k ") + p +
"_hJ(p')|r2|" + q +
" l>";
85 std::string r2_khJp_ql = std::string(
"<k_hJ(p') ") + p +
"|r2|" + q +
" l>";
87 std::string r2_pk_qhJl = std::string(
"<") + p +
" k|r2|" + q +
"_hJ(p') l>";
88 std::string r2_pk_qlhJ = std::string(
"<") + p +
" k|r2|" + q +
" l_hJ(p')>";
90 std::string r2_pk_lqhJ = std::string(
"<") + p +
" k|r2|l " + q +
"_hJ(p')>";
91 std::string r2_pk_lhJq = std::string(
"<") + p +
" k|r2|l_hJ(p') " + q +
">";
93 std::string pk_PQ = std::string(
"<") + p +
" k|r|p' q'>";
94 std::string kp_PQ = std::string(
"<k ") + p +
"|r|p' q'>";
95 std::string qk_PKQ = std::string(
"<") + q +
" k|r|p'_K(r') q'>";
96 std::string kq_PKQ = std::string(
"<k ") + q +
"|r|p'_K(r') q'>";
98 std::string pk_Pn = std::string(
"<") + p +
" k|r|p' n>";
99 std::string kp_Pn = std::string(
"<k ") + p +
"|r|p' n>";
100 std::string qk_PFn = std::string(
"<") + q +
" k|r|p'_F(r') n>";
101 std::string kq_PFn = std::string(
"<k ") + q +
"|r|p'_F(r') n>";
103 std::string pk_mA = std::string(
"<") + p +
" k|r|m a'>";
104 std::string kp_mA = std::string(
"<k ") + p +
"|r|m a'>";
105 std::string qk_mFA = std::string(
"<") + q +
" k|r|m_F(n) a'>";
106 std::string kq_mFA = std::string(
"<k ") + q +
"|r|m_F(n) a'>";
108 std::string pk_pq = std::string(
"<") + p +
" k|r|p b>";
109 std::string kp_pq = std::string(
"<k ") + p +
"|r|p b>";
110 std::string qk_pFb = std::string(
"<") + q +
" k|r|p_F(r) b>";
111 std::string kq_pFb = std::string(
"<k ") + q +
"|r|p_F(r) b>";
113 std::string qk_mFPA = std::string(
"<") + q +
" k|r|m_F(p') a'>";
114 std::string kq_mFPA = std::string(
"<k ") + q +
"|r|m_F(p') a'>";
116 std::string qk_mA = std::string(
"<") + q +
" k|r|m a'>";
117 std::string kq_mA = std::string(
"<k ") + q +
"|r|m a'>";
118 std::string pk_mFPA = std::string(
"<") + p +
" k|r|m_F(p') a'>";
119 std::string kp_mFPA = std::string(
"<k ") + p +
"|r|m_F(p') a'>";
121 std::string pk_Ab = std::string(
"<") + p +
" k|r|a' b>";
122 std::string kp_Ab = std::string(
"<k ") + p +
"|r|a' b>";
123 std::string qk_AFb = std::string(
"<") + q +
" k|r|a'_F(q) b>";
124 std::string kq_AFb = std::string(
"<k ") + q +
"|r|a'_F(q) b>";
126 std::string qk_Ab = std::string(
"<") + q +
" k|r|a' b>";
127 std::string kq_Ab = std::string(
"<k ") + q +
"|r|a' b>";
128 std::string pk_AFb = std::string(
"<") + p +
" k|r|a'_F(q) b>";
129 std::string kp_AFb = std::string(
"<k ") + p +
"|r|a'_F(q) b>";
131 std::string pq = p + std::string(
",") + q;
136 ( B_C1 * _4(rTr_pkql.c_str()) + B_C2 * _4(rTr_kpql.c_str())
139 B_C1 * (_4(r2_phJk_ql.c_str()) + _4(r2_pkhJ_ql.c_str()))
140 + B_C2 * (_4(r2_kphJ_ql.c_str()) + _4(r2_khJp_ql.c_str()))
142 + B_C1 * (_4(r2_pk_qhJl.c_str()) + _4(r2_pk_qlhJ.c_str()))
143 + B_C2 * (_4(r2_pk_lqhJ.c_str()) + _4(r2_pk_lhJq.c_str()))
147 - ( B_C1 * (_4(pk_PQ.c_str()) * _4(qk_PKQ.c_str())
148 + _4(kp_PQ.c_str()) * _4(kq_PKQ.c_str()))
149 + B_C2 * (_4(kp_PQ.c_str()) * _4(qk_PKQ.c_str())
150 + _4(pk_PQ.c_str()) * _4(kq_PKQ.c_str()))
153 - ( B_C1 * (_4(pk_Pn.c_str()) * _4(qk_PFn.c_str())
154 + _4(kp_Pn.c_str()) * _4(kq_PFn.c_str()))
155 + B_C2 * (_4(kp_Pn.c_str()) * _4(qk_PFn.c_str())
156 + _4(pk_Pn.c_str()) * _4(kq_PFn.c_str()))
159 + ( B_C1 * (_4(pk_mA.c_str()) * _4(qk_mFA.c_str())
160 + _4(kp_mA.c_str()) * _4(kq_mFA.c_str()))
161 + B_C2 * (_4(kp_mA.c_str()) * _4(qk_mFA.c_str())
162 + _4(pk_mA.c_str()) * _4(kq_mFA.c_str()))
165 - ( B_C1 * (_4(pk_pq.c_str()) * _4(qk_pFb.c_str())
166 + _4(kp_pq.c_str()) * _4(kq_pFb.c_str()))
167 + B_C2 * (_4(kp_pq.c_str()) * _4(qk_pFb.c_str())
168 + _4(pk_pq.c_str()) * _4(kq_pFb.c_str()))
171 - ( B_C1 * (_4(pk_mA.c_str()) * _4(qk_mFPA.c_str())
172 + _4(kp_mA.c_str()) * _4(kq_mFPA.c_str()))
173 + B_C2 * (_4(kp_mA.c_str()) * _4(qk_mFPA.c_str())
174 + _4(pk_mA.c_str()) * _4(kq_mFPA.c_str()))
176 + B_C1 * (_4(qk_mA.c_str()) * _4(pk_mFPA.c_str())
177 + _4(kq_mA.c_str()) * _4(kp_mFPA.c_str()))
178 + B_C2 * (_4(kq_mA.c_str()) * _4(pk_mFPA.c_str())
179 + _4(qk_mA.c_str()) * _4(kp_mFPA.c_str()))
182 - ( B_C1 * (_4(pk_Ab.c_str()) * _4(qk_AFb.c_str())
183 + _4(kp_Ab.c_str()) * _4(kq_AFb.c_str()))
184 + B_C2 * (_4(kp_Ab.c_str()) * _4(qk_AFb.c_str())
185 + _4(pk_Ab.c_str()) * _4(kq_AFb.c_str()))
187 + B_C1 * (_4(qk_Ab.c_str()) * _4(pk_AFb.c_str())
188 + _4(kq_Ab.c_str()) * _4(kp_AFb.c_str()))
189 + B_C2 * (_4(kq_Ab.c_str()) * _4(pk_AFb.c_str())
190 + _4(qk_Ab.c_str()) * _4(kp_AFb.c_str()))
195 template <
typename T>
197 SingleReference_R12Intermediates<T>::Bpr_qs(
const char* p,
const char* q)
200 const double C_0 = 0.5;
201 const double C_1 = 0.25;
202 const double B_C1 = 0.5 * C_0 * C_0 + 1.5 * C_1 * C_1;
203 const double B_C2 = 0.5 * C_0 * C_0 - 1.5 * C_1 * C_1;
205 std::string rTr_pkql = std::string(
"<") + p +
" k|rTr|" + q +
" l>";
206 std::string rTr_kpql = std::string(
"<k ") + p +
"|rTr|" + q +
" l>";
208 std::string r2_phJk_ql = std::string(
"<") + p +
"_hJ(p') k|r2|" + q +
" l>";
209 std::string r2_pkhJ_ql = std::string(
"<") + p +
" k_hJ(p')|r2|" + q +
" l>";
211 std::string r2_kphJ_ql = std::string(
"<k ") + p +
"_hJ(p')|r2|" + q +
" l>";
212 std::string r2_khJp_ql = std::string(
"<k_hJ(p') ") + p +
"|r2|" + q +
" l>";
214 std::string r2_pk_qhJl = std::string(
"<") + p +
" k|r2|" + q +
"_hJ(p') l>";
215 std::string r2_pk_qlhJ = std::string(
"<") + p +
" k|r2|" + q +
" l_hJ(p')>";
217 std::string r2_pk_lqhJ = std::string(
"<") + p +
" k|r2|l " + q +
"_hJ(p')>";
218 std::string r2_pk_lhJq = std::string(
"<") + p +
" k|r2|l_hJ(p') " + q +
">";
220 std::string pk_PQ = std::string(
"<") + p +
" k|r|p' q'>";
221 std::string kp_PQ = std::string(
"<k ") + p +
"|r|p' q'>";
222 std::string ql_PKQ = std::string(
"<") + q +
" l|r|p'_K(r') q'>";
223 std::string lq_PKQ = std::string(
"<l ") + q +
"|r|p'_K(r') q'>";
225 std::string pk_Pn = std::string(
"<") + p +
" k|r|p' n>";
226 std::string kp_Pn = std::string(
"<k ") + p +
"|r|p' n>";
227 std::string ql_PFn = std::string(
"<") + q +
" l|r|p'_F(r') n>";
228 std::string lq_PFn = std::string(
"<l ") + q +
"|r|p'_F(r') n>";
230 std::string pk_mA = std::string(
"<") + p +
" k|r|m a'>";
231 std::string kp_mA = std::string(
"<k ") + p +
"|r|m a'>";
232 std::string ql_mFA = std::string(
"<") + q +
" l|r|m_F(n) a'>";
233 std::string lq_mFA = std::string(
"<l ") + q +
"|r|m_F(n) a'>";
235 std::string pk_pq = std::string(
"<") + p +
" k|r|p b>";
236 std::string kp_pq = std::string(
"<k ") + p +
"|r|p b>";
237 std::string ql_pFb = std::string(
"<") + q +
" l|r|p_F(r) b>";
238 std::string lq_pFb = std::string(
"<l ") + q +
"|r|p_F(r) b>";
240 std::string ql_mFPA = std::string(
"<") + q +
" l|r|m_F(p') a'>";
241 std::string lq_mFPA = std::string(
"<l ") + q +
"|r|m_F(p') a'>";
243 std::string ql_mA = std::string(
"<") + q +
" l|r|m a'>";
244 std::string lq_mA = std::string(
"<l ") + q +
"|r|m a'>";
245 std::string pk_mFPA = std::string(
"<") + p +
" k|r|m_F(p') a'>";
246 std::string kp_mFPA = std::string(
"<k ") + p +
"|r|m_F(p') a'>";
248 std::string pk_Ab = std::string(
"<") + p +
" k|r|a' b>";
249 std::string kp_Ab = std::string(
"<k ") + p +
"|r|a' b>";
250 std::string ql_AFb = std::string(
"<") + q +
" l|r|a'_F(q) b>";
251 std::string lq_AFb = std::string(
"<l ") + q +
"|r|a'_F(q) b>";
253 std::string ql_Ab = std::string(
"<") + q +
" l|r|a' b>";
254 std::string lq_Ab = std::string(
"<l ") + q +
"|r|a' b>";
255 std::string pk_AFb = std::string(
"<") + p +
" k|r|a'_F(q) b>";
256 std::string kp_AFb = std::string(
"<k ") + p +
"|r|a'_F(q) b>";
261 B_C1 * _4(rTr_pkql.c_str()) + B_C2 * _4(rTr_kpql.c_str())
264 B_C1 * (_4(r2_phJk_ql.c_str()) + _4(r2_pkhJ_ql.c_str()))
265 + B_C2 * (_4(r2_kphJ_ql.c_str()) + _4(r2_khJp_ql.c_str()))
267 + B_C1 * (_4(r2_pk_qhJl.c_str()) + _4(r2_pk_qlhJ.c_str()))
268 + B_C2 * (_4(r2_pk_lqhJ.c_str()) + _4(r2_pk_lhJq.c_str()))
271 - ( B_C1 * (_4(pk_PQ.c_str()) * _4(ql_PKQ.c_str())
272 + _4(kp_PQ.c_str()) * _4(lq_PKQ.c_str()))
273 + B_C2 * (_4(kp_PQ.c_str()) * _4(ql_PKQ.c_str())
274 + _4(pk_PQ.c_str()) * _4(lq_PKQ.c_str()))
277 - ( B_C1 * (_4(pk_Pn.c_str()) * _4(ql_PFn.c_str())
278 + _4(kp_Pn.c_str()) * _4(lq_PFn.c_str()))
279 + B_C2 * (_4(kp_Pn.c_str()) * _4(ql_PFn.c_str())
280 + _4(pk_Pn.c_str()) * _4(lq_PFn.c_str()))
283 + ( B_C1 * (_4(pk_mA.c_str()) * _4(ql_mFA.c_str())
284 + _4(kp_mA.c_str()) * _4(lq_mFA.c_str()))
285 + B_C2 * (_4(kp_mA.c_str()) * _4(ql_mFA.c_str())
286 + _4(pk_mA.c_str()) * _4(lq_mFA.c_str()))
289 - ( B_C1 * (_4(pk_pq.c_str()) * _4(ql_pFb.c_str())
290 + _4(kp_pq.c_str()) * _4(lq_pFb.c_str()))
291 + B_C2 * (_4(kp_pq.c_str()) * _4(ql_pFb.c_str())
292 + _4(pk_pq.c_str()) * _4(lq_pFb.c_str()))
295 - ( B_C1 * (_4(pk_mA.c_str()) * _4(ql_mFPA.c_str())
296 + _4(kp_mA.c_str()) * _4(lq_mFPA.c_str()))
297 + B_C2 * (_4(kp_mA.c_str()) * _4(ql_mFPA.c_str())
298 + _4(pk_mA.c_str()) * _4(lq_mFPA.c_str()))
300 + B_C1 * (_4(ql_mA.c_str()) * _4(pk_mFPA.c_str())
301 + _4(lq_mA.c_str()) * _4(kp_mFPA.c_str()))
302 + B_C2 * (_4(lq_mA.c_str()) * _4(pk_mFPA.c_str())
303 + _4(ql_mA.c_str()) * _4(kp_mFPA.c_str()))
306 - ( B_C1 * (_4(pk_Ab.c_str()) * _4(ql_AFb.c_str())
307 + _4(kp_Ab.c_str()) * _4(lq_AFb.c_str()))
308 + B_C2 * (_4(kp_Ab.c_str()) * _4(ql_AFb.c_str())
309 + _4(pk_Ab.c_str()) * _4(lq_AFb.c_str()))
311 + B_C1 * (_4(ql_Ab.c_str()) * _4(pk_AFb.c_str())
312 + _4(lq_Ab.c_str()) * _4(kp_AFb.c_str()))
313 + B_C2 * (_4(lq_Ab.c_str()) * _4(pk_AFb.c_str())
314 + _4(ql_Ab.c_str()) * _4(kp_AFb.c_str()))
321 template <
typename T>
323 SingleReference_R12Intermediates<T>::VPQ_RS(
const char* p,
const char* q,
324 const char* r,
const char* s)
327 std::string gr_pqrs = std::string(
"<") + p +
" " + q +
"|gr|" + r +
" " + s +
">";
329 std::string rpq_pq = std::string(
"<") + p +
" " + q +
"|r|p1 q1>";
330 std::string grs_pq = std::string(
"<p1 q1|g|") + r +
" " + s +
">";
332 std::string rpq_apn = std::string(
"<") + p +
" " + q +
"|r|a1' n1>";
333 std::string grs_apn = std::string(
"<a1' n1|g|") + r +
" " + s +
">";
335 std::string rpq_nap = std::string(
"<") + p +
" " + q +
"|r|n1 a1'>";
336 std::string grs_nap = std::string(
"<n1 a1'|g|") + r +
" " + s +
">";
338 std::string pqrs = p + std::string(
",") + q + std::string(
",")
339 + r + std::string(
",") + s;
342 Vpq_rs(pqrs.c_str()) = _4(gr_pqrs.c_str())
343 - _4(rpq_pq.c_str()) * _4(grs_pq.c_str())
344 - _4(rpq_apn.c_str()) * _4(grs_apn.c_str())
345 - _4(rpq_nap.c_str()) * _4(grs_nap.c_str())
352 template <
typename T>
354 SingleReference_R12Intermediates<T>::VPq_Rs(
const char* p,
const char* q,
355 const char* r,
const char* s,
356 const double C_0,
const double C_1)
358 const double V_C1 = (0.5 * C_0 + 1.5 * C_1);
359 const double V_C2 = (0.5 * C_0 - 1.5 * C_1);
361 std::string gr_pqrs = std::string(
"<") + p +
" " + q +
"|gr|" + r +
" " + s +
">";
362 std::string gr_qprs = std::string(
"<") + q +
" " + p +
"|gr|" + r +
" " + s +
">";
364 std::string rpq_pq = std::string(
"<") + p +
" " + q +
"|r|p1 q1>";
365 std::string rqp_pq = std::string(
"<") + q +
" " + p +
"|r|p1 q1>";
366 std::string grs_pq = std::string(
"<p1 q1|g|") + r +
" " + s +
">";
368 std::string rpq_apn = std::string(
"<") + p +
" " + q +
"|r|a1' n1>";
369 std::string rqp_apn = std::string(
"<") + q +
" " + p +
"|r|a1' n1>";
370 std::string grs_apn = std::string(
"<a1' n1|g|") + r +
" " + s +
">";
372 std::string rpq_nap = std::string(
"<") + p +
" " + q +
"|r|n1 a1'>";
373 std::string rqp_nap = std::string(
"<") + q +
" " + p +
"|r|n1 a1'>";
374 std::string grs_nap = std::string(
"<n1 a1'|g|") + r +
" " + s +
">";
376 std::string pqrs = p + std::string(
",") + q + std::string(
",")
377 + r + std::string(
",") + s;
380 Vpq_rs(pqrs.c_str()) = V_C1 * _4(gr_pqrs.c_str()) + V_C2 * _4(gr_qprs.c_str())
381 - (V_C1 * _4(rpq_pq.c_str()) + V_C2 * _4(rqp_pq.c_str()))
383 - (V_C1 * _4(rpq_apn.c_str()) + V_C2 * _4(rqp_apn.c_str()))
384 * _4(grs_apn.c_str())
385 - (V_C1 * _4(rpq_nap.c_str()) + V_C2 * _4(rqp_nap.c_str()))
386 * _4(grs_nap.c_str())
393 template <
typename T>
395 SingleReference_R12Intermediates<T>::VRk_Sk(
const char* r,
const char* s,
396 const double C_0,
const double C_1)
398 const double V_C1 = (0.5 * C_0 + 1.5 * C_1);
399 const double V_C2 = (0.5 * C_0 - 1.5 * C_1);
401 std::string gr_rksk = std::string(
"<") + r +
" k1|gr|" + s +
" l1>";
402 std::string gr_krsk = std::string(
"<k1 ") + r +
"|gr|" + s +
" l1>";
404 std::string r_rkpq = std::string(
"<") + r +
" k1|r|p1 q1>";
405 std::string r_krpq = std::string(
"<k1 ") + r +
"|r|p1 q1>";
406 std::string g_skpq = std::string(
"<p1 q1|g|") + s +
" k1>";
408 std::string r_rkapn = std::string(
"<") + r +
" k1|r|a1' n1>";
409 std::string r_krapn = std::string(
"<k1 ") + r +
"|r|a1' n1>";
410 std::string g_skapn = std::string(
"<a1' n1|g|") + s +
" k1>";
412 std::string r_rknap = std::string(
"<") + r +
" k1|r|n1 a1'>";
413 std::string r_krnap = std::string(
"<k1 ") + r +
"|r|n1 a1'>";
414 std::string g_sknap = std::string(
"<n1 a1'|g|") + s +
" k1>";
416 std::string rs = r + std::string(
",") + s;
418 Vrk_sk(rs.c_str()) = (V_C1 * _4(gr_rksk.c_str()) + V_C2 * _4(gr_krsk.c_str()))
420 - (V_C1 * _4(r_rkpq.c_str()) + V_C2 * _4(r_krpq.c_str()))
422 - (V_C1 * _4(r_rkapn.c_str()) + V_C2 * _4(r_krapn.c_str()))
423 * _4(g_skapn.c_str())
424 - (V_C1 * _4(r_rknap.c_str()) + V_C2 * _4(r_krnap.c_str()))
425 * _4(g_sknap.c_str())
430 template <
typename T>
431 std::pair<typename SingleReference_R12Intermediates<T>::TArray2,
435 TArray2 V_ij_ij_cabs; V_ij_ij_cabs(
"i,j") = dotket(ij_xy(
"<i j|g|m a'>"), ij_xy(
"<i j|r|m a'>"));
439 TArray2 V_ij_ij; V_ij_ij(
"i,j") = take(ij_xy(
"<i j|gr|p q>"), ij) - dotket(ij_xy(
"<i j|g|p q>"), ij_xy(
"<i j|r|p q>"))
440 - V_ij_ij_cabs(
"i,j") - V_ij_ij_cabs(
"j,i");
442 TArray2 V_ij_ji_cabs = dotket(ij_xy(
"<i j|g|m a'>"), ij_xy(
"<i j|r|m a'>"),
true);
443 TArray2 V_ij_ji = take(ij_xy(
"<i j|gr|p q>"), ji) - dotket(ij_xy(
"<i j|g|p q>"), ij_xy(
"<i j|r|p q>"),
true)
444 - V_ij_ji_cabs(
"i,j") - V_ij_ji_cabs(
"j,i");
446 return std::make_pair(V_ij_ij,V_ij_ji);
450 template <
typename T>
451 std::pair<typename SingleReference_R12Intermediates<T>::TArray2,
455 TArray2 X_ij_ij_cabs = dotket(ij_xy(
"<i j|r|m a'>"), ij_xy(
"<i j|r|m a'>"));
459 TArray2 X_ij_ij = take(ij_xy(
"<i j|r2|p q>"), ij) - dotket(ij_xy(
"<i j|r|p q>"), ij_xy(
"<i j|r|p q>"))
460 - X_ij_ij_cabs(
"i,j") - X_ij_ij_cabs(
"j,i");
462 TArray2 X_ij_ji_cabs = dotket(ij_xy(
"<i j|r|m a'>"), ij_xy(
"<i j|r|m a'>"),
true);
463 TArray2 X_ij_ji = take(ij_xy(
"<i j|r2|p q>"), ji) - dotket(ij_xy(
"<i j|r|p q>"), ij_xy(
"<i j|r|p q>"),
true)
464 - X_ij_ji_cabs(
"i,j") - X_ij_ji_cabs(
"j,i");
466 return std::make_pair(X_ij_ij,X_ij_ji);
470 template <
typename T>
471 std::pair<typename SingleReference_R12Intermediates<T>::TArray2,
476 TArray2 B_ij_ij = take(ij_xy(
"<i j|rTr|p q>"), ij) + take(ij_xy(
"<i_hJ(p') j|r2|p q>"), ij)
477 - dotket(ij_xy(
"<i j|r|p' q'>"), ij_xy(
"<i j|r|p' q'_K(r')>"));
479 TArray2 B_ij_ji = take(ij_xy(
"<i j|rTr|p q>"), ji) + take(ij_xy(
"<i_hJ(p') j|r2|p q>"), ji);
481 return std::make_pair(B_ij_ij,B_ij_ji);
492 typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> EigenMatrixX;
494 const EigenMatrixX& Y_mat,
495 const EigenMatrixX& X1_mat,
496 const EigenMatrixX& X2_mat) :
497 E_(E), Y_mat_(Y_mat), X1_mat_(X1_mat), X2_mat_(X2_mat) {
499 template<
typename Index> T operator()(
const Index& i) {
500 return 1.0 / ( E_ + Y_mat_(i[1], i[1]) - X1_mat_(i[2], i[2]) - X2_mat_(i[3], i[3]) );
506 EigenMatrixX X1_mat_;
507 EigenMatrixX X2_mat_;
511 template <
typename T>
519 MPQC_ASSERT(orbital != 0);
520 const CalcType type = (orbital < 0) ? IP : EA;
522 const std::string X_label = (type == IP) ?
"i1" :
"a1";
523 const Ref<OrbitalSpace>& X_space = (type == IP) ? this->r12world()->refwfn()->occ_act()
524 : this->r12world()->refwfn()->uocc_act();
530 const double E = (type == IP) ? X_space->
evals()(X_space->
rank() + orbital) : X_space->
evals()(orbital - 1);
534 sedenom_eval_type Delta_jab_gen(E,
535 TA::array_to_eigen(fij),
536 TA::array_to_eigen(fab),
537 TA::array_to_eigen(fab) );
538 sedenom_eval_type Delta_ajk_gen(E,
539 TA::array_to_eigen(fab),
540 TA::array_to_eigen(fij),
541 TA::array_to_eigen(fij) );
543 std::ostringstream Xjab; Xjab <<
"<" << X_label <<
" j|g|a b>";
545 typedef TA::Array<T, 4, LazyTensor<T, 4, sedenom_eval_type > > TArray4dLazy;
546 TArray4dLazy Delta_Xjab(g_Xjab.world(), g_Xjab.trange());
549 for(
auto t = Delta_Xjab.trange().tiles_range().begin();
550 t != Delta_Xjab.trange().tiles_range().end(); ++t)
551 if (Delta_Xjab.is_local(*t)) {
552 std::array<std::size_t, 4> index;
553 std::copy(t->begin(), t->end(), index.begin());
554 madness::Future < typename TArray4dLazy::value_type >
559 Delta_Xjab.set(*t, tile);
562 std::ostringstream Xajk; Xajk <<
"<" << X_label <<
" a|g|j k>";
564 typedef TA::Array<T, 4, LazyTensor<T, 4, sedenom_eval_type > > TArray4dLazy;
565 TArray4dLazy Delta_Xajk(g_Xajk.world(), g_Xajk.trange());
568 for(
auto t = Delta_Xajk.trange().tiles_range().begin();
569 t != Delta_Xajk.trange().tiles_range().end(); ++t)
570 if (Delta_Xajk.is_local(*t)) {
571 std::array<std::size_t, 4> index;
572 std::copy(t->begin(), t->end(), index.begin());
573 madness::Future < typename TArray4dLazy::value_type >
578 Delta_Xajk.set(*t, tile);
581 TArray4 dg_Xjab; dg_Xjab(
"Y,j,a,b") = Delta_Xjab(
"Y,j,a,b") * (4 * g_Xjab(
"Y,j,a,b") - 2 * g_Xjab(
"Y,j,b,a"));
582 TArray4 dg_Xajk; dg_Xajk(
"Y,a,j,m") = Delta_Xajk(
"Y,a,j,m") * (4 * g_Xajk(
"Y,a,j,m") - 2 * g_Xajk(
"Y,a,m,j"));
588 TArray2 sigma2_hpp; sigma2_hpp(
"X,Y") = (1./2) * g_Xjab(
"X,j,a,b") * dg_Xjab(
"Y,j,a,b");
589 TArray2 sigma2_phh; sigma2_phh(
"X,Y") = (1./2) * g_Xajk(
"X,a,j,m") * dg_Xajk(
"Y,a,j,m");
591 ExEnv::out0() <<
"Fock:" << std::endl << fij << std::endl;
592 ExEnv::out0() <<
"SE2_hpp(e=" << E <<
"):" << std::endl << sigma2_hpp << std::endl;
593 ExEnv::out0() <<
"SE2_phh(e=" << E <<
"):" << std::endl << sigma2_phh << std::endl;
602 typedef TiledArray::Array<T, 2> Array;
609 H0_AB(h0_AB), H0_IJ(h0_ij) {
620 R1 = T1(
"i,b") * H0_AB(
"b,a") - H0_IJ(
"i,j") * T1(
"j,a");
629 typedef TiledArray::Array<T, 2> Array2;
630 typedef TiledArray::Array<T, 4> Array4;
639 const Array4& g_ij_ab,
const Array4& g_ia_jb) :
640 F_AB(f_AB), F_IJ(f_ij), G_IJ_AB(g_ij_ab), G_IA_JB(g_ia_jb) {
645 const Array4& G_IJ_AB;
646 const Array4& G_IA_JB;
653 residual = kappa(
"i,b") * F_AB(
"b,a") - F_IJ(
"i,j") * kappa(
"j,a")
654 + 4.0 * G_IJ_AB(
"i,j,a,b") * kappa(
"j,b")
655 - G_IJ_AB(
"i,j,b,a") * kappa(
"j,b")
656 - G_IA_JB(
"i,a,j,b") * kappa(
"j,b");
661 template <
typename T>
663 typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> EigenMatrixX;
665 const EigenMatrixX& O2_mat) :
666 O1_mat_(O1_mat), O2_mat_(O2_mat) {
668 template <
typename Index> T operator()(
const Index& i) {
669 return 1.0 / (- O1_mat_(i[0], i[0]) + O2_mat_(i[1], i[1]));
673 EigenMatrixX O1_mat_;
674 EigenMatrixX O2_mat_;
678 template <
typename T>
680 typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> EigenMatrixX;
682 const EigenMatrixX& O2_mat,
683 const EigenMatrixX& O3_mat,
684 const EigenMatrixX& O4_mat) :
685 O1_mat_(O1_mat), O2_mat_(O2_mat),
686 O3_mat_(O3_mat), O4_mat_(O4_mat) {
688 template <
typename Index> T operator()(
const Index& i) {
689 return 1.0 / (- O1_mat_(i[0], i[0]) - O2_mat_(i[1], i[1]) + O3_mat_(i[2], i[2]) + O4_mat_(i[3], i[3]));
693 EigenMatrixX O1_mat_;
694 EigenMatrixX O2_mat_;
695 EigenMatrixX O3_mat_;
696 EigenMatrixX O4_mat_;
702 typedef TiledArray::Array<T, 2> Array2;
703 typedef TiledArray::Array<T, 4> Array4;
712 const Array4& A_bjai;
719 R1(
"a,i") = K_bj(
"b,j") * A_bjai(
"b,j,a,i");
724 template <
typename T>
726 typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> EigenMatrixX;
727 e_ij(
const EigenMatrixX& O1_mat,
const EigenMatrixX& O2_mat):
728 O1_mat_(O1_mat), O2_mat_(O2_mat) {}
730 template <
typename Index> T operator()(
const Index& i) {
731 return (O1_mat_(i[0], i[0]) + O2_mat_(i[1], i[1]));
735 EigenMatrixX O1_mat_;
736 EigenMatrixX O2_mat_;
742 template <
typename T>
745 const TArray2& Tma) {
747 TArray2 D_e2_mn, D_e2_AB;
749 D_e2_mn(
"m,n")= TmA(
"m,A'") * TmA(
"n,A'");
751 D_e2_AB(
"A',B'") = TmA(
"m,A'") * TmA(
"m,B'");
755 g_aAmB(
"a,A',m,B'") = 2.0 * _4(
"<a A'|g|m B'>") - _4(
"<a A'|g|B' m>");
756 TArray4::wait_for_lazy_cleanup(g_aAmB.world());
758 TArray4d g_aAmn = ijxy(
"<a A'|g|m n>");
759 TArray4d g_ammn = ijxy(
"<a m|g|m1 n>");
762 Xam_E2(
"a,m") = 2.0 * (
763 - _2(
"<A'|F|a>") * TmA(
"m,A'")
764 + Tma(
"n,a") * _2(
"<m|F|n>")
765 + (TmA(
"n,A'") * Tma(
"n,a")) * _2(
"<m|F|A'>")
767 - ( 2.0 * _4(
"<a n|g|m A'>") - _4(
"<a n|g|A' m>")
768 + 2.0 * g_aAmn(
"a,A',m,n") - g_aAmn(
"a,A',n,m")
771 - g_aAmB(
"a,A',m,B'") * D_e2_AB(
"A',B'")
773 + (2.0 * g_ammn(
"a,n1,m,n2") - g_ammn(
"a,n1,n2,m"))
780 template <
typename T>
782 SingleReference_R12Intermediates<T>::Xam_mp2(
const TArray4& T2_ijab,
784 const TArray2& Dab) {
785 TArray2 Xai_mp2, Xam_mp2;
786 Xai_mp2(
"a,i") = 2.0 * (
790 * (2.0 * T2_ijab(
"i,l,c,d") - T2_ijab(
"l,i,c,d"))
792 Xam_mp2(
"a,m") = 2.0 * (
795 (2.0 * T2_ijab(
"k,l,a,c") - T2_ijab(
"k,l,c,a"))
800 - (2.0 * _4(
"<a c|g|m d>") - _4(
"<a c|g|d m>"))
803 + (2.0 * _4(
"<a l|g|m k>") - _4(
"<a l|g|k m>"))
823 return XaiAddToXam(Xam_mp2, Xai_mp2);
827 template <
typename T>
829 SingleReference_R12Intermediates<T>::Xam_Cmp2f12(
const double C_0,
const double C_1,
830 const TArray4& T2_ijab,
const TArray4& A_ijab,
831 const TArray2& Dij,
const TArray2& Dab,
832 const TArray2& RT_apb) {
833 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
834 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
835 const double RR_C1 = 0.5 * C_0 * C_0 + 1.5 * C_1 * C_1;
836 const double RR_C2 = 0.5 * C_0 * C_0 - 1.5 * C_1 * C_1;
839 T2pA_temp(
"i,j,a,b") = R_C1 * T2_ijab(
"i,j,a,b") + R_C2 * T2_ijab(
"j,i,a,b")
840 + RR_C1 * A_ijab(
"i,j,a,b") + RR_C2 * A_ijab(
"j,i,a,b");
842 TArray2 Xai_mp2f12, Xam_mp2f12;
847 * (R_C1 * A_ijab(
"i,l,c,d") + R_C2 * A_ijab(
"l,i,c,d"));
848 Xai_mp2f12(
"a,i") = Xai_mp2f12(
"a,i")
851 - _4(
"<a l|r|b_F(a') c>") * T2pA_temp(
"i,l,b,c");
852 Xai_mp2f12(
"a,i") = Xai_mp2f12(
"a,i")
854 - _4(
"<a l|r|c b_F(a')>") * T2pA_temp(
"i,l,c,b");
859 (R_C1 * A_ijab(
"k,l,a,c") + R_C2 * A_ijab(
"k,l,c,a"))
864 - (2.0 * _4(
"<a c|g|m d>") - _4(
"<a c|g|d m>"))
867 + (2.0 * _4(
"<a l|g|m k>") - _4(
"<a l|g|k m>"))
869 Xam_mp2f12(
"a,m") = Xam_mp2f12(
"a,m")
873 + T2pA_temp(
"k,l,a,b")
874 * (_4(
"<k l|r|m_F(a') b>") + _4(
"<k l|r|m b_F(a')>"));
877 TArray4d gab_map = ijxy(
"<a b|g|m a'>");
878 g_temp(
"a,a',m,b") = 2.0 * _4(
"<a a'|g|m b>") - _4(
"<a a'|g|b m>")
879 + 2.0 * gab_map(
"a,b,m,a'") - gab_map(
"b,a,m,a'");
881 Xam_mp2f12(
"a,m") = Xam_mp2f12(
"a,m")
884 - g_temp(
"a,a',m,b") * RT_apb(
"a',b");
886 return XaiAddToXam(Xam_mp2f12, Xai_mp2f12);
890 template <
typename T>
891 void SingleReference_R12Intermediates<T>::compute_Df12_XB(
const double C_0,
const double C_1,
892 TArray2& D_f12_ij, TArray2& D_f12_ab,
893 TArray2& D_f12_apbp, TArray2& D_f12_apb) {
895 const double RR_C1 = 0.5 * C_0 * C_0 + 1.5 * C_1 * C_1;
896 const double RR_C2 = 0.5 * C_0 * C_0 - 1.5 * C_1 * C_1;
900 TArray4d r2_ijkl = ijxy(
"<i j|r2|k l>");
901 TArray4d r_ijpq = ijxy(
"<i j|r|p q>");
902 TArray4d r_ijapn = ijxy(
"<i j|r|a' n>");
903 D_f12_ij(
"i,j") = (RR_C1 * r2_ijkl(
"i,k,j,l") + RR_C2 * r2_ijkl(
"k,i,j,l"))
905 - (RR_C1 * r_ijpq(
"i,k,p,q") + RR_C2 * r_ijpq(
"k,i,p,q"))
907 - (RR_C1 * r_ijapn(
"i,k,a',n") + RR_C2 * r_ijapn(
"k,i,a',n"))
908 * r_ijapn(
"j,k,a',n")
909 - (RR_C1 * r_ijapn(
"k,i,a',n") + RR_C2 * r_ijapn(
"i,k,a',n"))
910 * r_ijapn(
"k,j,a',n");
912 TArray4d::wait_for_lazy_cleanup(D_f12_ij.world());
915 TArray4d r_acpkl = ijxy(
"<a c'|r|k l>");
917 TArray4d r_apcpkl = ijxy(
"<a' c'|r|k l>");
918 D_f12_apb(
"a',b") = (RR_C1 * r_apcpkl(
"a',c',k,l") + RR_C2 * r_apcpkl(
"a',c',l,k"))
919 * r_acpkl(
"b,c',k,l");
921 D_f12_apbp(
"a',b'") = (RR_C1 * r_acpkl(
"c,a',l,k") + RR_C2 * r_acpkl(
"c,a',k,l"))
922 * r_acpkl(
"c,b',l,k")
923 + (RR_C1 * r_apcpkl(
"a',c',k,l") + RR_C2 * r_apcpkl(
"a',c',l,k"))
924 * r_apcpkl(
"b',c',k,l");
930 TArray4d::wait_for_lazy_cleanup(D_f12_ij.world());
932 D_f12_ab(
"a,b") = (RR_C1 * r_acpkl(
"a,c',k,l") + RR_C2 * r_acpkl(
"a,c',l,k"))
933 * r_acpkl(
"b,c',k,l");
937 template <
typename T>
939 SingleReference_R12Intermediates<T>::Xam_Df12_XB(
const double C_0,
const double C_1,
940 const TArray2& Df12_ij,
const TArray2& Df12_ab,
941 const TArray2& Df12_apbp,
const TArray2& Df12_apb) {
944 (2.0 * _4(
"<a k|g|m l>") - _4(
"<a k|g|l m>"))
947 TArray4d g_abmc = ijxy(
"<a b|g|m c>");
948 gdf12_am(
"a,m") = gdf12_am(
"a,m")
951 - (2.0 * g_abmc(
"a,b,m,c") - g_abmc(
"b,a,m,c"))
955 g_temp(
"a,b',m,c'") = 2.0 * _4(
"<a b'|g|m c'>") - _4(
"<a b'|g|c' m>");
956 TArray4d::wait_for_lazy_cleanup(g_temp.world());
958 gdf12_am(
"a,m") = gdf12_am(
"a,m")
960 - g_temp(
"a,b',m,c'") * Df12_apbp(
"b',c'");
964 g_temp(
"a,b',m,c") = 2.0 * _4(
"<a b'|g|m c>") - _4(
"<a b'|g|c m>");
965 gdf12_am(
"a,m") = gdf12_am(
"a,m")
967 - g_temp(
"a,b',m,c") * Df12_apb(
"b',c");
969 TArray4d g_abmcp = ijxy(
"<a b|g|m c'>");
970 gdf12_am(
"a,m") = gdf12_am(
"a,m")
972 - (2.0 * g_abmcp(
"a,b,m,c'") - g_abmcp(
"b,a,m,c'"))
978 template <
typename T>
980 SingleReference_R12Intermediates<T>::Xam_V(
const double C_0,
const double C_1) {
982 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
983 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
985 TArray2 Xai_V, Xam_V;
987 TArray4d gr_ak_ij = ijxy(
"<a k|gr|i j>");
988 TArray4d rpq_kl = ijxy(
"<p q|r|k l>");
989 TArray4d rapn_kl = ijxy(
"<a' n|r|k l>");
990 TArray4d rpq_ak = ijxy(
"<p q|r|a k>");
992 TArray4d gij_apm = ijxy(
"<i j|g|a' m>");
993 TArray4d rapn_ak = ijxy(
"<a' n|r|a k>");
994 TArray4d rapn_ka = ijxy(
"<a' n|r|k a>");
996 TArray2 Ikl = xy(
"<k|I|l>");
999 - ( (R_C1 * gr_ak_ij(
"a,k,i,l") + R_C2 * gr_ak_ij(
"a,k,l,i"))
1002 * ( R_C1 * rpq_kl(
"p,q,i,k") + R_C2 * rpq_kl(
"p,q,k,i") )
1003 - _4(
"<a k|g|a' n>")
1004 * ( R_C1 * rapn_kl(
"a',n,i,k") + R_C2 * rapn_kl(
"a',n,k,i"))
1005 - _4(
"<k a|g|a' n>")
1006 * ( R_C1 * rapn_kl(
"a',n,k,i") + R_C2 * rapn_kl(
"a',n,i,k"))
1009 - ( (R_C1 * gr_ak_ij(
"a,l,i,k") + R_C2 * gr_ak_ij(
"a,l,k,i"))
1012 * ( R_C1 * rpq_ak(
"p,q,a,k") + R_C2 * rpq_ak(
"q,p,a,k"))
1013 - gij_apm(
"i,k,a',n")
1014 * ( R_C1 * rapn_ak(
"a',n,a,k") + R_C2 * rapn_ka(
"a',n,k,a"))
1015 - gij_apm(
"k,i,a',n")
1016 * ( R_C1 * rapn_ka(
"a',n,k,a") + R_C2 * rapn_ak(
"a',n,a,k"))
1019 TArray4d::wait_for_lazy_cleanup(Xai_V.world());
1021 TArray4d raap_kl = ijxy(
"<a a'|r|k l>");
1022 TArray4d rmap_kl = ijxy(
"<m a'|r|k l>");
1025 ( R_C1 * raap_kl(
"a,a',k,l") + R_C2 * raap_kl(
"a,a',l,k"))
1026 * _4(
"<k l|g|m a'>")
1028 + ( R_C1 * rmap_kl(
"m,a',k,l") + R_C2 * rmap_kl(
"m,a',l,k"))
1029 * _4(
"<k l|g|a a'>");
1031 return XaiAddToXam(Xam_V, Xai_V);
1035 template <
typename T>
1037 SingleReference_R12Intermediates<T>::Xam_X(
const double C_0,
const double C_1) {
1039 const double RR_C1 = 0.5 * C_0 * C_0 + 1.5 * C_1 * C_1;
1040 const double RR_C2 = 0.5 * C_0 * C_0 - 1.5 * C_1 * C_1;
1042 TArray4d r2_akjl = ijxy(
"<a k|r2|j l>");
1043 TArray4d r2_kajl = ijxy(
"<k a|r2|j l>");
1044 TArray2 F_ij = xy(
"<i|F|j>");
1046 TArray4d r_pqjk = ijxy(
"<p q|r|j k>");
1047 TArray4d r_apnjk = ijxy(
"<a' n|r|j k>");
1048 TArray4d r_napjk = ijxy(
"<n a'|r|j k>");
1053 X_ai(
"a,i") = - (RR_C1 * r2_akjl(
"a,k,j,l") + RR_C2 * r2_kajl(
"k,a,j,l"))
1054 * _2(
"<l|I|k>") * F_ij(
"j,i")
1056 - (RR_C1 * r2_akjl(
"a,k,i,l") + RR_C2 * r2_kajl(
"k,a,i,l"))
1059 + (RR_C1 * _4(
"<a k|r|p q>") + RR_C2 * _4(
"<k a|r|p q>"))
1060 * ( r_pqjk(
"p,q,j,k") * F_ij(
"j,i")
1061 + r_pqjk(
"p,q,i,l") * F_ij(
"l,k"))
1063 + (RR_C1 * _4(
"<a k|r|a' n>") + RR_C2 * _4(
"<k a|r|a' n>"))
1064 * ( r_apnjk(
"a',n,j,k") * F_ij(
"j,i")
1065 + r_apnjk(
"a',n,i,l") * F_ij(
"l,k"))
1067 + (RR_C1 * _4(
"<a k|r|n a'>") + RR_C2 * _4(
"<k a|r|n a'>"))
1068 * ( r_napjk(
"n,a',j,k") * F_ij(
"j,i")
1069 + r_napjk(
"n,a',i,l") * F_ij(
"l,k"));
1072 TArray4d r_aapkl = ijxy(
"<a a'|r|k l>");
1073 TArray4d r_klmap = ijxy(
"<k l|r|m a'>");
1074 X_am(
"a,m") = (RR_C1 * r_aapkl(
"a,b',k,l") + RR_C2 * r_aapkl(
"a,b',l,k"))
1075 * ( r_klmap(
"j,l,m,b'") * F_ij(
"j,k")
1076 + r_klmap(
"k,j,m,b'") * F_ij(
"j,l"));
1078 return XaiAddToXam(X_am, X_ai);
1082 template <
typename T>
1084 SingleReference_R12Intermediates<T>::Xam_B(
const double C_0,
const double C_1) {
1086 const double B_C1 = 0.5 * C_0 * C_0 + 1.5 * C_1 * C_1;
1087 const double B_C2 = 0.5 * C_0 * C_0 - 1.5 * C_1 * C_1;
1093 TArray4d r_akPQ = ijxy(
"<a k|r|p' q'>");
1094 TArray4d r_kaPQ = ijxy(
"<k a|r|p' q'>");
1095 TArray4d rik_PKQ = ijxy(
"<i k|r|p'_K(r') q'>");
1097 TArray4d r_akPn = ijxy(
"<a k|r|p' n>");
1098 TArray4d r_kaPn = ijxy(
"<k a|r|p' n>");
1099 TArray4d rik_PFn = ijxy(
"<i k|r|p'_F(r') n>");
1101 TArray4d r_akmA = ijxy(
"<a k|r|m a'>");
1102 TArray4d r_kamA = ijxy(
"<k a|r|m a'>");
1103 TArray4d rik_mFA = ijxy(
"<i k|r|m_F(n) a'>");
1105 TArray4d r_akpq = ijxy(
"<a k|r|p b>");
1106 TArray4d r_kapq = ijxy(
"<k a|r|p b>");
1107 TArray4d rik_pFb = ijxy(
"<i k|r|p_F(r) b>");
1109 TArray4d rik_nFA = ijxy(
"<i k|r|n_F(p') a'>");
1111 TArray4d r_ikmA = ijxy(
"<i k|r|m a'>");
1112 TArray4d rak_nFA = ijxy(
"<a k|r|n_F(p') a'>");
1113 TArray4d rka_nFA = ijxy(
"<k a|r|n_F(p') a'>");
1114 TArray4d r_akAb = ijxy(
"<a k|r|a' b>");
1115 TArray4d r_kaAb = ijxy(
"<k a|r|a' b>");
1116 TArray4d rik_AFb = ijxy(
"<i k|r|a'_F(q) b>");
1118 TArray4d r_ikAb = ijxy(
"<i k|r|a' b>");
1119 TArray4d rak_AFb = ijxy(
"<a k|r|a'_F(q) b>");
1120 TArray4d rka_AFb = ijxy(
"<k a|r|a'_F(q) b>");
1123 - ( B_C1 * _4(
"<a k|rTr|i l>") + B_C2 * _4(
"<k a|rTr|i l>")
1125 + ( B_C1 * (_4(
"<a_hJ(p') l|r2|i k>") + _4(
"<a l_hJ(p')|r2|i k>")
1126 + _4(
"<a l|r2|i_hJ(p') k>") + _4(
"<a l|r2|i k_hJ(p')>"))
1128 + B_C2 * (_4(
"<l a_hJ(p')|r2|i k>") + _4(
"<l_hJ(p') a|r2|i k>")
1129 + _4(
"<l a|r2|i_hJ(p') k>") + _4(
"<l a|r2|i k_hJ(p')>"))
1133 + ( B_C1 * (r_akPQ(
"a,k,p',q'") * rik_PKQ(
"i,k,p',q'")
1134 + r_kaPQ(
"k,a,p',q'") * rik_PKQ(
"k,i,p',q'"))
1136 + B_C2 * (r_kaPQ(
"k,a,p',q'") * rik_PKQ(
"i,k,p',q'")
1137 + r_akPQ(
"a,k,p',q'") * rik_PKQ(
"k,i,p',q'"))
1140 + ( B_C1 * (r_akPn(
"a,k,p',n") * rik_PFn(
"i,k,p',n")
1141 + r_kaPn(
"k,a,p',n") * rik_PFn(
"k,i,p',n"))
1143 + B_C2 * (r_kaPn(
"k,a,p',n") * rik_PFn(
"i,k,p',n")
1144 + r_akPn(
"a,k,p',n") * rik_PFn(
"k,i,p',n"))
1147 - ( B_C1 * (r_akmA(
"a,k,m,a'") * rik_mFA(
"i,k,m,a'")
1148 + r_kamA(
"k,a,m,a'") * rik_mFA(
"k,i,m,a'"))
1150 + B_C2 * (r_kamA(
"k,a,m,a'") * rik_mFA(
"i,k,m,a'")
1151 + r_akmA(
"a,k,m,a'") * rik_mFA(
"k,i,m,a'"))
1154 + ( B_C1 * (r_akpq(
"a,k,p,b") * rik_pFb(
"i,k,p,b")
1155 + r_kapq(
"k,a,p,b") * rik_pFb(
"k,i,p,b"))
1157 + B_C2 * (r_kapq(
"k,a,p,b") * rik_pFb(
"i,k,p,b")
1158 + r_akpq(
"a,k,p,b") * rik_pFb(
"k,i,p,b"))
1161 + ( B_C1 * (r_akmA(
"a,k,n,a'") * rik_nFA(
"i,k,n,a'")
1162 + r_kamA(
"k,a,n,a'") * rik_nFA(
"k,i,n,a'"))
1164 + B_C2 * (r_kamA(
"k,a,n,a'") * rik_nFA(
"i,k,n,a'")
1165 + r_akmA(
"a,k,n,a'") * rik_nFA(
"k,i,n,a'"))
1167 + B_C1 * (r_ikmA(
"i,k,n,a'") * rak_nFA(
"a,k,n,a'")
1168 + r_ikmA(
"k,i,n,a'") * rka_nFA(
"k,a,n,a'"))
1170 + B_C2 * (r_ikmA(
"k,i,n,a'") * rak_nFA(
"a,k,n,a'")
1171 + r_ikmA(
"i,k,n,a'") * rka_nFA(
"k,a,n,a'"))
1174 + ( B_C1 * (r_akAb(
"a,k,a',b") * rik_AFb(
"i,k,a',b")
1175 + r_kaAb(
"k,a,a',b") * rik_AFb(
"k,i,a',b"))
1177 + B_C2 * (r_kaAb(
"k,a,a',b") * rik_AFb(
"i,k,a',b")
1178 + r_akAb(
"a,k,a',b") * rik_AFb(
"k,i,a',b"))
1180 + B_C1 * (r_ikAb(
"i,k,a',b") * rak_AFb(
"a,k,a',b")
1181 + r_ikAb(
"k,i,a',b") * rka_AFb(
"k,a,a',b"))
1183 + B_C2 * (r_ikAb(
"k,i,a',b") * rak_AFb(
"a,k,a',b")
1184 + r_ikAb(
"i,k,a',b") * rka_AFb(
"k,a,a',b"))
1216 TArray4d r_abpkl = ijxy(
"<a b'|r|k l>");
1217 TArray4d raFpbp_kl = ijxy(
"<a_F(c') b'|r|k l>");
1218 TArray4d raFbp_kl = ijxy(
"<a_F(c) b'|r|k l>");
1219 TArray4d rabpFp_kl = ijxy(
"<a b'_F(c')|r|k l>") ;
1221 B_am(
"a,m") = (B_C1 * r_abpkl(
"a,b',k,l") + B_C2 * r_abpkl(
"a,b',l,k"))
1222 * _4(
"<k l|r|m_F(c') b'>")
1226 + ( B_C1 * raFpbp_kl(
"a,b',k,l") + B_C2 * raFpbp_kl(
"a,b',l,k")
1227 + B_C1 * raFbp_kl(
"a,b',k,l") + B_C2 * raFbp_kl(
"a,b',l,k"))
1228 * _4(
"<k l|r|m b'>")
1230 + (B_C1 * rabpFp_kl(
"a,b',k,l") + B_C2 * rabpFp_kl(
"a,b',l,k"))
1231 * _4(
"<k l|r|m b'>")
1234 return XaiAddToXam(B_am, B_ai);
1238 template <
typename T>
1240 SingleReference_R12Intermediates<T>::Xiip_VBX(
const double C_0,
const double C_1) {
1242 const double RR_C1 = 0.5 * C_0 * C_0 + 1.5 * C_1 * C_1;
1243 const double RR_C2 = 0.5 * C_0 * C_0 - 1.5 * C_1 * C_1;
1246 const char* ip =
"i'";
1247 const char* i =
"i";
1248 TArray2 V_ipi = VRk_Sk(ip,i,C_0, C_1);
1249 TArray2 V_iip = VRk_Sk(i,ip,C_0, C_1);
1251 2.0 * (V_ipi(
"i',i") + V_iip(
"i,i'"));
1281 TArray2 F_ij = xy(
"<i|F|j>");
1282 TArray4d r2_ipk_jl = ijxy(
"<i' k|r2|j l>");
1283 TArray4d r_ipk_pq = ijxy(
"<i' k|r|p q>");
1284 TArray4d r_pqkl = ijxy(
"<p q|r|k l>");
1285 TArray4d r_ipk_apn = ijxy(
"<i' k|r|a' n>");
1286 TArray4d r_apn_kl = ijxy(
"<a' n|r|k l>");
1287 TArray4d r_kip_apn = ijxy(
"<k i'|r|a' n>");
1289 2.0 * ( (RR_C1 * r2_ipk_jl(
"i',k,j,l") + RR_C2 * r2_ipk_jl(
"i',k,l,j"))
1290 * _2(
"<l|I|k>") * F_ij(
"j,i")
1291 + (RR_C1 * r2_ipk_jl(
"i',k,i,l") + RR_C2 * r2_ipk_jl(
"i',k,l,i"))
1294 - (RR_C1 * r_ipk_pq(
"i',k,p,q") + RR_C2 * r_ipk_pq(
"i',k,q,p"))
1295 * ( r_pqkl(
"p,q,j,k") * F_ij(
"j,i")
1296 + r_pqkl(
"p,q,i,l") * F_ij(
"l,k"))
1298 - (RR_C1 * r_ipk_apn(
"i',k,a',n") + RR_C2 * r_kip_apn(
"k,i',a',n"))
1299 * ( r_apn_kl(
"a',n,j,k") * F_ij(
"j,i")
1300 + r_apn_kl(
"a',n,i,l") * F_ij(
"l,k"))
1302 - (RR_C1 * r_kip_apn(
"k,i',a',n") + RR_C2 * r_ipk_apn(
"i',k,a',n"))
1303 * ( r_apn_kl(
"a',n,k,j") * F_ij(
"j,i")
1304 + r_apn_kl(
"a',n,l,i") * F_ij(
"l,k"))
1308 TArray2 B_ipi = BPk_Qk(ip,i,C_0,C_1);
1310 2.0 * B_ipi(
"i',i");
1313 Xiip_f12(
"i,i'") = Xiip_V(
"i,i'") - Xiip_X(
"i,i'") + Xiip_B(
"i,i'");
1318 template <
typename T>
1320 SingleReference_R12Intermediates<T>::Xiip_CVT(
const double C_0,
const double C_1,
1321 const TArray2& T1,
const TArray4& T2){
1323 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
1324 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
1328 2.0 * ( _4(
"<i' l|r|b_F(a') c>")
1329 * (R_C1 * T2(
"b,c,i,l") + R_C2 * T2(
"b,c,l,i"))
1330 + _4(
"<i' l|r|c b_F(a')>")
1331 * (R_C1 * T2(
"c,b,i,l") + R_C2 * T2(
"c,b,l,i"))
1335 const char* ip =
"i'";
1336 const char* i =
"i";
1337 const char* l =
"l";
1338 const char* c =
"c";
1339 const char* d =
"d";
1340 TArray4 V_ipl_cd = VPq_Rs(ip,l,c,d,C_0, C_1);
1342 2.0 * V_ipl_cd(
"i',l,c,d") * T2(
"c,d,i,l");
1345 TArray4 V_ipl_ic = VPq_Rs(ip,l,i,c, C_0, C_1);
1346 TArray4 V_il_ipc = VPq_Rs(i,l,ip,c,C_0, C_1);
1347 TArray2 V_ipc = VRk_Sk(ip,c,C_0, C_1);
1351 (V_ipl_ic(
"i',l,i,c") + V_il_ipc(
"i,l,i',c")) * T1(
"c,l")
1354 + V_ipc(
"i',c") * T1(
"c,i")
1358 Xiip_C(
"i,i'") = Xiip_CT2(
"i,i'") + Xiip_VT2(
"i,i'") + Xiip_VT1(
"i,i'");
1363 template <
typename T>
1365 SingleReference_R12Intermediates<T>::Xam_CT2_ccsd(
const double C_0,
const double C_1,
1366 const TArray4& T2,
const TArray2& RT2_aPb) {
1367 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
1368 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
1370 TArray4d g_abmaP = ijxy(
"<a b|g|m a'>");
1371 TArray2 Xam_CT2, Xai_CT2;
1372 Xam_CT2(
"a,m") = 2.0 * (
1374 (R_C1 * T2(
"a,b,k,l") + R_C2 * T2(
"b,a,k,l"))
1375 * (_4(
"<k l|r|m_F(a') b>") + _4(
"<k l|r|m b_F(a')>"))
1380 - ( 2.0 * _4(
"<a a'|g|m b>") - _4(
"<a a'|g|b m>")
1381 + 2.0 * g_abmaP(
"a,b,m,a'") - g_abmaP(
"b,a,m,a'")
1384 Xai_CT2(
"a,i") = 2.0 * (
1385 - _4(
"<a l|r|b_F(a') c>")
1386 * (R_C1 * T2(
"b,c,i,l") + R_C2 * T2(
"b,c,l,i"))
1387 - _4(
"<a l|r|c b_F(a')>")
1388 * (R_C1 * T2(
"c,b,i,l") + R_C2 * T2(
"c,b,l,i"))
1391 return XaiAddToXam(Xam_CT2, Xai_CT2);
1395 template <
typename T>
1397 SingleReference_R12Intermediates<T>::Xam_VT_ccsd(
const double C_0,
const double C_1,
1398 const TArray2& T1,
const TArray4& T2) {
1400 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
1401 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
1403 const char* i =
"i";
1404 const char* j =
"j";
1405 const char* k =
"k";
1406 const char* l =
"l";
1407 const char* m =
"m";
1409 const char* a =
"a";
1410 const char* c =
"c";
1411 const char* d =
"d";
1413 TArray4 V_alic = VPq_Rs(a,l,i,c, C_0, C_1);
1414 TArray4 V_ilac = VPq_Rs(i,l,a,c,C_0, C_1);
1415 TArray2 V_ac = VRk_Sk(a,c,C_0, C_1);
1416 TArray2 V_jm = VRk_Sk(j,m,C_0, C_1);
1417 TArray4d r_klmaP = ijxy(
"<k l|r|m a'>");
1418 TArray4d r_abPkl = ijxy(
"<a b'|r|k l>");
1419 TArray2 Xam_VT1, Xai_VT1;
1420 Xam_VT1(
"a,m") = 2.0 * (
1421 T1(
"a,j") * V_jm(
"j,m")
1435 * (R_C1 * r_klmaP(
"k,l,m,b'") + R_C2 * r_klmaP(
"l,k,m,b'"))
1436 + _4(
"<a b'|g|c k>")
1437 * (R_C1 * r_klmaP(
"l,k,m,b'") + R_C2 * r_klmaP(
"k,l,m,b'"))
1439 + (R_C1 * r_abPkl(
"a,b',k,l") + R_C2 * r_abPkl(
"a,b',l,k"))
1440 * _4(
"<k c|g|m b'>")
1441 + (R_C1 * r_abPkl(
"a,b',l,k") + R_C2 * r_abPkl(
"a,b',k,l"))
1442 * _4(
"<c k|g|m b'>")
1445 Xai_VT1(
"a,i") = 2.0 * (
1447 - (V_alic(
"a,l,i,c") + V_ilac(
"i,l,a,c")) * T1(
"c,l")
1450 - V_ac(
"a,c") * T1(
"c,i")
1462 TArray2 Xam_VT1_tot = XaiAddToXam(Xam_VT1, Xai_VT1);
1464 TArray4 V_alcd = VPq_Rs(a,l,c,d,C_0, C_1);
1465 TArray4 V_klmd = VPq_Rs(k,l,m,d,C_0, C_1);
1466 TArray2 Xam_VT2, Xai_VT2;
1467 Xam_VT2(
"a,m") = 2.0 * (
1468 T2(
"a,d,k,l") * V_klmd(
"k,l,m,d")
1471 (R_C1 * r_abPkl(
"a,b',k,l") + R_C2 * r_abPkl(
"a,b',l,k"))
1472 * _4(
"<c d|g|m b'>")
1474 + _4(
"<a b'|g|c d>")
1475 * (R_C1 * r_klmaP(
"k,l,m,b'") + R_C2 * r_klmaP(
"l,k,m,b'"))
1478 Xai_VT2(
"a,i") = 2.0 * (
1479 - V_alcd(
"a,l,c,d") * T2(
"c,d,i,l")
1481 TArray2 Xam_VT2_tot = XaiAddToXam(Xam_VT2, Xai_VT2);
1484 Xam_VT_tot(
"a,m") = Xam_VT1_tot(
"a,m") + Xam_VT2_tot(
"a,m");
1489 template <
typename T>
1490 void SingleReference_R12Intermediates<T>::compute_T_cc2(TArray2& t1, TArray4& t2) {
1492 TArray2 fij = xy(
"<j|F|j>");
1493 TArray2 fab = xy(
"<a|F|b>");
1494 TArray2 fai = xy(
"<a|F|i>");
1497 typedef detail::diag_precond2<double> pceval_type;
1498 pceval_type Delta_ai_gen(TA::array_to_eigen(fab), TA::array_to_eigen(fij));
1500 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > > TArray2dLazy;
1501 TArray2dLazy Delta_ai(fai.world(), fai.trange());
1503 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > > TArray2d;
1505 for(
auto t = Delta_ai.trange().tiles_range().begin();
1506 t != Delta_ai.trange().tiles_range().end(); ++t)
1507 if (Delta_ai.is_local(*t)) {
1508 std::array<std::size_t, 2> index;
1509 std::copy(t->begin(), t->end(), index.begin());
1510 madness::Future < typename TArray2dLazy::value_type >
1511 tile((LazyTensor<T, 2, pceval_type >(&Delta_ai, index, &Delta_ai_gen)
1515 Delta_ai.set(*t, tile);
1519 typedef detail::diag_precond4<double> pc4eval_type;
1520 pc4eval_type Delta_abij_gen(TA::array_to_eigen(fab), TA::array_to_eigen(fab),
1521 TA::array_to_eigen(fij),TA::array_to_eigen(fij));
1523 TArray4d g_abij = ijxy(
"<a b|g|i j>");
1524 typedef TA::Array<T, 4, LazyTensor<T, 4, pc4eval_type > > TArray4dLazy;
1525 TArray4dLazy Delta_abij(g_abij.world(), g_abij.trange());
1528 for(
auto t = Delta_abij.trange().tiles_range().begin();
1529 t != Delta_abij.trange().tiles_range().end(); ++t)
1530 if (Delta_abij.is_local(*t)) {
1531 std::array<std::size_t, 4> index;
1532 std::copy(t->begin(), t->end(), index.begin());
1533 madness::Future < typename TArray4dLazy::value_type >
1534 tile((LazyTensor<T, 4, pc4eval_type >(&Delta_abij, index, &Delta_abij_gen)
1538 Delta_abij.set(*t, tile);
1542 t1(
"a,i") = fai(
"a,i") * Delta_ai(
"a,i");
1543 t2(
"a,b,i,j") = g_abij(
"a,b,i,j") * Delta_abij(
"a,b,i,j");
1545 tau(
"a,b,i,j") = t2(
"a,b,i,j") + t1(
"a,i") * t1(
"b,j");
1548 double E_1 = 2.0 * dot(fai(
"a,i"), t1(
"a,i"))
1549 + dot((2.0 * g_abij(
"a,b,i,j") - g_abij(
"b,a,i,j")), tau(
"a,b,i,j") );
1550 double Delta_E = std::abs(E_0 - E_1);
1552 TArray2 Iij = xy(
"<i|I|j>");
1553 TArray2 Iab = xy(
"<a|I|b>");
1555 TArray4d g_iabj = ijxy(
"<i a|g|b j>");
1556 TArray4d g_iajb = ijxy(
"<i a|g|j b>");
1557 TArray4d g_iacd = ijxy(
"<i a|g|c d>");
1558 TArray4d g_aicd = ijxy(
"<a i|g|c d>");
1559 TArray4d g_klai = ijxy(
"<k l|g|a i>");
1560 TArray4d g_klia = ijxy(
"<k l|g|i a>");
1561 TArray4d g_ijkl = ijxy(
"<i j|g|k l>");
1562 TArray4d g_abcd = ijxy(
"<a b|g|c d>");
1564 TArray2 hac, hki, hck;
1565 TArray4 a_klij, b_abcd;
1568 std::cout << indent << scprintf(
"%-5s",
"Iter") << scprintf(
"%-20s",
"Delta_E")
1569 << scprintf(
"%-20s",
"E(CC2)") << std::endl;
1570 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-20.10f", Delta_E)
1571 << scprintf(
"%-15.10f", E_1) << std::endl;
1573 while (Delta_E >= 1.0e-12) {
1577 - (2.0 * g_abij(
"c,d,k,l") - g_abij(
"c,d,l,k")) * tau(
"a,d,k,l");
1580 (2.0 * g_abij(
"c,d,k,l") - g_abij(
"d,c,k,l")) * tau(
"c,d,i,l");
1581 hck(
"c,k") = fai(
"c,k")
1582 + (2.0 * g_abij(
"c,d,k,l") - g_abij(
"d,c,k,l")) * t1(
"d,l");
1584 t1(
"a,i") = Delta_ai(
"a,i") * (
1586 fai(
"a,i") - 2.0 * fai(
"c,k") * t1(
"a,k") * t1(
"c,i")
1588 + t1(
"c,i") * hac(
"a,c") - t1(
"a,k") * hki(
"k,i")
1591 * (2.0 * t2(
"c,a,k,i") - t2(
"c,a,i,k") + t1(
"c,i") * t1(
"a,k"))
1593 + (2.0 * g_iabj(
"k,a,c,i") - g_iajb(
"k,a,i,c")) * t1(
"c,k")
1595 + (2.0 * g_iacd(
"k,a,c,d") - g_iacd(
"k,a,d,c")) * tau(
"c,d,k,i")
1597 - (2.0 * g_klai(
"k,l,c,i") - g_klai(
"l,k,c,i")) * tau(
"c,a,k,l")
1600 a_klij(
"k,l,i,j") = g_ijkl(
"k,l,i,j")
1601 + g_klia(
"k,l,i,c") * t1(
"c,j") + g_klai(
"k,l,c,j") * t1(
"c,i")
1602 + g_abij(
"c,d,k,l") * t1(
"c,i") * t1(
"d,j");
1603 b_abcd(
"a,b,c,d") = g_abcd(
"a,b,c,d")
1604 - g_aicd(
"a,k,c,d") * t1(
"b,k") - g_iacd(
"k,b,c,d") * t1(
"a,k");
1606 t2(
"a,b,i,j") = Delta_abij(
"a,b,i,j") * (
1610 + a_klij(
"k,l,i,j") * t1(
"a,k") * t1(
"b,l")
1612 + b_abcd(
"a,b,c,d") * t1(
"c,i") * t1(
"d,j")
1619 + (g_iacd(
"i,c,a,b") - g_iajb(
"k,b,i,c") * t1(
"a,k")) * t1(
"c,j")
1620 + (g_iacd(
"j,c,b,a") - g_iajb(
"k,a,j,c") * t1(
"b,k")) * t1(
"c,i")
1622 - (g_klai(
"i,j,a,k") + g_iabj(
"i,c,a,k") * t1(
"c,j")) * t1(
"b,k")
1623 - (g_klai(
"j,i,b,k") + g_iabj(
"j,c,b,k") * t1(
"c,i")) * t1(
"a,k")
1625 tau(
"a,b,i,j") = t2(
"a,b,i,j") + t1(
"a,i") * t1(
"b,j");
1629 E_1 = 2.0 * dot(fai(
"a,i"), t1(
"a,i"))
1630 + dot((2.0 * g_abij(
"a,b,i,j") - g_abij(
"b,a,i,j")), tau(
"a,b,i,j") );
1631 Delta_E = std::abs(E_0 - E_1);
1633 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-20.10f", Delta_E)
1634 << scprintf(
"%-15.10f", E_1) << std::endl;
1642 template <
typename T>
1643 void SingleReference_R12Intermediates<T>::compute_lambda_cc2(
const TArray2& t1,
const TArray4& t2,
1644 TArray2& L1, TArray4& L2) {
1646 TArray2 fij = xy(
"<j|F|j>");
1647 TArray2 fab = xy(
"<a|F|b>");
1648 TArray2 fai = xy(
"<a|F|i>");
1651 typedef detail::diag_precond2<double> pceval_type;
1652 pceval_type Delta_ai_gen(TA::array_to_eigen(fab), TA::array_to_eigen(fij));
1654 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > > TArray2dLazy;
1655 TArray2dLazy Delta_ai(fai.world(), fai.trange());
1657 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > > TArray2d;
1659 for(
auto t = Delta_ai.trange().tiles_range().begin();
1660 t != Delta_ai.trange().tiles_range().end(); ++t)
1661 if (Delta_ai.is_local(*t)) {
1662 std::array<std::size_t, 2> index;
1663 std::copy(t->begin(), t->end(), index.begin());
1664 madness::Future < typename TArray2dLazy::value_type >
1665 tile((LazyTensor<T, 2, pceval_type >(&Delta_ai, index, &Delta_ai_gen)
1669 Delta_ai.set(*t, tile);
1673 typedef detail::diag_precond4<double> pc4eval_type;
1674 pc4eval_type Delta_abij_gen(TA::array_to_eigen(fab), TA::array_to_eigen(fab),
1675 TA::array_to_eigen(fij),TA::array_to_eigen(fij));
1677 TArray4d g_abij = ijxy(
"<a b|g|i j>");
1678 typedef TA::Array<T, 4, LazyTensor<T, 4, pc4eval_type > > TArray4dLazy;
1679 TArray4dLazy Delta_abij(g_abij.world(), g_abij.trange());
1682 for(
auto t = Delta_abij.trange().tiles_range().begin();
1683 t != Delta_abij.trange().tiles_range().end(); ++t)
1684 if (Delta_abij.is_local(*t)) {
1685 std::array<std::size_t, 4> index;
1686 std::copy(t->begin(), t->end(), index.begin());
1687 madness::Future < typename TArray4dLazy::value_type >
1688 tile((LazyTensor<T, 4, pc4eval_type >(&Delta_abij, index, &Delta_abij_gen)
1692 Delta_abij.set(*t, tile);
1695 L1(
"a,i") = t1(
"a,i");
1696 L2(
"a,b,i,j") = t2(
"a,b,i,j");
1699 tau(
"a,b,i,j") = t2(
"a,b,i,j") + t1(
"a,i") * t1(
"b,j");
1703 double E_1_L = dot((2.0 * g_abij(
"a,b,i,j") - g_abij(
"b,a,i,j")), L2(
"a,b,i,j") );
1704 double Delta_E_L = std::abs(E_0_L - E_1_L);
1707 TArray4d g_abci = ijxy(
"<a b|g|c i>");
1708 TArray4d g_aikl = ijxy(
"<a i|g|k l>");
1709 TArray4d g_aibj = ijxy(
"<a i|g|b j>");
1710 TArray4d g_aijb = ijxy(
"<a i|g|j b>");
1711 TArray4d g_ijkl = ijxy(
"<i j|g|k l>");
1712 TArray4d g_abcd = ijxy(
"<a b|g|c d>");
1715 std::cout << indent << scprintf(
"%-5s",
"Iter") << scprintf(
"%-20s",
"Delta_E_L")
1716 << scprintf(
"%-20s",
"E_L(CC2)") << std::endl;
1717 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-20.10f", Delta_E_L)
1718 << scprintf(
"%-15.10f", E_1_L) << std::endl;
1721 TArray2 Iai, Gac, Kki, Iai_L2;
1722 TArray4 R_akic, Q_akic, A_klim, E_klic, B_aecd, F_akcd;
1723 TArray4 H_abcj, J_kbij;
1725 Iai(
"a,i") = fai(
"a,i")
1726 + (2.0 * g_abij(
"a,c,i,k") - g_abij(
"a,c,k,i")) * t1(
"c,k");
1731 - (2.0 * g_abci(
"a,d,c,k") - g_abci(
"d,a,c,k")) * t1(
"d,k")
1732 + (2.0 * g_abij(
"a,d,k,l") - g_abij(
"a,d,l,k")) * tau(
"c,d,k,l");
1735 fai(
"c,i") * t1(
"c,k")
1736 + (2.0 * g_aikl(
"c,k,l,i") - g_aikl(
"c,k,i,l")) * t1(
"c,l")
1737 + (2.0 * g_abij(
"c,d,i,l") - g_abij(
"c,d,l,i")) * tau(
"c,d,k,l");
1739 R_akic(
"a,k,i,c") = g_aibj(
"a,k,c,i") + g_abci(
"a,d,c,i") * t1(
"d,k")
1740 - g_aikl(
"a,k,l,i") * t1(
"c,l")
1741 - g_abij(
"a,d,l,i") * tau(
"c,d,l,k")
1744 Q_akic(
"a,k,i,c") = g_aijb(
"a,k,i,c") + g_abci(
"d,a,c,i") * t1(
"d,k")
1745 - g_aikl(
"a,k,i,l") * t1(
"c,l")
1746 - g_abij(
"a,d,l,i") * t2(
"c,d,k,l")
1747 + g_abij(
"a,d,i,l") * (2.0 * t2(
"c,d,k,l") - tau(
"c,d,l,k"))
1750 A_klim(
"k,l,i,m") = - (2.0 * g_ijkl(
"k,l,i,m") - g_ijkl(
"k,l,m,i"))
1751 - (2.0 * g_abij(
"c,d,i,m") - g_abij(
"c,d,m,i")) * t1(
"c,k") * t1(
"d,l")
1752 - (2.0 * g_aikl(
"c,l,i,m") - g_aikl(
"c,l,m,i")) * t1(
"c,k")
1753 - (2.0 * g_aikl(
"c,k,m,i") - g_aikl(
"c,k,i,m")) * t1(
"c,l");
1755 E_klic(
"k,l,i,c") = 2.0 * g_aikl(
"c,i,l,k") - g_aikl(
"c,i,k,l")
1757 + A_klim(
"k,l,i,m") * t1(
"c,m")
1759 + (2.0 * g_abci(
"e,d,c,i") - g_abci(
"d,e,c,i")) * t1(
"d,k") * t1(
"e,l")
1761 + (2.0 * g_aijb(
"d,l,i,c") - g_aibj(
"d,l,c,i")) * t1(
"d,k")
1762 + (2.0 * g_aibj(
"d,k,c,i") - g_aijb(
"d,k,i,c")) * t1(
"d,l")
1765 B_aecd(
"a,e,c,d") = - (2.0 * g_abcd(
"a,e,c,d") - g_abcd(
"e,a,c,d"))
1766 - (2.0 * g_abij(
"a,e,k,l") - g_abij(
"e,a,k,l")) * t1(
"c,k") * t1(
"d,l")
1767 + (2.0 * g_abci(
"e,a,d,k") - g_abci(
"a,e,d,k")) * t1(
"c,k")
1768 + (2.0 * g_abci(
"a,e,c,k") - g_abci(
"e,a,c,k")) * t1(
"d,k");
1770 F_akcd(
"a,k,c,d") = - (2.0 * g_abci(
"c,d,a,k") - g_abci(
"d,c,a,k"))
1772 + B_aecd(
"a,e,c,d") * t1(
"e,k")
1774 - (2.0 * g_aikl(
"a,k,m,l") - g_aikl(
"a,k,l,m")) * t1(
"d,l") * t1(
"c,m")
1776 + (2.0 * g_aibj(
"a,k,c,l") - g_aijb(
"a,k,l,c")) * t1(
"d,l")
1777 + (2.0 * g_aijb(
"a,k,l,d") - g_aibj(
"a,k,d,l")) * t1(
"c,l")
1780 H_abcj(
"a,b,c,j") = - g_abci(
"a,b,c,j")
1781 + g_abij(
"a,b,k,j") * t1(
"c,k");
1783 J_kbij(
"k,b,i,j") = g_aikl(
"b,k,j,i")
1784 + g_abij(
"b,c,j,i") * t1(
"c,k");
1786 while (Delta_E_L >= 1.0e-12) {
1789 L1(
"a,i") = Delta_ai(
"a,i") * (
1793 - Gac(
"a,c") * L1(
"c,i")
1795 - Kki(
"k,i") * L1(
"a,k")
1797 - (R_akic(
"a,k,i,c") - 2.0 * Q_akic(
"a,k,i,c")) * L1(
"c,k")
1799 - E_klic(
"k,l,i,c") * L2(
"a,c,k,l")
1801 - F_akcd(
"a,k,c,d") * L2(
"c,d,i,k")
1804 L2(
"a,b,i,j") = Delta_abij(
"a,b,i,j") * (
1813 + L1(
"a,i") * Iai(
"b,j")
1814 + L1(
"b,j") * Iai(
"a,i")
1827 - H_abcj(
"a,b,c,j") * L1(
"c,i")
1828 - H_abcj(
"b,a,c,i") * L1(
"c,j")
1831 - J_kbij(
"k,b,i,j") * L1(
"a,k")
1832 - J_kbij(
"k,a,j,i") * L1(
"b,k")
1835 #if 0 // close-shell L^a_i & alpha-beta case L^ab_ij in explicit form
1837 L1(
"a,i") = Delta_ai(
"a,i") * (
1840 + (2.0 * g_abij(
"a,b,i,j") - g_abij(
"a,b,j,i")) * t1(
"b,j")
1843 - ( fai(
"a,j") * t1(
"c,j")
1844 - (2.0 * g_abci(
"a,b,c,j") - g_abci(
"b,a,c,j")) * t1(
"b,j")
1845 + (2.0 * g_abij(
"a,d,k,l") - g_abij(
"a,d,l,k")) * tau(
"c,d,k,l"))
1849 - ( fai(
"c,i") * t1(
"c,k")
1850 + (2.0 * g_aikl(
"b,k,j,i") - g_aikl(
"b,k,i,j")) * t1(
"b,j")
1851 + (2.0 * g_abij(
"c,d,i,l") - g_abij(
"c,d,l,i")) * tau(
"c,d,k,l"))
1855 + ( 2.0 * g_aijb(
"a,k,i,c") - g_aibj(
"a,k,c,i")
1856 + (2.0 * g_abci(
"b,a,c,i") - g_abci(
"a,b,c,i")) * t1(
"b,k")
1857 - (2.0 * g_aikl(
"a,k,i,l") - g_aikl(
"a,k,l,i")) * t1(
"c,l")
1858 - (2.0 * g_abij(
"a,b,i,j") - g_abij(
"a,b,j,i")) * t1(
"c,j") * t1(
"b,k")
1859 + (2.0 * g_abij(
"a,b,i,j") - g_abij(
"a,b,j,i"))
1860 * (2.0 * t2(
"c,b,k,j") - t2(
"c,b,j,k"))
1864 - ( 2.0 * g_aikl(
"b,i,l,k") - g_aikl(
"b,i,k,l")
1866 + ( - (2.0 * g_ijkl(
"k,l,i,j") - g_ijkl(
"k,l,j,i"))
1867 - (2.0 * g_abij(
"c,d,i,j") - g_abij(
"c,d,j,i")) * t1(
"c,k") * t1(
"d,l")
1869 - (2.0 * g_aikl(
"c,l,i,j") - g_aikl(
"c,l,j,i")) * t1(
"c,k")
1870 - (2.0 * g_aikl(
"c,k,j,i") - g_aikl(
"c,k,i,j")) * t1(
"c,l")
1873 + (2.0 * g_abci(
"d,c,b,i") - g_abci(
"c,d,b,i")) * t1(
"d,l") * t1(
"c,k")
1875 + (2.0 * g_aijb(
"c,l,i,b") - g_aibj(
"c,l,b,i")) * t1(
"c,k")
1876 + (2.0 * g_aibj(
"c,k,b,i") - g_aijb(
"c,k,i,b")) * t1(
"c,l")
1880 - ( - 2.0 * g_abci(
"c,d,a,j") - g_abci(
"d,c,a,j")
1882 + ( - (2.0 * g_abcd(
"a,b,c,d") - g_abcd(
"b,a,c,d"))
1883 - (2.0 * g_abij(
"a,b,k,l") - g_abij(
"b,a,k,l")) * t1(
"c,k") * t1(
"d,l")
1885 + (2.0 * g_abci(
"b,a,d,k") - g_abci(
"a,b,d,k")) * t1(
"c,k")
1886 + (2.0 * g_abci(
"a,b,c,k") - g_abci(
"b,a,c,k")) * t1(
"d,k")
1889 - (2.0 * g_aikl(
"a,j,k,l") - g_aikl(
"a,j,l,k")) * t1(
"d,l") * t1(
"c,k")
1891 + (2.0 * g_aibj(
"a,j,c,k") - g_aijb(
"a,j,k,c")) * t1(
"d,k")
1892 + (2.0 * g_aijb(
"a,j,k,d") - g_aibj(
"a,j,d,k")) * t1(
"c,k")
1896 L2(
"a,b,i,j") = Delta_abij(
"a,b,i,j") * (
1904 + (2.0 * g_abij(
"a,f,i,n") - g_abij(
"a,f,n,i")) * t1(
"f,n"))
1908 + (2.0 * g_abij(
"b,f,j,n") - g_abij(
"b,f,n,j")) * t1(
"f,n"))
1912 - (- g_abci(
"a,b,e,j")
1913 + g_abij(
"a,b,n,j") * t1(
"e,n")) * L1(
"e,i")
1914 - (- g_abci(
"b,a,e,i")
1915 + g_abij(
"b,a,n,i") * t1(
"e,n")) * L1(
"e,j")
1918 - ( g_aikl(
"b,m,j,i")
1919 + g_abij(
"b,f,j,i") * t1(
"f,m")) * L1(
"a,m")
1920 - ( g_aikl(
"a,m,i,j")
1921 + g_abij(
"a,f,i,j") * t1(
"f,m")) * L1(
"b,m")
1926 E_1_L = dot((2.0 * g_abij(
"a,b,i,j") - g_abij(
"b,a,i,j")), L2(
"a,b,i,j") );
1927 Delta_E_L = std::abs(E_0_L - E_1_L);
1930 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-20.10f", Delta_E_L)
1931 << scprintf(
"%-15.10f", E_1_L) << std::endl;
1938 template <
typename T>
1939 void SingleReference_R12Intermediates<T>::compute_lambda_cc2_2(
const TArray2& t1,
const TArray4& t2,
1940 TArray2& L1, TArray4& L2) {
1942 TArray2 fij = xy(
"<j|F|j>");
1943 TArray2 fab = xy(
"<a|F|b>");
1944 TArray2 fai = xy(
"<a|F|i>");
1947 typedef detail::diag_precond2<double> pceval_type;
1948 pceval_type Delta_ai_gen(TA::array_to_eigen(fab), TA::array_to_eigen(fij));
1950 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > > TArray2dLazy;
1951 TArray2dLazy Delta_ai(fai.world(), fai.trange());
1953 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > > TArray2d;
1955 for(
auto t = Delta_ai.trange().tiles_range().begin();
1956 t != Delta_ai.trange().tiles_range().end(); ++t)
1957 if (Delta_ai.is_local(*t)) {
1958 std::array<std::size_t, 2> index;
1959 std::copy(t->begin(), t->end(), index.begin());
1960 madness::Future < typename TArray2dLazy::value_type >
1961 tile((LazyTensor<T, 2, pceval_type >(&Delta_ai, index, &Delta_ai_gen)
1965 Delta_ai.set(*t, tile);
1969 typedef detail::diag_precond4<double> pc4eval_type;
1970 pc4eval_type Delta_abij_gen(TA::array_to_eigen(fab), TA::array_to_eigen(fab),
1971 TA::array_to_eigen(fij),TA::array_to_eigen(fij));
1973 TArray4d g_abij = ijxy(
"<a b|g|i j>");
1974 typedef TA::Array<T, 4, LazyTensor<T, 4, pc4eval_type > > TArray4dLazy;
1975 TArray4dLazy Delta_abij(g_abij.world(), g_abij.trange());
1978 for(
auto t = Delta_abij.trange().tiles_range().begin();
1979 t != Delta_abij.trange().tiles_range().end(); ++t)
1980 if (Delta_abij.is_local(*t)) {
1981 std::array<std::size_t, 4> index;
1982 std::copy(t->begin(), t->end(), index.begin());
1983 madness::Future < typename TArray4dLazy::value_type >
1984 tile((LazyTensor<T, 4, pc4eval_type >(&Delta_abij, index, &Delta_abij_gen)
1988 Delta_abij.set(*t, tile);
1992 L1(
"a,i") = t1(
"a,i");
1993 L2(
"a,b,i,j") = t2(
"a,b,i,j");
1996 double E_1_L = dot((2.0 * g_abij(
"a,b,i,j") - g_abij(
"b,a,i,j")), L2(
"a,b,i,j") );
1997 double Delta_E_L = std::abs(E_0_L - E_1_L);
2000 std::cout << indent << scprintf(
"%-5s",
"Iter") << scprintf(
"%-20s",
"Delta_E_L")
2001 << scprintf(
"%-20s",
"E_L(CC2)") << std::endl;
2002 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-20.10f", Delta_E_L)
2003 << scprintf(
"%-15.10f", E_1_L) << std::endl;
2006 TArray4d g_abci = ijxy(
"<a b|g|c i>");
2007 TArray4d g_aikl = ijxy(
"<a i|g|k l>");
2008 TArray4d g_aibj = ijxy(
"<a i|g|b j>");
2009 TArray4d g_aijb = ijxy(
"<a i|g|j b>");
2010 TArray4d g_ijkl = ijxy(
"<i j|g|k l>");
2011 TArray4d g_abcd = ijxy(
"<a b|g|c d>");
2013 TArray4 tau2_aa, tau2_ab, Ttau_aa, Ttau_ab;
2014 tau2_aa(
"a,b,i,j") = t2(
"a,b,i,j") - t2(
"b,a,i,j")
2015 + (t1(
"a,i") * t1(
"b,j") - t1(
"b,i") * t1(
"a,j"));
2016 tau2_ab(
"a,b,i,j") = t2(
"a,b,i,j")
2017 + (t1(
"a,i") * t1(
"b,j"));
2019 Ttau_aa(
"a,b,i,j") = t2(
"a,b,i,j") - t2(
"b,a,i,j")
2020 + 0.5 * (t1(
"a,i") * t1(
"b,j") - t1(
"b,i") * t1(
"a,j"));
2021 Ttau_ab(
"a,b,i,j") = t2(
"a,b,i,j")
2022 + 0.5 * t1(
"a,i") * t1(
"b,j");
2024 TArray4 tau2t1_aa, tau2t1_ab, Ttaut1_aa, Ttaut1_ab;
2025 tau2t1_aa(
"a,b,i,j") = t1(
"a,i") * t1(
"b,j") - t1(
"b,i") * t1(
"a,j");
2026 tau2t1_ab(
"a,b,i,j") = t1(
"a,i") * t1(
"b,j");
2027 Ttaut1_aa(
"a,b,i,j") = 0.5 * t1(
"a,i") * t1(
"b,j") - t1(
"b,i") * t1(
"a,j");
2028 Ttaut1_ab(
"a,b,i,j") = 0.5 * t1(
"a,i") * t1(
"b,j");
2030 TArray2 TFme, TFae, TFmi;
2033 (2.0 * g_abij(
"e,f,m,n") - g_abij(
"e,f,n,m")) * t1(
"f,n");
2036 t1(
"f,m") * (2.0 * g_abci(
"e,f,a,m") - g_abci(
"f,e,a,m"))
2038 - 0.5 * Ttau_aa(
"a,f,m,n") * (g_abij(
"e,f,m,n") - g_abij(
"f,e,m,n"))
2039 - Ttau_ab(
"a,f,m,n") * g_abij(
"e,f,m,n")
2043 t1(
"e,n") * (2.0 * g_aikl(
"e,i,n,m") - g_aikl(
"e,i,m,n"))
2045 + 0.5 * Ttau_aa(
"e,f,i,n") * (g_abij(
"e,f,m,n") - g_abij(
"e,f,n,m"))
2046 + Ttau_ab(
"e,f,i,n") * g_abij(
"e,f,m,n")
2049 TArray2 CFme, CFae, CFmi;
2050 CFme(
"m,e") = TFme(
"m,e");
2051 CFae(
"a,e") = TFae(
"a,e") - 0.5 * t1(
"a,m") * TFme(
"m,e");
2052 CFmi(
"m,i") = TFmi(
"m,i") + 0.5 * t1(
"e,i") * TFme(
"m,e");
2055 TArray4 TW_MBEJ_aa, TW_MbEj_ab,CW_MBEJ_aa, CW_MbEj_ab;
2059 TW_MBEJ_aa(
"m,b,e,j") =
2060 g_aijb(
"e,j,m,b") - g_aibj(
"e,j,b,m")
2063 + t1(
"f,j") * (g_abci(
"f,e,b,m") - g_abci(
"e,f,b,m"))
2066 - t1(
"b,n") * (g_aikl(
"e,j,m,n") - g_aikl(
"e,j,n,m"))
2070 + 0.5 * ( (2.0 * t2(
"b,f,j,n") - t2(
"f,b,j,n"))
2072 - (t2(
"b,f,j,n") - t2(
"f,b,j,n"))
2076 - t1(
"f,j") * t1(
"b,n")
2077 * (g_abij(
"e,f,m,n") - g_abij(
"f,e,m,n"))
2080 TW_MbEj_ab(
"m,b,e,j") =
2083 + t1(
"f,j") * g_abci(
"f,e,b,m")
2085 - t1(
"b,n") * g_aikl(
"e,j,m,n")
2089 + 0.5 * ( (2.0 * t2(
"b,f,j,n") - t2(
"f,b,j,n"))
2091 - t2(
"b,f,j,n") * g_abij(
"f,e,m,n")
2094 - t1(
"f,j") * t1(
"b,n") * g_abij(
"e,f,m,n")
2098 CW_MBEJ_aa(
"m,b,e,j") =
2099 TW_MBEJ_aa(
"m,b,e,j")
2102 + 0.5 * (t2(
"f,b,n,j") - t2(
"b,f,n,j"))
2103 * (g_abij(
"e,f,m,n") - g_abij(
"f,e,m,n"))
2104 + 0.5 * t2(
"f,b,n,j") * g_abij(
"e,f,m,n")
2106 CW_MbEj_ab(
"m,b,e,j") =
2107 TW_MbEj_ab(
"m,b,e,j")
2110 + 0.5 * (t2(
"f,b,n,j") - t2(
"b,f,n,j"))
2112 + 0.5 * t2(
"f,b,n,j")
2113 * (g_abij(
"e,f,m,n") - g_abij(
"f,e,m,n"))
2118 TArray4 TW_ABEF_aa, TW_AbEf_ab, CW_ABEF_aa, CW_AbEf_ab, CW_ABEI_aa, CW_AbEi_ab;
2121 TW_ABEF_aa(
"a,b,e,f") =
2122 g_abcd(
"a,b,e,f") - g_abcd(
"b,a,e,f")
2126 - t1(
"b,m") * (g_abci(
"e,f,a,m") - g_abci(
"f,e,a,m"))
2128 + t1(
"a,m") * (g_abci(
"e,f,b,m") - g_abci(
"f,e,b,m"))
2131 + 0.25 * tau2t1_aa(
"a,b,m,n") * (g_abij(
"e,f,m,n") - g_abij(
"f,e,m,n"))
2134 TW_AbEf_ab(
"a,b,e,f") =
2139 - t1(
"b,m") * g_abci(
"e,f,a,m")
2141 - t1(
"a,m") * g_abci(
"f,e,b,m")
2144 + 0.5 * tau2t1_ab(
"a,b,m,n") * g_abij(
"e,f,m,n")
2148 CW_ABEF_aa(
"a,b,e,f") =
2149 TW_ABEF_aa(
"a,b,e,f")
2151 + 0.25 * tau2t1_aa(
"a,b,m,n") * (g_abij(
"e,f,m,n") - g_abij(
"f,e,m,n"));
2153 CW_AbEf_ab(
"a,b,e,f") =
2154 TW_AbEf_ab(
"a,b,e,f")
2156 + 0.5 * tau2t1_ab(
"a,b,m,n") * g_abij(
"e,f,m,n");
2159 CW_ABEI_aa(
"a,b,e,i") =
2160 g_abci(
"a,b,e,i") - g_abci(
"b,a,e,i")
2166 + t1(
"f,i") * CW_ABEF_aa(
"a,b,e,f")
2169 + 0.5 * (g_aikl(
"e,i,m,n") - g_aikl(
"e,i,n,m")) * tau2t1_aa(
"a,b,m,n")
2182 * ( g_aijb(
"b,m,i,e") - g_aibj(
"b,m,e,i")
2188 * (- g_aibj(
"a,m,e,i") + g_aijb(
"a,m,i,e")
2195 CW_AbEi_ab(
"a,b,e,i") =
2202 + t1(
"f,i") * CW_AbEf_ab(
"a,b,e,f")
2205 + g_aikl(
"e,i,m,n") * tau2t1_ab(
"a,b,m,n")
2217 * ( g_aijb(
"b,m,i,e")
2223 * (- g_aibj(
"a,m,e,i")
2229 TArray4 TW_MNIJ_aa, TW_MnIj_ab, CW_MNIJ_aa, CW_MnIj_ab, CW_MBIJ_aa, CW_MbIj_ab;
2232 TW_MNIJ_aa(
"m,n,i,j") =
2233 g_ijkl(
"m,n,i,j") - g_ijkl(
"n,m,i,j")
2237 + t1(
"e,j") * (g_aikl(
"e,i,n,m") - g_aikl(
"e,i,m,n"))
2239 + t1(
"e,i") * (g_aikl(
"e,j,m,n") - g_aikl(
"e,j,n,m"))
2242 + 0.25 * tau2t1_aa(
"e,f,i,j") * (g_abij(
"e,f,m,n") - g_abij(
"e,f,n,m"))
2244 TW_MnIj_ab(
"m,n,i,j") =
2249 + t1(
"e,j") * g_aikl(
"e,i,n,m")
2251 + t1(
"e,i") * g_aikl(
"e,j,m,n")
2254 + 0.5 * tau2t1_ab(
"e,f,i,j") * g_abij(
"e,f,m,n")
2258 CW_MNIJ_aa(
"m,n,i,j") =
2259 TW_MNIJ_aa(
"m,n,i,j")
2261 + 0.25 * tau2t1_aa(
"e,f,i,j") * (g_abij(
"e,f,m,n") - g_abij(
"e,f,n,m"))
2263 CW_MnIj_ab(
"m,n,i,j") =
2264 TW_MnIj_ab(
"m,n,i,j")
2266 + 0.5 * tau2t1_ab(
"e,f,i,j") * g_abij(
"e,f,m,n")
2270 CW_MBIJ_aa(
"m,b,i,j") =
2271 g_aikl(
"b,m,j,i") - g_aikl(
"b,m,i,j")
2277 - t1(
"b,n") * CW_MNIJ_aa(
"m,n,i,j")
2280 + 0.5 * (g_abci(
"f,e,b,m") - g_abci(
"e,f,b,m")) * tau2t1_aa(
"e,f,i,j")
2293 * ( g_aijb(
"e,j,m,b") - g_aibj(
"e,j,b,m")
2300 * ( g_aijb(
"e,i,m,b") - g_aibj(
"e,i,b,m")
2307 CW_MbIj_ab(
"m,b,i,j") =
2314 - t1(
"b,n") * CW_MnIj_ab(
"m,n,i,j")
2317 + g_abci(
"f,e,b,m") * tau2t1_ab(
"e,f,i,j")
2329 * ( g_aijb(
"e,j,m,b")
2336 * (- g_aibj(
"e,i,b,m")
2342 TArray4 CW_MnIe_ab, CW_MniE_ab, CW_AmEf_ab, CW_aMEf_ab;
2344 CW_MnIe_ab(
"m,n,i,e") =
2347 + t1(
"f,i") * g_abij(
"f,e,m,n")
2349 CW_MniE_ab(
"m,n,i,e") =
2352 - t1(
"f,i") * g_abij(
"f,e,n,m")
2355 CW_AmEf_ab(
"a,m,e,f") =
2358 - t1(
"a,n") * g_abij(
"e,f,n,m")
2360 CW_aMEf_ab(
"a,m,e,f") =
2363 + t1(
"a,n") * g_abij(
"f,e,n,m")
2366 while (Delta_E_L >= 1.0e-9) {
2368 L1(
"a,i") = Delta_ai(
"a,i") * (
2372 + L1(
"e,i") * CFae(
"e,a")
2374 - L1(
"a,m") * CFmi(
"i,m")
2376 + L1(
"e,m") * (CW_MBEJ_aa(
"i,e,a,m") + CW_MbEj_ab(
"i,e,a,m"))
2378 + 0.5 * (L2(
"e,f,i,m") - L2(
"e,f,m,i") ) * CW_ABEI_aa(
"e,f,a,m")
2379 + L2(
"e,f,i,m") * CW_AbEi_ab(
"e,f,a,m")
2381 - 0.5 * (L2(
"a,e,m,n") - L2(
"e,a,m,n") ) * CW_MBIJ_aa(
"i,e,m,n")
2382 - L2(
"a,e,m,n") * CW_MbIj_ab(
"i,e,m,n")
2385 L2(
"a,b,i,j") = Delta_abij(
"a,b,i,j") * (
2398 + L1(
"e,i") * CW_AmEf_ab(
"e,j,a,b")
2399 - L1(
"e,j") * CW_aMEf_ab(
"e,i,a,b")
2402 - L1(
"a,m") * CW_MnIe_ab(
"i,j,m,b")
2403 + L1(
"b,m") * CW_MniE_ab(
"i,j,m,a")
2406 + L1(
"a,i") * CFme(
"j,b")
2409 + L1(
"b,j") * CFme(
"i,a")
2413 E_1_L = dot((2.0 * g_abij(
"a,b,i,j") - g_abij(
"b,a,i,j")), L2(
"a,b,i,j") );
2414 Delta_E_L = std::abs(E_0_L - E_1_L);
2417 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-20.10f", Delta_E_L)
2418 << scprintf(
"%-15.10f", E_1_L) << std::endl;
2424 template <
typename T>
2425 void SingleReference_R12Intermediates<T>::compute_cc2_1rdm_amp(
2426 const TArray2& T1_cc2,
const TArray4& T2_cc2,
2427 const TArray2& L1_cc2,
const TArray4& L2_cc2,
2428 TArray2& Dij_cc2, TArray2& Dab_cc2,
2429 TArray2& Dia_cc2, TArray2& Dai_cc2) {
2432 - 0.5 * ( (2.0 * T2_cc2(
"c,d,i,k") - T2_cc2(
"c,d,k,i"))
2434 + (2.0 * T2_cc2(
"c,d,j,k") - T2_cc2(
"c,d,k,j"))
2438 - 0.5 * ( T1_cc2(
"c,i") * L1_cc2(
"c,j")
2439 + T1_cc2(
"c,j") * L1_cc2(
"c,i")
2445 0.5 * ( (2.0 * T2_cc2(
"a,c,k,l") - T2_cc2(
"c,a,k,l"))
2447 + (2.0 * T2_cc2(
"b,c,k,l") - T2_cc2(
"c,b,k,l"))
2451 + 0.5 * ( L1_cc2(
"a,k") * T1_cc2(
"b,k")
2452 + L1_cc2(
"b,k") * T1_cc2(
"a,k")
2459 + (2.0 * T2_cc2(
"a,c,i,k") - T2_cc2(
"a,c,k,i")
2460 - T1_cc2(
"c,i") * T1_cc2(
"a,k"))
2478 template <
typename T>
2479 void SingleReference_R12Intermediates<T>::compute_Delta_cc(
const TA::TiledRange& TR_ai,
2480 const TA::TiledRange& TR_abij,
2481 TArray2& D_ai, TArray4& D_abij) {
2482 TArray2 fij = xy(
"<j|F|j>");
2483 TArray2 fab = xy(
"<a|F|b>");
2486 typedef detail::diag_precond2<double> pceval_type;
2487 pceval_type Delta_ai_gen(TA::array_to_eigen(fab), TA::array_to_eigen(fij));
2489 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > > TArray2dLazy;
2490 TArray2dLazy Delta_ai(fij.world(), TR_ai);
2492 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > > TArray2d;
2494 for(
auto t = Delta_ai.trange().tiles_range().begin();
2495 t != Delta_ai.trange().tiles_range().end(); ++t)
2496 if (Delta_ai.is_local(*t)) {
2497 std::array<std::size_t, 2> index;
2498 std::copy(t->begin(), t->end(), index.begin());
2499 madness::Future < typename TArray2dLazy::value_type >
2500 tile((LazyTensor<T, 2, pceval_type >(&Delta_ai, index, &Delta_ai_gen)
2504 Delta_ai.set(*t, tile);
2506 D_ai(
"a,i") = Delta_ai(
"a,i");
2509 typedef detail::diag_precond4<double> pc4eval_type;
2510 pc4eval_type Delta_abij_gen(TA::array_to_eigen(fab), TA::array_to_eigen(fab),
2511 TA::array_to_eigen(fij),TA::array_to_eigen(fij));
2513 typedef TA::Array<T, 4, LazyTensor<T, 4, pc4eval_type > > TArray4dLazy;
2514 TArray4dLazy Delta_abij(fij.world(), TR_abij);
2517 for(
auto t = Delta_abij.trange().tiles_range().begin();
2518 t != Delta_abij.trange().tiles_range().end(); ++t)
2519 if (Delta_abij.is_local(*t)) {
2520 std::array<std::size_t, 4> index;
2521 std::copy(t->begin(), t->end(), index.begin());
2522 madness::Future < typename TArray4dLazy::value_type >
2523 tile((LazyTensor<T, 4, pc4eval_type >(&Delta_abij, index, &Delta_abij_gen)
2527 Delta_abij.set(*t, tile);
2529 D_abij(
"a,b,i,j") = Delta_abij(
"a,b,i,j");
2530 fij.world().gop.fence();
2534 template <
typename T>
2535 void SingleReference_R12Intermediates<T>::compute_intermediates_TFW_ccsd(
2536 const TArray2& t1,
const TArray4& t2,
2537 const TArray4d& g_abij,
const TArray4d& g_aikl,
2538 const TArray4d& g_aibj,
const TArray4d& g_aijb,
2539 const TArray4d& g_abci,
2540 const TArray4d& g_ijkl,
const TArray4d& g_abcd,
2541 TArray2& TFkc, TArray2& TFac, TArray2& TFki,
2542 TArray4& TW_KbCj_ab,TArray4& TW_KbcJ_ba,
2543 TArray4& TW_AbCd_ab, TArray4& TW_KlIj_ab) {
2544 TArray4 tau_ab, Ttau_ab;
2545 tau_ab(
"a,b,i,j") = t2(
"a,b,i,j") + (t1(
"a,i") * t1(
"b,j"));
2546 Ttau_ab(
"a,b,i,j") = t2(
"a,b,i,j") + 0.5 * t1(
"a,i") * t1(
"b,j");
2549 gabij_temp(
"a,b,i,j") = 2.0 * g_abij(
"a,b,i,j") - g_abij(
"a,b,j,i");
2553 gabij_temp(
"c,d,k,l") * t1(
"d,l");
2556 t1(
"d,k") * (2.0 * g_abci(
"c,d,a,k") - g_abci(
"d,c,a,k"))
2558 - Ttau_ab(
"a,d,k,l") * gabij_temp(
"c,d,k,l")
2562 t1(
"c,l") * (2.0 * g_aikl(
"c,i,l,k") - g_aikl(
"c,i,k,l"))
2564 + Ttau_ab(
"c,d,i,l") * gabij_temp(
"c,d,k,l")
2569 TW_KbCj_ab(
"k,b,c,j") =
2572 + t1(
"d,j") * g_abci(
"d,c,b,k")
2574 - t1(
"b,l") * g_aikl(
"c,j,k,l")
2578 + 0.5 * ( t2(
"b,d,j,l") * gabij_temp(
"c,d,k,l")
2579 - t2(
"d,b,j,l") * g_abij(
"c,d,k,l")
2582 - t1(
"d,j") * (t1(
"b,l") * g_abij(
"c,d,k,l"))
2586 TW_KbcJ_ba(
"k,b,c,j") =
2589 - t1(
"d,j") * g_abci(
"c,d,b,k")
2591 + t1(
"b,l") * g_aikl(
"c,j,l,k")
2595 + 0.5 * t2(
"d,b,j,l") * g_abij(
"d,c,k,l")
2597 + t1(
"d,j") * (t1(
"b,l") * g_abij(
"d,c,k,l"))
2601 TW_AbCd_ab(
"a,b,c,d") =
2606 - t1(
"b,k") * g_abci(
"c,d,a,k")
2608 - t1(
"a,k") * g_abci(
"d,c,b,k")
2612 + 0.5 * tau_ab(
"a,b,k,l") * g_abij(
"c,d,k,l")
2616 TW_KlIj_ab(
"k,l,i,j") =
2621 + t1(
"c,j") * g_aikl(
"c,i,l,k")
2623 + t1(
"c,i") * g_aikl(
"c,j,k,l")
2627 + 0.5 * tau_ab(
"c,d,i,j") * g_abij(
"c,d,k,l")
2632 template <
typename T>
2633 void SingleReference_R12Intermediates<T>::compute_intermediates_CW_ccsd(
2634 const TArray2& t1,
const TArray4& t2,
2635 TArray2& CFkc, TArray2& CFac, TArray2& CFki,
2636 TArray4& CW_KbCj_ab, TArray4& CW_KbcJ_ba,
2637 TArray4& CW_AbCd_ab, TArray4& CW_AbCi_ab,
2638 TArray4& CW_KlIj_ab, TArray4& CW_KbIj_ab,
2639 TArray4& CW_KlIc_ab, TArray4& CW_KliC_ab,
2640 TArray4& CW_AkCd_ab) {
2642 TArray4 tau_ab, Ttau_ab;
2643 tau_ab(
"a,b,i,j") = t2(
"a,b,i,j") + (t1(
"a,i") * t1(
"b,j"));
2645 Ttau_ab(
"a,b,i,j") = t2(
"a,b,i,j") + 0.5 * t1(
"a,i") * t1(
"b,j");
2647 TArray4d g_abij = ijxy(
"<a b|g|i j>");
2648 TArray4d g_abci = ijxy(
"<a b|g|c i>");
2649 TArray4d g_aikl = ijxy(
"<a i|g|k l>");
2650 TArray4d g_aibj = ijxy(
"<a i|g|b j>");
2651 TArray4d g_aijb = ijxy(
"<a i|g|j b>");
2652 TArray4d g_ijkl = ijxy(
"<i j|g|k l>");
2653 TArray4d g_abcd = ijxy(
"<a b|g|c d>");
2656 TArray2 TFkc, TFac, TFki;
2660 TW_AbCd_ab, TW_KlIj_ab;
2662 compute_intermediates_TFW_ccsd(t1, t2,
2664 g_aibj, g_aijb, g_abci,
2667 TW_KbCj_ab, TW_KbcJ_ba,
2668 TW_AbCd_ab, TW_KlIj_ab);
2671 CFkc(
"k,c") = TFkc(
"k,c");
2672 CFac(
"a,c") = TFac(
"a,c") - 0.5 * t1(
"a,k") * TFkc(
"k,c");
2673 CFki(
"k,i") = TFki(
"k,i") + 0.5 * t1(
"c,i") * TFkc(
"k,c");
2676 CW_KbCj_ab(
"k,b,c,j") =
2677 TW_KbCj_ab(
"k,b,c,j")
2680 + 0.5 * (t2(
"d,b,l,j") - t2(
"b,d,l,j"))
2682 + 0.5 * t2(
"d,b,l,j")
2683 * (g_abij(
"c,d,k,l") - g_abij(
"d,c,k,l"))
2686 CW_KbcJ_ba(
"k,b,c,j") =
2687 TW_KbcJ_ba(
"k,b,c,j")
2690 + 0.5 * t2(
"b,d,l,j") * g_abij(
"d,c,k,l")
2694 CW_AbCd_ab(
"a,b,c,d") =
2695 TW_AbCd_ab(
"a,b,c,d")
2699 + 0.5 * tau_ab(
"a,b,k,l") * g_abij(
"c,d,k,l");
2702 t2_temp(
"a,b,i,j") = 2.0 * t2(
"a,b,i,j") - t2(
"a,b,j,i");
2704 CW_AbCi_ab(
"a,b,c,i") =
2708 - CFkc(
"k,c") * t2(
"a,b,k,i")
2711 + t1(
"d,i") * CW_AbCd_ab(
"a,b,c,d")
2715 + g_aikl(
"c,i,k,l") * tau_ab(
"a,b,k,l")
2720 - g_abci(
"d,c,b,k") * t2(
"a,d,k,i")
2722 + ( g_abci(
"c,d,a,k") * t2_temp(
"b,d,i,k")
2723 - g_abci(
"d,c,a,k") * t2(
"b,d,i,k"))
2728 * ( g_aijb(
"b,k,i,c")
2730 + ( t2_temp(
"d,b,l,i") * g_abij(
"c,d,k,l")
2731 - t2(
"d,b,l,i") * g_abij(
"d,c,k,l"))
2735 * (- g_aibj(
"a,k,c,i")
2737 + t2(
"a,d,l,i") * g_abij(
"c,d,l,k")
2742 CW_KlIj_ab(
"k,l,i,j") =
2743 TW_KlIj_ab(
"k,l,i,j")
2746 + 0.5 * tau_ab(
"c,d,i,j") * g_abij(
"c,d,k,l")
2750 CW_KbIj_ab(
"k,b,i,j") =
2754 + CFkc(
"k,c") * t2(
"c,b,i,j")
2757 - t1(
"b,l") * CW_KlIj_ab(
"k,l,i,j")
2761 + g_abci(
"d,c,b,k") * tau_ab(
"c,d,i,j")
2766 + g_aikl(
"c,i,l,k") * t2_temp(
"b,c,j,l")
2767 - g_aikl(
"c,i,k,l") * t2(
"b,c,j,l")
2769 - g_aikl(
"c,j,k,l") * t2(
"c,b,i,l")
2774 * ( g_aijb(
"c,j,k,b")
2776 + t2_temp(
"b,d,j,l") * g_abij(
"c,d,k,l")
2777 - t2(
"b,d,j,l") * g_abij(
"d,c,k,l")
2781 * (- g_aibj(
"c,i,b,k")
2783 + t2(
"b,d,l,i") * g_abij(
"d,c,k,l")
2788 CW_KlIc_ab(
"k,l,i,c") =
2791 + t1(
"d,i") * g_abij(
"d,c,k,l")
2793 CW_KliC_ab(
"k,l,i,c") =
2796 - t1(
"d,i") * g_abij(
"d,c,l,k")
2800 CW_AkCd_ab(
"a,k,c,d") =
2803 - t1(
"a,l") * g_abij(
"c,d,l,k")
2809 template <
typename T>
2810 void SingleReference_R12Intermediates<T>::compute_T_ccsd(TArray2& t1, TArray4& t2,
2811 const std::string method) {
2815 TArray2 fai = xy(
"<a|F|i>");
2816 TArray4d g_abij = ijxy(
"<a b|g|i j>");
2820 compute_Delta_cc(fai.trange(), g_abij.trange(), Delta_ai, Delta_abij);
2823 t1(
"a,i") = fai(
"a,i") * Delta_ai(
"a,i");
2824 t2(
"a,b,i,j") = g_abij(
"a,b,i,j") * Delta_abij(
"a,b,i,j");
2826 TArray2 T1_f12contri;
2827 TArray4 T2_f12contri,
2828 T2_f12contri_T1, V_KLAJ_temp, V_IJKL_temp;
2829 if (method ==
"f12b" || method ==
"F12b") {
2830 const double C_0 = 1.0 / 2.0;
2831 const double C_1 = 1.0 / 4.0;
2832 const double RC1 = 0.5 * (C_0 + C_1);
2833 const double RC2 = 0.5 * (C_0 - C_1);
2835 const char* i =
"i";
2836 const char* j =
"j";
2837 const char* k =
"k";
2838 const char* l =
"l";
2839 const char* a =
"a";
2840 const char* b =
"b";
2845 TArray2 Via = VRk_Sk(i, a, C_0, C_1);
2846 T1_f12contri(
"a,i") = Delta_ai(
"a,i") * Via(
"i,a");
2847 t1(
"a,i") = t1(
"a,i") + T1_f12contri(
"a,i");
2850 TArray4d r_ijaFb = ijxy(
"<i j|r|a_F(c') b>");
2851 TArray4 V_IJAB = VPQ_RS(i, j, a, b);
2852 T2_f12contri(
"a,b,i,j") = Delta_abij(
"a,b,i,j") * (
2854 RC1 * r_ijaFb(
"i,j,a,b") + RC2 * r_ijaFb(
"j,i,a,b")
2855 + RC1 * r_ijaFb(
"j,i,b,a") + RC2 * r_ijaFb(
"i,j,b,a")
2857 + RC1 * V_IJAB(
"i,j,a,b") + RC2 * V_IJAB(
"j,i,a,b")
2862 TArray4 V_KLAJ = VPQ_RS(k, l, a, j);
2863 TArray4 V_IJKL = VPQ_RS(i, j, k, l);
2864 V_KLAJ_temp(
"i,j,a,k") = RC1 * V_KLAJ(
"i,j,a,k") + RC2 * V_KLAJ(
"j,i,a,k");
2865 V_IJKL_temp(
"i,j,k,l") = RC1 * V_IJKL(
"i,j,k,l") + RC2 * V_IJKL(
"j,i,k,l");
2867 t2(
"a,b,i,j") = t2(
"a,b,i,j")
2868 + T2_f12contri(
"a,b,i,j")
2873 tau_ab(
"a,b,i,j") = t2(
"a,b,i,j") + t1(
"a,i") * t1(
"b,j");
2876 gabij_temp(
"a,b,i,j") = 2.0 * g_abij(
"a,b,i,j") - g_abij(
"b,a,i,j");
2880 dot(gabij_temp(
"a,b,i,j"), tau_ab(
"a,b,i,j") );
2881 double Delta_E = std::abs(E_0 - E_1);
2884 std::cout << indent << scprintf(
"%-5s",
"Iter") << scprintf(
"%-20s",
"Delta_E")
2885 << scprintf(
"%-20s",
"E(CCSD)") << std::endl;
2886 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-15.12f", Delta_E)
2887 << scprintf(
"%-15.12f", E_1) << std::endl;
2889 TArray2 TFkc, TFac, TFki;
2893 TW_AbCd_ab, TW_KlIj_ab;
2895 TArray4d g_aikl = ijxy(
"<a i|g|k l>");
2896 TArray4d g_aibj = ijxy(
"<a i|g|b j>");
2897 TArray4d g_aijb = ijxy(
"<a i|g|j b>");
2898 TArray4d g_abci = ijxy(
"<a b|g|c i>");
2899 TArray4d g_ijkl = ijxy(
"<i j|g|k l>");
2900 TArray4d g_abcd = ijxy(
"<a b|g|c d>");
2902 TArray4 t2_unsymm, t2_interim;
2904 while (Delta_E >= 1.0e-12) {
2906 compute_intermediates_TFW_ccsd(t1, t2,
2908 g_aibj, g_aijb, g_abci,
2911 TW_KbCj_ab, TW_KbcJ_ba,
2912 TW_AbCd_ab, TW_KlIj_ab);
2914 t2_interim(
"a,b,i,j") = 2.0 * t2(
"a,b,i,j") - t2(
"b,a,i,j");
2916 auto t1_temp = Delta_ai(
"a,i") * (
2920 TFac(
"a,c") * t1(
"c,i")
2922 - TFki(
"k,i") * t1(
"a,k")
2924 + TFkc(
"k,c") * t2_interim(
"a,c,i,k")
2926 + t1(
"c,k") * (2.0 * g_aijb(
"a,k,i,c") - g_aibj(
"a,k,c,i"))
2928 - t2_interim(
"c,a,k,l") * g_aikl(
"c,i,k,l")
2930 + t2_interim(
"c,d,i,k") * g_abci(
"c,d,a,k")
2933 auto t2_temp = Delta_abij(
"a,b,i,j") * (
2938 + t2(
"a,c,i,j") * (TFac(
"b,c") - 0.5 * t1(
"b,k") * TFkc(
"k,c"))
2939 + t2(
"c,b,i,j") * (TFac(
"a,c") - 0.5 * t1(
"a,k") * TFkc(
"k,c"))
2942 - t2(
"a,b,i,k") * (TFki(
"k,j") + 0.5 * t1(
"c,j") * TFkc(
"k,c"))
2943 - t2(
"a,b,k,j") * (TFki(
"k,i") + 0.5 * t1(
"c,i") * TFkc(
"k,c"))
2946 + tau_ab(
"a,b,k,l") * TW_KlIj_ab(
"k,l,i,j")
2949 + tau_ab(
"c,d,i,j") * TW_AbCd_ab(
"a,b,c,d")
2952 + ( t2(
"a,c,i,k") * TW_KbcJ_ba(
"k,b,c,j")
2953 + t2_interim(
"a,c,i,k") * TW_KbCj_ab(
"k,b,c,j")
2955 - t1(
"c,i") * (t1(
"a,k") * g_aijb(
"b,k,j,c"))
2958 - (- t2(
"c,b,i,k") * TW_KbcJ_ba(
"k,a,c,j")
2959 + t1(
"c,i") * (t1(
"b,k") * g_aibj(
"a,k,c,j"))
2962 - (- t2(
"a,c,k,j") * TW_KbcJ_ba(
"k,b,c,i")
2963 + t1(
"c,j") * (t1(
"a,k") * g_aibj(
"b,k,c,i"))
2966 + ( t2(
"b,c,j,k") * TW_KbcJ_ba(
"k,a,c,i")
2967 + t2_interim(
"b,c,j,k") * TW_KbCj_ab(
"k,a,c,i")
2969 - t1(
"c,j") * (t1(
"b,k") * g_aijb(
"a,k,i,c"))
2973 + t1(
"c,i") * g_abci(
"a,b,c,j")
2974 + t1(
"c,j") * g_abci(
"b,a,c,i")
2977 - t1(
"a,k") * g_aikl(
"b,k,j,i")
2978 - t1(
"b,k") * g_aikl(
"a,k,i,j")
2981 if (method ==
"f12b" || method ==
"F12b") {
2983 + T1_f12contri(
"a,i")
2987 T2_f12contri_T1(
"a,b,i,j") = Delta_abij(
"a,b,i,j") * (
2989 - V_KLAJ_temp(
"i,j,a,k") * t1(
"b,k")
2990 - V_KLAJ_temp(
"j,i,b,k") * t1(
"a,k")
2992 + V_IJKL_temp(
"i,j,k,l") * t1(
"a,k") * t1(
"b,l")
2995 t2_unsymm(
"a,b,i,j") = t2_temp
2996 + T2_f12contri(
"a,b,i,j")
2997 + T2_f12contri_T1(
"a,b,i,j")
3000 t1(
"a,i") = t1_temp;
3001 t2_unsymm(
"a,b,i,j") = t2_temp;
3004 t2(
"a,b,i,j") = 0.5 * (t2_unsymm(
"a,b,i,j") + t2_unsymm(
"b,a,j,i"));
3005 tau_ab(
"a,b,i,j") = t2(
"a,b,i,j") + t1(
"a,i") * t1(
"b,j");
3010 dot(gabij_temp(
"a,b,i,j"), tau_ab(
"a,b,i,j") );
3011 Delta_E = std::abs(E_0 - E_1);
3013 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-15.12f", Delta_E)
3014 << scprintf(
"%-15.12f", E_1) << std::endl;
3020 template <
typename T>
3021 void SingleReference_R12Intermediates<T>::compute_lambda_ccsd(
const TArray2& t1,
const TArray4& t2,
3022 TArray2& L1, TArray4& L2,
3023 const std::string method) {
3025 TArray4d g_abij = ijxy(
"<a b|g|i j>");
3026 TArray4d g_abci = ijxy(
"<a b|g|c i>");
3027 TArray2 fai = xy(
"<a|F|i>");
3033 compute_Delta_cc(fai.trange(), g_abij.trange(), Delta_ai, Delta_abij);
3036 TArray2 L1_f12contri, L1_f12b, L1_f12b_L2;
3037 TArray4 L2_f12contri, Vijab, Vklib, Vklij;
3038 if (method ==
"ccsd" || method ==
"CCSD") {
3039 L1(
"a,i") = t1(
"a,i");
3040 L2(
"a,b,i,j") = t2(
"a,b,i,j");
3043 const double C_0 = 1.0 / 2.0;
3044 const double C_1 = 1.0 / 4.0;
3045 const double RC1 = 0.5 * (C_0 + C_1);
3046 const double RC2 = 0.5 * (C_0 - C_1);
3049 const char* i =
"i";
3050 const char* a =
"a";
3051 V_ia = VRk_Sk(i,a, C_0, C_1);
3053 L1_f12contri(
"a,i") = Delta_ai(
"a,i") * V_ia(
"i,a");
3056 TArray4d r_ijaPn = ijxy(
"<i j|r|a' n>");
3057 TArray4d g_aPnab = ijxy(
"<a' n|g|a b>");
3058 rg_ijab(
"i,j,a,b") = _4(
"<i j|gr|a b>")
3059 - _4(
"<i j|r|p q>") * _4(
"<p q|g|a b>")
3060 - r_ijaPn(
"i,j,a',n") * g_aPnab(
"a',n,a,b")
3061 - r_ijaPn(
"j,i,a',n") * g_aPnab(
"a',n,b,a");
3063 TArray4d r_ijaFb = ijxy(
"<i j|r|a_F(c') b>");
3065 L2_f12contri(
"a,b,i,j") = Delta_abij(
"a,b,i,j")
3066 * ( RC1 * r_ijaFb(
"i,j,a,b") + RC2 * r_ijaFb(
"j,i,a,b")
3067 + RC1 * r_ijaFb(
"j,i,b,a") + RC2 * r_ijaFb(
"i,j,b,a")
3068 + RC1 * rg_ijab(
"i,j,a,b") + RC2 * rg_ijab(
"j,i,a,b")
3071 if (method ==
"f12" || method ==
"F12") {
3072 L1(
"a,i") = t1(
"a,i") + L1_f12contri(
"a,i") * 2.0;
3073 L2(
"a,b,i,j") = t2(
"a,b,i,j") + L2_f12contri(
"a,b,i,j") * 2.0;
3075 }
else if (method ==
"f12b" || method ==
"F12b") {
3078 const char* j =
"j";
3079 const char* k =
"k";
3080 const char* l =
"l";
3081 const char* b =
"b";
3084 Vijab = VPq_Rs(i, j, a, b, C_0, C_1);
3085 L1_f12b(
"a,i") = Delta_ai(
"a,i")
3086 * (Vijab(
"i,j,a,b") * t1(
"b,j"));
3089 Vklib = VPq_Rs(k, l, i, b, C_0, C_1);
3090 Vklij = VPq_Rs(k, l, i, j, C_0, C_1);
3101 L1(
"a,i") = t1(
"a,i")
3102 + L1_f12contri(
"a,i")
3105 L2(
"a,b,i,j") = t2(
"a,b,i,j")
3106 + L2_f12contri(
"a,b,i,j")
3112 gabij_temp(
"a,b,i,j") = 2.0 * g_abij(
"a,b,i,j") - g_abij(
"b,a,i,j");
3116 double E_1_L = dot(gabij_temp(
"a,b,i,j"), L2(
"a,b,i,j") );
3117 double Delta_E_L = std::abs(E_0_L - E_1_L);
3120 std::cout << indent << scprintf(
"%-5s",
"Iter") << scprintf(
"%-20s",
"Delta_E_L")
3121 << scprintf(
"%-20s",
"E_L(CCSD)") << std::endl;
3122 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-15.12f", Delta_E_L)
3123 << scprintf(
"%-15.12f", E_1_L) << std::endl;
3126 TArray2 CFkc, CFac, CFki;
3132 CW_AbCd_ab, CW_AbCi_ab,
3134 CW_KlIj_ab, CW_KbIj_ab,
3136 CW_KlIc_ab, CW_KliC_ab, CW_AkCd_ab;
3138 compute_intermediates_CW_ccsd(t1, t2, CFkc, CFac, CFki,
3139 CW_KbCj_ab, CW_KbcJ_ba,
3140 CW_AbCd_ab, CW_AbCi_ab,
3141 CW_KlIj_ab, CW_KbIj_ab,
3142 CW_KlIc_ab, CW_KliC_ab, CW_AkCd_ab);
3146 TArray4 L2_unsymm, L2abij_temp;
3148 while (Delta_E_L >= 1.0e-12) {
3150 L2abij_temp(
"a,b,i,j") = 2.0 * L2(
"a,b,i,j") - L2(
"b,a,i,j");
3153 - t2(
"c,d,k,l") * L2abij_temp(
"a,d,k,l");
3155 t2(
"c,d,k,l") * L2abij_temp(
"c,d,i,l");
3157 auto L1_temp = Delta_ai(
"a,i") * (
3161 + L1(
"c,i") * CFac(
"c,a")
3163 - L1(
"a,k") * CFki(
"i,k")
3165 + L1(
"c,k") * (2.0 * CW_KbCj_ab(
"i,c,a,k") + CW_KbcJ_ba(
"i,c,a,k"))
3167 + L2abij_temp(
"c,d,i,k") * CW_AbCi_ab(
"c,d,a,k")
3169 - L2abij_temp(
"a,c,k,l") * CW_KbIj_ab(
"i,c,k,l")
3173 - CGac(
"c,d") * (2.0 * CW_AkCd_ab(
"c,i,d,a") - CW_AkCd_ab(
"c,i,a,d"))
3175 - CGki(
"k,l") * (2.0 * CW_KlIc_ab(
"k,i,l,a") + CW_KliC_ab(
"k,i,l,a"))
3178 auto L2_temp = Delta_abij(
"a,b,i,j") * (
3183 + L1(
"c,i") * CW_AkCd_ab(
"c,j,a,b")
3184 + L1(
"c,j") * CW_AkCd_ab(
"c,i,b,a")
3187 - L1(
"a,k") * CW_KlIc_ab(
"i,j,k,b")
3188 + L1(
"b,k") * CW_KliC_ab(
"i,j,k,a")
3191 + L1(
"a,i") * CFkc(
"j,b")
3194 + L1(
"b,j") * CFkc(
"i,a")
3198 + L2(
"a,c,i,j") * CFac(
"c,b")
3199 + L2(
"c,b,i,j") * CFac(
"c,a")
3203 - L2(
"a,b,i,k") * CFki(
"j,k")
3204 - L2(
"a,b,k,j") * CFki(
"i,k")
3208 + L2(
"a,b,k,l") * CW_KlIj_ab(
"i,j,k,l")
3211 + L2(
"c,d,i,j") * CW_AbCd_ab(
"c,d,a,b")
3214 + ( L2abij_temp(
"a,c,i,k") * CW_KbCj_ab(
"j,c,b,k")
3215 + L2(
"a,c,i,k") * CW_KbcJ_ba(
"j,c,b,k"))
3217 + L2(
"c,b,i,k") * CW_KbcJ_ba(
"j,c,a,k")
3219 + L2(
"a,c,k,j") * CW_KbcJ_ba(
"i,c,b,k")
3221 + ( L2abij_temp(
"b,c,j,k") * CW_KbCj_ab(
"i,c,a,k")
3222 + L2(
"b,c,j,k") * CW_KbcJ_ba(
"i,c,a,k"))
3225 + g_abij(
"a,c,i,j") * CGac(
"b,c")
3226 + g_abij(
"c,b,i,j") * CGac(
"a,c")
3229 - g_abij(
"a,b,i,k") * CGki(
"k,j")
3230 - g_abij(
"a,b,k,j") * CGki(
"k,i")
3233 if (method ==
"ccsd" || method ==
"CCSD") {
3234 L1(
"a,i") = L1_temp;
3235 L2_unsymm(
"a,b,i,j") = L2_temp;
3237 }
else if (method ==
"f12" || method ==
"F12") {
3238 L1(
"a,i") = L1_temp + L1_f12contri(
"a,i") * 2.0;
3239 L2_unsymm(
"a,b,i,j") = L2_temp + L2_f12contri(
"a,b,i,j") * 2.0;
3241 }
else if (method ==
"f12b" || method ==
"F12b") {
3243 L1_f12b_L2(
"a,i") = Delta_ai(
"a,i") * (
3245 - Vklib(
"k,l,i,b") * L2(
"a,b,k,l")
3248 + Vklij(
"k,l,i,j") * L2(
"a,b,k,l") * t1(
"b,j")
3252 + L1_f12contri(
"a,i")
3253 + L1_f12b(
"a,i") + L1_f12b_L2(
"a,i")
3255 L2_unsymm(
"a,b,i,j") = L2_temp
3256 + L2_f12contri(
"a,b,i,j")
3261 L2(
"a,b,i,j") = 0.5 * (L2_unsymm(
"a,b,i,j") + L2_unsymm(
"b,a,j,i"));
3264 E_1_L = dot(gabij_temp(
"a,b,i,j"), L2(
"a,b,i,j") );
3265 Delta_E_L = std::abs(E_0_L - E_1_L);
3268 std::cout << indent << scprintf(
"%-5.0f", iter) << scprintf(
"%-15.12f", Delta_E_L)
3269 << scprintf(
"%-15.12f", E_1_L) << std::endl;
3275 template <
typename T>
3276 void SingleReference_R12Intermediates<T>::compute_Gamma_ijab_ccsd(
const TArray2& T1,
const TArray4& T2,
3277 const TArray4& tau_ab,
3278 const TArray2& L1,
const TArray4& L2,
3279 TArray4& Gamma_IjAb_ab) {
3398 Gamma_IjAb_ab(
"i,j,a,b") =
3399 0.25 * tau_ab(
"a,b,i,j")
3403 + 0.25 * tau_ab(
"c,d,i,j") * L2(
"c,d,k,l")
3408 - 0.125 * (T2(
"c,d,i,l") - T2(
"c,d,l,i"))
3409 * (L2(
"c,d,k,l") - L2(
"c,d,l,k")) * tau_ab(
"a,b,k,j")
3410 - 0.25 * T2(
"c,d,i,l") * L2(
"c,d,k,l") * tau_ab(
"a,b,k,j")
3412 - 0.125 * (T2(
"c,d,j,l") - T2(
"c,d,l,j"))
3413 * (L2(
"c,d,k,l") - L2(
"c,d,l,k")) * tau_ab(
"a,b,i,k")
3414 - 0.25 * T2(
"c,d,j,l") * L2(
"c,d,k,l") * tau_ab(
"a,b,i,k")
3417 - 0.25 * ( T1(
"c,i") * tau_ab(
"a,b,k,j")
3418 + T1(
"c,j") * tau_ab(
"a,b,i,k")
3423 - 0.125 * (T2(
"a,d,k,l") - T2(
"d,a,k,l"))
3424 * (L2(
"c,d,k,l") - L2(
"c,d,l,k")) * tau_ab(
"c,b,i,j")
3425 - 0.25 * T2(
"a,d,k,l") * L2(
"c,d,k,l") * tau_ab(
"c,b,i,j")
3427 - 0.125 * (T2(
"b,d,k,l") - T2(
"d,b,k,l"))
3428 * (L2(
"c,d,k,l") - L2(
"c,d,l,k")) * tau_ab(
"a,c,i,j")
3429 - 0.25 * T2(
"b,d,k,l") * L2(
"c,d,k,l") * tau_ab(
"a,c,i,j")
3432 - 0.25 * ( T1(
"a,k") * tau_ab(
"c,b,i,j")
3433 + T1(
"b,k") * tau_ab(
"a,c,i,j")
3438 + 0.125 * ( (T2(
"a,c,i,k") - T2(
"c,a,i,k"))
3439 * (L2(
"c,d,k,l") - L2(
"d,c,k,l")) * T2(
"b,d,j,l")
3440 + (T2(
"a,c,i,k") - T2(
"c,a,i,k"))
3441 * L2(
"c,d,k,l") * (T2(
"b,d,j,l") - T2(
"d,b,j,l"))
3442 + T2(
"a,c,i,k") * (L2(
"c,d,k,l") - L2(
"d,c,k,l"))
3443 * (T2(
"b,d,j,l") - T2(
"d,b,j,l"))
3444 + T2(
"a,c,i,k") * L2(
"c,d,k,l") * T2(
"b,d,j,l")
3447 + T2(
"c,b,i,k") * L2(
"c,d,l,k") * T2(
"a,d,l,j")
3450 + T2(
"a,c,k,j") * L2(
"d,c,k,l") * T2(
"d,b,i,l")
3453 + T2(
"b,c,j,k") * (L2(
"c,d,k,l") - L2(
"d,c,k,l"))
3454 * (T2(
"a,d,i,l") - T2(
"d,a,i,l"))
3455 + T2(
"b,c,j,k") * L2(
"c,d,k,l") * T2(
"a,d,i,l")
3456 + (T2(
"b,c,j,k") - T2(
"c,b,j,k"))
3457 * L2(
"c,d,k,l") * (T2(
"a,d,i,l") - T2(
"d,a,i,l"))
3458 + (T2(
"b,c,j,k") - T2(
"c,b,j,k"))
3459 * (L2(
"c,d,k,l") - L2(
"d,c,k,l"))
3463 - 0.25 * ( T1(
"c,i") * T1(
"a,k")
3464 * ( (L2(
"c,d,k,l") - L2(
"d,c,k,l")) * T2(
"b,d,j,l")
3465 + L2(
"c,d,k,l") * (T2(
"b,d,j,l") - T2(
"d,b,j,l"))
3468 - T1(
"c,i") * T1(
"b,k") * L2(
"c,d,l,k") * T2(
"a,d,l,j")
3470 - T1(
"c,j") * T1(
"a,k") * L2(
"d,c,k,l") * T2(
"d,b,i,l")
3472 + T1(
"c,j") * T1(
"b,k")
3473 * ( (L2(
"c,d,k,l") - L2(
"d,c,k,l")) * T2(
"a,d,i,l")
3474 + L2(
"c,d,k,l") * (T2(
"a,d,i,l") - T2(
"d,a,i,l"))
3479 - 0.25 * ( (- 2.0 * T2(
"a,c,i,k") + T2(
"c,a,i,k")
3480 + 2.0 * T1(
"c,i") * T1(
"a,k")
3483 + (- 2.0 * T2(
"b,c,j,k") + T2(
"c,b,j,k")
3484 + 2.0 * T1(
"c,j") * T1(
"b,k")
3489 + 0.75 * ( T1(
"a,i") * T1(
"c,j") * T1(
"b,k")
3490 + T1(
"b,j") * T1(
"c,i") * T1(
"a,k")
3497 template <
typename T>
3498 void SingleReference_R12Intermediates<T>::compute_Gamma2_ccsd(
const TArray2& T1,
const TArray4& T2,
3499 const TArray2& L1,
const TArray4& L2,
3500 const TArray4& tau_aa,
const TArray4& tau_ab,
3501 TArray4& Gamma_IjKa_ab,
3502 TArray4& Gamma_AbCi_ab,
3503 TArray4& Gamma_iBjA_ab, TArray4& Gamma_iBJa_ba,
3504 TArray4& Gamma_AbCd_ab, TArray4& Gamma_IjKl_ab,
3505 TArray4& Gamma_IjAb_ab) {
3508 CGac(
"a,c") = - 0.5 * (T2(
"c,d,k,l") - T2(
"d,c,k,l"))
3509 * (L2(
"a,d,k,l") - L2(
"d,a,k,l"))
3510 - T2(
"c,d,k,l") * L2(
"a,d,k,l");
3512 CGki(
"k,i") = 0.5 * (T2(
"c,d,k,l") - T2(
"c,d,l,k"))
3513 * (L2(
"c,d,i,l") - L2(
"c,d,l,i"))
3514 + T2(
"c,d,k,l") * L2(
"c,d,i,l");
3516 TArray4 VKlIj_ab, VIBJA_aa, VIbJa_ab, ViBJa_ba, VAbCd_ab;
3518 VKlIj_ab(
"k,l,i,j") = tau_ab(
"c,d,k,l") * L2(
"c,d,i,j");
3520 VIBJA_aa(
"i,b,j,a") = 0.5 * (T2(
"a,c,i,k") - T2(
"a,c,k,i"))
3521 * (L2(
"b,c,j,k") - L2(
"b,c,k,j"))
3522 + 0.5 * T2(
"a,c,i,k") * L2(
"b,c,j,k");
3523 VIbJa_ab(
"i,b,j,a") = 0.5 * T2(
"c,a,i,k") * L2(
"c,b,j,k");
3524 ViBJa_ba(
"i,b,j,a") = 0.5 * (T2(
"a,c,i,k") - T2(
"a,c,k,i")) * L2(
"b,c,j,k")
3525 + 0.5 * T2(
"a,c,i,k") * (L2(
"b,c,j,k") - L2(
"b,c,k,j"));
3532 VAbCd_ab(
"a,b,c,d") = tau_ab(
"c,d,k,l") * L2(
"a,b,k,l");
3535 Gamma_IjKa_ab(
"i,j,k,a") =
3536 - 0.125 * tau_ab(
"c,a,i,j") * L1(
"c,k")
3539 - 0.125 * L2(
"c,a,i,j") * T1(
"c,k")
3542 + 0.125 * VKlIj_ab(
"i,j,k,l") * T1(
"a,l")
3546 + 0.25 * VIbJa_ab(
"i,c,k,a") * T1(
"c,j")
3548 - 0.25 * ViBJa_ba(
"j,c,k,a") * T1(
"c,i")
3551 - 0.125 * CGki(
"i,k") * T1(
"a,j")
3570 Gamma_AbCi_ab(
"a,b,c,i") =
3571 0.125 * tau_ab(
"a,b,k,i") * L1(
"c,k")
3574 + 0.125 * L2(
"a,b,k,i") * T1(
"c,k")
3577 - 0.125 * T1(
"d,i") * VAbCd_ab(
"c,d,a,b")
3581 + 0.25 * ViBJa_ba(
"i,c,k,b") * T1(
"a,k")
3583 - 0.25 * VIbJa_ab(
"i,c,k,a") * T1(
"b,k")
3587 - 0.125 * CGac(
"c,a") * T1(
"b,i")
3611 Gamma_iBJa_ba(
"i,b,j,a") =
3613 - 0.25 * ViBJa_ba(
"i,b,j,a")
3615 - 0.25 * ViBJa_ba(
"j,a,i,b")
3619 + 0.125 * T1(
"c,i") * T1(
"a,k") * L2(
"b,c,j,k")
3621 + 0.125 * T1(
"c,j") * T1(
"b,k") * L2(
"a,c,i,k")
3625 - 0.125 * L1(
"b,j") * T1(
"a,i")
3627 - 0.125 * L1(
"a,i") * T1(
"b,j")
3631 Gamma_iBjA_ab(
"i,b,j,a") =
3633 - 0.25 * VIbJa_ab(
"i,b,j,a")
3635 - 0.25 * VIbJa_ab(
"j,a,i,b")
3639 - 0.125 * T1(
"c,i") * T1(
"a,k") * L2(
"c,b,j,k")
3641 - 0.125 * T1(
"c,j") * T1(
"b,k") * L2(
"c,a,i,k")
3647 Gamma_IjKl_ab(
"i,j,k,l") =
3648 0.125 * VKlIj_ab(
"k,l,i,j")
3649 + 0.125 * VKlIj_ab(
"i,j,k,l");
3652 Gamma_AbCd_ab(
"a,b,c,d") =
3653 0.125 * VAbCd_ab(
"a,b,c,d")
3654 + 0.125 * VAbCd_ab(
"c,d,a,b");
3656 Gamma_IjAb_ab(
"i,j,a,b") =
3657 0.125 * tau_ab(
"a,b,i,j")
3660 + 0.125 * L2(
"a,b,i,j")
3663 + 0.125 * VKlIj_ab(
"i,j,k,l") * tau_ab(
"a,b,k,l")
3667 - 0.125 * (CGki(
"i,k") + T1(
"c,i") * L1(
"c,k")) * tau_ab(
"a,b,k,j")
3669 - 0.125 * (CGki(
"j,k") + T1(
"c,j") * L1(
"c,k")) * tau_ab(
"a,b,i,k")
3673 + 0.125 * (CGac(
"c,a") - T1(
"a,k") * L1(
"c,k")) * tau_ab(
"c,b,i,j")
3675 + 0.125 * (CGac(
"c,b") - T1(
"b,k") * L1(
"c,k")) * tau_ab(
"a,c,i,j")
3679 + 0.125 * (T2(
"a,c,i,k") - T2(
"c,a,i,k")) * ViBJa_ba(
"j,c,k,b")
3680 + 0.125 * T2(
"a,c,i,k") * VIBJA_aa(
"j,c,k,b")
3682 + 0.125 * T2(
"b,c,k,i") * VIbJa_ab(
"j,c,k,a")
3684 + 0.125 * T2(
"a,c,k,j") * VIbJa_ab(
"i,c,k,b")
3686 + 0.125 * T2(
"b,c,j,k") * VIBJA_aa(
"i,c,k,a")
3687 + 0.125 * (T2(
"b,c,j,k") - T2(
"c,b,j,k")) * ViBJa_ba(
"i,c,k,a")
3690 - 0.25 * T1(
"c,i") * T1(
"a,k") * ViBJa_ba(
"j,c,k,b")
3692 + 0.25 * T1(
"c,i") * T1(
"b,k") * VIbJa_ab(
"j,c,k,a")
3694 + 0.25 * T1(
"c,j") * T1(
"a,k") * VIbJa_ab(
"i,c,k,b")
3696 - 0.25 * T1(
"c,j") * T1(
"b,k") * ViBJa_ba(
"i,c,k,a")
3702 (- 2.0 * T2(
"a,c,i,k") + T2(
"c,a,i,k")
3703 + 2.0 * T1(
"c,i") * T1(
"a,k")
3706 + (- 2.0 * T2(
"b,c,j,k") + T2(
"c,b,j,k")
3707 + 2.0 * T1(
"c,j") * T1(
"b,k")
3713 T1(
"a,i") * T1(
"c,j") * T1(
"b,k")
3715 + T1(
"b,j") * T1(
"c,i") * T1(
"a,k")
3723 template <
typename T>
3724 void SingleReference_R12Intermediates<T>::compute_ccsd_1rdm_amp(
const TArray2& T1,
const TArray4& T2,
3725 const TArray2& L1,
const TArray4& L2,
3726 TArray2& Dij, TArray2& Dab,
3727 TArray2& Dia, TArray2& Dai) {
3730 T2_temp(
"a,b,i,j") = 2.0 * T2(
"a,b,i,j") - T2(
"a,b,j,i");
3733 - 0.5 * ( T2_temp(
"c,d,i,k") * L2(
"c,d,j,k")
3734 + T2_temp(
"c,d,j,k") * L2(
"c,d,i,k")
3737 - 0.5 * ( T1(
"c,i") * L1(
"c,j")
3738 + T1(
"c,j") * L1(
"c,i")
3743 0.5 * ( T2_temp(
"a,c,k,l") * L2(
"b,c,k,l")
3744 + T2_temp(
"b,c,k,l") * L2(
"a,c,k,l")
3747 + 0.5 * ( L1(
"a,k") * T1(
"b,k")
3748 + L1(
"b,k") * T1(
"a,k")
3755 + (T2_temp(
"a,c,i,k") - T1(
"c,i") * T1(
"a,k")) * L1(
"c,k")
3758 - (2.0 * L2(
"c,d,k,l") - L2(
"d,c,k,l"))
3759 * ( T2(
"c,d,i,l") * T1(
"a,k")
3760 + T2(
"a,d,k,l") * T1(
"c,i")
3770 template <
typename T>
3771 void SingleReference_R12Intermediates<T>::compute_Xam_ccsd(
const TArray2& T1,
const TArray4& T2,
3772 const TArray2& L1,
const TArray4& L2,
3773 TArray2& Xam_tot, TArray2& Xiip) {
3776 tau_ab(
"a,b,i,j") = T2(
"a,b,i,j") + (T1(
"a,i") * T1(
"b,j"));
3780 TArray4 Gamma_IjAb_ab;
3781 compute_Gamma_ijab_ccsd(T1, T2, tau_ab, L1, L2,
3784 TArray4 Gamma_AbIj_ab;
3785 Gamma_AbIj_ab(
"a,b,i,j") =
3786 0.25 * L2(
"a,b,i,j");
3798 TArray4 Gamma_AbCd_ab;
3799 Gamma_AbCd_ab(
"a,b,c,d") =
3800 0.25 * L2(
"a,b,k,l") * tau_ab(
"c,d,k,l");
3802 TArray4 Gamma_IjKl_ab;
3803 Gamma_IjKl_ab(
"i,j,k,l") =
3804 0.25 * tau_ab(
"c,d,i,j") * L2(
"c,d,k,l");
3823 TArray4 Gamma_IjKa_ab;
3824 Gamma_IjKa_ab(
"i,j,k,a") =
3825 - 0.25 * tau_ab(
"c,a,i,j") * L1(
"c,k")
3828 + 0.25 * tau_ab(
"c,d,i,j") * L2(
"c,d,k,l") * T1(
"a,l")
3831 + 0.25 * T2(
"a,c,l,i") * L2(
"c,d,k,l") * T1(
"d,j")
3833 - 0.25 * ( (T2(
"a,c,j,l") - T2(
"a,c,l,j")) * L2(
"c,d,l,k")
3834 + T2(
"a,c,j,l") * (L2(
"c,d,l,k") - L2(
"c,d,k,l"))
3838 - 0.125 * ( (T2(
"c,d,i,l") - T2(
"c,d,l,i")) * (L2(
"c,d,k,l") - L2(
"c,d,l,k"))
3839 + 2.0 * T2(
"c,d,i,l") * L2(
"c,d,k,l")
3843 TArray4 Gamma_AKIJ_aa, Gamma_AkIj_ab;
3844 Gamma_AkIj_ab(
"a,k,i,j") =
3845 - 0.25 * T1(
"c,k") * L2(
"a,c,i,j");
3847 TArray4 Gamma_CiAb_ab;
3848 Gamma_CiAb_ab(
"c,i,a,b") =
3849 0.25 * tau_ab(
"a,b,k,i") * L1(
"c,k")
3852 - 0.25 * T1(
"d,i") * L2(
"c,d,k,l") * tau_ab(
"a,b,k,l")
3855 - 0.25 * T2(
"a,d,l,i") * L2(
"c,d,l,k") * T1(
"b,k")
3857 + 0.25 * ( (T2(
"b,d,i,l") - T2(
"b,d,l,i")) * L2(
"c,d,k,l")
3858 + T2(
"b,d,i,l") * (L2(
"c,d,k,l") - L2(
"c,d,l,k"))
3862 + 0.125 * T1(
"b,i") * (T2(
"a,d,k,l") - T2(
"d,a,k,l"))
3863 * (L2(
"c,d,k,l") - L2(
"c,d,l,k"))
3864 + 0.25 * T1(
"b,i") * T2(
"a,d,k,l") * L2(
"c,d,k,l")
3867 TArray4 Gamma_AbCi_ab;
3868 Gamma_AbCi_ab(
"a,b,c,i") =
3869 0.25 * L2(
"a,b,k,i") * T1(
"c,k");
3871 TArray4 Gamma_aJiB_ab, Gamma_AjiB_ba;
3872 Gamma_aJiB_ab(
"a,j,i,b") =
3873 0.25 * (L2(
"a,c,i,k") - L2(
"c,a,i,k")) * T2(
"c,b,k,j")
3874 + 0.25 * L2(
"a,c,i,k") * (T2(
"c,b,k,j") - T2(
"b,c,k,j"))
3877 - 0.25 * L2(
"a,c,i,k") * T1(
"c,j") * T1(
"b,k")
3879 + 0.25 * L1(
"a,i") * T1(
"b,j")
3882 Gamma_AjiB_ba(
"a,j,i,b") =
3883 0.25 * L2(
"c,a,i,k") * T2(
"b,c,k,j")
3886 + 0.25 * L2(
"a,c,k,i") * T1(
"c,j") * T1(
"b,k")
3891 TArray2 Dij, Dab, Dia, Dai;
3892 compute_ccsd_1rdm_amp(T1, T2, L1, L2, Dij, Dab, Dia, Dai);
3894 TArray4d g_ijma = ijxy(
"<i j|g|m a>");
3895 TArray4d g_mabc = ijxy(
"<m a|g|b c>");
3896 TArray4d g_mabi = ijxy(
"<m a|g|b i>");
3897 TArray4d g_maib = ijxy(
"<m a|g|i b>");
3899 TArray4d g_imkl = ijxy(
"<i m|g|k l>");
3900 TArray4d g_miab = ijxy(
"<m i|g|a b>");
3901 TArray4d g_imbj = ijxy(
"<i m|g|b j>");
3902 TArray4d g_imjb = ijxy(
"<i m|g|j b>");
3904 TArray4d g_ijak = ijxy(
"<i j|g|a k>");
3905 TArray4d g_abci = ijxy(
"<a b|g|c i>");
3906 TArray4d g_aibj = ijxy(
"<a i|g|b j>");
3907 TArray4d g_iabj = ijxy(
"<i a|g|b j>");
3909 TArray4d g_ijab = ijxy(
"<i j|g|a b>");
3910 TArray4d g_abcd = ijxy(
"<a b|g|c d>");
3913 Xam(
"a,m") = (Dai(
"a,j") + Dia(
"j,a")) * _2(
"<j|F|m>")
3914 + (Dab(
"a,c") + Dab(
"c,a")) * _2(
"<c|F|m>")
3916 - (2.0 * g_mabc(
"m,c,a,d") - g_mabc(
"m,c,d,a"))
3917 * (Dab(
"c,d") + Dab(
"d,c"))
3918 - (2.0 * g_imjb(
"l,m,k,a") - g_imbj(
"l,m,a,k"))
3919 * (Dij(
"k,l") + Dij(
"l,k"))
3920 - ( 2.0 * g_miab(
"m,j,a,b") - g_miab(
"m,j,b,a")
3921 + 2.0 * g_mabi(
"m,b,a,j") - g_maib(
"m,b,j,a")
3922 ) * (Dia(
"j,b") + Dai(
"b,j"))
3927 (Gamma_IjAb_ab(
"k,l,a,b") + Gamma_AbIj_ab(
"a,b,k,l"))
3928 * (g_ijma(
"k,l,m,b") * 2.0 - g_ijma(
"l,k,m,b"))
3931 + (Gamma_AbCd_ab(
"c,d,a,b") + Gamma_AbCd_ab(
"a,b,c,d"))
3932 * (g_mabc(
"m,b,c,d") * 2.0 - g_mabc(
"m,b,d,c"))
3935 + ( Gamma_CiAb_ab(
"c,k,a,b") - Gamma_CiAb_ab(
"c,k,b,a")
3936 - Gamma_AbCi_ab(
"b,a,c,k") + Gamma_AbCi_ab(
"a,b,c,k"))
3937 * (g_mabi(
"m,b,c,k") - g_maib(
"m,b,k,c"))
3938 + (Gamma_CiAb_ab(
"c,k,a,b") + Gamma_AbCi_ab(
"a,b,c,k"))
3940 - (- Gamma_CiAb_ab(
"c,k,b,a") - Gamma_AbCi_ab(
"b,a,c,k"))
3945 + (Gamma_IjKa_ab(
"l,k,j,a") + Gamma_AkIj_ab(
"a,j,k,l"))
3946 * (g_imkl(
"j,m,l,k") * 2.0 - g_imkl(
"j,m,k,l"))
3949 + (Gamma_AbCi_ab(
"c,d,a,j") + Gamma_CiAb_ab(
"a,j,c,d"))
3950 * (g_miab(
"m,j,c,d") * 2.0 - g_miab(
"m,j,d,c"))
3953 + ( Gamma_aJiB_ab(
"c,k,j,a") + Gamma_AjiB_ba(
"c,k,j,a")
3954 + Gamma_aJiB_ab(
"a,j,k,c") + Gamma_AjiB_ba(
"a,j,k,c"))
3955 * (g_imbj(
"j,m,c,k") - g_imjb(
"j,m,k,c"))
3956 + (Gamma_aJiB_ab(
"c,k,j,a") + Gamma_aJiB_ab(
"a,j,k,c"))
3958 - (Gamma_AjiB_ba(
"c,k,j,a") + Gamma_AjiB_ba(
"a,j,k,c"))
3963 Xai(
"a,i") = - _2(
"<a|F|b>") * (Dai(
"b,i") + Dia(
"i,b"))
3964 - _2(
"<a|F|l>") * (Dij(
"l,i") + Dij(
"i,l"))
3969 (Gamma_IjKl_ab(
"k,l,i,j") + Gamma_IjKl_ab(
"i,j,k,l"))
3970 * (g_ijak(
"k,l,a,j") * 2.0 - g_ijak(
"l,k,a,j"))
3973 + (Gamma_AbIj_ab(
"c,d,i,j") + Gamma_IjAb_ab(
"i,j,c,d"))
3974 * (g_abci(
"c,d,a,j") * 2.0 - g_abci(
"d,c,a,j"))
3977 + (- (Gamma_AkIj_ab(
"c,k,i,j") - Gamma_AkIj_ab(
"c,k,j,i"))
3978 + Gamma_IjKa_ab(
"i,j,k,c") - Gamma_IjKa_ab(
"j,i,k,c"))
3979 * (g_iabj(
"j,a,c,k") - g_aibj(
"a,j,c,k"))
3981 + ( Gamma_AkIj_ab(
"c,k,j,i") + Gamma_IjKa_ab(
"i,j,k,c"))
3983 - ( - Gamma_AkIj_ab(
"c,k,i,j") - Gamma_IjKa_ab(
"j,i,k,c"))
3988 + (Gamma_IjKa_ab(
"k,l,i,b") + Gamma_AkIj_ab(
"b,i,l,k"))
3989 * (g_ijab(
"k,l,a,b") * 2.0 - g_ijab(
"l,k,a,b"))
3992 + (Gamma_AbCi_ab(
"d,c,b,i") + Gamma_CiAb_ab(
"b,i,d,c"))
3993 * (g_abcd(
"c,d,a,b") * 2.0 - g_abcd(
"d,c,a,b"))
3996 + ( Gamma_aJiB_ab(
"c,k,i,b") + Gamma_AjiB_ba(
"c,k,i,b")
3997 + Gamma_aJiB_ab(
"b,i,k,c") + Gamma_AjiB_ba(
"b,i,k,c"))
3998 * (g_abci(
"a,b,c,k") - g_abci(
"b,a,c,k"))
3999 + (Gamma_aJiB_ab(
"c,k,i,b") + Gamma_aJiB_ab(
"b,i,k,c"))
4001 - (Gamma_AjiB_ba(
"c,k,i,b") + Gamma_AjiB_ba(
"b,i,k,c"))
4006 Xam_tot = XaiAddToXam(Xam, Xai);
4108 const std::size_t nocc = Xam.trange().elements_range().extent()[1];
4109 const std::size_t naocc = Xai.trange().elements_range().extent()[1];
4110 if (nocc != naocc) {
4111 TArray4d g_ijipk = ijxy(
"<i j|g|i' k>");
4112 TArray4d g_abipi = ijxy(
"<a b|g|i' i>");
4113 TArray4d g_ipibj = ijxy(
"<i' i|g|b j>");
4114 TArray4d g_iipbj = ijxy(
"<i i'|g|b j>");
4115 TArray4d g_ijipb = ijxy(
"<i j|g|i' b>");
4116 TArray4d g_abipd = ijxy(
"<a b|g|i' d>");
4117 TArray4d g_aipbi = ijxy(
"<a i'|g|b i>");
4119 Xiip(
"i,i'") = - 4.0 * (
4122 (Gamma_IjKl_ab(
"k,l,i,j") + Gamma_IjKl_ab(
"i,j,k,l"))
4123 * (g_ijipk(
"k,l,i',j") * 2.0 - g_ijipk(
"l,k,i',j"))
4126 + (Gamma_AbIj_ab(
"c,d,i,j") + Gamma_IjAb_ab(
"i,j,c,d"))
4127 * (g_abipi(
"c,d,i',j") * 2.0 - g_abipi(
"d,c,i',j"))
4130 + (- (Gamma_AkIj_ab(
"c,k,i,j") - Gamma_AkIj_ab(
"c,k,j,i"))
4131 + Gamma_IjKa_ab(
"i,j,k,c") - Gamma_IjKa_ab(
"j,i,k,c"))
4132 * (g_iipbj(
"j,i',c,k") - g_ipibj(
"i',j,c,k"))
4133 + ( Gamma_AkIj_ab(
"c,k,j,i") + Gamma_IjKa_ab(
"i,j,k,c"))
4134 * g_iipbj(
"j,i',c,k")
4135 - ( - Gamma_AkIj_ab(
"c,k,i,j") - Gamma_IjKa_ab(
"j,i,k,c"))
4136 * g_ipibj(
"i',j,c,k")
4140 + (Gamma_IjKa_ab(
"k,l,i,b") + Gamma_AkIj_ab(
"b,i,l,k"))
4141 * (g_ijipb(
"k,l,i',b") * 2.0 - g_ijipb(
"l,k,i',b"))
4144 + (Gamma_AbCi_ab(
"d,c,b,i") + Gamma_CiAb_ab(
"b,i,d,c"))
4145 * (g_abipd(
"c,d,i',b") * 2.0 - g_abipd(
"d,c,i',b"))
4148 + ( Gamma_aJiB_ab(
"c,k,i,b") + Gamma_AjiB_ba(
"c,k,i,b")
4149 + Gamma_aJiB_ab(
"b,i,k,c") + Gamma_AjiB_ba(
"b,i,k,c"))
4150 * (g_abipi(
"c,b,i',k") - g_aipbi(
"b,i',c,k"))
4151 + (Gamma_aJiB_ab(
"c,k,i,b") + Gamma_aJiB_ab(
"b,i,k,c"))
4152 * g_abipi(
"c,b,i',k")
4153 - (Gamma_AjiB_ba(
"c,k,i,b") + Gamma_AjiB_ba(
"b,i,k,c"))
4154 * g_aipbi(
"b,i',c,k")
4162 template <
typename T>
4166 <<
"Compute dipole and quadrupole moments" << std::endl;
4168 bool compute_dipole =
true;
4169 bool compute_quadrupole =
true;
4170 bool compute_EFG =
false;
4172 #define INCLUDE_CABS_Singles_CONTRI 1
4173 #define INCLUDE_MP2_CONTRI 1
4174 #define INCLUDE_MP2F12C_CONTRI 1
4175 #define INCLUDE_F12_CONTRI 1
4177 #define INCLUDE_CCSD_CONTRI 1
4178 #define INCLUDE_CCSDF12C_CONTRI 1
4180 double conv_target = 1e-10;
4186 if (compute_dipole) {
4187 mu_z_mn = xy(
"<m|mu_z|n>");
4188 mu_z_am = xy(
"<a|mu_z|m>");
4192 TArray2 q_xx_mn, q_yy_mn, q_zz_mn;
4193 TArray2 Qxx_mn, Qyy_mn, Qzz_mn, Qxz_mn, Qxy_mn, Qyz_mn;
4194 TArray2 q_xx_am, q_yy_am, q_zz_am;
4195 TArray2 Qxx_am, Qyy_am, Qzz_am, Qxy_am, Qxz_am, Qyz_am;
4196 if (compute_quadrupole) {
4197 q_xx_mn = xy(
"<m|q_xx|n>");
4198 q_yy_mn = xy(
"<m|q_yy|n>");
4199 q_zz_mn = xy(
"<m|q_zz|n>");
4200 Qxx_mn(
"m,n") = q_xx_mn(
"m,n") - (q_zz_mn(
"m,n") + q_yy_mn(
"m,n")) * 0.5;
4201 Qyy_mn(
"m,n") = q_yy_mn(
"m,n") - (q_zz_mn(
"m,n") + q_xx_mn(
"m,n")) * 0.5;
4202 Qzz_mn(
"m,n") = q_zz_mn(
"m,n") - (q_xx_mn(
"m,n") + q_yy_mn(
"m,n")) * 0.5;
4203 Qxz_mn(
"m,n") = _2(
"<m|q_xz|n>") * 1.5;
4204 Qxy_mn(
"m,n") = _2(
"<m|q_xy|n>") * 1.5;
4205 Qyz_mn(
"m,n") = _2(
"<m|q_yz|n>") * 1.5;
4207 q_xx_am = xy(
"<a|q_xx|m>");
4208 q_yy_am = xy(
"<a|q_yy|m>");
4209 q_zz_am = xy(
"<a|q_zz|m>");
4210 Qxx_am(
"a,m") = q_xx_am(
"a,m") - (q_zz_am(
"a,m") + q_yy_am(
"a,m")) * 0.5;
4211 Qyy_am(
"a,m") = q_yy_am(
"a,m") - (q_zz_am(
"a,m") + q_xx_am(
"a,m")) * 0.5;
4212 Qzz_am(
"a,m") = q_zz_am(
"a,m") - (q_xx_am(
"a,m") + q_yy_am(
"a,m")) * 0.5;
4213 Qxy_am(
"a,m") = _2(
"<a|q_xy|m>") * 1.5;
4214 Qxz_am(
"a,m") = _2(
"<a|q_xz|m>") * 1.5;
4215 Qyz_am(
"a,m") = _2(
"<a|q_yz|m>") * 1.5;
4219 TArray2 v_xx_mn, v_yy_mn, v_zz_mn, v_xy_mn, v_xz_mn, v_yz_mn;
4220 TArray2 v_xx_am, v_yy_am, v_zz_am, v_xy_am, v_xz_am, v_yz_am;
4222 v_xx_mn = xy(
"<m|ddphi_xx|n>");
4223 v_yy_mn = xy(
"<m|ddphi_yy|n>");
4224 v_zz_mn = xy(
"<m|ddphi_zz|n>");
4225 v_xy_mn = xy(
"<m|ddphi_xy|n>");
4226 v_xz_mn = xy(
"<m|ddphi_xz|n>");
4227 v_yz_mn = xy(
"<m|ddphi_yz|n>");
4229 v_xx_am = xy(
"<a|ddphi_xx|m>");
4230 v_yy_am = xy(
"<a|ddphi_yy|m>");
4231 v_zz_am = xy(
"<a|ddphi_zz|m>");
4232 v_xy_am = xy(
"<a|ddphi_xy|m>");
4233 v_xz_am = xy(
"<a|ddphi_xz|m>");
4234 v_yz_am = xy(
"<a|ddphi_yz|m>");
4239 const int natom = mol->
natom();
4244 double mu_z_n = 0.0, mu_z_scf = 0.0;
4245 if (compute_dipole) {
4247 for(
int a = 0; a < natom; ++a) {
4248 const double x = mol->r(a, 0);
4249 const double y = mol->r(a, 1);
4250 const double z = mol->r(a, 2);
4251 const double Z = mol->Z(a);
4256 mu_z_scf = dot(mu_z_mn(
"m,n"), Imn(
"m,n"));
4260 double q_xx_n = 0.0, q_yy_n = 0.0, q_zz_n = 0.0;
4261 double q_xy_n = 0.0, q_xz_n = 0.0, q_yz_n = 0.0;
4262 double q_xx_scf = 0.0, q_yy_scf = 0.0, q_zz_scf = 0.0,
4263 q_xy_scf = 0.0, q_xz_scf = 0.0, q_yz_scf = 0.0;
4264 if (compute_quadrupole) {
4266 for(
int a = 0; a < natom; ++a) {
4267 const double x = mol->r(a, 0);
4268 const double y = mol->r(a, 1);
4269 const double z = mol->r(a, 2);
4270 const double Z = mol->Z(a);
4272 q_xx_n += Z * (x * x - (z * z + y * y) * 0.5);
4273 q_yy_n += Z * (y * y - (z * z + x * x) * 0.5);
4274 q_zz_n += Z * (z * z - (x * x + y * y) * 0.5);
4275 q_xy_n += Z * (x * y * 1.5);
4276 q_xz_n += Z * (x * z * 1.5);
4277 q_yz_n += Z * (y * z * 1.5);
4281 q_xx_scf = dot(Qxx_mn(
"m,n"), Imn(
"m,n"));
4282 q_yy_scf = dot(Qyy_mn(
"m,n"), Imn(
"m,n"));
4283 q_zz_scf = dot(Qzz_mn(
"m,n"), Imn(
"m,n"));
4284 q_xy_scf = dot(Qxy_mn(
"m,n"), Imn(
"m,n"));
4285 q_xz_scf = dot(Qxz_mn(
"m,n"), Imn(
"m,n"));
4286 q_yz_scf = dot(Qyz_mn(
"m,n"), Imn(
"m,n"));
4292 double v_xx_n = 0.0, v_yy_n = 0.0, v_zz_n = 0.0;
4293 double v_xy_n = 0.0, v_xz_n = 0.0, v_yz_n = 0.0;
4294 for(
int i = 1; i < natom; i++) {
4295 const double x = mol->r(0, 0) - mol->r(i, 0);
4296 const double y = mol->r(0, 1) - mol->r(i, 1);
4297 const double z = mol->r(0, 2) - mol->r(i, 2);
4298 const double r2 = x * x + y * y + z * z;
4299 const double r = pow(r2, 0.5);
4300 const double Z = mol->Z(i);
4302 v_xx_n += - Z * (3.0 * x * x - r2) / (r * r2 * r2);
4303 v_yy_n += - Z * (3.0 * y * y - r2) / (r * r2 * r2);
4304 v_zz_n += - Z * (3.0 * z * z - r2) / (r * r2 * r2);
4306 v_xy_n += - Z * (3.0 * x * y) / (r * r2 * r2);
4307 v_xz_n += - Z * (3.0 * x * z) / (r * r2 * r2);
4308 v_yz_n += - Z * (3.0 * y * z) / (r * r2 * r2);
4312 const double v_xx_scf = dot(v_xx_mn(
"m,n"), Imn(
"m,n"));
4313 const double v_yy_scf = dot(v_yy_mn(
"m,n"), Imn(
"m,n"));
4314 const double v_zz_scf = dot(v_zz_mn(
"m,n"), Imn(
"m,n"));
4315 const double v_xy_scf = dot(v_xy_mn(
"m,n"), Imn(
"m,n"));
4316 const double v_xz_scf = dot(v_xz_mn(
"m,n"), Imn(
"m,n"));
4317 const double v_yz_scf = dot(v_yz_mn(
"m,n"), Imn(
"m,n"));
4319 std::cout << std::endl << indent
4320 <<
"electric gradient (HF=SCF+N)" << std::endl
4321 << indent <<
"v_xx (HF) = " <<
scprintf(
"%12.10f", v_xx_n + v_xx_scf * 2.0)
4322 << indent <<
" v_yy (HF) = " <<
scprintf(
"%12.10f", v_yy_n + v_yy_scf * 2.0)
4323 << indent <<
" v_zz (HF) = " <<
scprintf(
"%12.10f", v_zz_n + v_zz_scf * 2.0)
4325 << indent <<
"v_xy (HF) = " <<
scprintf(
"%12.10f", v_xy_n + v_xy_scf * 2.0)
4326 << indent <<
" v_xz (HF) = " <<
scprintf(
"%12.10f", v_xz_n + v_xz_scf * 2.0)
4327 << indent <<
" v_yz (HF) = " <<
scprintf(
"%12.10f", v_yz_n + v_yz_scf * 2.0)
4333 TArray4d g_mnab = ijxy(
"<m n|g|a b>");
4335 A_bnam(
"b,n,a,m") = - _4(
"<b n|g|a m>") - g_mnab(
"m,n,b,a") + 4.0 * g_mnab(
"n,m,b,a")
4336 + _2(
"<b|F|a>") * Imn(
"m,n") - _2(
"<a|I|b>") * _2(
"<m|F|n>");
4341 mFmn(
"m,n") = - _2(
"<m|F|n>");
4342 mFab(
"a,b") = - _2(
"<a|F|b>");
4344 pceval_type Delta_am_gen(TA::array_to_eigen(mFab), TA::array_to_eigen(mFmn));
4346 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > >
TArray2d;
4348 TArray2d Delta_am(Iam.world(), Iam.trange());
4351 for(
auto t = Delta_am.trange().tiles_range().begin();
4352 t != Delta_am.trange().tiles_range().end(); ++t)
4353 if (Delta_am.is_local(*t)) {
4354 std::array<std::size_t, 2> index;
4355 std::copy(t->begin(), t->end(), index.begin());
4356 madness::Future < typename TArray2d::value_type >
4361 Delta_am.set(*t, tile);
4364 preconditioner(
"a,m") = Delta_am(
"a,m");
4367 TA::ConjugateGradientSolver<TiledArray::Array<T,2>,
4371 double mu_z_e2 = 0.0, mu_z_e2or = 0.0;
4372 double q_xx_e2 = 0.0, q_yy_e2 = 0.0, q_zz_e2 = 0.0;
4373 double q_xx_e2or = 0.0, q_yy_e2or = 0.0, q_zz_e2or = 0.0;
4374 #if INCLUDE_CABS_Singles_CONTRI
4377 <<
"Compute CABS_singles contributions" << std::endl;
4378 TArray2 TmA = xy(
"<m|T1|A'>");
4386 <<
"Compute CABS_singles D" << std::endl;
4388 D_e2_mn(
"m,n") = TmA(
"m,A'") * TmA(
"n,A'");
4389 D_e2_AB(
"A',B'") = TmA(
"m,A'") * TmA(
"m,B'");
4393 <<
"Compute CABS_singles Xam" << std::endl;
4394 TArray2 Xam_E2 = Xam_CabsSingles(TmA, Tma);
4395 TArray2 Dbn_E2(Xam_E2.world(), Xam_E2.trange());
4397 auto resnorm_E2 = cg_solver2(Orbital_relaxation_Abnam,
4404 if (compute_dipole) {
4405 TArray2 mu_z_AB = xy(
"<A'|mu_z|B'>");
4406 TArray2 mu_z_mA = xy(
"<m|mu_z|A'>");
4408 mu_z_e2 = - dot(mu_z_mn(
"m,n"), D_e2_mn(
"m,n"))
4409 + dot(mu_z_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4410 + dot(mu_z_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4413 mu_z_e2or = dot(mu_z_am(
"a,m"), Dbn_E2(
"a,m"));
4417 if (compute_quadrupole) {
4418 TArray2 q_xx_AB = xy(
"<A'|q_xx|B'>");
4419 TArray2 q_yy_AB = xy(
"<A'|q_yy|B'>");
4420 TArray2 q_zz_AB = xy(
"<A'|q_zz|B'>");
4421 TArray2 Qxx_AB, Qyy_AB, Qzz_AB;
4422 Qxx_AB(
"A',B'") = q_xx_AB(
"A',B'") - (q_zz_AB(
"A',B'") + q_yy_AB(
"A',B'")) * 0.5;
4423 Qyy_AB(
"A',B'") = q_yy_AB(
"A',B'") - (q_xx_AB(
"A',B'") + q_zz_AB(
"A',B'")) * 0.5;
4424 Qzz_AB(
"A',B'") = q_zz_AB(
"A',B'") - (q_xx_AB(
"A',B'") + q_yy_AB(
"A',B'")) * 0.5;
4426 TArray2 q_xx_mA = xy(
"<m|q_xx|A'>");
4427 TArray2 q_yy_mA = xy(
"<m|q_yy|A'>");
4428 TArray2 q_zz_mA = xy(
"<m|q_zz|A'>");
4429 TArray2 Qxx_mA, Qyy_mA, Qzz_mA;
4430 Qxx_mA(
"m,A'") = q_xx_mA(
"m,A'") - (q_zz_mA(
"m,A'") + q_yy_mA(
"m,A'") ) * 0.5;
4431 Qyy_mA(
"m,A'") = q_yy_mA(
"m,A'") - (q_xx_mA(
"m,A'") + q_zz_mA(
"m,A'") ) * 0.5;
4432 Qzz_mA(
"m,A'") = q_zz_mA(
"m,A'") - (q_xx_mA(
"m,A'") + q_yy_mA(
"m,A'") ) * 0.5;
4434 q_xx_e2 = - dot(Qxx_mn(
"m,n"), D_e2_mn(
"m,n"))
4435 + dot(Qxx_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4436 + dot(Qxx_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4437 q_yy_e2 = - dot(Qyy_mn(
"m,n"), D_e2_mn(
"m,n"))
4438 + dot(Qyy_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4439 + dot(Qyy_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4440 q_zz_e2 = - dot(Qzz_mn(
"m,n"), D_e2_mn(
"m,n"))
4441 + dot(Qzz_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4442 + dot(Qzz_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4444 q_xx_e2or = dot(Qxx_am(
"a,m"), Dbn_E2(
"a,m"));
4445 q_yy_e2or = dot(Qyy_am(
"a,m"), Dbn_E2(
"a,m"));
4446 q_zz_e2or = dot(Qzz_am(
"a,m"), Dbn_E2(
"a,m"));
4452 TArray2 v_xx_mA = xy(
"<m|ddphi_xx|A'>");
4453 TArray2 v_yy_mA = xy(
"<m|ddphi_yy|A'>");
4454 TArray2 v_zz_mA = xy(
"<m|ddphi_zz|A'>");
4455 TArray2 v_xy_mA = xy(
"<m|ddphi_xy|A'>");
4456 TArray2 v_xz_mA = xy(
"<m|ddphi_xz|A'>");
4457 TArray2 v_yz_mA = xy(
"<m|ddphi_yz|A'>");
4459 TArray2 v_xx_AB = xy(
"<A'|ddphi_xx|B'>");
4460 TArray2 v_yy_AB = xy(
"<A'|ddphi_yy|B'>");
4461 TArray2 v_zz_AB = xy(
"<A'|ddphi_zz|B'>");
4462 TArray2 v_xy_AB = xy(
"<A'|ddphi_xy|B'>");
4463 TArray2 v_xz_AB = xy(
"<A'|ddphi_xz|B'>");
4464 TArray2 v_yz_AB = xy(
"<A'|ddphi_yz|B'>");
4466 const double v_xx_e2 = - dot(v_xx_mn(
"m,n"), D_e2_mn(
"m,n"))
4467 + dot(v_xx_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4468 + dot(v_xx_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4469 const double v_yy_e2 = - dot(v_yy_mn(
"m,n"), D_e2_mn(
"m,n"))
4470 + dot(v_yy_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4471 + dot(v_yy_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4472 const double v_zz_e2 = - dot(v_zz_mn(
"m,n"), D_e2_mn(
"m,n"))
4473 + dot(v_zz_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4474 + dot(v_zz_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4475 const double v_xy_e2 = - dot(v_xy_mn(
"m,n"), D_e2_mn(
"m,n"))
4476 + dot(v_xy_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4477 + dot(v_xy_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4478 const double v_xz_e2 = - dot(v_xz_mn(
"m,n"), D_e2_mn(
"m,n"))
4479 + dot(v_xz_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4480 + dot(v_xz_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4481 const double v_yz_e2 = - dot(v_yz_mn(
"m,n"), D_e2_mn(
"m,n"))
4482 + dot(v_yz_AB(
"A',B'"), D_e2_AB(
"A',B'"))
4483 + dot(v_yz_mA(
"m,A'"), TmA(
"m,A'")) * 2.0;
4485 const double v_xx_e2or = dot(v_xx_am(
"a,m"), Dbn_E2(
"a,m"));
4486 const double v_yy_e2or = dot(v_yy_am(
"a,m"), Dbn_E2(
"a,m"));
4487 const double v_zz_e2or = dot(v_zz_am(
"a,m"), Dbn_E2(
"a,m"));
4488 const double v_xy_e2or = dot(v_xy_am(
"a,m"), Dbn_E2(
"a,m"));
4489 const double v_xz_e2or = dot(v_xz_am(
"a,m"), Dbn_E2(
"a,m"));
4490 const double v_yz_e2or = dot(v_yz_am(
"a,m"), Dbn_E2(
"a,m"));
4492 std::cout << std::endl << indent
4493 <<
"electric gradient (E2)" << std::endl
4494 << indent <<
"v_xx (E2) = " <<
scprintf(
"%12.10f", v_xx_e2 * 2.0)
4495 << indent <<
" v_yy (E2) = " <<
scprintf(
"%12.10f", v_yy_e2 * 2.0)
4496 << indent <<
" v_zz (E2) = " <<
scprintf(
"%12.10f", v_zz_e2 * 2.0)
4498 << indent <<
"v_xy (E2) = " <<
scprintf(
"%12.10f", v_xy_e2 * 2.0)
4499 << indent <<
" v_xz (E2) = " <<
scprintf(
"%12.10f", v_xz_e2 * 2.0)
4500 << indent <<
" v_yz (E2) = " <<
scprintf(
"%12.10f", v_yz_e2 * 2.0)
4502 std::cout << std::endl << indent
4503 <<
"electric gradient (E2 orbital response)" << std::endl
4504 << indent <<
"v_xx (E2 or) = " <<
scprintf(
"%12.10f", v_xx_e2or * 2.0)
4505 << indent <<
" v_yy (E2 or) = " <<
scprintf(
"%12.10f", v_yy_e2or * 2.0)
4506 << indent <<
" v_zz (E2 or) = " <<
scprintf(
"%12.10f", v_zz_e2or * 2.0)
4508 << indent <<
"v_xy (E2 or) = " <<
scprintf(
"%12.10f", v_xy_e2or * 2.0)
4509 << indent <<
" v_xz (E2 or) = " <<
scprintf(
"%12.10f", v_xz_e2or * 2.0)
4510 << indent <<
" v_yz (E2 or) = " <<
scprintf(
"%12.10f", v_yz_e2or * 2.0)
4511 << std::endl << std::endl;
4520 const std::size_t nocc = mFmn.trange().elements_range().extent()[0];
4521 const std::size_t naocc = Fij.trange().elements_range().extent()[0];
4525 TArray2 mu_z_ij, mu_z_ab, mu_z_ijp;
4526 if (compute_dipole) {
4527 mu_z_ij = xy(
"<i|mu_z|j>");
4528 mu_z_ab = xy(
"<a|mu_z|b>");
4530 if (nocc != naocc) {
4531 mu_z_ijp = xy(
"<i|mu_z|j'>");
4536 TArray2 q_xx_ij, q_yy_ij, q_zz_ij, Qxx_ij, Qyy_ij, Qzz_ij;
4537 TArray2 q_xx_ab, q_yy_ab, q_zz_ab, Qxx_ab, Qyy_ab, Qzz_ab;
4539 TArray2 Qxx_ijp, Qyy_ijp, Qzz_ijp;
4540 if (compute_quadrupole){
4541 q_xx_ij = xy(
"<i|q_xx|j>");
4542 q_yy_ij = xy(
"<i|q_yy|j>");
4543 q_zz_ij = xy(
"<i|q_zz|j>");
4544 Qxx_ij(
"i,j") = q_xx_ij(
"i,j") - (q_zz_ij(
"i,j") + q_yy_ij(
"i,j")) * 0.5;
4545 Qyy_ij(
"i,j") = q_yy_ij(
"i,j") - (q_zz_ij(
"i,j") + q_xx_ij(
"i,j")) * 0.5;
4546 Qzz_ij(
"i,j") = q_zz_ij(
"i,j") - (q_xx_ij(
"i,j") + q_yy_ij(
"i,j")) * 0.5;
4548 q_xx_ab = xy(
"<a|q_xx|b>");
4549 q_yy_ab = xy(
"<a|q_yy|b>");
4550 q_zz_ab = xy(
"<a|q_zz|b>");
4551 Qxx_ab(
"a,b") = q_xx_ab(
"a,b") - (q_zz_ab(
"a,b") + q_yy_ab(
"a,b")) * 0.5;
4552 Qyy_ab(
"a,b") = q_yy_ab(
"a,b") - (q_zz_ab(
"a,b") + q_xx_ab(
"a,b")) * 0.5;
4553 Qzz_ab(
"a,b") = q_zz_ab(
"a,b") - (q_xx_ab(
"a,b") + q_yy_ab(
"a,b")) * 0.5;
4555 if (nocc != naocc) {
4556 TArray2 q_xx_ijp = xy(
"<i|q_xx|j'>");
4557 TArray2 q_yy_ijp = xy(
"<i|q_yy|j'>");
4558 TArray2 q_zz_ijp = xy(
"<i|q_zz|j'>");
4559 Qxx_ijp(
"i,j'") = q_xx_ijp(
"i,j'") - (q_zz_ijp(
"i,j'") + q_yy_ijp(
"i,j'")) * 0.5;
4560 Qyy_ijp(
"i,j'") = q_yy_ijp(
"i,j'") - (q_zz_ijp(
"i,j'") + q_xx_ijp(
"i,j'")) * 0.5;
4561 Qzz_ijp(
"i,j'") = q_zz_ijp(
"i,j'") - (q_xx_ijp(
"i,j'") + q_yy_ijp(
"i,j'")) * 0.5;
4566 TArray2 v_xx_ij, v_yy_ij, v_zz_ij, v_xy_ij, v_xz_ij, v_yz_ij;
4567 TArray2 v_xx_ab, v_yy_ab, v_zz_ab, v_xy_ab, v_xz_ab, v_yz_ab;
4569 v_xx_ij = xy(
"<i|ddphi_xx|j>");
4570 v_yy_ij = xy(
"<i|ddphi_yy|j>");
4571 v_zz_ij = xy(
"<i|ddphi_zz|j>");
4572 v_xy_ij = xy(
"<i|ddphi_xy|j>");
4573 v_xz_ij = xy(
"<i|ddphi_xz|j>");
4574 v_yz_ij = xy(
"<i|ddphi_yz|j>");
4576 v_xx_ab = xy(
"<a|ddphi_xx|b>");
4577 v_yy_ab = xy(
"<a|ddphi_yy|b>");
4578 v_zz_ab = xy(
"<a|ddphi_zz|b>");
4579 v_xy_ab = xy(
"<a|ddphi_xy|b>");
4580 v_xz_ab = xy(
"<a|ddphi_xz|b>");
4581 v_yz_ab = xy(
"<a|ddphi_yz|b>");
4587 if (nocc != naocc) {
4589 TArray2 Fipjp = xy(
"<i'|F|j'>");
4590 pceval_type Delta_ijp_gen(TA::array_to_eigen(Fij), TA::array_to_eigen(Fipjp));
4592 TArray2 Fijp = xy(
"<i|F|j'>");
4593 TArray2d Delta_ijp(Fijp.world(), Fijp.trange());
4595 for(
auto t = Delta_ijp.trange().tiles_range().begin();
4596 t != Delta_ijp.trange().tiles_range().end(); ++t)
4597 if (Delta_ijp.is_local(*t)) {
4598 std::array<std::size_t, 2> index;
4599 std::copy(t->begin(), t->end(), index.begin());
4600 madness::Future < typename TArray2d::value_type >
4605 Delta_ijp.set(*t, tile);
4607 Delta_ijp_F(
"i,j'") = Delta_ijp(
"i,j'");
4609 A_ijpam(
"i,j',a,m") = 4.0 * _4(
"<i a|g|j' m>") - _4(
"<i a|g|m j'>") - _4(
"<i m|g|a j'>");
4616 mFij(
"i,j") = - _2(
"<i|F|j>");
4617 TArray4d g_ijab = ijxy(
"<i j|g|a b>");
4620 typedef TA::Array<T, 4, LazyTensor<T, 4, pc4eval_type > > TArray4dLazy;
4621 TArray4dLazy Delta_ijab(g_ijab.world(), g_ijab.trange());
4622 pc4eval_type Delta_ijab_gen(TA::array_to_eigen(mFij), TA::array_to_eigen(mFij),
4623 TA::array_to_eigen(mFab),TA::array_to_eigen(mFab));
4625 for(
auto t = Delta_ijab.trange().tiles_range().begin();
4626 t != Delta_ijab.trange().tiles_range().end(); ++t)
4627 if (Delta_ijab.is_local(*t)) {
4628 std::array<std::size_t, 4> index;
4629 std::copy(t->begin(), t->end(), index.begin());
4630 madness::Future < typename TArray4dLazy::value_type >
4635 Delta_ijab.set(*t, tile);
4640 T2_ijab(
"i,j,a,b") = g_ijab(
"i,j,a,b") * Delta_ijab(
"i,j,a,b");
4642 double mu_z_mp2 = 0.0, mu_z_mp2or = 0.0;
4643 double q_xx_mp2 = 0.0, q_yy_mp2 = 0.0, q_zz_mp2 = 0.0;
4644 double q_xx_mp2or = 0.0, q_yy_mp2or = 0.0, q_zz_mp2or = 0.0;
4645 #if INCLUDE_MP2_CONTRI
4648 <<
"Compute MP2 contributions" << std::endl;
4651 D_mp2_ij(
"i,j") = (2.0 * T2_ijab(
"i,k,a,b") - T2_ijab(
"k,i,a,b"))
4652 * T2_ijab(
"j,k,a,b");
4653 D_mp2_ab(
"a,b") = (2.0 * T2_ijab(
"i,j,a,c") - T2_ijab(
"i,j,c,a"))
4654 * T2_ijab(
"i,j,b,c");
4657 TArray2 X_mp2_nfzc = Xam_mp2(T2_ijab, D_mp2_ij, D_mp2_ab);
4662 if (nocc != naocc) {
4664 <<
"Include frozen-core MP2 contributions" << std::endl;
4665 Dijp_or_mp2(
"i,j'") = - ( _4(
"<j' l|g|c d>")
4666 * (2.0 * T2_ijab(
"i,l,c,d") - T2_ijab(
"l,i,c,d"))
4667 ) * Delta_ijp_F(
"i,j'") * 2.0;
4669 Xam_Dijp_or(
"a,m") = A_ijpam(
"i,j',a,m") * Dijp_or_mp2(
"i,j'");
4670 X_mp2(
"a,m") = X_mp2_nfzc(
"a,m") - Xam_Dijp_or(
"a,m");
4686 X_mp2(
"a,m") = X_mp2_nfzc(
"a,m");
4690 TArray2 Dbn_mp2(X_mp2.world(), X_mp2.trange());
4691 auto resnorm_mp2 = cg_solver2(Orbital_relaxation_Abnam,
4698 if (compute_dipole) {
4700 mu_z_mp2 = - dot(mu_z_ij(
"i,j"), D_mp2_ij(
"i,j"))
4701 + dot(mu_z_ab(
"a,b"), D_mp2_ab(
"a,b"));
4704 mu_z_mp2or = dot(mu_z_am(
"a,m"), Dbn_mp2(
"a,m"));
4706 if (nocc != naocc) {
4707 mu_z_mp2or += dot(mu_z_ijp(
"i,j'"), Dijp_or_mp2(
"i,j'"));
4712 if (compute_quadrupole) {
4713 q_xx_mp2 = - dot(Qxx_ij(
"i,j"), D_mp2_ij(
"i,j"))
4714 + dot(Qxx_ab(
"a,b"), D_mp2_ab(
"a,b"));
4715 q_yy_mp2 = - dot(Qyy_ij(
"i,j"), D_mp2_ij(
"i,j"))
4716 + dot(Qyy_ab(
"a,b"), D_mp2_ab(
"a,b"));
4717 q_zz_mp2 = - dot(Qzz_ij(
"i,j"), D_mp2_ij(
"i,j"))
4718 + dot(Qzz_ab(
"a,b"), D_mp2_ab(
"a,b"));
4727 q_xx_mp2or = dot(Qxx_am(
"a,m"), Dbn_mp2(
"a,m"));
4728 q_yy_mp2or = dot(Qyy_am(
"a,m"), Dbn_mp2(
"a,m"));
4729 q_zz_mp2or = dot(Qzz_am(
"a,m"), Dbn_mp2(
"a,m"));
4735 if (nocc != naocc) {
4736 q_xx_mp2or += dot(Qxx_ijp(
"i,j'"), Dijp_or_mp2(
"i,j'"));
4737 q_yy_mp2or += dot(Qyy_ijp(
"i,j'"), Dijp_or_mp2(
"i,j'"));
4738 q_zz_mp2or += dot(Qzz_ijp(
"i,j'"), Dijp_or_mp2(
"i,j'"));
4744 const double v_xx_mp2 = - dot(v_xx_ij(
"i,j"), D_mp2_ij(
"i,j"))
4745 + dot(v_xx_ab(
"a,b"), D_mp2_ab(
"a,b"));
4746 const double v_yy_mp2 = - dot(v_yy_ij(
"i,j"), D_mp2_ij(
"i,j"))
4747 + dot(v_yy_ab(
"a,b"), D_mp2_ab(
"a,b"));
4748 const double v_zz_mp2 = - dot(v_zz_ij(
"i,j"), D_mp2_ij(
"i,j"))
4749 + dot(v_zz_ab(
"a,b"), D_mp2_ab(
"a,b"));
4750 const double v_xy_mp2 = - dot(v_xy_ij(
"i,j"), D_mp2_ij(
"i,j"))
4751 + dot(v_xy_ab(
"a,b"), D_mp2_ab(
"a,b"));
4752 const double v_xz_mp2 = - dot(v_xz_ij(
"i,j"), D_mp2_ij(
"i,j"))
4753 + dot(v_xz_ab(
"a,b"), D_mp2_ab(
"a,b"));
4754 const double v_yz_mp2 = - dot(v_yz_ij(
"i,j"), D_mp2_ij(
"i,j"))
4755 + dot(v_yz_ab(
"a,b"), D_mp2_ab(
"a,b"));
4757 const double v_xx_mp2or = dot(v_xx_am(
"a,m"), Dbn_mp2(
"a,m"));
4758 const double v_yy_mp2or = dot(v_yy_am(
"a,m"), Dbn_mp2(
"a,m"));
4759 const double v_zz_mp2or = dot(v_zz_am(
"a,m"), Dbn_mp2(
"a,m"));
4760 const double v_xy_mp2or = dot(v_xy_am(
"a,m"), Dbn_mp2(
"a,m"));
4761 const double v_xz_mp2or = dot(v_xz_am(
"a,m"), Dbn_mp2(
"a,m"));
4762 const double v_yz_mp2or = dot(v_yz_am(
"a,m"), Dbn_mp2(
"a,m"));
4764 std::cout << std::endl << indent
4765 <<
"electric gradient (MP2)" << std::endl
4766 << indent <<
"v_xx (MP2) = " <<
scprintf(
"%12.10f", - v_xx_mp2 * 2.0)
4767 << indent <<
" v_yy (MP2) = " <<
scprintf(
"%12.10f", - v_yy_mp2 * 2.0)
4768 << indent <<
" v_zz (MP2) = " <<
scprintf(
"%12.10f", - v_zz_mp2 * 2.0)
4770 << indent <<
"v_xy (MP2) = " <<
scprintf(
"%12.10f", - v_xy_mp2 * 2.0)
4771 << indent <<
" v_xz (MP2) = " <<
scprintf(
"%12.10f", - v_xz_mp2 * 2.0)
4772 << indent <<
" v_yz (MP2) = " <<
scprintf(
"%12.10f", - v_yz_mp2 * 2.0)
4774 std::cout << std::endl << indent
4775 <<
"electric gradient (MP2 orbital response)" << std::endl
4776 << indent <<
"v_xx (MP2 or) = " <<
scprintf(
"%12.10f", - v_xx_mp2or * 2.0)
4777 << indent <<
" v_yy (MP2 or) = " <<
scprintf(
"%12.10f", - v_yy_mp2or * 2.0)
4778 << indent <<
" v_zz (MP2 or) = " <<
scprintf(
"%12.10f", - v_zz_mp2or * 2.0)
4780 << indent <<
"v_xy (MP2 or) = " <<
scprintf(
"%12.10f", - v_xy_mp2or * 2.0)
4781 << indent <<
" v_xz (MP2 or) = " <<
scprintf(
"%12.10f", - v_xz_mp2or * 2.0)
4782 << indent <<
" v_yz (MP2 or) = " <<
scprintf(
"%12.10f", - v_yz_mp2or * 2.0)
4783 << std::endl << std::endl;
4792 if (compute_dipole) {
4793 mu_z_apb = xy(
"<a'|mu_z|b>");
4796 TArray2 q_xx_apb, q_yy_apb, q_zz_apb;
4797 TArray2 Qxx_apb, Qyy_apb, Qzz_apb, Qxy_apb, Qxz_apb, Qyz_apb;
4798 if (compute_quadrupole) {
4799 q_xx_apb = xy(
"<a'|q_xx|b>");
4800 q_yy_apb = xy(
"<a'|q_yy|b>");
4801 q_zz_apb = xy(
"<a'|q_zz|b>");
4803 Qxx_apb(
"a',b") = q_xx_apb(
"a',b") - (q_zz_apb(
"a',b") + q_yy_apb(
"a',b")) * 0.5;
4804 Qyy_apb(
"a',b") = q_yy_apb(
"a',b") - (q_zz_apb(
"a',b") + q_xx_apb(
"a',b")) * 0.5 ;
4805 Qzz_apb(
"a',b") = q_zz_apb(
"a',b") - (q_xx_apb(
"a',b") + q_yy_apb(
"a',b")) * 0.5;
4806 Qxy_apb(
"a',b") = _2(
"<a'|q_xy|b>") * 1.5;
4807 Qxz_apb(
"a',b") = _2(
"<a'|q_xz|b>") * 1.5;
4808 Qyz_apb(
"a',b") = _2(
"<a'|q_yz|b>") * 1.5;
4811 TArray2 v_xx_apb, v_yy_apb, v_zz_apb, v_xy_apb, v_xz_apb, v_yz_apb;
4813 v_xx_apb = xy(
"<a'|ddphi_xx|b>");
4814 v_yy_apb = xy(
"<a'|ddphi_yy|b>");
4815 v_zz_apb = xy(
"<a'|ddphi_zz|b>");
4816 v_xy_apb = xy(
"<a'|ddphi_xy|b>");
4817 v_xz_apb = xy(
"<a'|ddphi_xz|b>");
4818 v_yz_apb = xy(
"<a'|ddphi_yz|b>");
4822 const double C_0 = 1.0 / 2.0;
4823 const double C_1 = 1.0 / 4.0;
4825 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
4826 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
4827 const double RR_C1 = 0.5 * C_0 * C_0 + 1.5 * C_1 * C_1;
4828 const double RR_C2 = 0.5 * C_0 * C_0 - 1.5 * C_1 * C_1;
4831 double mu_z_mp2f12C = 0.0, mu_z_mp2f12Cor = 0.0;
4832 double q_xx_mp2f12C = 0.0, q_yy_mp2f12C = 0.0, q_zz_mp2f12C = 0.0;
4833 double q_xx_mp2f12Cor = 0.0, q_yy_mp2f12Cor = 0.0, q_zz_mp2f12Cor = 0.0;
4834 #if INCLUDE_MP2F12C_CONTRI
4837 <<
"Compute MP2 F12 coupling contributions" << std::endl;
4839 C_ijab(
"i,j,a,b") = _4(
"<i j|r|a_F(a') b>") + _4(
"<i j|r|a b_F(a')>");
4840 A_ijab(
"i,j,a,b") = C_ijab(
"i,j,a,b") * Delta_ijab(
"i,j,a,b");
4844 <<
"Compute density from coupling contribution" << std::endl;
4845 TArray2 D_mp2f12_ij, D_mp2f12_ab;
4846 D_mp2f12_ij(
"i,j") = (R_C1 * A_ijab(
"i,k,a,b") + R_C2 * A_ijab(
"k,i,a,b"))
4847 * T2_ijab(
"j,k,a,b")
4849 + (R_C1 * A_ijab(
"j,k,a,b") + R_C2 * A_ijab(
"k,j,a,b"))
4850 * T2_ijab(
"i,k,a,b")
4852 + (RR_C1 * A_ijab(
"i,k,a,b") + RR_C2 * A_ijab(
"k,i,a,b"))
4853 * A_ijab(
"j,k,a,b");
4854 D_mp2f12_ab(
"a,b") = (R_C1 * T2_ijab(
"i,j,a,c") + R_C2 * T2_ijab(
"i,j,c,a"))
4857 + (R_C1 * T2_ijab(
"i,j,b,c") + R_C2 * T2_ijab(
"i,j,c,b"))
4860 + (RR_C1 * A_ijab(
"i,j,a,c") + RR_C2 * A_ijab(
"i,j,c,a"))
4861 * A_ijab(
"i,j,b,c");
4865 RT_apb(
"a',b") = _4(
"<a' c|r|k l>")
4866 * ( R_C1 * T2_ijab(
"k,l,b,c") + R_C2 * T2_ijab(
"k,l,c,b")
4867 + RR_C1 * A_ijab(
"k,l,b,c") + RR_C2 * A_ijab(
"k,l,c,b")
4872 <<
"Compute orbital response from coupling contribution" << std::endl;
4873 TArray2 Xmp2f12_contri_nfzc = Xam_Cmp2f12(C_0, C_1,T2_ijab, A_ijab,
4874 D_mp2f12_ij, D_mp2f12_ab, RT_apb);
4879 if (nocc != naocc) {
4881 <<
"Include frozen-core contributions for MP2 F12 coupling" << std::endl;
4883 Xiip_CT2_mp2(
"i,i'") =
4884 _4(
"<i' l|r|b_F(a') c>")
4885 * ( R_C1 * T2_ijab(
"i,l,b,c") + R_C2 * T2_ijab(
"l,i,b,c")
4886 + RR_C1 * A_ijab(
"i,l,b,c") + RR_C2 * A_ijab(
"l,i,b,c")
4888 + _4(
"<i' l|r|c b_F(a')>")
4889 * ( R_C1 * T2_ijab(
"i,l,c,b") + R_C2 * T2_ijab(
"l,i,c,b")
4890 + RR_C1 * A_ijab(
"i,l,c,b") + RR_C2 * A_ijab(
"l,i,c,b")
4893 + _4(
"<i' l|g|c d>")
4894 * (R_C1 * A_ijab(
"i,l,c,d") + R_C2 * A_ijab(
"l,i,c,d"))
4897 Diip_Cmp2(
"i,i'") = - Xiip_CT2_mp2(
"i,i'") * Delta_ijp_F(
"i,i'");
4899 Xmp2f12_contri(
"a,m") = Xmp2f12_contri_nfzc(
"a,m") - A_ijpam(
"i,j',a,m") * Diip_Cmp2(
"i,j'");
4902 Xmp2f12_contri(
"a,m") = Xmp2f12_contri_nfzc(
"a,m");
4905 TArray2 Dbn_mp2f12(Xmp2f12_contri.world(), Xmp2f12_contri.trange());
4906 auto resnorm_mp2f12 = cg_solver2(Orbital_relaxation_Abnam,
4913 if (compute_dipole) {
4915 mu_z_mp2f12C = - dot(mu_z_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4916 + dot(mu_z_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4917 + dot(mu_z_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4920 mu_z_mp2f12Cor = dot(mu_z_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4922 if (nocc != naocc) {
4923 mu_z_mp2f12Cor += dot(mu_z_ijp(
"i,j'"), Diip_Cmp2(
"i,j'"));
4928 if (compute_quadrupole) {
4929 q_xx_mp2f12C = - dot(Qxx_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4930 + dot(Qxx_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4931 + dot(Qxx_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4932 q_yy_mp2f12C = - dot(Qyy_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4933 + dot(Qyy_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4934 + dot(Qyy_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4935 q_zz_mp2f12C = - dot(Qzz_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4936 + dot(Qzz_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4937 + dot(Qzz_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4949 q_xx_mp2f12Cor = dot(Qxx_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4950 q_yy_mp2f12Cor = dot(Qyy_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4951 q_zz_mp2f12Cor = dot(Qzz_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4957 if (nocc != naocc) {
4958 q_xx_mp2f12Cor += dot(Qxx_ijp(
"i,j'"), Diip_Cmp2(
"i,j'"));
4959 q_yy_mp2f12Cor += dot(Qyy_ijp(
"i,j'"), Diip_Cmp2(
"i,j'"));
4960 q_zz_mp2f12Cor += dot(Qzz_ijp(
"i,j'"), Diip_Cmp2(
"i,j'"));
4966 const double v_xx_mp2f12C = - dot(v_xx_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4967 + dot(v_xx_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4968 + dot(v_xx_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4969 const double v_yy_mp2f12C = - dot(v_yy_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4970 + dot(v_yy_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4971 + dot(v_yy_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4972 const double v_zz_mp2f12C = - dot(v_zz_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4973 + dot(v_zz_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4974 + dot(v_zz_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4975 const double v_xy_mp2f12C = - dot(v_xy_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4976 + dot(v_xy_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4977 + dot(v_xy_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4978 const double v_xz_mp2f12C = - dot(v_xz_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4979 + dot(v_xz_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4980 + dot(v_xz_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4981 const double v_yz_mp2f12C = - dot(v_yz_ij(
"i,j"), D_mp2f12_ij(
"i,j"))
4982 + dot(v_yz_ab(
"a,b"), D_mp2f12_ab(
"a,b"))
4983 + dot(v_yz_apb(
"a',b"), RT_apb(
"a',b")) * 2.0;
4985 const double v_xx_mp2f12Cor = dot(v_xx_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4986 const double v_yy_mp2f12Cor = dot(v_yy_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4987 const double v_zz_mp2f12Cor = dot(v_zz_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4988 const double v_xy_mp2f12Cor = dot(v_xy_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4989 const double v_xz_mp2f12Cor = dot(v_xz_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4990 const double v_yz_mp2f12Cor = dot(v_yz_am(
"a,m"), Dbn_mp2f12(
"a,m"));
4992 std::cout << std::endl << indent
4993 <<
"electric gradient (MP2F12 coupling)" << std::endl
4994 << indent <<
"v_xx (MP2F12 C) = " <<
scprintf(
"%12.10f", v_xx_mp2f12C * 2.0)
4995 << indent <<
" v_yy (MP2F12 C) = " <<
scprintf(
"%12.10f", v_yy_mp2f12C * 2.0)
4996 << indent <<
" v_zz (MP2F12 C) = " <<
scprintf(
"%12.10f", v_zz_mp2f12C * 2.0)
4998 << indent <<
"v_xy (MP2F12 C) = " <<
scprintf(
"%12.10f", v_xy_mp2f12C * 2.0)
4999 << indent <<
" v_xz (MP2F12 C) = " <<
scprintf(
"%12.10f", v_xz_mp2f12C * 2.0)
5000 << indent <<
" v_yz (MP2F12 C) = " <<
scprintf(
"%12.10f", v_yz_mp2f12C * 2.0)
5002 std::cout << std::endl << indent
5003 <<
"electric gradient (MP2F12 coupling orbital response)" << std::endl
5004 << indent <<
"v_xx (MP2F12 C or) = " <<
scprintf(
"%12.10f", v_xx_mp2f12Cor * 2.0)
5005 << indent <<
" v_yy (MP2F12 C or) = " <<
scprintf(
"%12.10f", v_yy_mp2f12Cor * 2.0)
5006 << indent <<
" v_zz (MP2F12 C or) = " <<
scprintf(
"%12.10f", v_zz_mp2f12Cor * 2.0)
5008 << indent <<
"v_xy (MP2F12 C or) = " <<
scprintf(
"%12.10f", v_xy_mp2f12Cor * 2.0)
5009 << indent <<
" v_xz (MP2F12 C or) = " <<
scprintf(
"%12.10f", v_xz_mp2f12Cor * 2.0)
5010 << indent <<
" v_yz (MP2F12 C or) = " <<
scprintf(
"%12.10f", v_yz_mp2f12Cor * 2.0)
5011 << std::endl << std::endl;
5019 double mu_z_f12 = 0.0, mu_z_f12or = 0.0;
5020 double q_xx_f12 = 0.0, q_yy_f12 = 0.0, q_zz_f12 = 0.0;
5021 double q_xx_f12or = 0.0, q_yy_f12or = 0.0, q_zz_f12or = 0.0;
5022 #if INCLUDE_F12_CONTRI
5025 <<
"Compute F12 contributions" << std::endl;
5027 ExEnv::out0() << std::endl << indent <<
"Compute D_f12" << std::endl;
5029 TArray2 D_f12_ij, D_f12_ab, D_f12_apbp, D_f12_apb;
5030 compute_Df12_XB(C_0, C_1, D_f12_ij, D_f12_ab, D_f12_apbp, D_f12_apb);
5035 ExEnv::out0() << std::endl << indent <<
"Compute X and B density contribution to Xam" << std::endl;
5037 TArray2 gdf12_am = Xam_Df12_XB(C_0, C_1, D_f12_ij,D_f12_ab,
5038 D_f12_apbp, D_f12_apb);
5041 ExEnv::out0() << std::endl << indent <<
"Compute V Xam" << std::endl;
5042 TArray2 Xam_Vcontri = Xam_V(C_0, C_1);
5043 ExEnv::out0() << std::endl << indent <<
"Compute X Xam" << std::endl;
5044 TArray2 Xam_Xcontri = Xam_X(C_0, C_1);
5045 ExEnv::out0() << std::endl << indent <<
"Compute B Xam" << std::endl;
5046 TArray2 Xam_Bcontri = Xam_B(C_0, C_1);
5050 Xam_f12_nfzc(
"a,m") = 2.0 * ( Xam_Vcontri(
"a,m")
5051 - Xam_Xcontri(
"a,m")
5052 + Xam_Bcontri(
"a,m")
5058 if (nocc != naocc) {
5060 <<
"Include frozen-core F12 contributions" << std::endl;
5061 TArray2 Xiip_f12 = Xiip_VBX(C_0, C_1);
5062 Diip_f12(
"i,i'") = - Xiip_f12(
"i,i'") * Delta_ijp_F(
"i,i'");
5064 Xam_f12(
"a,m") = Xam_f12_nfzc(
"a,m") - A_ijpam(
"i,j',a,m") * Diip_f12(
"i,j'");
5066 Xam_f12(
"a,m") = Xam_f12_nfzc(
"a,m");
5069 TArray2 Dbn_f12(Xam_f12.world(), Xam_f12.trange());
5070 auto resnorm_f12 = cg_solver2(Orbital_relaxation_Abnam,
5080 (2.0 * _4(
"<a k|g|m l>") - _4(
"<a k|g|l m>"))
5084 - (2.0 * g_abmc(
"a,b,m,c") - g_abmc(
"b,a,m,c"))
5086 - (2.0 * _4(
"<a b'|g|m c'>") - _4(
"<a b'|g|c' m>"))
5087 * D_f12_apbp(
"b',c'")
5088 - (2.0 * _4(
"<a b'|g|m c>") - _4(
"<a b'|g|c m>"))
5090 - (2.0 * _4(
"<a b|g|m c'>") - _4(
"<a b|g|c' m>"))
5091 * D_f12_apb(
"c',b");
5094 Xam_V_nfzc(
"a,m") = 2.0 * Xam_Vcontri(
"a,m");
5096 Xam_X_nfzc(
"a,m") = 2.0 * (- Xam_Xcontri(
"a,m") + gdf12_X_am(
"a,m"));
5098 Xam_B_nfzc(
"a,m") = 2.0 * (Xam_Bcontri(
"a,m")+ gdf12_B_am(
"a,m"));
5102 TArray2 D_iip_V, D_iip_X, D_iip_B;
5103 if (nocc != naocc) {
5105 <<
"Include frozen-core V, X, and B contributions" << std::endl;
5107 const char* ip =
"i'";
5108 const char* i =
"i";
5109 TArray2 V_ipi = VRk_Sk(ip,i,C_0, C_1);
5110 TArray2 V_iip = VRk_Sk(i,ip,C_0, C_1);
5112 2.0 * (V_ipi(
"i',i") + V_iip(
"i,i'"));
5113 D_iip_V(
"i,i'") = - Xiip_V(
"i,i'") * Delta_ijp_F(
"i,i'");
5114 Xam_V(
"a,m") = Xam_V_nfzc(
"a,m") - A_ijpam(
"i,j',a,m") * D_iip_V(
"i,j'");
5118 TArray4d r2_ipk_jl = ijxy(
"<i' k|r2|j l>");
5119 TArray4d r_ipk_pq = ijxy(
"<i' k|r|p q>");
5120 TArray4d r_pqkl = ijxy(
"<p q|r|k l>");
5121 TArray4d r_ipk_apn = ijxy(
"<i' k|r|a' n>");
5122 TArray4d r_apn_kl = ijxy(
"<a' n|r|k l>");
5123 TArray4d r_kip_apn = ijxy(
"<k i'|r|a' n>");
5125 - 2.0 * ( (RR_C1 * r2_ipk_jl(
"i',k,j,l") + RR_C2 * r2_ipk_jl(
"i',k,l,j"))
5126 * _2(
"<l|I|k>") * F_ij(
"j,i")
5127 + (RR_C1 * r2_ipk_jl(
"i',k,i,l") + RR_C2 * r2_ipk_jl(
"i',k,l,i"))
5130 - (RR_C1 * r_ipk_pq(
"i',k,p,q") + RR_C2 * r_ipk_pq(
"i',k,q,p"))
5131 * ( r_pqkl(
"p,q,j,k") * F_ij(
"j,i")
5132 + r_pqkl(
"p,q,i,l") * F_ij(
"l,k"))
5134 - (RR_C1 * r_ipk_apn(
"i',k,a',n") + RR_C2 * r_kip_apn(
"k,i',a',n"))
5135 * ( r_apn_kl(
"a',n,j,k") * F_ij(
"j,i")
5136 + r_apn_kl(
"a',n,i,l") * F_ij(
"l,k"))
5138 - (RR_C1 * r_kip_apn(
"k,i',a',n") + RR_C2 * r_ipk_apn(
"i',k,a',n"))
5139 * ( r_apn_kl(
"a',n,k,j") * F_ij(
"j,i")
5140 + r_apn_kl(
"a',n,l,i") * F_ij(
"l,k"))
5142 D_iip_X(
"i,i'") = - Xiip_X(
"i,i'") * Delta_ijp_F(
"i,i'");
5143 Xam_X(
"a,m") = Xam_X_nfzc(
"a,m") - A_ijpam(
"i,j',a,m") * D_iip_X(
"i,j'");
5146 TArray2 B_ipi = BPk_Qk(ip,i,C_0,C_1);
5148 2.0 * B_ipi(
"i',i");
5149 D_iip_B(
"i,i'") = - Xiip_B(
"i,i'") * Delta_ijp_F(
"i,i'");
5150 Xam_B(
"a,m") = Xam_B_nfzc(
"a,m") - A_ijpam(
"i,j',a,m") * D_iip_B(
"i,j'");
5152 Xam_V(
"a,m") = Xam_V_nfzc(
"a,m");
5153 Xam_X(
"a,m") = Xam_X_nfzc(
"a,m");
5154 Xam_B(
"a,m") = Xam_B_nfzc(
"a,m");
5157 TArray2 Dbn_V(Xam_V.world(), Xam_V.trange());
5158 auto resnorm_V = cg_solver2(Orbital_relaxation_Abnam,
5163 TArray2 Dbn_X(Xam_X.world(), Xam_X.trange());
5164 auto resnorm_X = cg_solver2(Orbital_relaxation_Abnam,
5169 TArray2 Dbn_B(Xam_B.world(), Xam_B.trange());
5170 auto resnorm_B = cg_solver2(Orbital_relaxation_Abnam,
5176 if (compute_dipole) {
5177 double mu_z_X, mu_z_B, mu_z_Vor, mu_z_Xor, mu_z_Bor;
5180 - dot(mu_z_ij(
"i,j"), D_f12_ij(
"i,j"));
5181 TArray2 mu_z_apbp = xy(
"<a'|mu_z|b'>");
5183 dot(mu_z_ab(
"a,b"), D_f12_ab(
"a,b"))
5184 + dot(mu_z_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5185 + dot(mu_z_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0;
5187 mu_z_Vor = dot(mu_z_am(
"a,m"), Dbn_V(
"a,m"));
5188 mu_z_Xor = dot(mu_z_am(
"a,m"), Dbn_X(
"a,m"));
5189 mu_z_Bor = dot(mu_z_am(
"a,m"), Dbn_B(
"a,m"));
5190 if (nocc != naocc) {
5191 mu_z_Vor += dot(mu_z_ijp(
"i,j'"), D_iip_V(
"i,j'"));
5192 mu_z_Xor += dot(mu_z_ijp(
"i,j'"), D_iip_X(
"i,j'"));
5193 mu_z_Bor += dot(mu_z_ijp(
"i,j'"), D_iip_B(
"i,j'"));
5196 std::cout << std::endl << indent
5197 <<
"mu_z (V orbital response) = " <<
scprintf(
"%15.12f", - mu_z_Vor * 2.0)
5198 << std::endl << indent
5199 <<
"mu_z (X) = " <<
scprintf(
"%15.12f",- mu_z_X * 2.0)
5200 << std::endl << indent
5201 <<
"mu_z (X orbital response) = " <<
scprintf(
"%15.12f", - mu_z_Xor * 2.0)
5202 << std::endl << indent
5203 <<
"mu_z (B) = " <<
scprintf(
"%15.12f",- mu_z_B * 2.0)
5204 << std::endl << indent
5205 <<
"mu_z (B orbital response) = " <<
scprintf(
"%15.12f", - mu_z_Bor * 2.0)
5210 if (compute_dipole) {
5211 TArray2 mu_z_apbp = xy(
"<a'|mu_z|b'>");
5214 - dot(mu_z_ij(
"i,j"), D_f12_ij(
"i,j"))
5216 + dot(mu_z_ab(
"a,b"), D_f12_ab(
"a,b"))
5217 + dot(mu_z_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5218 + dot(mu_z_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0
5220 mu_z_f12or = dot(mu_z_am(
"a,m"), Dbn_f12(
"a,m"));
5221 if (nocc != naocc) {
5222 mu_z_f12or += dot(mu_z_ijp(
"i,j'"), Diip_f12(
"i,j'"));
5227 if (compute_quadrupole) {
5228 TArray2 q_xx_apbp = xy(
"<a'|q_xx|b'>");
5229 TArray2 q_yy_apbp = xy(
"<a'|q_yy|b'>");
5230 TArray2 q_zz_apbp = xy(
"<a'|q_zz|b'>");
5232 TArray2 Qxx_apbp, Qyy_apbp, Qzz_apbp;
5233 Qxx_apbp(
"a',b'") = q_xx_apbp(
"a',b'") - (q_zz_apbp(
"a',b'") + q_yy_apbp(
"a',b'")) * 0.5;
5234 Qyy_apbp(
"a',b'") = q_yy_apbp(
"a',b'") - (q_zz_apbp(
"a',b'") + q_xx_apbp(
"a',b'")) * 0.5;
5235 Qzz_apbp(
"a',b'") = q_zz_apbp(
"a',b'") - (q_xx_apbp(
"a',b'") + q_yy_apbp(
"a',b'")) * 0.5;
5237 q_xx_f12 = - dot(Qxx_ij(
"i,j"), D_f12_ij(
"i,j"))
5238 + dot(Qxx_ab(
"a,b"), D_f12_ab(
"a,b"))
5239 + dot(Qxx_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5240 + dot(Qxx_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0
5242 q_yy_f12 = - dot(Qyy_ij(
"i,j"), D_f12_ij(
"i,j"))
5243 + dot(Qyy_ab(
"a,b"), D_f12_ab(
"a,b"))
5244 + dot(Qyy_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5245 + dot(Qyy_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0
5247 q_zz_f12 = - dot(Qzz_ij(
"i,j"), D_f12_ij(
"i,j"))
5248 + dot(Qzz_ab(
"a,b"), D_f12_ab(
"a,b"))
5249 + dot(Qzz_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5250 + dot(Qzz_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0
5266 q_xx_f12or = dot(Qxx_am(
"a,m"), Dbn_f12(
"a,m"));
5267 q_yy_f12or = dot(Qyy_am(
"a,m"), Dbn_f12(
"a,m"));
5268 q_zz_f12or = dot(Qzz_am(
"a,m"), Dbn_f12(
"a,m"));
5274 if (nocc != naocc) {
5275 q_xx_f12or += dot(Qxx_ijp(
"i,j'"), Diip_f12(
"i,j'"));
5276 q_yy_f12or += dot(Qyy_ijp(
"i,j'"), Diip_f12(
"i,j'"));
5277 q_zz_f12or += dot(Qzz_ijp(
"i,j'"), Diip_f12(
"i,j'"));
5282 TArray2 v_xx_apbp = xy(
"<a'|ddphi_xx|b'>");
5283 TArray2 v_yy_apbp = xy(
"<a'|ddphi_yy|b'>");
5284 TArray2 v_zz_apbp = xy(
"<a'|ddphi_zz|b'>");
5285 TArray2 v_xy_apbp = xy(
"<a'|ddphi_xy|b'>");
5286 TArray2 v_xz_apbp = xy(
"<a'|ddphi_xz|b'>");
5287 TArray2 v_yz_apbp = xy(
"<a'|ddphi_yz|b'>");
5290 const double v_xx_f12 = - dot(v_xx_ij(
"i,j"), D_f12_ij(
"i,j"))
5291 + dot(v_xx_ab(
"a,b"), D_f12_ab(
"a,b"))
5292 + dot(v_xx_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5293 + dot(v_xx_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0;
5294 const double v_yy_f12 = - dot(v_yy_ij(
"i,j"), D_f12_ij(
"i,j"))
5295 + dot(v_yy_ab(
"a,b"), D_f12_ab(
"a,b"))
5296 + dot(v_yy_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5297 + dot(v_yy_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0;
5298 const double v_zz_f12 = - dot(v_zz_ij(
"i,j"), D_f12_ij(
"i,j"))
5299 + dot(v_zz_ab(
"a,b"), D_f12_ab(
"a,b"))
5300 + dot(v_zz_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5301 + dot(v_zz_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0;
5302 const double v_xy_f12 = - dot(v_xy_ij(
"i,j"), D_f12_ij(
"i,j"))
5303 + dot(v_xy_ab(
"a,b"), D_f12_ab(
"a,b"))
5304 + dot(v_xy_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5305 + dot(v_xy_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0;
5306 const double v_xz_f12 = - dot(v_xz_ij(
"i,j"), D_f12_ij(
"i,j"))
5307 + dot(v_xz_ab(
"a,b"), D_f12_ab(
"a,b"))
5308 + dot(v_xz_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5309 + dot(v_xz_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0;
5310 const double v_yz_f12 = - dot(v_yz_ij(
"i,j"), D_f12_ij(
"i,j"))
5311 + dot(v_yz_ab(
"a,b"), D_f12_ab(
"a,b"))
5312 + dot(v_yz_apbp(
"a',b'"), D_f12_apbp(
"a',b'"))
5313 + dot(v_yz_apb(
"a',b"), D_f12_apb(
"a',b")) * 2.0;
5315 const double v_xx_f12or = dot(v_xx_am(
"a,m"), Dbn_f12(
"a,m"));
5316 const double v_yy_f12or = dot(v_yy_am(
"a,m"), Dbn_f12(
"a,m"));
5317 const double v_zz_f12or = dot(v_zz_am(
"a,m"), Dbn_f12(
"a,m"));
5318 const double v_xy_f12or = dot(v_xy_am(
"a,m"), Dbn_f12(
"a,m"));
5319 const double v_xz_f12or = dot(v_xz_am(
"a,m"), Dbn_f12(
"a,m"));
5320 const double v_yz_f12or = dot(v_yz_am(
"a,m"), Dbn_f12(
"a,m"));
5322 std::cout << indent <<
"electric gradient (F12)" << std::endl
5323 << indent <<
"v_xx (F12) = " <<
scprintf(
"%12.10f", v_xx_f12 * 2.0)
5324 << indent <<
" v_yy (F12) = " <<
scprintf(
"%12.10f", v_yy_f12 * 2.0)
5325 << indent <<
" v_zz (F12) = " <<
scprintf(
"%12.10f", v_zz_f12 * 2.0)
5327 << indent <<
"v_xy (F12) = " <<
scprintf(
"%12.10f", v_xy_f12 * 2.0)
5328 << indent <<
" v_xz (F12) = " <<
scprintf(
"%12.10f", v_xz_f12 * 2.0)
5329 << indent <<
" v_yz (F12) = " <<
scprintf(
"%12.10f", v_yz_f12 * 2.0)
5331 std::cout << indent <<
"electric gradient (F12 orbital response)" << std::endl
5332 << indent <<
"v_xx (F12 or) = " <<
scprintf(
"%12.10f", v_xx_f12or * 2.0)
5333 << indent <<
" v_yy (F12 or) = " <<
scprintf(
"%12.10f", v_yy_f12or * 2.0)
5334 << indent <<
" v_zz (F12 or) = " <<
scprintf(
"%12.10f", v_zz_f12or * 2.0)
5336 << indent <<
"v_xy (F12 or) = " <<
scprintf(
"%12.10f", v_xy_f12or * 2.0)
5337 << indent <<
" v_xz (F12 or) = " <<
scprintf(
"%12.10f", v_xz_f12or * 2.0)
5338 << indent <<
" v_yz (F12 or) = " <<
scprintf(
"%12.10f", v_yz_f12or * 2.0)
5339 << std::endl << std::endl;
5344 ExEnv::out0() << std::endl << indent <<
"Start CCSD computation" << std::endl;
5345 double mu_z_ccsd = 0.0, mu_z_ccsdor = 0.0;
5346 double q_xx_ccsd = 0.0, q_yy_ccsd = 0.0, q_zz_ccsd = 0.0;
5347 double q_xx_ccsdor = 0.0, q_yy_ccsdor = 0.0, q_zz_ccsdor = 0.0;
5350 TArray2 Qxx_ai, Qyy_ai, Qzz_ai, Qxy_ai, Qxz_ai, Qyz_ai;
5356 ExEnv::out0() << std::endl << indent <<
"Compute CC2 T amplitudes " << std::endl;
5357 compute_T_cc2(T1_cc2,T2_cc2);
5359 ExEnv::out0() << std::endl << indent <<
"Compute CC2 lambda amplitudes " << std::endl;
5360 compute_lambda_cc2(T1_cc2, T2_cc2, L1_cc2, L2_cc2);
5363 TArray2 Dij_cc2, Dab_cc2, Dia_cc2, Dai_cc2;
5364 ExEnv::out0() << indent <<
"Compute CC2 density from amplitudes" << std::endl;
5365 compute_cc2_1rdm_amp(T1_cc2, T2_cc2, L1_cc2, L2_cc2,
5366 Dij_cc2, Dab_cc2, Dia_cc2, Dai_cc2);
5373 ExEnv::out0() << indent <<
"Using Gauss's formula" << std::endl;
5374 compute_lambda_cc2_2(T1_cc2, T2_cc2, L1_cc2_2, L2_cc2_2);
5377 ExEnv::out0() << indent <<
"Compute CCSD T amplitudes " << std::endl;
5380 compute_T_ccsd(T1, T2,
"CCSD");
5382 ExEnv::out0() << std::endl << indent <<
"Compute CCSD L amplitudes " << std::endl;
5385 compute_lambda_ccsd(T1, T2, L1, L2,
"CCSD");
5387 #if INCLUDE_CCSD_CONTRI
5390 TArray2 Dij_ccsd, Dab_ccsd, Dia_ccsd, Dai_ccsd;
5392 <<
"Compute CCSD density from amplitudes" << std::endl;
5393 compute_ccsd_1rdm_amp(T1, T2, L1, L2,
5394 Dij_ccsd, Dab_ccsd, Dia_ccsd, Dai_ccsd);
5396 ExEnv::out0() << std::endl << indent <<
"Compute CCSD Xam and Xai" << std::endl;
5397 TArray2 Xam_ccsd_nfzc, Xiip_ccsd;
5398 compute_Xam_ccsd(T1, T2, L1, L2, Xam_ccsd_nfzc, Xiip_ccsd);
5400 TArray2 Diip_or_ccsd, Xam_ccsd;
5401 if (nocc != naocc) {
5403 <<
"Include frozen-core CCSD contributions" << std::endl;
5404 Diip_or_ccsd(
"i,i'") = Xiip_ccsd(
"i,i'") * Delta_ijp_F(
"i,i'");
5407 Xam_Diip_ccsd(
"a,m") = A_ijpam(
"i,i',a,m") * Diip_or_ccsd(
"i,i'");
5408 Xam_ccsd(
"a,m") = Xam_ccsd_nfzc(
"a,m") - Xam_Diip_ccsd(
"a,m");
5415 Xam_ccsd(
"a,m") = Xam_ccsd_nfzc(
"a,m");
5419 TArray2 Dbn_ccsd(Xam_ccsd.world(), Xam_ccsd.trange());
5420 auto resnorm_ccsd = cg_solver2(Orbital_relaxation_Abnam,
5426 if (compute_dipole) {
5427 mu_z_ai = xy(
"<a|mu_z|i>");
5428 mu_z_ccsd = dot(mu_z_ij(
"i,j"), Dij_ccsd(
"i,j"))
5429 + dot(mu_z_ab(
"a,b"), Dab_ccsd(
"a,b"))
5430 + dot(mu_z_ai(
"a,i"), Dai_ccsd(
"a,i"))
5431 + dot(mu_z_ai(
"a,i"), Dia_ccsd(
"i,a"))
5434 mu_z_ccsdor = dot(mu_z_am(
"a,m"), Dbn_ccsd(
"a,m"));
5435 if (nocc != naocc) {
5436 mu_z_ccsdor += dot(mu_z_ijp(
"i,i'"), Diip_or_ccsd(
"i,i'"));
5446 if (compute_quadrupole) {
5447 TArray2 q_xx_ai = xy(
"<a|q_xx|i>");
5448 TArray2 q_yy_ai = xy(
"<a|q_yy|i>");
5449 TArray2 q_zz_ai = xy(
"<a|q_zz|i>");
5450 Qxx_ai(
"a,i") = q_xx_ai(
"a,i") - (q_zz_ai(
"a,i") + q_yy_ai(
"a,i")) * 0.5;
5451 Qyy_ai(
"a,i") = q_yy_ai(
"a,i") - (q_zz_ai(
"a,i") + q_xx_ai(
"a,i")) * 0.5;
5452 Qzz_ai(
"a,i") = q_zz_ai(
"a,i") - (q_xx_ai(
"a,i") + q_yy_ai(
"a,i")) * 0.5;
5454 q_xx_ccsd = dot(Qxx_ij(
"i,j"), Dij_ccsd(
"i,j"))
5455 + dot(Qxx_ab(
"a,b"), Dab_ccsd(
"a,b"))
5456 + dot(Qxx_ai(
"a,i"), Dai_ccsd(
"a,i"))
5457 + dot(Qxx_ai(
"a,i"), Dia_ccsd(
"i,a"))
5459 q_yy_ccsd = dot(Qyy_ij(
"i,j"), Dij_ccsd(
"i,j"))
5460 + dot(Qyy_ab(
"a,b"), Dab_ccsd(
"a,b"))
5461 + dot(Qyy_ai(
"a,i"), Dai_ccsd(
"a,i"))
5462 + dot(Qyy_ai(
"a,i"), Dia_ccsd(
"i,a"))
5464 q_zz_ccsd = dot(Qzz_ij(
"i,j"), Dij_ccsd(
"i,j"))
5465 + dot(Qzz_ab(
"a,b"), Dab_ccsd(
"a,b"))
5466 + dot(Qzz_ai(
"a,i"), Dai_ccsd(
"a,i"))
5467 + dot(Qzz_ai(
"a,i"), Dia_ccsd(
"i,a"))
5470 q_xx_ccsdor = dot(Qxx_am(
"a,m"), Dbn_ccsd(
"a,m"));
5471 q_yy_ccsdor = dot(Qyy_am(
"a,m"), Dbn_ccsd(
"a,m"));
5472 q_zz_ccsdor = dot(Qzz_am(
"a,m"), Dbn_ccsd(
"a,m"));
5474 if (nocc != naocc) {
5475 q_xx_ccsdor += dot(Qxx_ijp(
"i,j'"), Diip_or_ccsd(
"i,j'"));
5476 q_yy_ccsdor += dot(Qyy_ijp(
"i,j'"), Diip_or_ccsd(
"i,j'"));
5477 q_zz_ccsdor += dot(Qzz_ijp(
"i,j'"), Diip_or_ccsd(
"i,j'"));
5484 double mu_z_Cccsdf12 = 0.0, mu_z_Cccsdf12or = 0.0;
5485 double q_xx_Cccsdf12 = 0.0, q_yy_Cccsdf12 = 0.0, q_zz_Cccsdf12 = 0.0;
5486 double q_xx_Cccsdf12or = 0.0, q_yy_Cccsdf12or = 0.0, q_zz_Cccsdf12or = 0.0;
5487 #if INCLUDE_CCSDF12C_CONTRI
5490 ExEnv::out0() << std::endl << indent <<
"Compute CCSD(2)_F12 L amplitudes " << std::endl;
5493 compute_lambda_ccsd(T1, T2, L1_f12, L2_f12,
"F12");
5496 TArray2 Dij_ccsd_f12, Dab_ccsd_f12, Dia_ccsd_f12, Dai_ccsd_f12;
5498 <<
"Compute CCSD density from amplitudes in CCSD(2)_F12" << std::endl;
5499 compute_ccsd_1rdm_amp(T1, T2, L1_f12, L2_f12,
5500 Dij_ccsd_f12, Dab_ccsd_f12, Dia_ccsd_f12, Dai_ccsd_f12);
5503 <<
"Compute CCSD Xam and Xai in CCSD(2)_F12" << std::endl;
5504 TArray2 Xam_ccsd_f12_nfzc, Xiip_ccsd_f12;
5505 compute_Xam_ccsd(T1, T2, L1_f12, L2_f12, Xam_ccsd_f12_nfzc, Xiip_ccsd_f12);
5508 TArray2 Diip_ccsd_f12, Xam_ccsd_f12;
5509 if (nocc != naocc) {
5510 Diip_ccsd_f12(
"i,i'") = Xiip_ccsd_f12(
"i,i'") * Delta_ijp_F(
"i,i'");
5511 Xam_ccsd_f12(
"a,m") = Xam_ccsd_f12_nfzc(
"a,m") - A_ijpam(
"i,i',a,m") * Diip_ccsd_f12(
"i,i'");
5513 Xam_ccsd_f12(
"a,m") = Xam_ccsd_f12_nfzc(
"a,m");
5516 TArray2 Dbn_ccsd_f12(Xam_ccsd_f12.world(), Xam_ccsd_f12.trange());
5517 auto resnorm_ccsd_f12 = cg_solver2(Orbital_relaxation_Abnam,
5524 <<
"Compute CCSD F12 coupling contributions" << std::endl;
5528 RT2_aPb(
"a',b") = _4(
"<a' c|r|k l>")
5529 * (R_C1 * T2(
"b,c,k,l") + R_C2 * T2(
"c,b,k,l"));
5531 TArray2 Xam_CT2_cc = Xam_CT2_ccsd(C_0, C_1, T2, RT2_aPb);
5533 TArray2 Xam_VT_cc = Xam_VT_ccsd(C_0, C_1, T1, T2);
5535 Xam_CVT_cc_nfzc(
"a,m") = Xam_CT2_cc(
"a,m") + Xam_VT_cc(
"a,m");
5538 TArray2 Diip_CVT_cc, Xam_CVT_cc;
5539 if (nocc != naocc) {
5541 <<
"Include frozen-core contributions for CCSD F12 coupling" << std::endl;
5542 TArray2 Xiip_couling = Xiip_CVT(C_0, C_1, T1, T2);
5543 Diip_CVT_cc(
"i,i'") = - Xiip_couling(
"i,i'") * Delta_ijp_F(
"i,i'");
5546 Xam_Diip_CVT(
"a,m") = - A_ijpam(
"i,j',a,m") * Diip_CVT_cc(
"i,j'");
5548 Xam_CVT_cc(
"a,m") = Xam_CVT_cc_nfzc(
"a,m") + Xam_Diip_CVT(
"a,m");
5550 Xam_CVT_cc(
"a,m") = Xam_CVT_cc_nfzc(
"a,m");
5553 TArray2 Dbn_CVT_cc(Xam_CVT_cc.world(), Xam_CVT_cc.trange());
5554 auto resnorm_CVT_cc = cg_solver2(Orbital_relaxation_Abnam,
5560 if (compute_dipole) {
5561 double mu_z_ccsd_f12 = dot(mu_z_ij(
"i,j"), Dij_ccsd_f12(
"i,j"))
5562 + dot(mu_z_ab(
"a,b"), Dab_ccsd_f12(
"a,b"))
5563 + dot(mu_z_ai(
"a,i"), Dai_ccsd_f12(
"a,i"))
5564 + dot(mu_z_ai(
"a,i"), Dia_ccsd_f12(
"i,a"))
5566 + dot(mu_z_apb(
"a',b"), RT2_aPb(
"a',b")) * 2.0
5569 double mu_z_ccsdor_f12 = dot(mu_z_am(
"a,m"), Dbn_ccsd_f12(
"a,m"))
5570 + dot(mu_z_am(
"a,m"), Dbn_CVT_cc(
"a,m"));
5572 if (nocc != naocc) {
5573 mu_z_ccsdor_f12 += dot(mu_z_ijp(
"i,j'"), Diip_ccsd_f12(
"i,j'"))
5574 + dot(mu_z_ijp(
"i,j'"), Diip_CVT_cc(
"i,j'"));
5577 mu_z_Cccsdf12 = mu_z_ccsd_f12 - mu_z_ccsd;
5578 mu_z_Cccsdf12or = mu_z_ccsdor_f12 - mu_z_ccsdor;
5581 if (compute_quadrupole) {
5582 double q_xx_ccsd_f12 = dot(Qxx_ij(
"i,j"), Dij_ccsd_f12(
"i,j"))
5583 + dot(Qxx_ab(
"a,b"), Dab_ccsd_f12(
"a,b"))
5584 + dot(Qxx_ai(
"a,i"), Dai_ccsd_f12(
"a,i"))
5585 + dot(Qxx_ai(
"a,i"), Dia_ccsd_f12(
"i,a"))
5586 + dot(Qxx_apb(
"a',b"), RT2_aPb(
"a',b")) * 2.0
5588 double q_yy_ccsd_f12 = dot(Qyy_ij(
"i,j"), Dij_ccsd_f12(
"i,j"))
5589 + dot(Qyy_ab(
"a,b"), Dab_ccsd_f12(
"a,b"))
5590 + dot(Qyy_ai(
"a,i"), Dai_ccsd_f12(
"a,i"))
5591 + dot(Qyy_ai(
"a,i"), Dia_ccsd_f12(
"i,a"))
5592 + dot(Qyy_apb(
"a',b"), RT2_aPb(
"a',b")) * 2.0
5594 double q_zz_ccsd_f12 = dot(Qzz_ij(
"i,j"), Dij_ccsd_f12(
"i,j"))
5595 + dot(Qzz_ab(
"a,b"), Dab_ccsd_f12(
"a,b"))
5596 + dot(Qzz_ai(
"a,i"), Dai_ccsd_f12(
"a,i"))
5597 + dot(Qzz_ai(
"a,i"), Dia_ccsd_f12(
"i,a"))
5598 + dot(Qzz_apb(
"a',b"), RT2_aPb(
"a',b")) * 2.0
5601 double q_xx_ccsdor_f12 = dot(Qxx_am(
"a,m"), Dbn_ccsd_f12(
"a,m"))
5602 + dot(Qxx_am(
"a,m"), Dbn_CVT_cc(
"a,m"));
5603 double q_yy_ccsdor_f12 = dot(Qyy_am(
"a,m"), Dbn_ccsd_f12(
"a,m"))
5604 + dot(Qyy_am(
"a,m"), Dbn_CVT_cc(
"a,m"));
5605 double q_zz_ccsdor_f12 = dot(Qzz_am(
"a,m"), Dbn_ccsd_f12(
"a,m"))
5606 + dot(Qzz_am(
"a,m"), Dbn_CVT_cc(
"a,m"));
5608 if (nocc != naocc) {
5609 q_xx_ccsdor_f12 += dot(Qxx_ijp(
"i,j'"), Diip_ccsd_f12(
"i,j'"))
5610 + dot(Qxx_ijp(
"i,j'"), Diip_CVT_cc(
"i,j'"));
5611 q_yy_ccsdor_f12 += dot(Qyy_ijp(
"i,j'"), Diip_ccsd_f12(
"i,j'"))
5612 + dot(Qyy_ijp(
"i,j'"), Diip_CVT_cc(
"i,j'"));
5613 q_zz_ccsdor_f12 += dot(Qzz_ijp(
"i,j'"), Diip_ccsd_f12(
"i,j'"))
5614 + dot(Qzz_ijp(
"i,j'"), Diip_CVT_cc(
"i,j'"));
5617 q_xx_Cccsdf12 = q_xx_ccsd_f12 - q_xx_ccsd;
5618 q_yy_Cccsdf12 = q_yy_ccsd_f12 - q_yy_ccsd;
5619 q_zz_Cccsdf12 = q_zz_ccsd_f12 - q_zz_ccsd;
5620 q_xx_Cccsdf12or = q_xx_ccsdor_f12 - q_xx_ccsdor;
5621 q_yy_Cccsdf12or = q_yy_ccsdor_f12 - q_yy_ccsdor;
5622 q_zz_Cccsdf12or = q_zz_ccsdor_f12 - q_zz_ccsdor;
5629 if (compute_dipole) {
5630 std::cout << std::endl << indent <<
"Dipole moment "
5631 << std::endl << indent
5632 <<
"mu_z (HF=SCF+N) = " <<
scprintf(
"%15.12f", mu_z_n - mu_z_scf * 2.0)
5634 << std::endl << std::endl << indent
5635 <<
"mu_z (E2) = " <<
scprintf(
"%15.12f", - mu_z_e2 * 2.0)
5636 << std::endl << indent
5637 <<
"mu_z (E2 orbital response) = " <<
scprintf(
"%15.12f", - mu_z_e2or * 2.0)
5638 << std::endl << std::endl << indent
5639 <<
"mu_z (MP2) = " <<
scprintf(
"%15.12f", - mu_z_mp2 * 2.0)
5640 << std::endl << indent
5641 <<
"mu_z (MP2 orbital response) = "<<
scprintf(
"%15.12f", - mu_z_mp2or * 2.0)
5642 << std::endl << std::endl << indent
5643 <<
"mu_z (MP2F12 coupling) = " <<
scprintf(
"%15.12f", - mu_z_mp2f12C * 2.0)
5644 << std::endl << indent
5645 <<
"mu_z (MP2-F12 coupling orbital response) = " <<
scprintf(
"%15.12f", - mu_z_mp2f12Cor * 4.0)
5646 << std::endl << std::endl << indent
5647 <<
"mu_z (F12) = " <<
scprintf(
"%15.12f",- mu_z_f12 * 2.0)
5648 << std::endl << indent
5649 <<
"mu_z (F12 orbital response) = " <<
scprintf(
"%15.12f", - mu_z_f12or * 2.0)
5650 << std::endl << std::endl << indent
5651 <<
"mu_z (CCSD) = " <<
scprintf(
"%15.12f", - mu_z_ccsd * 2.0)
5652 << std::endl << indent
5653 <<
"mu_z (CCSD orbital response) = " <<
scprintf(
"%15.12f", - mu_z_ccsdor * 2.0)
5654 << std::endl << std::endl << indent
5655 <<
"mu_z (CCSDF12 coupling) = " <<
scprintf(
"%15.12f", - mu_z_Cccsdf12 * 2.0)
5656 << std::endl << indent
5657 <<
"mu_z (CCSDF12 coupling orbital response) = " <<
scprintf(
"%15.12f", - mu_z_Cccsdf12or * 2.0)
5661 if (compute_quadrupole) {
5662 std::cout << std::endl << indent
5663 <<
"Traceless quadrupole moment"
5664 << std::endl << indent
5665 <<
"q_xx (HF) = " <<
scprintf(
"%12.10f", q_xx_n - q_xx_scf * 2.0)
5666 <<
" q_yy (HF) = " <<
scprintf(
"%12.10f", q_yy_n - q_yy_scf * 2.0)
5667 <<
" q_zz (HF) = " <<
scprintf(
"%12.10f", q_zz_n - q_zz_scf * 2.0)
5668 << std::endl << indent
5669 <<
"q_xy (HF) = " <<
scprintf(
"%12.10f", q_xy_n - q_xy_scf * 2.0)
5670 <<
" q_xz (HF) = " <<
scprintf(
"%12.10f", q_xz_n - q_xz_scf * 2.0)
5671 <<
" q_yz (HF) = " <<
scprintf(
"%12.10f", q_yz_n - q_yz_scf * 2.0)
5674 std::cout << std::endl << indent
5675 <<
"q_xx (E2) = " <<
scprintf(
"%12.10f", - q_xx_e2 * 2.0)
5676 <<
" q_yy (E2) = " <<
scprintf(
"%12.10f", - q_yy_e2 * 2.0)
5677 <<
" q_zz (E2) = " <<
scprintf(
"%12.10f", - q_zz_e2 * 2.0)
5678 << std::endl << indent
5679 <<
"q_xx (E2 or) = " <<
scprintf(
"%12.10f", - q_xx_e2or * 2.0)
5680 <<
" q_yy (E2 or) = " <<
scprintf(
"%12.10f", - q_yy_e2or * 2.0)
5681 <<
" q_zz (E2 or) = " <<
scprintf(
"%12.10f", - q_zz_e2or * 2.0)
5684 std::cout << std::endl << indent
5685 <<
"q_xx (MP2) = " <<
scprintf(
"%12.10f", - q_xx_mp2 * 2.0)
5686 <<
" q_yy (MP2) = " <<
scprintf(
"%12.10f", - q_yy_mp2 * 2.0)
5687 <<
" q_zz (MP2) = " <<
scprintf(
"%12.10f", - q_zz_mp2 * 2.0)
5688 << std::endl << indent
5689 <<
"q_xx (MP2 or) = " <<
scprintf(
"%12.10f", - q_xx_mp2or * 2.0)
5690 <<
" q_yy (MP2 or) = " <<
scprintf(
"%12.10f", - q_yy_mp2or * 2.0)
5691 <<
" q_zz (MP2 or) = " <<
scprintf(
"%12.10f", - q_zz_mp2or * 2.0)
5694 std::cout << std::endl << indent
5695 <<
"q_xx (MP2F12 C) = " <<
scprintf(
"%12.10f", - q_xx_mp2f12C * 2.0)
5696 <<
" q_yy (MP2F12 C) = " <<
scprintf(
"%12.10f", - q_yy_mp2f12C * 2.0)
5697 <<
" q_zz (MP2F12 C) = " <<
scprintf(
"%12.10f", - q_zz_mp2f12C * 2.0)
5698 << std::endl << indent
5699 <<
"q_xx (MP2F12 C or) = " <<
scprintf(
"%12.10f", - q_xx_mp2f12Cor * 2.0)
5700 <<
" q_yy (MP2F12 C or) = " <<
scprintf(
"%12.10f", - q_yy_mp2f12Cor * 2.0)
5701 <<
" q_zz (MP2F12 C or) = " <<
scprintf(
"%12.10f", - q_zz_mp2f12Cor * 2.0)
5704 std::cout << std::endl << indent
5705 <<
"q_xx (F12) = " <<
scprintf(
"%12.10f", - q_xx_f12 * 2.0)
5706 <<
" q_yy (F12) = " <<
scprintf(
"%12.10f", - q_yy_f12 * 2.0)
5707 <<
" q_zz (F12) = " <<
scprintf(
"%12.10f", - q_zz_f12 * 2.0)
5708 << std::endl << indent
5709 <<
"q_xx (F12 or) = " <<
scprintf(
"%12.10f", - q_xx_f12or * 2.0)
5710 <<
" q_yy (F12 or) = " <<
scprintf(
"%12.10f", - q_yy_f12or * 2.0)
5711 <<
" q_zz (F12 or) = " <<
scprintf(
"%12.10f", - q_zz_f12or * 2.0)
5714 std::cout << std::endl << indent
5715 <<
"q_xx (CCSD) = " <<
scprintf(
"%12.10f", - q_xx_ccsd * 2.0)
5716 <<
" q_yy (CCSD) = " <<
scprintf(
"%12.10f", - q_yy_ccsd * 2.0)
5717 <<
" q_zz (CCSD) = " <<
scprintf(
"%12.10f", - q_zz_ccsd * 2.0)
5718 << std::endl << indent
5719 <<
"q_xx (CCSD or) = " <<
scprintf(
"%12.10f", - q_xx_ccsdor * 2.0)
5720 <<
" q_yy (CCSD or) = " <<
scprintf(
"%12.10f", - q_yy_ccsdor * 2.0)
5721 <<
" q_zz (CCSD or) = " <<
scprintf(
"%12.10f", - q_zz_ccsdor * 2.0)
5724 std::cout << std::endl << indent
5725 <<
"q_xx (CCSDF12 C) = " <<
scprintf(
"%12.10f", - q_xx_Cccsdf12 * 2.0)
5726 <<
" q_yy (CCSDF12 C) = " <<
scprintf(
"%12.10f", - q_yy_Cccsdf12 * 2.0)
5727 <<
" q_zz (CCSDF12 C) = " <<
scprintf(
"%12.10f", - q_zz_Cccsdf12 * 2.0)
5728 << std::endl << indent
5729 <<
"q_xx (CCSDF12 C or) = " <<
scprintf(
"%12.10f", - q_xx_Cccsdf12or * 2.0)
5730 <<
" q_yy (CCSDF12 C or) = " <<
scprintf(
"%12.10f", - q_yy_Cccsdf12or * 2.0)
5731 <<
" q_zz (CCSDF12 C or) = " <<
scprintf(
"%12.10f", - q_zz_Cccsdf12or * 2.0)
5732 << std::endl << std::endl;
5738 template <
typename T>
5741 const TArray4& T2,
const TArray2& RT2_aPb,
5742 const TArray4& L2,
const TArray2& RL2_aPb) {
5743 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
5744 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
5746 TArray4d g_abmaP = ijxy(
"<a b|g|m a'>");
5747 TArray2 Xam_CT2, Xai_CT2;
5750 ( R_C1 * T2(
"a,b,k,l") + R_C2 * T2(
"b,a,k,l")
5751 + R_C1 * L2(
"a,b,k,l") + R_C2 * L2(
"b,a,k,l")
5752 ) * (_4(
"<k l|r|m_F(a') b>") + _4(
"<k l|r|m b_F(a')>"))
5756 - ( 2.0 * _4(
"<a a'|g|m b>") - _4(
"<a a'|g|b m>")
5757 + 2.0 * g_abmaP(
"a,b,m,a'") - g_abmaP(
"b,a,m,a'")
5758 ) * (RT2_aPb(
"a',b") + RL2_aPb(
"a',b")
5762 - _4(
"<a l|r|b_F(a') c>")
5763 * ( R_C1 * T2(
"b,c,i,l") + R_C2 * T2(
"b,c,l,i")
5764 + R_C1 * L2(
"b,c,i,l") + R_C2 * L2(
"b,c,l,i")
5766 - _4(
"<a l|r|c b_F(a')>")
5767 * ( R_C1 * T2(
"c,b,i,l") + R_C2 * T2(
"c,b,l,i")
5768 + R_C1 * L2(
"c,b,i,l") + R_C2 * L2(
"c,b,l,i")
5772 return XaiAddToXam(Xam_CT2, Xai_CT2);
5777 template <
typename T>
5779 SingleReference_R12Intermediates<T>::Xam_VTL_f12b(
const double C_0,
const double C_1,
5780 const TArray2& T1,
const TArray4& T2,
5781 const TArray2& L1,
const TArray4& L2) {
5783 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
5784 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
5786 const char* i =
"i";
5787 const char* j =
"j";
5788 const char* k =
"k";
5789 const char* l =
"l";
5790 const char* m =
"m";
5792 const char* a =
"a";
5793 const char* c =
"c";
5794 const char* d =
"d";
5796 TArray4 V_alic = VPq_Rs(a,l,i,c, C_0, C_1);
5797 TArray4 V_ilac = VPq_Rs(i,l,a,c,C_0, C_1);
5798 TArray2 V_ac = VRk_Sk(a,c,C_0, C_1);
5799 TArray2 V_jm = VRk_Sk(j,m,C_0, C_1);
5800 TArray4d r_klmaP = ijxy(
"<k l|r|m a'>");
5801 TArray4d r_abPkl = ijxy(
"<a b'|r|k l>");
5802 TArray2 Xam_VT1L1, Xai_VT1L1;
5804 (T1(
"a,j") + L1(
"a,j")) * V_jm(
"j,m")
5808 * (R_C1 * r_klmaP(
"k,l,m,b'") + R_C2 * r_klmaP(
"l,k,m,b'"))
5809 + _4(
"<a b'|g|c k>")
5810 * (R_C1 * r_klmaP(
"l,k,m,b'") + R_C2 * r_klmaP(
"k,l,m,b'"))
5812 + (R_C1 * r_abPkl(
"a,b',k,l") + R_C2 * r_abPkl(
"a,b',l,k"))
5813 * _4(
"<k c|g|m b'>")
5814 + (R_C1 * r_abPkl(
"a,b',l,k") + R_C2 * r_abPkl(
"a,b',k,l"))
5815 * _4(
"<c k|g|m b'>")
5816 ) * (T1(
"c,l") + L1(
"c,l"))
5820 - (V_alic(
"a,l,i,c") + V_ilac(
"i,l,a,c"))
5821 * (T1(
"c,l") + L1(
"c,l"))
5824 - V_ac(
"a,c") * (T1(
"c,i") + L1(
"c,i"))
5826 TArray2 Xam_VT1L1_tot = XaiAddToXam(Xam_VT1L1, Xai_VT1L1);
5828 TArray4 V_alcd = VPq_Rs(a,l,c,d,C_0, C_1);
5829 TArray4 V_klmd = VPq_Rs(k,l,m,d,C_0, C_1);
5830 TArray2 Xam_VT2L2, Xai_VT2L2;
5832 (T2(
"a,d,k,l") + L2(
"a,d,k,l")) * V_klmd(
"k,l,m,d")
5835 (R_C1 * r_abPkl(
"a,b',k,l") + R_C2 * r_abPkl(
"a,b',l,k"))
5836 * _4(
"<c d|g|m b'>")
5838 + _4(
"<a b'|g|c d>")
5839 * (R_C1 * r_klmaP(
"k,l,m,b'") + R_C2 * r_klmaP(
"l,k,m,b'"))
5840 ) * (T2(
"c,d,k,l") + L2(
"c,d,k,l"))
5843 - V_alcd(
"a,l,c,d") * (T2(
"c,d,i,l") + L2(
"c,d,i,l"))
5845 TArray2 Xam_VT2L2_tot = XaiAddToXam(Xam_VT2L2, Xai_VT2L2);
5847 TArray2 Xam_VTL_tot;
5848 Xam_VTL_tot(
"a,m") = Xam_VT1L1_tot(
"a,m") + Xam_VT2L2_tot(
"a,m");
5856 template <
typename T>
5858 SingleReference_R12Intermediates<T>::Xam_VT1T1_f12b(
const double C_0,
const double C_1,
5859 const TArray2& T1) {
5860 const char* k =
"k";
5861 const char* l =
"l";
5862 const char* m =
"m";
5864 const char* a =
"a";
5865 const char* c =
"c";
5866 const char* d =
"d";
5868 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
5869 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
5871 TArray4 Vklmd = VPq_Rs(k, l, m, d, C_0, C_1);
5872 TArray4 Valcd = VPq_Rs(a, l, c, d, C_0, C_1);
5877 TArray4d rmbp_kl = ijxy(
"<m b'|r|k l>");
5878 TArray4d rabp_kl = ijxy(
"<a b'|r|k l>");
5884 * T1(
"a,k") * T1(
"d,l")
5888 + ( (R_C1 * rmbp_kl(
"m,b',k,l") + R_C2 * rmbp_kl(
"m,b',l,k"))
5889 * _4(
"<a b'|g|c d>")
5890 + (R_C1 * rabp_kl(
"a,b',k,l") + R_C2 * rabp_kl(
"a,b',l,k"))
5891 * _4(
"<m b'|g|c d>")
5892 ) * T1(
"c,k") * T1(
"d,l")
5896 - Valcd(
"a,l,c,d") * T1(
"c,i") * T1(
"d,l")
5899 return XaiAddToXam(Xam_VT1T1, Xai_VT1T1);
5902 template <
typename T>
5904 SingleReference_R12Intermediates<T>::Xam_VT1T1_f12b_test(
const double C_0,
const double C_1,
5905 const TArray4& tauT1_ab) {
5907 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
5908 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
5910 const char* k =
"k";
5911 const char* l =
"l";
5912 const char* m =
"m";
5914 const char* a =
"a";
5915 const char* c =
"c";
5916 const char* d =
"d";
5918 TArray4d r_klmaP = ijxy(
"<k l|r|m a'>");
5919 TArray4d r_abPkl = ijxy(
"<a b'|r|k l>");
5922 TArray4 V_alcd = VPq_Rs(a,l,c,d,C_0, C_1);
5923 TArray4 V_klmd = VPq_Rs(k,l,m,d,C_0, C_1);
5926 tauT1_ab(
"a,d,k,l") * V_klmd(
"k,l,m,d")
5929 (R_C1 * r_abPkl(
"a,b',k,l") + R_C2 * r_abPkl(
"a,b',l,k"))
5930 * _4(
"<c d|g|m b'>")
5932 + _4(
"<a b'|g|c d>")
5933 * (R_C1 * r_klmaP(
"k,l,m,b'") + R_C2 * r_klmaP(
"l,k,m,b'"))
5934 ) * tauT1_ab(
"c,d,k,l")
5937 - V_alcd(
"a,l,c,d") * tauT1_ab(
"c,d,i,l")
5940 return XaiAddToXam(Xam, Xai);
5947 template <
typename T>
5949 SingleReference_R12Intermediates<T>::Xam_VL2T1_f12b(
const double C_0,
const double C_1,
5950 const TArray2& T1,
const TArray4& L2) {
5952 const char* k =
"k";
5953 const char* l =
"l";
5954 const char* j =
"j";
5955 const char* m =
"m";
5956 const char* a =
"a";
5957 const char* c =
"c";
5959 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
5960 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
5962 TArray4d rmbp_kl = ijxy(
"<m b'|r|k l>");
5963 TArray4d rabp_kl = ijxy(
"<a b'|r|k l>");
5965 TArray4 V_ALCJ = VPQ_RS(a, l, c, j);
5966 TArray4 V_LACJ = VPQ_RS(l, a, c, j);
5967 TArray4 V_KLCA = VPQ_RS(k, l, c, a);
5968 TArray4 V_KLMJ = VPQ_RS(k, l, m, j);
5972 - (R_C1 * V_KLMJ(
"k,l,m,j") + R_C2 * V_KLMJ(
"l,k,m,j"))
5973 * L2(
"a,d,k,l") * T1(
"d,j")
5977 - ( (R_C1 * rmbp_kl(
"m,b',k,l") + R_C2 * rmbp_kl(
"m,b',l,k"))
5978 * _4(
"<a b'|g|c j>")
5979 + (R_C1 * rmbp_kl(
"m,b',l,k") + R_C2 * rmbp_kl(
"m,b',k,l"))
5980 * _4(
"<a b'|g|j c>")
5982 + (R_C1 * rabp_kl(
"a,b',k,l") + R_C2 * rabp_kl(
"a,b',l,k"))
5983 * _4(
"<m b'|g|c j>")
5984 + (R_C1 * rabp_kl(
"a,b',l,k") + R_C2 * rabp_kl(
"a,b',k,l"))
5985 * _4(
"<m b'|g|j c>")
5986 ) * L2(
"c,d,k,l") * T1(
"d,j")
5990 ( R_C1 * ( V_ALCJ(
"a,l,c,j") * L2(
"c,d,i,l")
5991 + V_LACJ(
"l,a,c,j") * L2(
"c,d,l,i"))
5992 + R_C2 * ( V_ALCJ(
"a,l,c,j") * L2(
"c,d,l,i")
5993 + V_LACJ(
"l,a,c,j") * L2(
"c,d,i,l"))
5997 + (R_C1 * V_KLCA(
"k,l,c,a") + R_C2 * V_KLCA(
"l,k,c,a"))
5998 * L2(
"c,d,k,l") * T1(
"d,i")
6001 return XaiAddToXam(Xam_VL2T1, Xai_VL2T1);
6005 template <
typename T>
6007 SingleReference_R12Intermediates<T>::Xam_VL2T1_f12b_test(
const double C_0,
const double C_1,
6008 const TArray2& T1,
const TArray4& L2) {
6010 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
6011 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
6013 const char* j =
"j";
6014 const char* k =
"k";
6015 const char* l =
"l";
6016 const char* m =
"m";
6018 const char* a =
"a";
6019 const char* c =
"c";
6021 TArray4d r_klmaP = ijxy(
"<k l|r|m a'>");
6022 TArray4d r_abPkl = ijxy(
"<a b'|r|k l>");
6024 TArray4 V_alcj = VPq_Rs(a,l,c,j,C_0, C_1);
6025 TArray4 V_lacj = VPq_Rs(l,a,c,j,C_0, C_1);
6026 TArray4 V_klca = VPq_Rs(k,l,c,a,C_0, C_1);
6027 TArray4 V_klmj = VPq_Rs(k,l,m,j,C_0, C_1);
6030 - L2(
"a,d,k,l") * V_klmj(
"k,l,m,j") * T1(
"d,j")
6033 (R_C1 * r_abPkl(
"a,b',k,l") + R_C2 * r_abPkl(
"a,b',l,k"))
6034 * _4(
"<c j|g|m b'>")
6035 + (R_C1 * r_abPkl(
"a,b',l,k") + R_C2 * r_abPkl(
"a,b',k,l"))
6036 * _4(
"<j c|g|m b'>")
6038 + _4(
"<a b'|g|c j>")
6039 * (R_C1 * r_klmaP(
"k,l,m,b'") + R_C2 * r_klmaP(
"l,k,m,b'"))
6040 + _4(
"<a b'|g|j c>")
6041 * (R_C1 * r_klmaP(
"l,k,m,b'") + R_C2 * r_klmaP(
"k,l,m,b'"))
6042 ) * L2(
"c,d,k,l") * T1(
"d,j")
6045 (V_alcj(
"a,l,c,j") * L2(
"c,d,i,l") + V_lacj(
"l,a,c,j") * L2(
"c,d,l,i"))
6048 + L2(
"c,d,k,l") * V_klca(
"k,l,c,a") * T1(
"d,i")
6051 return XaiAddToXam(Xam, Xai);
6056 template <
typename T>
6058 SingleReference_R12Intermediates<T>::Xam_VL2T1T1_f12b(
const double C_0,
const double C_1,
6059 const TArray2& T1,
const TArray4& L2) {
6061 const char* k =
"k";
6062 const char* l =
"l";
6063 const char* j =
"j";
6064 const char* a =
"a";
6066 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
6067 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
6069 TArray4d rmbp_kl = ijxy(
"<m b'|r|k l>");
6070 TArray4d rabp_kl = ijxy(
"<a b'|r|k l>");
6072 TArray4 V_AJKL = VPQ_RS(a, j, k, l);
6073 TArray4 V_KLAJ = VPQ_RS(k, l, a, j);
6077 TArray2 Xam_VL2T1T1;
6078 Xam_VL2T1T1(
"a,m") =
6080 ( (R_C1 * rmbp_kl(
"m,b',k,l") + R_C2 * rmbp_kl(
"m,b',l,k"))
6081 * _4(
"<a b'|g|i j>")
6083 + (R_C1 * rabp_kl(
"a,b',k,l") + R_C2 * rabp_kl(
"a,b',l,k"))
6084 * _4(
"<m b'|g|i j>")
6085 ) * L2(
"c,d,k,l") * T1(
"c,i") * T1(
"d,j")
6087 TArray2 Xai_VL2T1T1;
6088 Xai_VL2T1T1(
"a,i") =
6089 - (R_C1 * V_AJKL(
"a,j,k,l") + R_C2 * V_AJKL(
"a,j,l,k"))
6090 * L2(
"c,d,i,j") * T1(
"c,k") * T1(
"d,l")
6093 - (R_C1 * V_KLAJ(
"k,l,a,j") + R_C2 * V_KLAJ(
"l,k,a,j"))
6094 * L2(
"c,d,k,l") * T1(
"c,i") * T1(
"d,j")
6097 return XaiAddToXam(Xam_VL2T1T1, Xai_VL2T1T1);
6100 template <
typename T>
6102 SingleReference_R12Intermediates<T>::Xam_VL2T1T1_f12b_test(
const double C_0,
const double C_1,
6103 const TArray2& T1,
const TArray4& L2) {
6105 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
6106 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
6108 const char* j =
"j";
6109 const char* k =
"k";
6110 const char* l =
"l";
6111 const char* a =
"a";
6113 TArray4d r_klmaP = ijxy(
"<k l|r|m a'>");
6114 TArray4d r_abPkl = ijxy(
"<a b'|r|k l>");
6116 TArray4 V_ajkl = VPq_Rs(a,j,k,l,C_0, C_1);
6117 TArray4 V_klaj = VPq_Rs(k,l,a,j,C_0, C_1);
6120 (R_C1 * r_abPkl(
"a,b',k,l") + R_C2 * r_abPkl(
"a,b',l,k"))
6121 * _4(
"<i j|g|m b'>")
6123 + _4(
"<a b'|g|i j>")
6124 * (R_C1 * r_klmaP(
"k,l,m,b'") + R_C2 * r_klmaP(
"l,k,m,b'"))
6125 ) * L2(
"c,d,k,l") * T1(
"c,i") * T1(
"d,j")
6128 - L2(
"c,d,k,l") * V_klaj(
"k,l,a,j") * T1(
"c,i") * T1(
"d,j")
6130 - V_ajkl(
"a,j,k,l") * T1(
"c,k") * T1(
"d,l") * L2(
"c,d,i,j")
6133 return XaiAddToXam(Xam, Xai);
6137 template <
typename T>
6139 SingleReference_R12Intermediates<T>::Xiip_CVT_f12b(
const double C_0,
const double C_1,
6140 const TArray2& T1,
const TArray4& T2,
6141 const TArray2& L1,
const TArray4& L2){
6143 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
6144 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
6146 const char* ip =
"i'";
6147 const char* i =
"i";
6148 const char* l =
"l";
6149 const char* c =
"c";
6150 const char* d =
"d";
6154 _4(
"<i' l|r|b_F(a') c>")
6155 * ( R_C1 * T2(
"b,c,i,l") + R_C2 * T2(
"b,c,l,i")
6156 + R_C1 * L2(
"b,c,i,l") + R_C2 * L2(
"b,c,l,i"))
6157 + _4(
"<i' l|r|c b_F(a')>")
6158 * ( R_C1 * T2(
"c,b,i,l") + R_C2 * T2(
"c,b,l,i")
6159 + R_C1 * L2(
"c,b,i,l") + R_C2 * L2(
"c,b,l,i"))
6163 TArray4 V_ipl_cd = VPq_Rs(ip,l,c,d,C_0, C_1);
6164 Xiip_VT2L2(
"i,i'") =
6165 V_ipl_cd(
"i',l,c,d") * (T2(
"c,d,i,l") + L2(
"c,d,i,l"));
6168 TArray4 V_ipl_ic = VPq_Rs(ip,l,i,c, C_0, C_1);
6169 TArray4 V_il_ipc = VPq_Rs(i,l,ip,c,C_0, C_1);
6170 TArray2 V_ipc = VRk_Sk(ip,c,C_0, C_1);
6171 Xiip_VT1L1(
"i,i'") =
6173 (V_ipl_ic(
"i',l,i,c") + V_il_ipc(
"i,l,i',c"))
6174 * (T1(
"c,l") + L1(
"c,l"))
6177 + V_ipc(
"i',c") * (T1(
"c,i") + L1(
"c,i"))
6181 Xiip_C1(
"i,i'") = Xiip_CTL(
"i,i'") + Xiip_VT2L2(
"i,i'") + Xiip_VT1L1(
"i,i'");
6186 template <
typename T>
6188 SingleReference_R12Intermediates<T>::Xiip_VT1T1_f12b(
const double C_0,
const double C_1,
6189 const TArray2& T1,
const TArray4& T2,
6190 const TArray4& L2) {
6191 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
6192 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
6194 const char* ip =
"i'";
6195 const char* i =
"i";
6196 const char* j =
"j";
6197 const char* k =
"k";
6198 const char* l =
"l";
6199 const char* c =
"c";
6200 const char* d =
"d";
6202 TArray4 V_ipl_cd = VPq_Rs(ip,l,c,d,C_0, C_1);
6204 Xiip_VT1T1(
"i,i'") =
6205 V_ipl_cd(
"i',l,c,d") * T1(
"c,i") * T1(
"d,l");
6208 TArray4 V_IPL_CJ = VPQ_RS(ip, l, c, j);
6209 TArray4 V_LIP_CJ = VPQ_RS(l, ip, c, j);
6210 TArray4 V_KL_CIP = VPQ_RS(k, l, c, ip);
6213 ( R_C1 * ( V_IPL_CJ(
"i',l,c,j") * L2(
"c,d,i,l")
6214 + V_LIP_CJ(
"l,i',c,j") * L2(
"c,d,l,i"))
6215 + R_C2 * ( V_IPL_CJ(
"i',l,c,j") * L2(
"c,d,l,i")
6216 + V_LIP_CJ(
"l,i',c,j") * L2(
"c,d,i,l"))
6220 + (R_C1 * V_KL_CIP(
"k,l,c,i'") + R_C2 * V_KL_CIP(
"l,k,c,i'"))
6221 * L2(
"c,d,k,l") * T1(
"d,i")
6224 TArray4 V_IPJ_KL = VPQ_RS(ip, j, k, l);
6225 TArray4 V_KL_IPJ = VPQ_RS(k, l, ip, j);
6226 TArray2 Xai_VL2T1T1;
6227 Xai_VL2T1T1(
"i,i'") =
6228 (R_C1 * V_IPJ_KL(
"i',j,k,l") + R_C2 * V_IPJ_KL(
"i',j,l,k"))
6229 * L2(
"c,d,i,j") * T1(
"c,k") * T1(
"d,l")
6232 + (R_C1 * V_KL_IPJ(
"k,l,i',j") + R_C2 * V_KL_IPJ(
"l,k,i',j"))
6233 * L2(
"c,d,k,l") * T1(
"c,i") * T1(
"d,j")
6237 Xiip_C2(
"i,i'") = Xiip_VT1T1(
"i,i'") + Xai_VL2T1(
"i,i'") + Xai_VL2T1T1(
"i,i'");
6241 template <
typename T>
6245 <<
"Compute CCSD-F12b coupling contri. to dipole and quadrupole moments" << std::endl;
6247 bool compute_dipole =
true;
6248 bool compute_quadrupole =
true;
6250 double conv_target = 1e-10;
6253 const double C_0 = 1.0 / 2.0;
6254 const double C_1 = 1.0 / 4.0;
6255 const double RC1 = 0.5 * (C_0 + C_1);
6256 const double RC2 = 0.5 * (C_0 - C_1);
6258 const double R_C1 = (0.5 * C_0 + 1.5 * C_1);
6259 const double R_C2 = (0.5 * C_0 - 1.5 * C_1);
6261 const char* i =
"i";
6262 const char* j =
"j";
6263 const char* k =
"k";
6264 const char* l =
"l";
6265 const char* m =
"m";
6267 const char* a =
"a";
6268 const char* b =
"b";
6269 const char* c =
"c";
6270 const char* d =
"d";
6274 TArray4d g_mnab = ijxy(
"<m n|g|a b>");
6276 A_bnam(
"b,n,a,m") = - _4(
"<b n|g|a m>") - g_mnab(
"m,n,b,a") + 4.0 * g_mnab(
"n,m,b,a")
6277 + _2(
"<b|F|a>") * _2(
"<m|I|n>") - _2(
"<a|I|b>") * _2(
"<m|F|n>");
6282 mFmn(
"m,n") = - _2(
"<m|F|n>");
6283 mFab(
"a,b") = - _2(
"<a|F|b>");
6285 pceval_type Delta_am_gen(TA::array_to_eigen(mFab), TA::array_to_eigen(mFmn));
6287 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > >
TArray2d;
6289 TArray2d Delta_am(Iam.world(), Iam.trange());
6292 for(
auto t = Delta_am.trange().tiles_range().begin();
6293 t != Delta_am.trange().tiles_range().end(); ++t)
6294 if (Delta_am.is_local(*t)) {
6295 std::array<std::size_t, 2> index;
6296 std::copy(t->begin(), t->end(), index.begin());
6297 madness::Future < typename TArray2d::value_type >
6302 Delta_am.set(*t, tile);
6305 preconditioner(
"a,m") = Delta_am(
"a,m");
6308 TA::ConjugateGradientSolver<TiledArray::Array<T,2>,
6314 const std::size_t nocc = mFmn.trange().elements_range().extent()[0];
6315 const std::size_t naocc = Fij.trange().elements_range().extent()[0];
6320 if (nocc != naocc) {
6322 TArray2 Fipjp = xy(
"<i'|F|j'>");
6323 pceval_type Delta_ijp_gen(TA::array_to_eigen(Fij), TA::array_to_eigen(Fipjp));
6325 TArray2 Fijp = xy(
"<i|F|j'>");
6326 TArray2d Delta_ijp(Fijp.world(), Fijp.trange());
6328 for(
auto t = Delta_ijp.trange().tiles_range().begin();
6329 t != Delta_ijp.trange().tiles_range().end(); ++t)
6330 if (Delta_ijp.is_local(*t)) {
6331 std::array<std::size_t, 2> index;
6332 std::copy(t->begin(), t->end(), index.begin());
6333 madness::Future < typename TArray2d::value_type >
6338 Delta_ijp.set(*t, tile);
6340 Delta_ijp_F(
"i,j'") = Delta_ijp(
"i,j'");
6342 A_ijpam(
"i,j',a,m") = 4.0 * _4(
"<i a|g|j' m>") - _4(
"<i a|g|m j'>") - _4(
"<i m|g|a j'>");
6345 TArray2 mu_z_ij, mu_z_ijp, mu_z_ab, mu_z_ai, mu_z_am;
6346 if (compute_dipole) {
6347 mu_z_ij = xy(
"<i|mu_z|j>");
6348 mu_z_ab = xy(
"<a|mu_z|b>");
6349 mu_z_ai = xy(
"<a|mu_z|i>");
6350 mu_z_am = xy(
"<a|mu_z|m>");
6353 mu_z_ijp = xy(
"<i|mu_z|j'>");
6357 TArray2 Qxx_ij, Qyy_ij, Qzz_ij, Qxx_ab, Qyy_ab, Qzz_ab,
6358 Qxx_ai, Qyy_ai, Qzz_ai, Qxx_am, Qyy_am, Qzz_am,
6359 Qxx_apb, Qyy_apb, Qzz_apb,
6361 Qxx_ijp, Qyy_ijp, Qzz_ijp;
6363 if (compute_quadrupole){
6365 TArray2 q_xx_ij = xy(
"<i|q_xx|j>");
6366 TArray2 q_yy_ij = xy(
"<i|q_yy|j>");
6367 TArray2 q_zz_ij = xy(
"<i|q_zz|j>");
6368 Qxx_ij(
"i,j") = q_xx_ij(
"i,j") - (q_zz_ij(
"i,j") + q_yy_ij(
"i,j")) * 0.5;
6369 Qyy_ij(
"i,j") = q_yy_ij(
"i,j") - (q_zz_ij(
"i,j") + q_xx_ij(
"i,j")) * 0.5;
6370 Qzz_ij(
"i,j") = q_zz_ij(
"i,j") - (q_xx_ij(
"i,j") + q_yy_ij(
"i,j")) * 0.5;
6372 TArray2 q_xx_ab = xy(
"<a|q_xx|b>");
6373 TArray2 q_yy_ab = xy(
"<a|q_yy|b>");
6374 TArray2 q_zz_ab = xy(
"<a|q_zz|b>");
6375 Qxx_ab(
"a,b") = q_xx_ab(
"a,b") - (q_zz_ab(
"a,b") + q_yy_ab(
"a,b")) * 0.5;
6376 Qyy_ab(
"a,b") = q_yy_ab(
"a,b") - (q_zz_ab(
"a,b") + q_xx_ab(
"a,b")) * 0.5;
6377 Qzz_ab(
"a,b") = q_zz_ab(
"a,b") - (q_xx_ab(
"a,b") + q_yy_ab(
"a,b")) * 0.5;
6379 TArray2 q_xx_ai = xy(
"<a|q_xx|i>");
6380 TArray2 q_yy_ai = xy(
"<a|q_yy|i>");
6381 TArray2 q_zz_ai = xy(
"<a|q_zz|i>");
6382 Qxx_ai(
"a,i") = q_xx_ai(
"a,i") - (q_zz_ai(
"a,i") + q_yy_ai(
"a,i")) * 0.5;
6383 Qyy_ai(
"a,i") = q_yy_ai(
"a,i") - (q_zz_ai(
"a,i") + q_xx_ai(
"a,i")) * 0.5;
6384 Qzz_ai(
"a,i") = q_zz_ai(
"a,i") - (q_xx_ai(
"a,i") + q_yy_ai(
"a,i")) * 0.5;
6386 TArray2 q_xx_am = xy(
"<a|q_xx|m>");
6387 TArray2 q_yy_am = xy(
"<a|q_yy|m>");
6388 TArray2 q_zz_am = xy(
"<a|q_zz|m>");
6389 Qxx_am(
"a,m") = q_xx_am(
"a,m") - (q_zz_am(
"a,m") + q_yy_am(
"a,m")) * 0.5;
6390 Qyy_am(
"a,m") = q_yy_am(
"a,m") - (q_zz_am(
"a,m") + q_xx_am(
"a,m")) * 0.5;
6391 Qzz_am(
"a,m") = q_zz_am(
"a,m") - (q_xx_am(
"a,m") + q_yy_am(
"a,m")) * 0.5;
6393 TArray2 q_xx_apb = xy(
"<a'|q_xx|b>");
6394 TArray2 q_yy_apb = xy(
"<a'|q_yy|b>");
6395 TArray2 q_zz_apb = xy(
"<a'|q_zz|b>");
6396 Qxx_apb(
"a',b") = q_xx_apb(
"a',b") - (q_zz_apb(
"a',b") + q_yy_apb(
"a',b")) * 0.5;
6397 Qyy_apb(
"a',b") = q_yy_apb(
"a',b") - (q_zz_apb(
"a',b") + q_xx_apb(
"a',b")) * 0.5 ;
6398 Qzz_apb(
"a',b") = q_zz_apb(
"a',b") - (q_xx_apb(
"a',b") + q_yy_apb(
"a',b")) * 0.5;
6400 if (nocc != naocc) {
6401 TArray2 q_xx_ijp = xy(
"<i|q_xx|j'>");
6402 TArray2 q_yy_ijp = xy(
"<i|q_yy|j'>");
6403 TArray2 q_zz_ijp = xy(
"<i|q_zz|j'>");
6404 Qxx_ijp(
"i,j'") = q_xx_ijp(
"i,j'") - (q_zz_ijp(
"i,j'") + q_yy_ijp(
"i,j'")) * 0.5;
6405 Qyy_ijp(
"i,j'") = q_yy_ijp(
"i,j'") - (q_zz_ijp(
"i,j'") + q_xx_ijp(
"i,j'")) * 0.5;
6406 Qzz_ijp(
"i,j'") = q_zz_ijp(
"i,j'") - (q_xx_ijp(
"i,j'") + q_yy_ijp(
"i,j'")) * 0.5;
6410 double muz_ccsd = 0.0, muz_ccsdor = 0.0;
6411 double q_xx_ccsd = 0.0, q_yy_ccsd = 0.0, q_zz_ccsd = 0.0;
6412 double q_xx_ccsdor = 0.0, q_yy_ccsdor = 0.0, q_zz_ccsdor = 0.0;
6414 ExEnv::out0() << indent <<
"Compute CCSD T amplitudes " << std::endl;
6417 compute_T_ccsd(T1_ccsd, T2_ccsd,
"CCSD");
6419 ExEnv::out0() << indent <<
"Compute CCSD L amplitudes " << std::endl;
6422 compute_lambda_ccsd(T1_ccsd, T2_ccsd, L1_ccsd, L2_ccsd,
"CCSD");
6425 TArray2 Dij_ccsd, Dab_ccsd, Dia_ccsd, Dai_ccsd;
6427 <<
"Compute CCSD density from amplitudes" << std::endl;
6428 compute_ccsd_1rdm_amp(T1_ccsd, T2_ccsd, L1_ccsd, L2_ccsd,
6429 Dij_ccsd, Dab_ccsd, Dia_ccsd, Dai_ccsd);
6431 ExEnv::out0() << std::endl << indent <<
"Compute CCSD Xam and Xai" << std::endl;
6432 TArray2 Xam_ccsd_nfzc, Xiip_ccsd;
6433 compute_Xam_ccsd(T1_ccsd, T2_ccsd, L1_ccsd, L2_ccsd,
6434 Xam_ccsd_nfzc, Xiip_ccsd);
6436 TArray2 Diip_or_ccsd, Xam_ccsd;
6437 if (nocc != naocc) {
6439 <<
"Include frozen-core CCSD contributions" << std::endl;
6440 Diip_or_ccsd(
"i,i'") = Xiip_ccsd(
"i,i'") * Delta_ijp_F(
"i,i'");
6443 Xam_Diip_ccsd(
"a,m") = A_ijpam(
"i,i',a,m") * Diip_or_ccsd(
"i,i'");
6444 Xam_ccsd(
"a,m") = Xam_ccsd_nfzc(
"a,m") - Xam_Diip_ccsd(
"a,m");
6446 Xam_ccsd(
"a,m") = Xam_ccsd_nfzc(
"a,m");
6450 TArray2 Dbn_ccsd(Xam_ccsd.world(), Xam_ccsd.trange());
6451 auto resnorm_ccsd = cg_solver2(Orbital_relaxation_Abnam,
6457 if (compute_dipole) {
6458 muz_ccsd = dot(mu_z_ij(
"i,j"), Dij_ccsd(
"i,j"))
6459 + dot(mu_z_ab(
"a,b"), Dab_ccsd(
"a,b"))
6460 + dot(mu_z_ai(
"a,i"), Dai_ccsd(
"a,i"))
6461 + dot(mu_z_ai(
"a,i"), Dia_ccsd(
"i,a"))
6464 muz_ccsdor = dot(mu_z_am(
"a,m"), Dbn_ccsd(
"a,m"));
6465 if (nocc != naocc) {
6466 muz_ccsdor += dot(mu_z_ijp(
"i,i'"), Diip_or_ccsd(
"i,i'"));
6476 if (compute_quadrupole) {
6477 q_xx_ccsd = dot(Qxx_ij(
"i,j"), Dij_ccsd(
"i,j"))
6478 + dot(Qxx_ab(
"a,b"), Dab_ccsd(
"a,b"))
6479 + dot(Qxx_ai(
"a,i"), Dai_ccsd(
"a,i"))
6480 + dot(Qxx_ai(
"a,i"), Dia_ccsd(
"i,a"))
6482 q_yy_ccsd = dot(Qyy_ij(
"i,j"), Dij_ccsd(
"i,j"))
6483 + dot(Qyy_ab(
"a,b"), Dab_ccsd(
"a,b"))
6484 + dot(Qyy_ai(
"a,i"), Dai_ccsd(
"a,i"))
6485 + dot(Qyy_ai(
"a,i"), Dia_ccsd(
"i,a"))
6487 q_zz_ccsd = dot(Qzz_ij(
"i,j"), Dij_ccsd(
"i,j"))
6488 + dot(Qzz_ab(
"a,b"), Dab_ccsd(
"a,b"))
6489 + dot(Qzz_ai(
"a,i"), Dai_ccsd(
"a,i"))
6490 + dot(Qzz_ai(
"a,i"), Dia_ccsd(
"i,a"))
6493 q_xx_ccsdor = dot(Qxx_am(
"a,m"), Dbn_ccsd(
"a,m"));
6494 q_yy_ccsdor = dot(Qyy_am(
"a,m"), Dbn_ccsd(
"a,m"));
6495 q_zz_ccsdor = dot(Qzz_am(
"a,m"), Dbn_ccsd(
"a,m"));
6497 if (nocc != naocc) {
6498 q_xx_ccsdor += dot(Qxx_ijp(
"i,j'"), Diip_or_ccsd(
"i,j'"));
6499 q_yy_ccsdor += dot(Qyy_ijp(
"i,j'"), Diip_or_ccsd(
"i,j'"));
6500 q_zz_ccsdor += dot(Qzz_ijp(
"i,j'"), Diip_or_ccsd(
"i,j'"));
6516 ExEnv::out0() << indent <<
"Compute CCSD-F12b T amplitudes " << std::endl;
6519 compute_T_ccsd(T1_f12b, T2_f12b,
"F12b");
6522 ExEnv::out0() << std::endl << indent <<
"Compute CCSD-F12b L amplitudes " << std::endl;
6525 compute_lambda_ccsd(T1_f12b, T2_f12b, L1_f12b, L2_f12b,
"F12b");
6532 TArray4d r_ijaFb = ijxy(
"<i j|r|a_F(c') b>");
6533 Cijab(
"i,j,a,b") = R_C1 * r_ijaFb(
"i,j,a,b") + R_C2 * r_ijaFb(
"j,i,a,b")
6534 + R_C1 * r_ijaFb(
"j,i,b,a") + R_C2 * r_ijaFb(
"i,j,b,a");
6536 CT2(
"i,j") = Cijab(
"i,k,a,b") * T2_f12b(
"a,b,j,k");
6537 double E_CT2 = dot(CT2(
"i,j"), _2(
"<j|I|i>"));
6538 std::cout << std::endl
6539 << indent <<
"E_CT2 = " <<
scprintf(
"%15.12f", E_CT2)
6544 V_ia = VRk_Sk(i,a, C_0, C_1);
6546 TArray4 Vijab = VPq_Rs(i, j, a, b, C_0, C_1);
6548 VT2(
"i,j") = Vijab(
"i,k,a,b") * T2_f12b(
"a,b,j,k");
6550 double E_VT = dot(V_ia(
"i,a"), T1_f12b(
"a,i")) * 2.0
6551 + dot(VT2(
"i,j"), _2(
"<j|I|i>"));
6552 std::cout << indent <<
"E_VT = " <<
scprintf(
"%15.12f", E_VT)
6556 double E_VT1T1 = dot(Vijab(
"i,j,a,b"), T1_f12b(
"a,i") * T1_f12b(
"b,j"));
6557 std::cout << indent <<
"E_VT1T1 = " <<
scprintf(
"%15.12f", E_VT1T1)
6560 std::cout << indent <<
"E (Coupling in F12b) = "
6561 <<
scprintf(
"%15.12f", (E_CT2+E_VT+E_VT1T1))
6569 TArray2 Dij_f12b, Dab_f12b, Dia_f12b, Dai_f12b;
6571 <<
"Compute CCSD density from amplitudes in CCSD-F12b" << std::endl;
6572 compute_ccsd_1rdm_amp(T1_f12b, T2_f12b, L1_f12b, L2_f12b,
6573 Dij_f12b, Dab_f12b, Dia_f12b, Dai_f12b);
6576 <<
"Compute CCSD Xam and Xai in CCSD-F12b" << std::endl;
6577 TArray2 Xam_f12b_nfzc, Xiip_f12b;
6578 compute_Xam_ccsd(T1_f12b, T2_f12b, L1_f12b, L2_f12b, Xam_f12b_nfzc, Xiip_f12b);
6581 if (nocc != naocc) {
6582 Diip_f12b(
"i,i'") = Xiip_f12b(
"i,i'") * Delta_ijp_F(
"i,i'");
6583 Xam_f12b(
"a,m") = Xam_f12b_nfzc(
"a,m") - A_ijpam(
"i,i',a,m") * Diip_f12b(
"i,i'");
6585 Xam_f12b(
"a,m") = Xam_f12b_nfzc(
"a,m");
6588 TArray2 Dbn_f12b(Xam_f12b.world(), Xam_f12b.trange());
6589 auto resnorm_f12b = cg_solver2(Orbital_relaxation_Abnam,
6597 <<
"Compute CCSD F12b coupling contributions" << std::endl;
6601 RT2_aPb(
"a',b") = _4(
"<a' c|r|k l>")
6602 * (R_C1 * T2_f12b(
"b,c,k,l") + R_C2 * T2_f12b(
"c,b,k,l"));
6604 RL2_aPb(
"a',b") = _4(
"<a' c|r|k l>")
6605 * (R_C1 * L2_f12b(
"b,c,k,l") + R_C2 * L2_f12b(
"c,b,k,l"));
6607 TArray2 Xam_CT2L2 = Xam_CT2L2_f12b(C_0, C_1, T2_f12b, RT2_aPb, L2_f12b, RL2_aPb);
6610 TArray2 Xam_VTL = Xam_VTL_f12b(C_0, C_1, T1_f12b, T2_f12b, L1_f12b, L2_f12b);
6613 TArray2 X_VT1T1 = Xam_VT1T1_f12b(C_0, C_1, T1_f12b);
6620 TArray2 X_VL2T1 = Xam_VL2T1_f12b(C_0, C_1, T1_f12b, L2_f12b);
6625 TArray2 X_VL2T1T1 = Xam_VL2T1T1_f12b(C_0, C_1, T1_f12b, L2_f12b);
6630 Xam_C_nfzc(
"a,m") = Xam_CT2L2(
"a,m")
6639 if (nocc != naocc) {
6641 <<
"Include frozen-core contributions for CCSD F12 coupling" << std::endl;
6642 TArray2 Xiip_couling1 = Xiip_CVT_f12b(C_0, C_1, T1_f12b, T2_f12b, L1_f12b, L2_f12b);
6643 TArray2 Xiip_couling2 = Xiip_VT1T1_f12b(C_0, C_1, T1_f12b, T2_f12b, L2_f12b);
6644 Diip_C(
"i,i'") = - (Xiip_couling1(
"i,i'") + Xiip_couling2(
"i,i'"))
6645 * Delta_ijp_F(
"i,i'");
6648 Xam_Diip_C(
"a,m") = - A_ijpam(
"i,j',a,m") * Diip_C(
"i,j'");
6650 Xam_C(
"a,m") = Xam_C_nfzc(
"a,m") + Xam_Diip_C(
"a,m");
6652 Xam_C(
"a,m") = Xam_C_nfzc(
"a,m");
6655 TArray2 Dbn_C(Xam_C.world(), Xam_C.trange());
6656 auto resnorm_C = cg_solver2(Orbital_relaxation_Abnam,
6676 if (compute_dipole) {
6677 mu_z_apb = xy(
"<a'|mu_z|b>");
6678 double muz_f12b = dot(mu_z_ij(
"i,j"), Dij_f12b(
"i,j"))
6679 + dot(mu_z_ab(
"a,b"), Dab_f12b(
"a,b"))
6680 + dot(mu_z_ai(
"a,i"), Dai_f12b(
"a,i"))
6681 + dot(mu_z_ai(
"a,i"), Dia_f12b(
"i,a"))
6683 + dot(mu_z_apb(
"a',b"), RT2_aPb(
"a',b"))
6684 + dot(mu_z_apb(
"a',b"), RL2_aPb(
"a',b"))
6687 double muz_f12bor = dot(mu_z_am(
"a,m"), Dbn_f12b(
"a,m"))
6688 + dot(mu_z_am(
"a,m"), Dbn_C(
"a,m"))
6691 if (nocc != naocc) {
6692 muz_f12b += dot(mu_z_ijp(
"i,j'"), Diip_f12b(
"i,j'"))
6693 + dot(mu_z_ijp(
"i,j'"), Diip_C(
"i,j'"));
6702 double muz_Cf12b = muz_f12b - muz_ccsd;
6703 double muz_Cf12bor = muz_f12bor - muz_ccsdor;
6705 std::cout << std::endl << indent
6706 <<
"mu_z (F12b C) = " <<
scprintf(
"%15.12f", - muz_Cf12b * 2.0)
6707 << std::endl << indent
6708 <<
"mu_z (F12b C or) = " <<
scprintf(
"%15.12f", - muz_Cf12bor * 2.0)
6709 << std::endl << std::endl;
6712 if (compute_quadrupole) {
6713 double q_xx_f12b = dot(Qxx_ij(
"i,j"), Dij_f12b(
"i,j"))
6714 + dot(Qxx_ab(
"a,b"), Dab_f12b(
"a,b"))
6715 + dot(Qxx_ai(
"a,i"), Dai_f12b(
"a,i"))
6716 + dot(Qxx_ai(
"a,i"), Dia_f12b(
"i,a"))
6717 + dot(Qxx_apb(
"a',b"), RT2_aPb(
"a',b"))
6718 + dot(Qxx_apb(
"a',b"), RL2_aPb(
"a',b"))
6720 double q_yy_f12b = dot(Qyy_ij(
"i,j"), Dij_f12b(
"i,j"))
6721 + dot(Qyy_ab(
"a,b"), Dab_f12b(
"a,b"))
6722 + dot(Qyy_ai(
"a,i"), Dai_f12b(
"a,i"))
6723 + dot(Qyy_ai(
"a,i"), Dia_f12b(
"i,a"))
6724 + dot(Qyy_apb(
"a',b"), RT2_aPb(
"a',b"))
6725 + dot(Qyy_apb(
"a',b"), RL2_aPb(
"a',b"))
6727 double q_zz_f12b = dot(Qzz_ij(
"i,j"), Dij_f12b(
"i,j"))
6728 + dot(Qzz_ab(
"a,b"), Dab_f12b(
"a,b"))
6729 + dot(Qzz_ai(
"a,i"), Dai_f12b(
"a,i"))
6730 + dot(Qzz_ai(
"a,i"), Dia_f12b(
"i,a"))
6731 + dot(Qzz_apb(
"a',b"), RT2_aPb(
"a',b"))
6732 + dot(Qzz_apb(
"a',b"), RL2_aPb(
"a',b"))
6735 double q_xx_f12bor = dot(Qxx_am(
"a,m"), Dbn_f12b(
"a,m"))
6736 + dot(Qxx_am(
"a,m"), Dbn_C(
"a,m"));
6737 double q_yy_f12bor = dot(Qyy_am(
"a,m"), Dbn_f12b(
"a,m"))
6738 + dot(Qyy_am(
"a,m"), Dbn_C(
"a,m"));
6739 double q_zz_f12bor = dot(Qzz_am(
"a,m"), Dbn_f12b(
"a,m"))
6740 + dot(Qzz_am(
"a,m"), Dbn_C(
"a,m"));
6742 if (nocc != naocc) {
6743 q_xx_f12bor += dot(Qxx_ijp(
"i,j'"), Diip_f12b(
"i,j'"))
6744 + dot(Qxx_ijp(
"i,j'"), Diip_C(
"i,j'"));
6745 q_yy_f12bor += dot(Qyy_ijp(
"i,j'"), Diip_f12b(
"i,j'"))
6746 + dot(Qyy_ijp(
"i,j'"), Diip_C(
"i,j'"));
6747 q_zz_f12bor += dot(Qzz_ijp(
"i,j'"), Diip_f12b(
"i,j'"))
6748 + dot(Qzz_ijp(
"i,j'"), Diip_C(
"i,j'"));
6761 double q_xx_f12b_C = q_xx_f12b - q_xx_ccsd;
6762 double q_yy_f12b_C = q_yy_f12b - q_yy_ccsd;
6763 double q_zz_f12b_C = q_zz_f12b - q_zz_ccsd;
6764 double q_xx_f12bor_C = q_xx_f12bor - q_xx_ccsdor;
6765 double q_yy_f12bor_C = q_yy_f12bor - q_yy_ccsdor;
6766 double q_zz_f12bor_C = q_zz_f12bor - q_zz_ccsdor;
6767 std::cout << std::endl << indent
6768 <<
"q_xx (F12b C) = " <<
scprintf(
"%12.10f", - q_xx_f12b_C * 2.0)
6769 <<
" q_yy (F12b C) = " <<
scprintf(
"%12.10f", - q_yy_f12b_C * 2.0)
6770 <<
" q_zz (F12b C) = " <<
scprintf(
"%12.10f", - q_zz_f12b_C * 2.0)
6771 << std::endl << indent
6772 <<
"q_xx (F12b C or) = " <<
scprintf(
"%12.10f", - q_xx_f12bor_C * 2.0)
6773 <<
" q_yy (F12b C or) = " <<
scprintf(
"%12.10f", - q_yy_f12bor_C * 2.0)
6774 <<
" q_zz (F12b C or) = " <<
scprintf(
"%12.10f", - q_zz_f12bor_C * 2.0)
6775 << std::endl << std::endl;
6781 template <
typename T>
6785 #define ENABLE_SRR12_RDM1 1
6787 #if ENABLE_SRR12_RDM1
6843 typedef TiledArray::Array<T,2> Array;
6844 Array Fii = _2(
"<i|F|j>");
6845 Array FAA = _2(
"<A'|F|B'>");
6849 TA::ConjugateGradientSolver<Array, detail::_CABS_singles_h0t1<double> > cg_solver;
6850 Array FiA = _2(
"<i|F|A'>");
6851 Array minus_FiA = -1.0 * FiA(
"i,A'");
6852 Array T1_recomp = FiA;
6856 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > >
TArray2d;
6857 TArray2d Delta_iA(FiA.world(), FiA.trange());
6858 pceval_type Delta_iA_gen(TA::array_to_eigen(Fii),
6859 TA::array_to_eigen(FAA));
6862 for(
auto t=Delta_iA.trange().tiles_range().begin();
6863 t!=Delta_iA.trange().tiles_range().end();
6865 if (Delta_iA.is_local(*t)) {
6866 std::array<std::size_t, 2> index; std::copy(t->begin(), t->end(), index.begin());
6867 madness::Future < typename TArray2d::value_type >
6872 Delta_iA.set(*t, tile);
6874 Array preconditioner = Delta_iA(
"i,A'");
6877 std::cout <<
"FiA:\n" << FiA << std::endl;
6878 std::cout <<
"Fii:\n" << Fii << std::endl;
6879 std::cout <<
"FAA:\n" << FAA << std::endl;
6880 std::cout <<
"preconditioner:\n" << preconditioner << std::endl;
6884 auto resnorm = cg_solver(cabs_singles_rhs_eval,
6889 std::cout <<
"Converged CG to " << resnorm << std::endl;
6890 const double E2_cabs = 2.0 * dot(T1_recomp(
"i,A'"), _2(
"<i|F|A'>"));
6891 std::cout <<
"E2_cabs (re-recomputed) = " << E2_cabs << std::endl;
6895 const double mu_z_e = 2*dot(_2(
"<i|mu_z|A'>"), T1_recomp(
"i,A'"))
6896 - dot(_2(
"<i|mu_z|j>"), T1_recomp(
"i,A'") * T1_recomp(
"j,A'") )
6897 + dot(_2(
"<A'|mu_z|B'>"), T1_recomp(
"i,A'") * T1_recomp(
"i,B'") );
6898 std::cout <<
"Mu_z (2)_S = " << 2*mu_z_e << std::endl;
6899 std::cout <<
"Mu_z ref = " << (dot(_2(
"<i|mu_z|j>"),_2(
"<i|gamma|j>")))
6905 const double q_zz_e = 2*dot(_2(
"<i|q_zz|A'>"), T1_recomp(
"i,A'"))
6906 - dot(_2(
"<i|q_zz|j>"), T1_recomp(
"i,A'") * T1_recomp(
"j,A'") )
6907 + dot(_2(
"<A'|q_zz|B'>"), T1_recomp(
"i,A'") * T1_recomp(
"i,B'") );
6908 std::cout <<
"Q_zz (2)_S = " << 2*q_zz_e << std::endl;
6909 std::cout <<
"Q_zz ref = " << (dot(_2(
"<i|q_zz|j>"),_2(
"<i|gamma|j>")))
6915 TArray2 Tia = T1_recomp(
"j,A'") * _2(
"<A'|I|a>");
6916 TArray2 Xia_1 = 2* (_2(
"<i|F|j>") * Tia(
"j,a") - T1_recomp(
"i,B'") * _2(
"<B'|F|a>"))
6917 + 2 * _2(
"<i|F|C'>") * T1_recomp(
"j,C'") * Tia(
"j,a")
6918 - 2 * (2 * _4(
"<j i|g|B' a>") - _4(
"<j i|g|a B'>") + 2 * _4(
"<j a|g|B' i>") - _4(
"<j a|g|i B'>")) * T1_recomp(
"j,B'")
6919 - 2 * (2 * _4(
"<B' i|g|C' a>") - _4(
"<B' i|g|a C'>")) * T1_recomp(
"j,B'") * T1_recomp(
"j,C'")
6920 + 2 * (2 * _4(
"<j i|g|k a>") - _4(
"<j i|g|a k>")) * T1_recomp(
"j,B'") * T1_recomp(
"k,B'");
6921 std::cout <<
"Xia_1, should not be 0:\n" << Xia_1 << std::endl;
6924 TArray4 G_ij_ab = _4(
"<i j|g|a b>");
6925 TArray4 G_ia_jb = _4(
"<i a|g|j b>");
6928 TA::ConjugateGradientSolver<Array, detail::_OrbResponse<double> > cg_solver;
6929 Array kappa = Xia_1;
6933 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > >
TArray2d;
6934 TArray2d Delta_ia(Xia_1.world(), Xia_1.trange());
6935 pceval_type Delta_ia_gen(TA::array_to_eigen(Fii),
6936 TA::array_to_eigen(Faa));
6939 for(
auto t=Delta_ia.trange().tiles_range().begin();
6940 t!=Delta_ia.trange().tiles_range().end();
6942 if (Delta_ia.is_local(*t)) {
6943 std::array<std::size_t, 2> index; std::copy(t->begin(), t->end(), index.begin());
6944 madness::Future < typename TArray2d::value_type >
6949 Delta_ia.set(*t, tile);
6951 Array preconditioner = Delta_ia(
"i,a");
6954 auto resnorm = cg_solver(response_lhs_eval,
6959 std::cout <<
"Converged CG to " << resnorm << std::endl;
6964 response_lhs_eval(kappa, res);
6965 std::cout <<
"should be zero = " << TA::expressions::norm2(res(
"i,a") - Xia_1(
"i,a"));
6968 const double mu_z_e = dot(kappa(
"i,a"), _2(
"<i|mu_z|a>"));
6969 std::cout <<
"mu_z_e (orb response) = " << 2*mu_z_e << std::endl;
6976 std::cout <<
"computing E2_cabs due to CABS only as the first-order space\n";
6977 typedef TiledArray::Array<T,2> Array;
6978 Array Fii = _2(
"<i|F|j>");
6979 Array FAA = _2(
"<a'|F|b'>");
6983 TA::ConjugateGradientSolver<Array, detail::_CABS_singles_h0t1<double> > cg_solver;
6984 Array FiA = _2(
"<i|F|a'>");
6985 Array minus_FiA = -1.0 * FiA(
"i,a'");
6986 Array T1_recomp = FiA;
6990 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > >
TArray2d;
6991 TArray2d Delta_iA(FiA.world(), FiA.trange());
6992 pceval_type Delta_iA_gen(TA::array_to_eigen(Fii),
6993 TA::array_to_eigen(FAA));
6996 for(
auto t=Delta_iA.trange().tiles_range().begin();
6997 t!=Delta_iA.trange().tiles_range().end();
6999 if (Delta_iA.is_local(*t)) {
7000 std::array<std::size_t, 2> index; std::copy(t->begin(), t->end(), index.begin());
7001 madness::Future < typename TArray2d::value_type >
7006 Delta_iA.set(*t, tile);
7008 Array preconditioner = Delta_iA(
"i,a'");
7011 std::cout <<
"FiA:\n" << FiA << std::endl;
7012 std::cout <<
"Fii:\n" << Fii << std::endl;
7013 std::cout <<
"FAA:\n" << FAA << std::endl;
7014 std::cout <<
"preconditioner:\n" << preconditioner << std::endl;
7018 auto resnorm = cg_solver(cabs_singles_rhs_eval,
7023 std::cout <<
"Converged CG to " << resnorm << std::endl;
7024 const double E2_cabs = 2.0 * dot(T1_recomp(
"i,a'"), _2(
"<i|F|a'>"));
7025 std::cout <<
"E2_cabs (re-recomputed) = " << E2_cabs << std::endl;
7029 const double mu_z_e = 2*dot(_2(
"<i|mu_z|a'>"), T1_recomp(
"i,a'"))
7030 - dot(_2(
"<i|mu_z|j>"), T1_recomp(
"i,a'") * T1_recomp(
"j,a'") )
7031 + dot(_2(
"<a'|mu_z|b'>"), T1_recomp(
"i,a'") * T1_recomp(
"i,b'") );
7032 std::cout <<
"Mu_z (2)_S = " << 2*mu_z_e << std::endl;
7038 TArray2 Xia_1 = - 2 * T1_recomp(
"i,b'") * _2(
"<b'|F|a>")
7039 - 2 * (2 * _4(
"<j i|g|b' a>") - _4(
"<j i|g|a b'>") + 2 * _4(
"<j a|g|b' i>") - _4(
"<j a|g|i b'>")) * T1_recomp(
"j,b'")
7040 - 2 * (2 * _4(
"<b' i|g|c' a>") - _4(
"<b' i|g|a c'>")) * T1_recomp(
"j,b'") * T1_recomp(
"j,c'")
7041 + 2 * (2 * _4(
"<j i|g|k a>") - _4(
"<j i|g|a k>")) * T1_recomp(
"j,b'") * T1_recomp(
"k,b'");
7042 std::cout <<
"Xia_1, should not be 0:\n" << Xia_1 << std::endl;
7045 TArray4 G_ij_ab = _4(
"<i j|g|a b>");
7046 TArray4 G_ia_jb = _4(
"<i a|g|j b>");
7049 TA::ConjugateGradientSolver<Array, detail::_OrbResponse<double> > cg_solver;
7050 Array kappa = Xia_1;
7054 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > >
TArray2d;
7055 TArray2d Delta_ia(Xia_1.world(), Xia_1.trange());
7056 pceval_type Delta_ia_gen(TA::array_to_eigen(Fii),
7057 TA::array_to_eigen(Faa));
7060 for(
auto t=Delta_ia.trange().tiles_range().begin();
7061 t!=Delta_ia.trange().tiles_range().end();
7063 if (Delta_ia.is_local(*t)) {
7064 std::array<std::size_t, 2> index; std::copy(t->begin(), t->end(), index.begin());
7065 madness::Future < typename TArray2d::value_type >
7070 Delta_ia.set(*t, tile);
7072 Array preconditioner = Delta_ia(
"i,a");
7075 auto resnorm = cg_solver(response_lhs_eval,
7080 std::cout <<
"Converged CG to " << resnorm << std::endl;
7081 const double mu_z_e = dot(kappa(
"i,a"), _2(
"<i|mu_z|a>"));
7082 std::cout <<
"mu_z_e (orb reponse) = " << 2*mu_z_e << std::endl;
7089 std::cout <<
"computing E2_obs (virtuals is the first-order space)\n";
7090 typedef TiledArray::Array<T,2> Array;
7091 Array Fii = _2(
"<i|F|j>");
7092 Array FAA = _2(
"<a|F|b>");
7096 TA::ConjugateGradientSolver<Array, detail::_CABS_singles_h0t1<double> > cg_solver;
7097 Array FiA = _2(
"<i|F|a>");
7098 Array minus_FiA = -1.0 * FiA(
"i,a");
7103 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > >
TArray2d;
7104 TArray2d Delta_iA(FiA.world(), FiA.trange());
7105 pceval_type Delta_iA_gen(TA::array_to_eigen(Fii),
7106 TA::array_to_eigen(FAA));
7109 for(
auto t=Delta_iA.trange().tiles_range().begin();
7110 t!=Delta_iA.trange().tiles_range().end();
7112 if (Delta_iA.is_local(*t)) {
7113 std::array<std::size_t, 2> index; std::copy(t->begin(), t->end(), index.begin());
7114 madness::Future < typename TArray2d::value_type >
7119 Delta_iA.set(*t, tile);
7121 Array preconditioner = Delta_iA(
"i,a");
7124 std::cout <<
"FiA:\n" << FiA << std::endl;
7125 std::cout <<
"Fii:\n" << Fii << std::endl;
7126 std::cout <<
"FAA:\n" << FAA << std::endl;
7127 std::cout <<
"preconditioner:\n" << preconditioner << std::endl;
7131 auto resnorm = cg_solver(cabs_singles_rhs_eval,
7136 std::cout <<
"Converged CG to " << resnorm << std::endl;
7138 const double E2_obs = 2.0 * dot(T1_obs(
"i,a"), _2(
"<i|F|a>"));
7139 std::cout <<
"E2_obs = " << E2_obs << std::endl;
7140 const double E0_obs = dot(_2(
"<i|F|j>"), _2(
"<i|gamma|j>"));
7141 std::cout <<
"E0_obs = " <<
scprintf(
"%15.10lf",E0_obs) << std::endl;
7145 const double mu_z_e = 2*dot(_2(
"<i|mu_z|a>"), T1_obs(
"i,a"))
7146 - dot(_2(
"<i|mu_z|j>"), T1_obs(
"i,a") * T1_obs(
"j,a") )
7147 + dot(_2(
"<a|mu_z|b>"), T1_obs(
"i,a") * T1_obs(
"i,b") );
7148 std::cout <<
scprintf(
"Mu_z (2)_S OBS = %25.15lf", 2*mu_z_e) << std::endl;
7149 std::cout <<
scprintf(
"Mu_z ref = %25.15lf", (dot(_2(
"<i|mu_z|j>"),_2(
"<i|gamma|j>")))) << std::endl;
7155 TArray2 Xia_1 = _2(
"<i|F|j>") * T1_obs(
"j,a") - T1_obs(
"i,b") * _2(
"<b|F|a>")
7156 + 2 * _2(
"<i|F|c>") * T1_obs(
"j,c") * T1_obs(
"j,a")
7157 + 2 * T1_obs(
"i,c") * T1_obs(
"j,c") * _2(
"<j|F|a>")
7159 std::cout <<
"Xia_1, should not be 0:\n" << Xia_1 << std::endl;
7161 std::cout <<
"Fia, should be close to Xia_1:\n" << Fia << std::endl;
7164 TArray4 G_ij_ab = _4(
"<i j|g|a b>");
7165 TArray4 G_ia_jb = _4(
"<i a|g|j b>");
7168 TA::ConjugateGradientSolver<Array, detail::_OrbResponse<double> > cg_solver;
7169 Array kappa = Xia_1;
7173 typedef TA::Array<T, 2, LazyTensor<T, 2, pceval_type > >
TArray2d;
7174 TArray2d Delta_ia(Xia_1.world(), Xia_1.trange());
7175 pceval_type Delta_ia_gen(TA::array_to_eigen(Fii),
7176 TA::array_to_eigen(Faa));
7179 for(
auto t=Delta_ia.trange().tiles_range().begin();
7180 t!=Delta_ia.trange().tiles_range().end();
7182 if (Delta_ia.is_local(*t)) {
7183 std::array<std::size_t, 2> index; std::copy(t->begin(), t->end(), index.begin());
7184 madness::Future < typename TArray2d::value_type >
7189 Delta_ia.set(*t, tile);
7191 Array preconditioner = Delta_ia(
"i,a");
7194 auto resnorm = cg_solver(response_lhs_eval,
7199 std::cout <<
"Converged CG to " << resnorm << std::endl;
7200 std::cout <<
scprintf(
"E_2 (orb reponse) = %25.15lf", 2*dot(kappa(
"i,a"), _2(
"<i|F|a>"))) << std::endl;
7201 const double mu_z_e = dot(kappa(
"i,a"), _2(
"<i|mu_z|a>"));
7202 std::cout <<
scprintf(
"mu_z_e (orb reponse) = %25.15lf", 2*mu_z_e) << std::endl;
7208 for(
int i=0; i<10; ++i) {
7209 TArray4 should_be_zero = _4(
"<b j|g|a i>") - _4(
"<b i|g|a j>");
7210 std::cout <<
"should be 0: " << TA::expressions::norminf(should_be_zero(
"b,j,a,i")) << std::endl;
7220 #else // ENABLE_SRR12_RDM1
7226 template <
typename T>
7231 V_ij_mn(
"i1,i2,m1,m2") = _4(
"<i1 i2|gr|m1 m2>") - _4(
"<i1 i2|r|p1 p2>") * _4(
"<m1 m2|g|p1 p2>")
7232 - _4(
"<i1 i2|r|m3_gamma(m) a'>") * _4(
"<m1 m2|g|m3 a'>");
7234 if (symmetrize_p1_p2)
7235 V_ij_mn(
"i1,i2,m1,m2") = 0.5 * (V_ij_mn(
"i1,i2,m1,m2") + V_ij_mn(
"i2,i1,m2,m1"));
7240 template <
typename T>
7245 X_ij_kl(
"i1,i2,j1,j2") = _4(
"<i1 i2|r2|j1 j2>") - _4(
"<i1 i2|r|p1 p2>") * _4(
"<j1 j2|r|p1 p2>")
7246 - _4(
"<i1 i2|r|m3_gamma(m) a'>") * _4(
"<j1 j2|r|m3 a'>");
7248 if (symmetrize_p1_p2)
7249 X_ij_kl(
"i1,i2,j1,j2") = 0.5 * (X_ij_kl(
"i1,i2,j1,j2") + X_ij_kl(
"i2,i1,j2,j1"));
7254 template <
typename T>
7259 B_ij_kl(
"i1,i2,j1,j2") =
7265 _4(
"<i1 i2|rTr|j1 j2>") + 2.0 * _4(
"<i1 i2|r2|j1 j2_hJ(p')>")
7268 - 2.0 * _4(
"<i1 i2|r|r' s'>") * _4(
"<j1 j2|r|r' s'_K(p')>")
7271 - 2.0 * _4(
"<i1 i2|r|r s>") * _4(
"<j1 j2|r|r s_F(p)>")
7274 - 4.0 * _4(
"<i1 i2|r|r s>") * _4(
"<j1 j2|r|r s_F(a')>")
7277 - _4(
"<i1 i2|r|n_gamma(m) b'>") * _4(
"<j1 j2|r|n b'_F(a')>")
7280 - _4(
"<i1 i2|r|n_gamma(m) a'>") * _4(
"<j1 j2|r|n_F(p') a'>");
7282 B_ij_kl(
"i1,i2,j1,j2") = 0.5
7283 * (B_ij_kl(
"i1,i2,j1,j2") + B_ij_kl(
"i2,i1,j2,j1"));
7284 B_ij_kl(
"i1,i2,j1,j2") = 0.5
7285 * (B_ij_kl(
"i1,i2,j1,j2") + B_ij_kl(
"j1,j2,i1,i2"));
7287 if (symmetrize_p1_p2)
7288 B_ij_kl(
"i1,i2,j1,j2") = 0.5
7289 * (B_ij_kl(
"i1,i2,j1,j2") + B_ij_kl(
"i2,i1,j2,j1"));
7297 #endif // end of header guard