MADNESS 0.10.1
CCPotentials.h
Go to the documentation of this file.
1/*
2 * CCPotentials.h
3 *
4 * Created on: 4 Jan 2017
5 * Author: kottmanj
6 */
7
8#ifndef SRC_APPS_CHEM_CCPOTENTIALS_H_
9#define SRC_APPS_CHEM_CCPOTENTIALS_H_
10
13#include<madness/chem/nemo.h>
17
18namespace madness {
19/// Class which calculates all types of CC2 Potentials
21public:
22 CCPotentials(World& world_, const std::shared_ptr<const Nemo> nemo, const CCParameters& param);
23
24 void reset_nemo(const std::shared_ptr<const Nemo> nemo) {
25 nemo_ = nemo;
26 mo_ket_ = (make_mo_ket(*nemo));
27 mo_bra_ = (make_mo_bra(*nemo));
28 orbital_energies_ = init_orbital_energies(*nemo);
29 };
30
31 Info update_info(const CCParameters& parameters, const std::shared_ptr<const Nemo> nemo) const {
32 Info info;
33 info.mo_bra = mo_bra().get_vecfunction();
34 info.mo_ket = mo_ket().get_vecfunction();
35 info.molecular_coordinates = nemo->get_calc()->molecule.get_all_coords_vec();
36 info.parameters = parameters;
37 info.R_square = nemo->R_square;
38 info.R = nemo->R;
39 info.U1 = nemo->ncf->U1vec();
40 info.U2 = nemo->ncf->U2();
41 info.intermediate_potentials = get_potentials;
42 info.orbital_energies = orbital_energies_;
43 info.fock=nemo->compute_fock_matrix(nemo->get_calc()->amo, nemo->get_calc()->aocc);
44 return info;
45 }
46
47 virtual
49
50 /// forms the regularized functions from Q and Qt Ansatz for CIS(D) where tau=0 and t=mo so that Qt=Q
51 void test_pair_consistency(const CCPairFunction<double, 6>& u, const size_t i, const size_t j,
52 const CC_vecfunction& x) const;
53
54 bool test_compare_pairs(const CCPair& pair1, const CCPair& pair2) const;
55
56 void test_pairs();
57
58 void test_singles_potential(Info& info) const;
59
60 void test();
61
62 /// Returns the full 6D function from a CCPair structure (only recommended for debug purposes)
63 real_function_6d make_6D_pair(const CCPair& pair) const;
64
65 /// Function to load a function from disc
66 /// @param[in] f the function which will be loaded
67 /// @param[in] name of the file in which the function was stored
68 /// @param do_print
69 /// @return true or false depending on if the data was found on disc
70 template <typename T, size_t NDIM>
71 bool load_function(Function<T, NDIM>& f, const std::string name, bool do_print) const {
73 archive::BinaryFstreamInputArchive>::exists(world, name.c_str());
74 if (exists) {
75 if ((world.rank() == 0) and do_print) print("loading function", name);
77 ar & f;
78 if (do_print) f.print_size(name);
79 if (f.is_compressed()) {
80 if (world.rank()==0 and do_print) print("function is compressed -- reconstructing");
81 f.change_tree_state(reconstructed);
82 if (do_print) f.print_size(name+" reconstructed");
83 save(f, name);
84 }
86 f.truncate();
87 f.print_size(name);
88 return true;
89 } else {
90 if ((world.rank()==0) and do_print) print("could not find function",name);
91 }
92 return false;
93 }
94
95 /// Plotting (convenience)
96 void plot(const vector_real_function_3d& f, const std::string& msg) const;
97
98 /// Plotting (convenience)
99 void plot(const real_function_3d& f, const std::string& msg, const bool doprint = true) const;
100
101 /// print size of a function
102 template <size_t NDIM>
103 void print_size(const Function<double, NDIM>& f, const std::string& msg, const bool print = true) const {
104 if (print) f.print_size(msg);
105 }
106
107 /// returns a vector of all orbital energies
108 std::vector<double> get_orbital_energies() const { return orbital_energies_; }
109
110 /// returns epsilon_i + epsilon_j (needed for bsh operator of pairs)
111 double get_epsilon(const size_t i, const size_t j) const {
112 return orbital_energies_[i] + orbital_energies_[j];
113 }
114
115 /// returns epsilon_i + epsilon_j (needed for bsh operator of pairs)
116 static double get_epsilon(const size_t i, const size_t j, const Info& info) {
117 return info.orbital_energies[i] + info.orbital_energies[j];
118 }
119
120 /// returns a vector of all active mos without nuclear correlation factor (nemos)
123 for (size_t i = parameters.freeze(); i < mo_ket_.size(); i++) result.push_back(mo_ket_(i).function);
124 return result;
125 }
126
127 /// returns a vector of all active mos multiplied with the squared nuclear currelation factor: mo_bra = R^2*mo_ket
130 for (size_t i = parameters.freeze(); i < mo_bra_.size(); i++) result.push_back(mo_bra_(i).function);
131 return result;
132 }
133
134 /// get the corresponding mo bra vectors to a ket vector
137 for (const auto& ktmp : ket.functions) {
138 result.push_back(mo_bra_(ktmp.first).function);
139 }
140 return result;
141 }
142
143 /// returns a specific mo
144 CCFunction<double, 3> mo_ket(const size_t& i) const {
145 return mo_ket_(i);
146 }
147
148 // returns constant mo_ket_
150 return mo_ket_;
151 }
152
153 /// returns a specific mo multiplied with the squared nuclear correlation factor
154 CCFunction<double, 3> mo_bra(const size_t& i) const {
155 return mo_bra_(i);
156 }
157
158 // returns constant mo_bra_
160 return mo_bra_;
161 }
162
163 /// make bra element: R^2|t>
167
169 vector_real_function_3d bra = mul(world, nemo_->ncf->square(), t);
170 truncate(world, bra);
171 return bra;
172 }
173
174 /// makes the t intermediates
175 /// t_i = mo_ket_(i) + factor*tau(i)
176 /// if factor!=1 then we can not use intermediates and set the type to UNDEFINED
177 CC_vecfunction make_t_intermediate(const CC_vecfunction& tau, const CCParameters& parameters) const;
178
179 /// makes the t intermediates
180 /// t_i = mo_ket_(i) + factor*tau(i)
181 /// if the core is frozen the core ti will just be mo_ket_
183
184 /// makes the t intermediates
185 /// t_i = mo_ket_(i) + tau(i)
186 /// if the core is frozen the core ti will just be mo_ket_
188
189 /// makes the t intermediates
190
191 /// t_i = mo_ket_(i) + tau(i)
192 /// skip frozen orbitals
194
195 /// makes the t intermediates
196 /// t_i = mo_ket_(i) + tau
197 /// i = tau.i
199
200private:
201 /// Helper function to initialize the const mo_bra and ket elements adn orbital energies
203 make_mo_bra(const Nemo& nemo) const;
204
205 /// Helper function to initialize the const mo_bra and ket elements
207 make_mo_ket(const Nemo& nemo) const;
208
209 /// Transfers Eigenvalues of HF MOs from Nemo (Tensor Format) to std::vector<double> format
210 std::vector<double>
211 init_orbital_energies(const Nemo& nemo) const;
212
213public:
214 /// return the regularized MP2 ansatz: |\tau_ij> = |u_ij> + Q12 f12 |ij>
215 static CCPair make_pair_mp2(World& world, const real_function_6d& u, const size_t i, const size_t j,
216 const Info& info, bool compute_Q12_f12_ij);
217
218 /// return the regularized CC2 ansatz: |\tau_ij> = |u_ij> + Q12t f12 |t_i t_j>
219 static CCPair make_pair_cc2(World& world, const real_function_6d& u,
220 const CC_vecfunction& gs_singles, const size_t i, const size_t j, const Info& info, const bool compute_Q12_f12_ij);
221
222 /// return the regularized CC2 ansatz: |x_ij> = |u_ij> + Q12t f12 |t_i t_j> + ?????
223 static CCPair make_pair_lrcc2(World& world, const CalcType& ctype,
224 const real_function_6d& u, const CC_vecfunction& gs_singles,
225 const CC_vecfunction& ex_singles, const size_t i, const size_t j, const Info& info,
226 const bool compute_Q12_f12);
227
228 // Pair functions
229
230 /// creates pair functions for ground states
231 /// the full pair-functions is: pair = u + Qt12f12|titj>
232 /// this is decomposed in different types of CCPairFunction
233 /// the CC_Pair2 class holds an vector of CCPairFunction
234 /// we use: Qt12 = 1 - Ot1 - Ot2 + Ot12 = 1 - Ot1(1-0.5*Ot2) - Ot2(1-0.5O*t1)
235 /// depending on parameters.QtAnsatz we use the t functions also in the projector
236 /// functions[0] = u , the pure 6D part
237 /// functions[1] = f12|titj>
238 /// functions[2] = -Ot1(1-0.5*Ot2)f12|titj>
239 /// functions[3] = -(1-0.5*Ot1)Ot2f12|titj>
240 CCPair
241 make_pair_gs(const real_function_6d& u, const CC_vecfunction& tau, const size_t i, const size_t j) const;
242
243 /// creates pair functions for Excited states
244 /// the full pair-functions is: pair = u + Qt12f12|xitj> + Qt12f12|tixj> - OxQtf12|titj> - QtOxf12|titj>
245 /// the old Ansatz (not QtAnsatz) was: pair = u + Q12f12|xitj> + Q12f12|tixj>
246 /// this is decomposed in different types of CCPairFunction
247 /// the CC_Pair2 class holds an vector of CCPairFunction
248 /// we use: Qt12 = 1 - Ot1 - Ot2 + Ot12 = 1 - Ot1(1-0.5*Ot2) - Ot2(1-0.5O*t1)
249 /// functions[0] = u , the pure 6D part
250 /// functions[1] = f12|xitj>
251 /// functions[2] = f12|tixj>
252 /// functions[3] = -Ot1(1-0.5*Ot2)f12|xitj>
253 /// functions[4] = -(1-0.5*Ot1)Ot2f12|xitj>
254 /// functions[5] = -Ot1(1-0.5*Ot2)f12|tixj>
255 /// functions[6] = -(1-0.5*Ot1)Ot2f12|tixj>
256 /// functions[7] = -OxQtf12|titj> only for QtAnsatz
257 /// functions[8] = -QtOxf12|titj> only for QtAnsatz
258 CCPair
259 make_pair_ex(const real_function_6d& u, const CC_vecfunction& tau, const CC_vecfunction& x, const size_t i,
260 const size_t j, const CalcType ctype) const;
261
262 // Energy operations
263
264 /// Compute pair correlation energies of MP2 or CC2 Ground State
265 // Off diagonal pair energies are multiplied with 2.0 to acount for their permuted partners
266 /// @param[in] u the Pair_function
267 /// @param[in] singles the Singles (for MP2 give empty function) for the energy contribution over disconnected doubles
268 /// @param[out] 2*<ij|g|u> - <ji|g|u> , where i and j are determined by u (see CC_Pair class)
269 static double
271 const CCPair& u,
272 const CC_vecfunction& singles,
273 const Info& info);
274
275 /// Compute CC2 correlation energy
276 /// @param[in] The Pair_function
277 /// @param[out] \sum_{ij} 2*<ij|g|u> - <ji|g|u> + 2*<ij|g|\tau_i\tau_j> - <ji|g|\tau_i\tau_j> , where i and j are determined by u (see CC_Pair class)
278 /// since we do not compute all pairs (symmetry reasons) the off diagonal pair energies are conted twice
279 /// the cc2 pair functions are dependent on the doubles (see CC_Pair structure, and make_pair function) so make shure they are updated
280 /// @param world
281 /// @param info
282 static double
283 compute_cc2_correlation_energy(World& world, const CC_vecfunction& singles, const Pairs<CCPair>& doubles,
284 const Info& info, const std::string msg="");
285
286
287 static double
289
290 /// compute the expectation value excitation energy using the CIS/CCS/CC2 singles
291 static double
293 const vector_real_function_3d& V, const bool print, const Info& info);
294
295 /// Something like a pair energy for CIS(D)/LRCC2 to estimate energy convergence
296 /// calculates the response part of s2b and s2c which are independent of the mp2 amplitudes
297 static double
298 compute_excited_pair_energy(World& world, const CCPair& d, const CC_vecfunction& x, const Info& info);
299
300 /// Compute the CIS(D) Energy Correction to CIS
301 double
302 compute_cispd_energy(const CC_vecfunction& x, const Pairs<CCPair> mp2, const Pairs<CCPair> cispd) const;
303
304 /// Compute the CC2 Excitation Energy
305 double
307 const Pairs<CCPair> dx) const;
308
309 // 6D operations
310
311 /// The 6D Fock residue on the cusp free pair function u_{ij}(1,2) is: (2J - Kn - Un)|u_{ij}>
313 fock_residue_6d(const CCPair& u) const;
314
315 /// Static function for the 6D Fock residue for use in macrotask
317 fock_residue_6d_macrotask(World& world, const CCPair& u, const CCParameters& parameters,
318 const std::vector<madness::Vector<double, 3>>& all_coords_vec,
319 const std::vector<real_function_3d>& mo_ket,
320 const std::vector<real_function_3d>& mo_bra,
321 const std::vector<real_function_3d>& U1,
322 const real_function_3d& U2);
323
324
325 /// Compute the constant part of MP2, CC2 or LR-CC2
326 ///
327 /// depending on pair.calc_type different terms are included in the constant part.
328 /// @param[in] pair the (empty) pair function, determines the terms in the constant part, contains some bookkeeping information (bsh_eps, i, j)
329 /// @param[in] gs_singles the ground-state singles for CC2 (used for the T1-transformed SO projector), may be left empty for MP2
330 /// @param[in] ex_singles the excited-state singles for CC2 (used for the T1-transformed SO projector), may be left empty for MP2 and GS-CC2
331 /// @param[in] info the Info object, containing the some basic quantities (MOs, parameters, etc)
332 /// @return the constant part of the MP2, CC2 or LR-CC2: G(Q12(g~|titj>))
334 make_constant_part_macrotask(World& world, const CCPair& pair,
335 const CC_vecfunction& gs_singles, const CC_vecfunction& ex_singles,
336 const LowRankFunction<double,6>& exchange_op,
337 const Info& info);
338
339 /// quick 3D-only Ue / GUe / GQUe references for all pairs (no 6D work)
340
341 /// reuses CorrelationFactor::compute_3d_references; meant to be called right
342 /// before the constant-part macrotask to compare the 3D references cheaply.
343 static void print_3d_references(World& world, const std::vector<CCPair>& pair_vec,
344 const Info& info);
345
346 /// iterate a pair for MP2, CC2, LRCC2 on constant singles
347 static CCPair iterate_pair_macrotask(World& world,
348 const CCPair& pair, const CC_vecfunction& gs_singles,
349 const CC_vecfunction& ex_singles,
350 const real_function_6d& coupling, const Info& info, const long maxiter);
351
352
353 /// Function evaluates the consant part of the Excited state for CIS(D) if the Q Ansatz is used
356 const real_convolution_6d* Gscreen = NULL) const;
357
358 /// Function evaluates the consant part of the Excited state for CIS(D) if the Qt Ansatz is used
361 const real_convolution_6d* Gscreen = NULL) const;
362
363 /// Apply the Regularization potential
364 /// \f$ V_{reg} = [ U_e - [K,f12] + f12(F12-eij) ]|titj> \f$
365 /// @param[in] ti, first function in the ket, for MP2 it is the Orbital, for CC2 the relaxed Orbital t_i=\phi_i + \tau_i
366 /// @param[in] tj, second function in the ket ...
367 /// @param[in] pointer to bsh operator (in order to screen)
368 /// @param[out] the regularization potential (unprojected), see equation above
371 const real_convolution_6d* Gscreen = NULL) const;
372
373 /// Apply the Regularization potential
374 /// \f$ V_{reg} = [ U_e - [K,f12] + f12(F12-eij) + [F,Qt] ]|titj> \f$
375 /// @param[in] ti, first function in the ket, for MP2 it is the Orbital, for CC2 the relaxed Orbital t_i=\phi_i + \tau_i
376 /// @param[in] tj, second function in the ket ...
377 /// @param exchange_op
378 /// @param[in] pointer to bsh operator (in order to screen)
379 /// @param[out] the regularization potential (unprojected), see equation above
380 std::vector<CCPairFunction<double, 6>>
381 static apply_Vreg(World& world, const CCFunction<double, 3>& ti, const CCFunction<double, 3>& tj,
382 const CC_vecfunction& gs_singles, const CC_vecfunction& ex_singles,
383 const Info& info, LowRankFunction<double, 6> exchange_op, const std::vector<std::string>& argument, const double bsh_eps);
384
385 /// evaluates: \f$ (F(1)-ei)|ti> (x) |tj> + |ti> (x) (F(2)-ej)|tj> \f$ with the help of the singles potential
386 /// singles equation is: (F-ei)|ti> = - V(ti)
387 /// response singles equation: (F-ei-omega)|xi> = - V(xi)
388 /// response: \f$ (F12-ei-ej-omega)|xitj> = (F1 - ei - omega)|xi> (x) |tj> + |xi> (x) (F2-ej)|tj> \f$
389 /// so in both cases the result will be: |V(ti),tj> + |ti,V(tj)>
390 /// @param[in] ti, first function in the ket, for MP2 it is the Orbital, for CC2 the relaxed Orbital t_i=\phi_i + \tau_i
391 /// @param[in] tj, second function in the ket ...
392 /// @param[in] pointer to bsh operator (in order to screen)
395 const real_convolution_6d* Gscreen = NULL) const;
396
397 /// evaluates: \f$ (F(1)-ei)|ti> (x) |tj> + |ti> (x) (F(2)-ej)|tj> \f$ with the help of the singles potential
398 /// singles equation is: (F-ei)|ti> = - V(ti)
399 /// response singles equation: (F-ei-omega)|xi> = - V(xi)
400 /// response: \f$ (F12-ei-ej-omega)|xitj> = (F1 - ei - omega)|xi> (x) |tj> + |xi> (x) (F2-ej)|tj> \f$
401 /// so in both cases the result will be: |V(ti),tj> + |ti,V(tj)>
402 /// @param[in] ti, first function in the ket, for MP2 it is the Orbital, for CC2 the relaxed Orbital t_i=\phi_i + \tau_i
403 /// @param[in] tj, second function in the ket ...
404 /// @param[in] pointer to bsh operator (in order to screen)
406 static apply_reduced_F(World& world, const CCFunction<double, 3>& ti, const CCFunction<double, 3>& tj,
407 const Info& info, const real_convolution_6d* Gscreen = NULL);
408
409 /// Apply Ue on a tensor product of two 3d functions: Ue(1,2) |x(1)y(2)> (will be either |ij> or |\tau_i\tau_j> or mixed forms)
410 /// The Transformed electronic regularization potential (Kutzelnigg) is R_{12}^{-1} U_e R_{12} with R_{12} = R_1*R_2
411 /// It is represented as: R_{12}^{-1} U_e R_{12} = U_e + R^-1[Ue,R]
412 /// where R^-1[Ue,R] = R^-1 [[T,f],R] (see: Regularizing the molecular potential in electronic structure calculations. II. Many-body
413 /// methods, F.A.Bischoff)
414 /// The double commutator can be evaluated as follows: R^-1[[T,f],R] = -Ue_{local}(1,2)*(Un_{local}(1) - Un_{local}(2))
415 /// @param[in] x the 3D function for particle 1
416 /// @param[in] y the 3D function for particle 2
417 /// @param[in] The BSH operator to screen: Has to be in NS form, Gscreen->modified == true
418 /// @return R^-1U_eR|x,y> the transformed electronic smoothing potential applied on |x,y> :
421 const real_convolution_6d* Gscreen = NULL) const;
422
424 static apply_Ue(World& world, const CCFunction<double, 3>& phi_i, const CCFunction<double, 3>& phi_j,
425 const Info& info, const real_convolution_6d* Gscreen);
426
427
428 /// return Kf12|xy>
429 static real_function_6d
430 apply_Kfxy(World& world, const CCFunction<double,3>& x, const CCFunction<double,3>& y, const Info& info,
431 const CCParameters& param);
432
433 static std::vector<CCPairFunction<double, 6>>
434 apply_KffK(World& world, const CCFunction<double, 3>& phi_i, const CCFunction<double, 3>& phi_j,
435 const LowRankFunction<double,6>& exchange_op,
436 const Info& info, const real_convolution_6d* Gscreen);
437
438 static std::vector<CCPairFunction<double, 6>>
439 apply_f12_coupling(World& world, const CCFunction<double, 3>& phi_i, const CCFunction<double, 3>& phi_j,
440 const Info& info, const real_convolution_6d* Gscreen);
441
444 const CC_vecfunction& gs_singles, const CC_vecfunction& ex_singles,
445 const Info& info, const real_convolution_6d* Gscreen);
446
449 const CC_vecfunction& gs_singles, const CC_vecfunction& ex_singles,
450 const Info& info, const real_convolution_6d* Gscreen);
451
452 /// Apply Ue on a tensor product of two 3d functions: Ue(1,2) |x(1)y(2)> (will be either |ij> or |\tau_i\tau_j> or mixed forms)
453 /// The Transformed electronic regularization potential (Kutzelnigg) is R_{12}^{-1} U_e R_{12} with R_{12} = R_1*R_2
454 /// It is represented as: R_{12}^{-1} U_e R_{12} = U_e + R^-1[Ue,R]
455 /// where R^-1[Ue,R] = R^-1 [[T,f],R] (see: Regularizing the molecular potential in electronic structure calculations. II. Many-body
456 /// methods, F.A.Bischoff)
457 /// The double commutator can be evaluated as follows: R^-1[[T,f],R] = -Ue_{local}(1,2)*(Un_{local}(1) - Un_{local}(2))
458 /// @param[in] x the 3D function for particle 1
459 /// @param[in] y the 3D function for particle 2
460 /// @param[in] Gscreen pointer to the BSH operator in order to screen, has to be in modified NS form, Gscreen->modified==true
461 /// the f12K|xy> part will be screened with the BSH while the Kf12|xy> can not be screened with the BSH operator but maybe with the coulomb
462 /// @return R^-1U_eR|x,y> the transformed electronic smoothing potential applied on |x,y> :
465 const real_convolution_6d* Gscreen = NULL) const;
466
467
468 /// Helper Function which performs the operation \f$ <xy|g12f12|ab> \f$
469 /// @param[in] function x, if nuclear correlation is used make sure this is the correct bra function
470 /// @param[in] function y, if nuclear correlation is used make sure this is the correct bra function
471 /// @param[in] function a,
472 /// @param[in] function b,
473 double
475 const CCFunction<double, 3>& b) const;
476
478 const CCFunction<double, 3>& a, const CCFunction<double, 3>& b) const {
479 error("xy_ff_ab not yet implemented");
480 return 0.0;
481 }
482
483 /// apply the operator gf = 1/(2\gamma)*(Coulomb - 4\pi*BSH_\gamma)
484 /// works only if f = (1-exp(-\gamma*r12))/(2\gamma)
485 static real_function_3d
486 apply_gf(World& world, const real_function_3d& f, const Info& info);
487
488 /// returns <xy|op|u>
489 /// loops over every entry in the vector and accumulates results
490 /// helper function for CIS(D) energy
491 static double
494 const std::vector<CCPairFunction<double, 6>>& u);
495
496 /// returns <xy|u> for a vector of CCPairFunction
497 /// the result is accumulated for every vercotr
498 /// helper functions for CIS(D) energy
499 static double
501 const std::vector<CCPairFunction<double, 6>>& u);
502
503 /// Functions which operate with the CCPairFunction structure
504 /// @param[in] function x, if nuclear correlation is used make sure this is the correct bra function
505 /// @param[in] function y, if nuclear correlation is used make sure this is the correct bra function
506 /// @param[in] CCPairFunction u,
507 static double
511
512 /// Helper Function which returns
513 /// @return <xy|op|ab>
514 /// @param[in] function x, if nuclear correlation is used make sure this is the correct bra function
515 /// @param[in] function y, if nuclear correlation is used make sure this is the correct bra function
516 /// @param[in] function a,
517 /// @param[in] function b,
518 double
521 const CCFunction<double, 3>& b) const;
522
523 /// get the correct pair function as vector of CCPairFunction functions
524 /// @param[in] The pair functions
525 /// @param[out] The demanded pair function as vector of CCPairFunction functions (includes regularization tails)
526 static std::vector<CCPairFunction<double, 6>>
527 get_pair_function(const Pairs<CCPair>& pairs, const size_t i, const size_t j);
528
529
530 /// returns <a|g12|u>_2
531 static real_function_3d
533 const size_t particle, const Info& info);
534
535 /// dummy to avoid confusion and for convenience
539
540 /// swap the particles of the CCPairFunction and return a new vector of swapped functions
541 static std::vector<CCPairFunction<double, 6>> swap_particles(const std::vector<CCPairFunction<double, 6>>& f) {
542 std::vector<CCPairFunction<double, 6>> swapped;
543 for (size_t i = 0; i < f.size(); i++) swapped.push_back(f[i].swap_particles());
544 return swapped;
545 }
546
547 /// Calculate the Overlap between two CCPairFunction <f1|f2>
548 /// @param[in] 6D function 1
549 /// @param[in] 6D function 2
550 double
552 return inner(f1, f2, nemo_->ncf->square());
553 };
554
555 /// Computes the squared norm of the pair function <x|x>
556 /// including all regularization tails
557 /// means: if x = u + f12|mn> + |ab> --> <x|x> = <u|u> + <u|f12|mn> + <u|ab> + ....
558 double
559 overlap(const CCPair& x) const;
560
561 // Projectors
562
563 /// Apply a projector to a CC_vecfunction
564 /// result: \f$ P(tau)f[i] = \sum_k tau[k]*<k|f[i]> \f$
565 /// ket state of the projector can vary
566 /// bra state are always MOs
568 apply_projector(const CC_vecfunction& f, const CC_vecfunction& ket_) const;
569
570 /// Apply Qt projector on 6D function
572 apply_Q12t(const real_function_6d& f, const CC_vecfunction& t) const;
573
574
575 /// Apply the Q projector to a CC_vecfunction
576 /// result: \f$ 1-c*P(tau)f[i] = 1 - c*\sum_k tau[k]*<k|f[i]> \f$
577 /// ket state of the projector can vary
578 /// bra state are always MOs
579 /// the factor c is usually 1 or 1/2
581 apply_Qt(const CC_vecfunction& f, const CC_vecfunction& ket_, const double c = 1.0) const;
582
583 /// Apply the Qt projector on a CCPairFunction
584 /// works in principle like apply_Ot
586 apply_Qt(const CCPairFunction<double, 6>& f, const CC_vecfunction& t, const size_t particle,
587 const double c = 1.0) const;
588
589 /// Apply Ot projector on decomposed or op_decomposed 6D function
590 /// The function does not work with type==pure right now (not needed)
591 /// for CCPairFunction type==decomposed_ : f = \sum_k |c_k,d_k> where c and d are stored as vectors
592 /// then the result is \sum_k |a_k,b_k> with a,b stored as vectors and
593 /// \f$ a_k = t_k \f$
594 /// \f$ b_k = Ot(d_k) or vise versa for particle==2
595 /// for CCPairFunction type == op_decomposd the function si f=op|xy> and we have for particle==1
596 /// \f$ a_k = t_k \f$
597 /// \f$ b_k = <mo_k|op|x>*y \f$
599 apply_Ot(const CCPairFunction<double, 6>& f, const CC_vecfunction& t, const size_t particle) const;
600
601 /// Apply the Greens Operator to a CCPairFunction
602 /// For CCPairFunction only type pure and type decomposed is supported
603 /// for the op_decomposed type a pure function can be constructed (not needed therefore not implemented yet)
605 apply_G(const CCPairFunction<double, 6>& u, const real_convolution_6d& G) const;
606
607 /// Apply BSH Operator and count time
608 real_function_6d apply_G(const real_function_6d& f, const real_convolution_6d& G) const {
609 CCTimer time(world, "Apply Greens Operator");
610 const real_function_6d result = G(f);
611 time.info(true, result.norm2());
612 return result;
613 }
614
615
616 // Coupled Cluster Singles potentials which work with CCPairFunction pairs
617 // notation follows Shavit & Bartlett Many-Body Methods ...
618
619 /// Calculates the CC2 singles potential for the ground state: result = Fock_residue + V
620 /// the V part is stored in the intermediate_potentials structure
622 get_CC2_singles_potential_gs(World& world, const CC_vecfunction& singles, const Pairs<CCPair>& doubles,
623 Info& info);
624
625 /// Calculates the CCS/CIS singles potential for the excited state: result = Fock_residue + V
626 /// the V part is stored in the intermediate_potentials structure
627 /// the expectation value is calculated and updated
629 get_CCS_potential_ex(World& world, const CC_vecfunction& x, const bool print, Info& info);
630
631 /// Calculates the CC2 singles potential for the Excited state: result = Fock_residue + V
632 /// the V part is stored in the intermediate_potentials structure
634 get_CC2_singles_potential_ex(World& world, const CC_vecfunction& gs_singles,
635 const Pairs<CCPair>& gs_doubles, const CC_vecfunction& ex_singles,
636 const Pairs<CCPair>& response_doubles, Info& info);
637
638 /// Calculates the CC2 singles potential for the Excited state: result = Fock_residue + V
639 /// the V part is stored in the intermediate_potentials structure
641 get_ADC2_singles_potential(World& world, const Pairs<CCPair>& gs_doubles,
642 CC_vecfunction& ex_singles, const Pairs<CCPair>& response_doubles, Info& info);
643
644 /// The potential manager for the ground state potential
645 /// CC2 singles potential parts of the ground state
646 /// Genereal function which evaluates a CC_singles potential
647 /// @param[in] Bra vectorfunction to contract the potential
648 /// @param[in] Singles of the Ground State
649 /// @param[in] Doubles of the Ground State
650 /// @param[in] Name of the potential
651 /// @param[out] the potential (without Q application)
652 /// @param world
653 double
654 potential_energy_gs(World& world, const CC_vecfunction& bra, const CC_vecfunction& singles,
655 const Pairs<CCPair>& doubles, const PotentialType& name) const;
656
657 /// The potential manager for the ground state potential
658 /// CC2 singles potential parts of the ground state
659 /// General function which evaluates a CC_singles potential
660 /// @param[in] result_index corresponds to indices of external lines in the diagram
661 /// @param[in] Singles of the Ground State
662 /// @param[in] Doubles of the Ground State
663 /// @param[in] Name of the potential
664 /// @param[out] the potential (without Q application)
665 /// @param world
666 static std::tuple<madness::vector_real_function_3d, madness::vector_real_function_3d>
667 potential_singles_gs(World& world, const std::vector<int>& result_index, const CC_vecfunction& singles,
668 const Pairs<CCPair>& doubles,
669 const PotentialType& name, const Info& info);
670
671 /// The integra manager for the excited state potential
672 /// CC2 singles potential parts of the ground state
673 /// Genereal function which evaluates a CC_singles potential
674 /// @param[in] The bra element
675 /// @param[in] Singles of the Ground State
676 /// @param[in] Doubles of the Ground State
677 /// @param[in] Singles of the Excited State
678 /// @param[in] Doubles of the Excited State
679 /// @param[in] Name of the potential
680 /// @param[out] the potential (without Q application)
681 /// @param world
682 double
683 potential_energy_ex(World& world, const CC_vecfunction& bra, const CC_vecfunction& singles_gs,
684 const Pairs<CCPair>& doubles_gs, const CC_vecfunction& singles_ex,
685 const Pairs<CCPair>& doubles_ex, const PotentialType& name) const;
686
687 /// The potential manager for the excited state potential
688 /// CC2 singles potential parts of the ground state
689 /// Genereal function which evaluates a CC_singles potential
690 /// @param[in] result_index dummy vector for partitioning the macrotasks, must have the length of the singles vector
691 /// @param[in] Singles of the Ground State
692 /// @param[in] Doubles of the Ground State
693 /// @param[in] Singles of the Excited State
694 /// @param[in] Doubles of the Excited State
695 /// @param[in] Name of the potential
696 /// @param[out] the potential (without Q application)
697 /// @param world
698 static std::tuple<madness::vector_real_function_3d, madness::vector_real_function_3d>
699 potential_singles_ex(World& world, const std::vector<int> result_index, const CC_vecfunction& singles_gs,
700 const Pairs<CCPair>& doubles_gs, const CC_vecfunction& singles_ex,
701 const Pairs<CCPair>& doubles_ex, const PotentialType& name, const Info& info);
702
703 /// The Fock operator is partitioned into F = T + Vn + R
704 /// the fock residue R= 2J-K+Un for closed shell is computed here
705 /// J_i = \sum_k <k|r12|k> |tau_i>
706 /// K_i = \sum_k <k|r12|tau_i> |k>
708 fock_residue_closed_shell(World& world, const CC_vecfunction& singles, const Info& info);
709
710 /// the K operator runs over ALL orbitals (also the frozen ones)
711 static real_function_3d
712 K(World& world, const CCFunction<double, 3>& f, const Info& info);
713
714 /// static version of k above for access from macrotask. will eventually replace former.
716 static K_macrotask(World& world, const std::vector<real_function_3d>& mo_ket,
717 const std::vector<real_function_3d>& mo_bra, const real_function_3d& f,
718 const CCParameters& parameters);
719
720 /// Exchange Operator on Pair function: -(K(1)+K(2))u(1,2)
721 /// if i==j in uij then the symmetry will be exploited
722 /// !!!!Prefactor (-1) is not included here!!!!
724 K(const real_function_6d& u, const bool symmetric) const;
725
726 /// static version of k above for access from macrotask. will eventually replace former.
728 static K_macrotask(World& world, const std::vector<real_function_3d>& mo_ket,
729 const std::vector<real_function_3d>& mo_bra,
730 const real_function_6d& u, const bool symmetric, const CCParameters& parameters);
731
732 /// Exchange Operator on Pair function: -(K(1)+K(2))u(1,2)
733 /// K(1)u(1,2) = \sum_k <k(3)|g13|u(3,2)> |k(1)>
734 /// 1. X(3,2) = bra_k(3)*u(3,2)
735 /// 2. Y(1,2) = \int X(3,2) g13 d3
736 /// 3. result = Y(1,2)*ket_k(1)
737 /// !!!!Prefactor (-1) is not included here!!!!
739 apply_K(const real_function_6d& u, const size_t& particle) const;
740
741 /// Static version of apply_K above for access from macrotask. Will eventually replace former.
743 static apply_K_macrotask(World& world, const std::vector<real_function_3d>& mo_ket,
744 const std::vector<real_function_3d>& mo_bra,
745 const real_function_6d& u, const size_t& particle, const CCParameters& parameters);
746
747 /// Apply the Exchange operator on a tensor product multiplied with f12
748 /// !!! Prefactor of (-1) is not inclued in K here !!!!
750 apply_Kf(const CCFunction<double, 3>& x, const CCFunction<double, 3>& y) const;
751
752 /// Apply fK on a tensor product of two 3D functions
753 /// fK|xy> = fK_1|xy> + fK_2|xy>
754 /// @param[in] x, the first 3D function in |xy>, structure holds index i and type (HOLE, PARTICLE, MIXED, UNDEFINED)
755 /// @param[in] y, the second 3D function in |xy> structure holds index i and type (HOLE, PARTICLE, MIXED, UNDEFINED)
756 /// @param[in] BSH operator to screen, has to be in modified NS form, Gscreen->modified()==true;
758 apply_fK(const CCFunction<double, 3>& x, const CCFunction<double, 3>& y,
759 const real_convolution_6d* Gscreen = NULL) const;
760
761 /// Creates a 6D function with the correlation factor and two given CCFunctions
763 make_f_xy(const CCFunction<double, 3>& x, const CCFunction<double, 3>& y,
764 const real_convolution_6d* Gscreen = NULL) const;
765
766 /// Creates a 6D function with the correlation factor and two given CCFunctions
768 static make_f_xy(World& world, const CCFunction<double, 3>& x, const CCFunction<double, 3>& y,
769 const Info& info, const real_convolution_6d* Gscreen = NULL);
770
772 static make_f_xy_macrotask(World& world, const real_function_3d& x_ket, const real_function_3d& y_ket,
773 const real_function_3d& x_bra, const real_function_3d& y_bra,
774 const size_t& i, const size_t& j, const CCParameters& parameters,
775 const FuncType& x_type, const FuncType& y_type,
776 const real_convolution_6d* Gscreen = NULL);
777
778 /// unprojected ccs (S3c) potential
779 /// returns 2kgtk|ti> - kgti|tk>
780 /// the ccs potential: ti = ti and tk = tauk
782 ccs_unprojected(World& world, const CC_vecfunction& ti, const CC_vecfunction& tk, const Info& info);
783
784 /// return RMS norm and max norm of residuals
785 template <typename T, std::size_t NDIM>
786 static std::pair<double, double> residual_stats(const std::vector<Function<T, NDIM>>& residual) {
787 if (residual.size() == 0) return std::make_pair(0.0, 0.0);
788 World& world = residual.front().world();
789 auto errors = norm2s(world, residual);
790 double rnorm = 0.0, maxrnorm = 0.0;
791 for (double& e : errors) {
792 maxrnorm = std::max(maxrnorm, e);
793 rnorm += e * e;
794 }
795 rnorm = sqrt(rnorm / errors.size());
796 return std::make_pair(rnorm, maxrnorm);
797 }
798
799 static void print_convergence(const std::string name, const double rmsresidual, const double maxresidual,
800 const double energy_diff, const int iteration) {
801 const std::size_t bufsize = 255;
802 char msg[bufsize];
803 std::snprintf(msg, bufsize,
804 "convergence of %s in iteration %2d at time %8.1fs: rms/max residual, energy change %.1e %.1e %.1e",
805 name.c_str(), iteration, wall_time(), rmsresidual, maxresidual,energy_diff);
806 print(msg);
807 }
808
809 // integrals from singles potentials
810
811 /// <xi|T|ti> + <xi|Vn|ti> + 2.0*<xi,k|g|ti,k> - <xi,k|g|k,ti>
812 double
813 x_s3a(const CC_vecfunction& x, const CC_vecfunction& t) const;
814
815 /// -<xi|e_i|ti>
816 double
817 x_s3b(const CC_vecfunction& x, const CC_vecfunction& t) const;
818
819 /// 2<xik|g|itk> - <xik|g|tki>
820 double
821 x_s3c(const CC_vecfunction& x, const CC_vecfunction& t) const;
822
823 /// 2<xik|g|t1it2k> - <xik|g|t2kt1i>
824 double
825 x_s5b(const CC_vecfunction& x, const CC_vecfunction& t1, const CC_vecfunction& t2) const;
826
827 /// -(2<lk|g|it1k> - <lk|g|t1ki>)* <xi|t2l>
828 double
829 x_s5c(const CC_vecfunction& x, const CC_vecfunction& t1, const CC_vecfunction& t2) const;
830
831 /// -(2<lk|g|t3i,t1k> - <lk|g|t1k,t3i>)* <xi|t2l>
832 double
833 x_s6(const CC_vecfunction& x, const CC_vecfunction& t1, const CC_vecfunction& t2,
834 const CC_vecfunction& t3) const;
835
836 /// 2.0 <xik|g|uik>- <kxi|g|uik>
837 double
838 x_s2b(const CC_vecfunction& x, const Pairs<CCPair>& u) const;
839
840 /// -( 2.0 <xi,k|(l_g_i)(2)|ukl> - <k,xi,(l_g_i)(1)|ukl> )
841 double
842 x_s2c(const CC_vecfunction& x, const Pairs<CCPair>& u) const;
843
844 /// -( <lk|g|uik> - <kl|g|uik> )*<xi|tl>
845 double
846 x_s4a(const CC_vecfunction& x, const CC_vecfunction& t, const Pairs<CCPair>& u) const;
847
848 /// -( 2.0 <xi,k|(l_g_ti)(2)|ukl> - <k,xi,(l_g_ti)(1)|ukl> )
849 double
850 x_s4b(const CC_vecfunction& x, const CC_vecfunction& t, const Pairs<CCPair>& u) const;
851
852 /// 4.0 <xil|(k_g_tk)|uil> - 2.0 <lxi|(k_g_tk)|uil> - 2.0 <xik|(l_g_tk)|uil> + <kxi|(l_g_tk)|uil>
853 double
854 x_s4c(const CC_vecfunction& x, const CC_vecfunction& t, const Pairs<CCPair>& u) const;
855
856 /// result: \sum_k( 2<k|g|uik>_2 - <k|g|uik>_1 )
857
858 /// singles are not needed explicitly but to determine if it is response or ground state
859 /// function return a vector of size 2*singles, the first half being the s2b potential, the second half
860 /// an intermediate that will be stored by the caller in the info structure
861 ///@param world
862 ///@param external_indices
863 ///@param[in] singles:CC_vecfunction fof type response or particle (depending on this the correct intermediates will be used) the functions themselves are not needed
864 ///@param[in] doubles:Pairs of CC_Pairs (GS or Response)
865 ///@param builder
866 ///@param info
867 ///@param[out] \f$ \sum_k( 2<k|g|uik>_2 - <k|g|uik>_1 ) \f$
868 /// Q-Projector is not applied, sign is correct
869 /// if the s2b potential has already been calculated it will be loaded from the intermediate_potentials structure
870 static std::tuple<madness::vector_real_function_3d, madness::vector_real_function_3d>
871 s2b(World& world, std::vector<int> external_indices, const CC_vecfunction& singles, const Pairs<CCPair>& doubles, const
872 CCPairBuilder& builder, const Info& info);
873
874 /// result: -\sum_k( <l|kgi|ukl>_2 - <l|kgi|ukl>_1)
875
876 /// singles are not needed explicitly but to determine if it is response or ground state
877 /// function return a vector of size 2*singles, the first half being the s2c potential, the second half
878 /// an intermediate that will be stored by the caller in the info structure
879 ///@param world
880 ///@param external_index
881 ///@param[in] singles:CC_vecfunction fof type response or particle (depending on this the correct intermediates will be used) the functions themselves are not needed
882 ///@param[in] doubles:Pairs of CC_Pairs (GS or Response)
883 ///@param builder
884 ///@param info
885 ///@param[out] \f$ -\sum_k( <l|kgi|ukl>_2 - <l|kgi|ukl>_1) \f$
886 /// Q-Projector is not applied, sign is correct
887 static std::tuple<vector<Function<double, 3>>, vector<Function<double, 3>>>
888 s2c(World& world, std::vector<int> external_index, const CC_vecfunction& singles, const Pairs<CCPair>& doubles, const
889 CCPairBuilder& builder, const Info& info);
890
891 /// the S4a potential can be calcualted from the S2b potential
892 /// result is \f$ s4a_i = - <l|s2b_i>*|tau_l> \f$
894 s4a_from_s2b(const vector_real_function_3d& s2b, const CC_vecfunction& singles) const;
895
896 // result: -\sum_k( <l|kgtaui|ukl>_2 - <l|kgtaui|ukl>_1) | kgtaui = <k|g|taui>
897 ///@param world
898 ///@param external_index
899 ///@param[in] singles:CC_vecfunction fof type response or particle (depending on this the correct intermediates will be used) the functions themselves are not needed
900 ///@param[in] doubles:Pairs of CC_Pairs (GS or Response)
901 ///@param info
902 ///@param[out] \f$ -( <l|kgtaui|ukl>_2 - <l|kgtaui|ukl>_1) | kgtaui = <k|g|taui> | taui=singles_i \f$
903 /// Q-Projector is not applied, sign is correct
905 s4b(World& world, std::vector<int> external_index, const CC_vecfunction& singles, const Pairs<CCPair>& doubles,
906 const CCPairBuilder& builder, const Info& info);
907
908
909 ///@param world
910 ///@param external_index
911 ///@param[in] singles:CC_vecfunction fof type response or particle (depending on this the correct intermediates will be used) the functions themselves are not needed
912 ///@param[in] doubles:Pairs of CC_Pairs (GS or Response)
913 ///@param info
914 ///@param[out] \f$ ( 4<l|kgtauk|uil>_2 - 2<l|kgtauk|uil>_1 - 2<k|lgtauk|uil>_2 + <k|lgtauk|uil>_1 ) \f$
915 /// Q-Projector is not applied, sign is correct
917 s4c(World& world, std::vector<int> external_index, const CC_vecfunction& singles, const Pairs<CCPair>& doubles,
918 const CCPairBuilder& builder, const Info& info);
919
920 // update the intermediates
921 void update_intermediates(const CC_vecfunction& t) {
922 g12->update_elements(mo_bra_, t);
923 // g12.sanity();
924 f12->update_elements(mo_bra_, t);
925 // f12.sanity();
926 }
927
928 /// clear stored potentials
929 /// if a response function is given only the response potentials are cleared (the GS potentials dont change anymore)
930 void clear_potentials(const CC_vecfunction& t) const {
931 if (t.type == RESPONSE) {
932 output("Clearing Response Singles-Potentials");
933 get_potentials.clear_response();
934 }
935 else {
936 output("Clearing all stored Singles-Potentials");
937 get_potentials.clear_all();
938 }
939 }
940
941public:
942 // member variables
943 /// MPI World
944 World& world;
945 /// the nemo structure which holds the nuclear correlation factor and all other functions from the reference calculation
946 std::shared_ptr<const Nemo> nemo_;
947 /// CC_Parameters: All parameters (see class description)
948 const CCParameters& parameters;
949 /// ket functions of the reference determinant
950 CC_vecfunction mo_ket_;
951 /// bra function of the reference determinant: bra = R2*ket, with R^2 beiing the squared nuclear correlation factor
952 CC_vecfunction mo_bra_;
953 /// orbital energies
954 std::vector<double> orbital_energies_;
955 /// the coulomb operator with all intermediates
956public:
957 std::shared_ptr<CCConvolutionOperator<double, 3>> g12;
958 /// the f12 operator with all intermediates
959 std::shared_ptr<CCConvolutionOperator<double, 3>> f12;
960 /// the correlation factor, holds necessary regularized potentials
961 CorrelationFactor corrfac;
962 /// Manager for stored intermediate potentials which are s2c, s2b and the whole singles potentials without fock-residue for GS and EX state
963 mutable CCIntermediatePotentials get_potentials;
964 /// POD for basis and intermediates
965 Info info;
966
967public:
968 /// Messenger structure for formated output and to store warnings
969 CCMessenger output;
970};
971} /* namespace madness */
972
973#endif /* SRC_APPS_CHEM_CCPOTENTIALS_H_ */
Operators for the molecular HF and DFT code.
Definition test_derivative.cc:24
Definition CCStructures.h:571
structure for a CC Function 3D which holds an index and a type
Definition ccpairfunction.h:45
a 6D function, either in full or low rank form, possibly including an 2-particle function
Definition ccpairfunction.h:373
Definition CCStructures.h:995
void test_pairs()
Definition CCPotentials.cc:3613
static CCPair make_pair_mp2(World &world, const real_function_6d &u, const size_t i, const size_t j, const Info &info, bool compute_Q12_f12_ij)
return the regularized MP2 ansatz: |\tau_ij> = |u_ij> + Q12 f12 |ij>
Definition CCPotentials.cc:69
static void print_3d_references(World &world, const std::vector< CCPair > &pair_vec, const Info &info)
quick 3D-only Ue / GUe / GQUe references for all pairs (no 6D work)
Definition CCPotentials.cc:744
double make_xy_op_ab(const CCFunction< double, 3 > &x, const CCFunction< double, 3 > &y, const CCConvolutionOperator< double, 3 > &op, const CCFunction< double, 3 > &a, const CCFunction< double, 3 > &b) const
Definition CCPotentials.cc:2080
static real_function_3d apply_s2b_operation(World &world, const CCFunction< double, 3 > &bra, const CCPairFunction< double, 6 > &u, const size_t particle, const Info &info)
returns <a|g12|u>_2
Definition CCPotentials.cc:2103
void test_singles_potential(Info &info) const
Definition CCPotentials.cc:3691
vector_real_function_3d make_bra(const CC_vecfunction &t) const
make bra element: R^2|t>
Definition CCPotentials.h:164
vector_real_function_3d get_active_mo_bra() const
returns a vector of all active mos multiplied with the squared nuclear currelation factor: mo_bra = R...
Definition CCPotentials.h:128
CC_vecfunction mo_ket() const
Definition CCPotentials.h:149
static real_function_6d apply_Kfxy(World &world, const CCFunction< double, 3 > &x, const CCFunction< double, 3 > &y, const Info &info, const CCParameters &param)
return Kf12|xy>
Definition CCPotentials.cc:1882
void reset_nemo(const std::shared_ptr< const Nemo > nemo)
Definition CCPotentials.h:24
static double make_xy_u(const CCFunction< double, 3 > &x, const CCFunction< double, 3 > &y, const std::vector< CCPairFunction< double, 6 > > &u)
Definition CCPotentials.cc:2052
static double compute_pair_correlation_energy(World &world, const CCPair &u, const CC_vecfunction &singles, const Info &info)
Compute pair correlation energies of MP2 or CC2 Ground State.
Definition CCPotentials.cc:336
vector_real_function_3d apply_projector(const CC_vecfunction &f, const CC_vecfunction &ket_) const
Definition CCPotentials.cc:2145
static double compute_excited_pair_energy(World &world, const CCPair &d, const CC_vecfunction &x, const Info &info)
Definition CCPotentials.cc:460
vector_real_function_3d get_active_mo_ket() const
returns a vector of all active mos without nuclear correlation factor (nemos)
Definition CCPotentials.h:121
CC_vecfunction make_full_t_intermediate(const CC_vecfunction &tau) const
Definition CCPotentials.cc:3420
static std::vector< CCPairFunction< double, 6 > > get_pair_function(const Pairs< CCPair > &pairs, const size_t i, const size_t j)
Definition CCPotentials.cc:2094
double overlap(const CCPairFunction< double, 6 > &f1, const CCPairFunction< double, 6 > &f2) const
Definition CCPotentials.h:551
real_function_6d apply_transformed_Ue(const CCFunction< double, 3 > &x, const CCFunction< double, 3 > &y, const real_convolution_6d *Gscreen=NULL) const
Definition CCPotentials.cc:1500
void test()
Definition CCPotentials.cc:3816
std::vector< double > init_orbital_energies(const Nemo &nemo) const
Transfers Eigenvalues of HF MOs from Nemo (Tensor Format) to std::vector<double> format.
Definition CCPotentials.cc:56
static double get_epsilon(const size_t i, const size_t j, const Info &info)
returns epsilon_i + epsilon_j (needed for bsh operator of pairs)
Definition CCPotentials.h:116
CCFunction< double, 3 > mo_bra(const size_t &i) const
returns a specific mo multiplied with the squared nuclear correlation factor
Definition CCPotentials.h:154
void print_size(const Function< double, NDIM > &f, const std::string &msg, const bool print=true) const
print size of a function
Definition CCPotentials.h:103
bool load_function(Function< T, NDIM > &f, const std::string name, bool do_print) const
Definition CCPotentials.h:71
void plot(const vector_real_function_3d &f, const std::string &msg) const
Plotting (convenience).
Definition CCPotentials.cc:3378
double compute_cispd_energy(const CC_vecfunction &x, const Pairs< CCPair > mp2, const Pairs< CCPair > cispd) const
Compute the CIS(D) Energy Correction to CIS.
Definition CCPotentials.cc:487
real_function_6d fock_residue_6d(const CCPair &u) const
The 6D Fock residue on the cusp free pair function u_{ij}(1,2) is: (2J - Kn - Un)|u_{ij}...
Definition CCPotentials.cc:558
static CC_vecfunction make_active_t_intermediate(const CC_vecfunction &tau, const Info &info)
makes the t intermediates
Definition CCPotentials.cc:3468
real_function_6d swap_particles(const real_function_6d &f) const
dummy to avoid confusion and for convenience
Definition CCPotentials.h:536
CCPotentials(World &world_, const std::shared_ptr< const Nemo > nemo, const CCParameters &param)
Definition CCPotentials.cc:23
real_function_6d make_constant_part_cispd(const CCPair &u, const CC_vecfunction &x, const real_convolution_6d *Gscreen=NULL) const
Function evaluates the consant part of the Excited state for CIS(D) if the Q Ansatz is used.
Definition CCPotentials.cc:1161
static double make_xy_op_u(const CCFunction< double, 3 > &x, const CCFunction< double, 3 > &y, const CCConvolutionOperator< double, 3 > &op, const std::vector< CCPairFunction< double, 6 > > &u)
Definition CCPotentials.cc:2069
static real_function_6d apply_reduced_F(World &world, const CCFunction< double, 3 > &ti, const CCFunction< double, 3 > &tj, const Info &info, const real_convolution_6d *Gscreen=NULL)
Definition CCPotentials.cc:1483
double make_xy_gf_ab(const CCFunction< double, 3 > &x, const CCFunction< double, 3 > &y, const CCFunction< double, 3 > &a, const CCFunction< double, 3 > &b) const
Definition CCPotentials.cc:2032
real_function_6d make_constant_part_cispd_Qt(const CCPair &u, const CC_vecfunction &x, const real_convolution_6d *Gscreen=NULL) const
Function evaluates the consant part of the Excited state for CIS(D) if the Qt Ansatz is used.
Definition CCPotentials.cc:1230
CC_vecfunction make_mo_bra(const Nemo &nemo) const
Helper function to initialize the const mo_bra and ket elements adn orbital energies.
Definition CCPotentials.cc:36
real_function_6d apply_Vreg(const CCFunction< double, 3 > &ti, const CCFunction< double, 3 > &tj, const real_convolution_6d *Gscreen=NULL) const
Definition CCPotentials.cc:1361
real_function_6d apply_exchange_commutator(const CCFunction< double, 3 > &x, const CCFunction< double, 3 > &y, const real_convolution_6d *Gscreen=NULL) const
Definition CCPotentials.cc:2006
static real_function_3d apply_gf(World &world, const real_function_3d &f, const Info &info)
Definition CCPotentials.cc:2040
void test_pair_consistency(const CCPairFunction< double, 6 > &u, const size_t i, const size_t j, const CC_vecfunction &x) const
forms the regularized functions from Q and Qt Ansatz for CIS(D) where tau=0 and t=mo so that Qt=Q
Definition CCPotentials.cc:3494
real_function_6d apply_Q12t(const real_function_6d &f, const CC_vecfunction &t) const
Apply Qt projector on 6D function.
Definition CCPotentials.cc:2158
double get_epsilon(const size_t i, const size_t j) const
returns epsilon_i + epsilon_j (needed for bsh operator of pairs)
Definition CCPotentials.h:111
static double compute_kinetic_energy(World &world, const vector_real_function_3d &xbra, const vector_real_function_3d &xket)
Definition CCPotentials.cc:420
CC_vecfunction make_mo_ket(const Nemo &nemo) const
Helper function to initialize the const mo_bra and ket elements.
Definition CCPotentials.cc:46
static madness::real_function_6d fock_residue_6d_macrotask(World &world, const CCPair &u, const CCParameters &parameters, const std::vector< madness::Vector< double, 3 > > &all_coords_vec, const std::vector< real_function_3d > &mo_ket, const std::vector< real_function_3d > &mo_bra, const std::vector< real_function_3d > &U1, const real_function_3d &U2)
Static function for the 6D Fock residue for use in macrotask.
Definition CCPotentials.cc:649
CCFunction< double, 3 > mo_ket(const size_t &i) const
returns a specific mo
Definition CCPotentials.h:144
static real_function_6d apply_Ue(World &world, const CCFunction< double, 3 > &phi_i, const CCFunction< double, 3 > &phi_j, const Info &info, const real_convolution_6d *Gscreen)
Definition CCPotentials.cc:1583
real_function_6d apply_reduced_F1(const CCFunction< double, 3 > &ti, const CCFunction< double, 3 > &tj, const real_convolution_6d *Gscreen=NULL) const
Definition CCPotentials.cc:1461
vector_real_function_3d apply_Qt(const CC_vecfunction &f, const CC_vecfunction &ket_, const double c=1.0) const
Definition CCPotentials.cc:2180
static double compute_cis_expectation_value(World &world, const CC_vecfunction &x, const vector_real_function_3d &V, const bool print, const Info &info)
compute the expectation value excitation energy using the CIS/CCS/CC2 singles
Definition CCPotentials.cc:431
static CCPairFunction< double, 6 > apply_commutator_F_Qt_f12(World &world, const CCFunction< double, 3 > &phi_i, const CCFunction< double, 3 > &phi_j, const CC_vecfunction &gs_singles, const CC_vecfunction &ex_singles, const Info &info, const real_convolution_6d *Gscreen)
calculate [F,Qt] f12 |rhs>
Definition CCPotentials.cc:1654
std::vector< double > get_orbital_energies() const
returns a vector of all orbital energies
Definition CCPotentials.h:108
CC_vecfunction make_t_intermediate(const CC_vecfunction &tau, const CCParameters &parameters) const
Definition CCPotentials.cc:3394
static CCPairFunction< double, 6 > apply_commutator_F_dQt_f12(World &world, const CCFunction< double, 3 > &phi_i, const CCFunction< double, 3 > &phi_j, const CC_vecfunction &gs_singles, const CC_vecfunction &ex_singles, const Info &info, const real_convolution_6d *Gscreen)
calculate [F,dQt] f12 |rhs>
Definition CCPotentials.cc:1684
double compute_cc2_excitation_energy(const CC_vecfunction &stau, const CC_vecfunction &sx, const Pairs< CCPair > dtau, const Pairs< CCPair > dx) const
Compute the CC2 Excitation Energy.
Definition CCPotentials.cc:537
real_function_6d make_6D_pair(const CCPair &pair) const
Returns the full 6D function from a CCPair structure (only recommended for debug purposes).
Definition CCPotentials.cc:3592
static std::vector< CCPairFunction< double, 6 > > swap_particles(const std::vector< CCPairFunction< double, 6 > > &f)
swap the particles of the CCPairFunction and return a new vector of swapped functions
Definition CCPotentials.h:541
bool test_compare_pairs(const CCPair &pair1, const CCPair &pair2) const
Definition CCPotentials.cc:3547
CCPair make_pair_gs(const real_function_6d &u, const CC_vecfunction &tau, const size_t i, const size_t j) const
Definition CCPotentials.cc:182
CCPair make_pair_ex(const real_function_6d &u, const CC_vecfunction &tau, const CC_vecfunction &x, const size_t i, const size_t j, const CalcType ctype) const
Definition CCPotentials.cc:237
static std::vector< CCPairFunction< double, 6 > > apply_KffK(World &world, const CCFunction< double, 3 > &phi_i, const CCFunction< double, 3 > &phi_j, const LowRankFunction< double, 6 > &exchange_op, const Info &info, const real_convolution_6d *Gscreen)
Definition CCPotentials.cc:1715
double make_xy_ff_ab(const CCFunction< double, 3 > &x, const CCFunction< double, 3 > &y, const CCFunction< double, 3 > &a, const CCFunction< double, 3 > &b) const
Definition CCPotentials.h:477
vector_real_function_3d get_mo_bra(const CC_vecfunction &ket) const
get the corresponding mo bra vectors to a ket vector
Definition CCPotentials.h:135
vector_real_function_3d make_bra(const vector_real_function_3d &t) const
Definition CCPotentials.h:168
CC_vecfunction mo_bra() const
Definition CCPotentials.h:159
static CCPair make_pair_cc2(World &world, const real_function_6d &u, const CC_vecfunction &gs_singles, const size_t i, const size_t j, const Info &info, const bool compute_Q12_f12_ij)
return the regularized CC2 ansatz: |\tau_ij> = |u_ij> + Q12t f12 |t_i t_j>
Definition CCPotentials.cc:97
static madness::real_function_6d make_constant_part_macrotask(World &world, const CCPair &pair, const CC_vecfunction &gs_singles, const CC_vecfunction &ex_singles, const LowRankFunction< double, 6 > &exchange_op, const Info &info)
the constant part is the contribution to the doubles that are independent of the doubles
Definition CCPotentials.cc:774
static double compute_cc2_correlation_energy(World &world, const CC_vecfunction &singles, const Pairs< CCPair > &doubles, const Info &info, const std::string msg="")
Definition CCPotentials.cc:386
static CCPair make_pair_lrcc2(World &world, const CalcType &ctype, const real_function_6d &u, const CC_vecfunction &gs_singles, const CC_vecfunction &ex_singles, const size_t i, const size_t j, const Info &info, const bool compute_Q12_f12)
return the regularized CC2 ansatz: |x_ij> = |u_ij> + Q12t f12 |t_i t_j> + ?????
Definition CCPotentials.cc:128
virtual ~CCPotentials()
Definition CCPotentials.h:48
Info update_info(const CCParameters &parameters, const std::shared_ptr< const Nemo > nemo) const
Definition CCPotentials.h:31
static std::vector< CCPairFunction< double, 6 > > apply_f12_coupling(World &world, const CCFunction< double, 3 > &phi_i, const CCFunction< double, 3 > &phi_j, const Info &info, const real_convolution_6d *Gscreen)
compute the coupled f12 contributions: f12 (\sum_k f_jk |ik> + f_ik |kj>)
Definition CCPotentials.cc:1855
static CCPair iterate_pair_macrotask(World &world, const CCPair &pair, const CC_vecfunction &gs_singles, const CC_vecfunction &ex_singles, const real_function_6d &coupling, const Info &info, const long maxiter)
iterate a pair for MP2, CC2, LRCC2 on constant singles
Definition CCPotentials.cc:1060
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:183
A multiresolution adaptive numerical function.
Definition mra.h:141
double norm2() const
Returns the 2-norm of the function ... global sum ... works in either basis.
Definition mra.h:853
LowRankFunction represents a hi-dimensional (NDIM) function as a sum of products of low-dimensional (...
Definition lowrankfunction.h:752
The Nemo class.
Definition nemo.h:377
A simple, fixed dimension vector.
Definition vector.h:64
A parallel world class.
Definition world.h:134
Wraps an archive around a binary filestream for input.
Definition binary_fstream_archive.h:104
An archive for storing local or parallel data, wrapping a BinaryFstreamInputArchive.
Definition parallel_archive.h:366
double(* f)(const coord_3d &)
Definition derivatives.cc:54
double(* f1)(const coord_3d &)
Definition derivatives.cc:55
double(* f2)(const coord_3d &)
Definition derivatives.cc:56
const std::size_t bufsize
Definition derivatives.cc:16
static double function(const coord_3d &r)
Normalized gaussian.
Definition functionio.cc:100
const int maxiter
Definition gygi_soltion.cc:68
static double u(double r, double c)
Definition he.cc:20
static double bsh_eps
Definition helium_exact.cc:62
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
void print(const tensorT &t)
Definition mcpfit.cc:140
Runtime details on the configuration and version of MADNESS.
Definition madness.h:69
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
CalcType
Calculation Types used by CC2.
Definition CCParameters.h:14
std::vector< double > norm2s(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norms of a vector of functions.
Definition vmra.h:976
Function< TENSOR_RESULT_TYPE(Q, T), NDIM > mul(const Q alpha, const Function< T, NDIM > &f, bool fence=true)
Returns new function equal to alpha*f(x) with optional fence.
Definition mra.h:1938
FuncType
Definition ccpairfunction.h:26
@ RESPONSE
Definition ccpairfunction.h:26
std::enable_if_t< NDIM%2==0, Function< T, NDIM > > swap_particles(const Function< T, NDIM > &f)
swap particles 1 and 2
Definition mra.h:2563
@ reconstructed
s coeffs at the leaves only
Definition funcdefaults.h:61
void truncate(World &world, std::vector< Function< T, NDIM > > &v, double tol=0.0, bool fence=true)
Truncates a vector of functions.
Definition vmra.h:336
std::vector< real_function_3d > vector_real_function_3d
Definition functypedefs.h:94
Function< double, 6 > real_function_6d
Definition functypedefs.h:83
NDIM & f
Definition mra.h:2817
void error(const char *msg)
Definition world.cc:147
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition timers.cc:48
Function< double, 3 > real_function_3d
Definition functypedefs.h:80
void print(const T &t, Ts &&... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:232
Function< T, CCPairFunction< T, NDIM >::LDIM > inner(const CCPairFunction< T, NDIM > &c, const Function< T, CCPairFunction< T, NDIM >::LDIM > &f, const std::tuple< int, int, int > v1, const std::tuple< int, int, int > v2)
Definition ccpairfunction.h:1007
PotentialType
CC2 Singles Potentials.
Definition CCStructures.h:32
SeparatedConvolution< double, 6 > real_convolution_6d
Definition functypedefs.h:139
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
void save(const Function< T, NDIM > &f, const std::string name)
Definition mra.h:3175
@ nemo
nemo's regularized orbitals F = psi/R
Definition Restart.h:60
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
static const double c
Definition relops.cc:10
Definition CCParameters.h:20
Timer Structure.
Definition CCStructures.h:131
A helper structure which holds a map of functions.
Definition CCStructures.h:334
vector_real_function_3d get_vecfunction() const
Returns all the functions of the map as vector.
Definition CCStructures.h:523
CC_functionmap functions
Definition CCStructures.h:471
POD holding some basic functions and some intermediates for the CC2 calculation.
Definition CCStructures.h:919
Definition CCStructures.h:246
Definition lowrankfunction.h:387
pcomplex_operatorT G
Definition tdse1d.cc:167
static double V(const coordT &r)
Definition tdse.cc:288
InputParameters param
Definition tdse.cc:203
Kernels< TDA, ClosedShell > K
Definition test_es_build_subworld.cpp:40
void e()
Definition test_sig.cc:75
F residual(const F &f)
Definition testcomplexfunctionsolver.cc:69