MADNESS 0.10.1
CC2.h
Go to the documentation of this file.
1/*
2 * CC2.h
3 *
4 * Created on: Aug 17, 2015
5 * Author: kottmanj
6 */
7
8#ifndef CC2_H_
9#define CC2_H_
10
12#include<madness/chem/SCF.h>
13#include<madness/chem/nemo.h>
15#include<madness/chem/mp3.h>
17#include <madness/mra/mra.h>
18#include <madness/mra/vmra.h>
19#include <madness/mra/lbdeux.h>
20#include <madness/misc/ran.h>
21#include<madness/chem/TDHF.h>
23
24#include "BSHApply.h"
25
26namespace madness {
27
29public:
30
31 CC2(World& world_, const commandlineparser& parser, const std::shared_ptr<Nemo> nemo_)
32 : world(world_),
33 parameters(world_,parser),
34 nemo(nemo_),
37
38 output.section("CC2 Class has been initialized with the following parameters");
39 // set the threshholds
40 // Set Protocoll
41 output("Set Protocol 3D");
42 nemo_->get_calc()->set_protocol<3>(world, parameters.thresh_3D());
43 output("Set Protocol 6D");
44 nemo_->get_calc()->set_protocol<6>(world, parameters.thresh_6D());
45
48 // Make sure that k is the same in 3d and 6d functions
50 // by default SCF sets the truncate_mode to 1
53 // set initial level to 3 (important to avoid undersampling issues)
54 // the "real initial level" is then 2 since the initial level gets substracted by one if refine is true (which is the default)
63
64 tdhf.reset(new TDHF(world,parser,nemo));
65
66 }
67
68 virtual ~CC2() {}
69
70
71 double value() {
72 return value(nemo->molecule().get_all_coords());
73 }
74
75 double value(const Tensor<double>& x) {
76 solve();
77 return 0.0;
78 }
79
80 void output_calc_info_schema(const std::string model, const double& energy) const;
81
82
83 std::string name() const {return "CC2";};
84
85 static void help() {
86 print_header2("help page for CC2");
87 print("The CC2 code computes correlated ground and excited state energies:\n");
88 print(" - MP2 ground state");
89 print(" - CC2 ground and excited states");
90 print(" - ADC(2) and CIS(D) excited states\n");
91 print("You need a SCF reference calculation from the nemo program. If there no such calculation can");
92 print("be found CC2 will perform its own. If excited states are requested also a CIS calculation is ");
93 print("necessary.\n");
94 print("Note that for correlated calculations the k parameter must be chosen small, typically k=5 or k=6 ");
95 print("because the curse of dimensions make higher k extremely expensive\n");
96 print("You can print all available calculation parameters by running\n");
97 print("cc2 --print_parameters\n");
98 print("You can perform a simple MP2 calculation by running\n");
99 print("cc2 --geometry=h2o.xyz\n");
100 print("provided you have an xyz file in your directory.\n");
101
102 }
103
104 static void print_parameters() {
106 print("\ndefault parameters for the cc2 program are\n");
107 param.print("cc2","end");
108 print("\n\nthe molecular geometry must be specified in a separate block:");
110 }
111
112 virtual bool selftest() {
113 return true;
114 };
115 void
116 plot(const real_function_3d& f, const std::string& msg = "unspecified function") const {
117 plot_plane(world, f, msg);
118 output("Plotted " + msg);
119 }
120
121 /// The World
123 /// Structure holds all the parameters used in the CC2 calculation
125 /// The SCF Calculation
126 std::shared_ptr<Nemo> nemo;
127 /// The excited state cis calculation
128 std::shared_ptr<TDHF> tdhf;
129 /// The CC Operator Class
130 CCPotentials CCOPS;
131 /// Formated Output (same as used in CC2Potentials structure)
133 /// map Pair struct to vector
135
136 /// solve the CC2 ground state equations, returns the correlation energy
137 void solve();
138
139
140 std::vector<CC_vecfunction>
141 solve_ccs() const;
142
143 double compute_mp3(const Pairs<CCPair>& mp2pairs) const {
144 MP3 mp3(CCOPS);
145 double mp3_contribution=mp3.mp3_energy_contribution_macrotask_driver(mp2pairs);
146 return mp3_contribution;
147 }
148
149 double
150 solve_cc2(CC_vecfunction& tau, Pairs<CCPair>& u, Info& info) const;
151
152 /// solve the excited state LR-CC2 equations for a given excitation
153
154 /// @param[in] gs_doubles: the ground state doubles
155 /// @param[in] gs_singles: the ground state singles
156 /// @param[in] cis: the CIS singles
157 /// @param[in] excitation: the excitation number
158 /// @return a tuple with the excited state doubles, the excited state singles and the excitation energy
159 std::tuple<Pairs<CCPair>, CC_vecfunction, double>
160 solve_lrcc2(Pairs<CCPair>& gs_doubles, const CC_vecfunction& gs_singles, const CC_vecfunction& cis,
161 const std::size_t excitation, Info& info) const;
162
163 double
164 solve_cispd(Pairs<CCPair>& doubles, const Pairs<CCPair>& mp2_pairs, const CC_vecfunction& cis_singles);
165
166 /// convencience function to iterate the CC2 ground state singles,
167 /// makes the right call on the iterate_singles functions
168 static bool
170 // CCOPS.clear_potentials(singles);
172 Pairs<CCPair> empty;
173 return iterate_singles(world, singles, CC_vecfunction(RESPONSE), doubles,
174 empty, CT_CC2, info.parameters.iter_max_3D(), info);
175 }
176
177 bool
179 MADNESS_ASSERT(singles.type == RESPONSE);
180 // CCOPS.clear_potentials(singles);
182 return iterate_singles(world, singles, CC_vecfunction(UNDEFINED), mp2, x, CT_ADC2, parameters.iter_max_3D(), info);
183 }
184
185 static bool
187 MADNESS_ASSERT(cc2_s.type == PARTICLE);
188 MADNESS_ASSERT(lrcc2_s.type == RESPONSE);
190 // CCOPS.clear_potentials(lrcc2_s);
191 return iterate_singles(world, lrcc2_s, cc2_s, cc2_d, lrcc2_d,
192 CT_LRCC2, info.parameters.iter_max_3D(), info);
193 }
194
195 /// convencience function to iterate the CCS Response singles,
196 /// makes the right call on the iterate_singles functions
197 bool
199 Pairs<CCPair> empty;
200 // CCOPS.clear_potentials(x);
202 return iterate_singles(world, x, CC_vecfunction(PARTICLE), empty, empty, CT_LRCCS, info.parameters.iter_max_3D(), info);
203 }
204
205 static bool
206 /// Iterates the singles equations for CCS, CC2, LRCC2
207 /// The corresponding regulairzation tails of the doubles are updated in every iteration (therefore doubles are not marked as const)
208 /// @param[in] : singles, the singles that are iterated
209 /// @param[in] : singles2, additional set of singles for potential (in LRCC2 this are the Ground State singles)
210 /// @param[in] : gs_doubles, Ground State doubles (Needed for CC2 and LRCC2)
211 /// @param[in] : ex_doubles, Excited State doubles (Needed for LRCC2)
212 /// @param[in] : ctype: the calculation type: CCS, CC2, CC2_response_
213 /// @param[in] : maxiter: maxmial number of iterations
214 /// @param[out]: true if the overall change of the singles is below 10*donv_6D
215 iterate_singles(World& world, CC_vecfunction& singles, const CC_vecfunction singles2, Pairs<CCPair>& gs_doubles,
216 Pairs<CCPair>& ex_doubles, const CalcType ctype, const std::size_t maxiter, Info& info) {
218 output.subsection("Iterate " + assign_name(ctype) + "-Singles");
219 CCTimer time_all(world, "Overall Iteration of " + assign_name(ctype) + "-Singles");
220 bool converged = true;
221
222 CC_vecfunction old_singles(singles);
223 for (auto& tmp : singles.functions)
224 old_singles(tmp.first).function = copy(tmp.second.function);
225 double old_omega=0.0;
226
227 // KAIN solver
229 typedef XNonlinearSolver<std::vector<Function<double, 3> >, double, allocT> solverT;
230 solverT solver(allocT(world, singles.size()));
231 solver.do_print = (world.rank() == 0);
232
233 print_size(world, singles.get_vecfunction(), "singles before iteration");
234
235 for (size_t iter = 0; iter < maxiter; iter++) {
236 // output.subsection("Microiteration " + std::to_string(iter) + " of " + assign_name(ctype) + "-Singles");
237 // CCTimer time(world, "Microiteration " + std::to_string(iter) + " of " + assign_name(ctype) + "-Singles");
238 double omega = 0.0;
239 if (ctype == CT_LRCC2) omega = singles.omega;
240 else if (ctype == CT_LRCCS) omega = singles.omega;
241 else if (ctype == CT_ADC2) omega = singles.omega;
242 print("omega 1" ,omega);
243
244 // consistency check
245 switch (ctype) {
246 case CT_CC2:
247 if (singles.type != PARTICLE)
248 output.warning("iterate_singles: CC2 demanded but singles are not of type PARTICLE");
249 break;
250 case CT_MP2: MADNESS_EXCEPTION("Demanded Singles Calculation for MP2 ????", 1);
251 break;
252 case CT_LRCC2:
253 if (singles.type != RESPONSE or singles2.type != PARTICLE)
254 output.warning("iterate_singles: CC2_response_ singles have wrong types");
255 break;
256 case CT_LRCCS:
257 if (singles.type != RESPONSE)
258 output.warning("iterate_singles: CCS_response_ singles have wrong types");
259 break;
260 case CT_CISPD: MADNESS_EXCEPTION("Demanded Singles Calculation for CIS(D)", 1);
261 break;
262 case CT_ADC2:
263 MADNESS_ASSERT(singles.type == RESPONSE);
264 break;
265 case CT_TEST: MADNESS_EXCEPTION("Iterate Singles not implemented for Experimental calculation", 1);
266 break;
267 default: MADNESS_EXCEPTION(
268 ("Unknown calculation type in iterate singles: " + assign_name(ctype)).c_str(), 1);
269 }
270
271 // get potentials
272 CCTimer time_V(world, assign_name(ctype) + "-Singles Potential");
274 if (ctype == CT_CC2) V = CCPotentials::get_CC2_singles_potential_gs(world, singles, gs_doubles, info);
275 else if (ctype == CT_LRCC2)
276 V = CCPotentials::get_CC2_singles_potential_ex(world, singles2, gs_doubles, singles, ex_doubles, info);
277 else if (ctype == CT_LRCCS) V = CCPotentials::get_CCS_potential_ex(world,singles,false, info);
278 // else if (ctype == CT_ADC2) V = CCOPS.get_ADC2_singles_potential(world, gs_doubles, singles, ex_doubles, info);
279 else MADNESS_EXCEPTION("iterate singles: unknown type", 1);
280
281 // add local coupling
283 truncate(world, V);
284 time_V.info(true, norm2(world, V));
285
286 // update excitation energy
287 if (ctype==CT_LRCC2 or ctype==CT_LRCCS or ctype==CT_ADC2) {
288 old_omega=omega;
289 omega = CCPotentials::compute_cis_expectation_value(world, singles, V, true, info);
290 singles.omega = omega;
291 }
292 if (world.rank()==0 and info.parameters.debug())
293 print("omega entering the update in the singles" ,omega);
294
295 // make bsh operators
296 scale(world, V, -2.0); // moved to BSHApply
297 std::vector<std::shared_ptr<SeparatedConvolution<double, 3> > > G(singles.size());
298 for (size_t i = 0; i < G.size(); i++) {
299 const double bsh_eps = info.orbital_energies[i + info.parameters.freeze()] + omega;
300 G[i] = std::shared_ptr<SeparatedConvolution<double, 3> >(
301 BSHOperatorPtr3D(world, sqrt(-2.0 * bsh_eps), info.parameters.lo(), info.parameters.thresh_bsh_3D()));
302 }
303 world.gop.fence();
304
305 // apply bsh operators
306 CCTimer time_applyG(world, "Apply G-Operators");
307 vector_real_function_3d GV = apply<SeparatedConvolution<double, 3>, double, 3>(world, G, V);
308 world.gop.fence();
309 time_applyG.info();
310
311 // apply Q-Projector to result
313 GV = Q(GV);
314
315 // Normalize Singles if it is excited state
316 if (ctype == CT_LRCCS or ctype == CT_LRCC2 or ctype == CT_ADC2) {
317 output("Normalizing new singles");
318 const double norm=inner(GV,info.R_square*GV);
319 scale(world, GV, 1.0 / norm);
320 } else output("Singles not normalized");
321
322 // residual
324
325 // information
326 const Tensor<double> R2xinnerx = inner(world, info.R_square*singles.get_vecfunction(),
327 singles.get_vecfunction());
328 const Tensor<double> R2GVinnerGV = inner(world, info.R_square*GV, GV);
329 const Tensor<double> R2rinnerr = inner(world, info.R_square*residual, residual);
330 const double R2vector_error = sqrt(R2rinnerr.sum());
331 auto [rmsresidual, maxresidual]=CCPotentials::residual_stats(residual);
332
333 // print information
334 if (world.rank() == 0) std::cout << "\n\n-----Results of current interation:-----\n";
335 if (world.rank() == 0)
336 std::cout << "\nName: ||" << singles.name(0) << "||, ||GV" << singles.name(0) << ", ||residual||" << "\n";
337 if (world.rank() == 0)
338 std::cout << singles.name(0) << ": " << std::scientific << std::setprecision(info.parameters.output_prec())
339 << sqrt(R2xinnerx.sum()) << ", " << sqrt(R2GVinnerGV.sum()) << ", " << sqrt(R2rinnerr.sum())
340 << "\n----------------------------------------\n";
341 for (size_t i = 0; i < GV.size(); i++) {
342 if (world.rank() == 0)
343 std::cout << singles(i + info.parameters.freeze()).name() << ": " << std::scientific
344 << std::setprecision(info.parameters.output_prec())
345 << sqrt(R2xinnerx(i)) << ", " << sqrt(R2GVinnerGV(i)) << ", " << sqrt(R2rinnerr(i))
346 << "\n";
347 }
348 if (world.rank() == 0) std::cout << "\n----------------------------------------\n\n";
349
350 // make second order update (only for response)
351 if (ctype == CT_LRCC2 or ctype == CT_LRCCS) {
352 double Rtmp = inner(world, info.R_square*residual, V).sum();
353 double Rtmp2 = inner(world, info.R_square*GV, GV).sum();
354 const double Rdelta = (0.5 * Rtmp / Rtmp2);
355 if (world.rank() == 0) std::cout << "omega, second-order update (FYI): " << std::fixed
356 << std::setprecision(info.parameters.output_prec() + 2) << omega << ", " << Rdelta << "\n\n";
357 }
358
359 // update singles
360 singles.omega = omega;
361 vector_real_function_3d new_singles = truncate(GV);
362 if (info.parameters.kain()) new_singles = solver.update(singles.get_vecfunction(), residual);
363 if (info.parameters.debug()) print_size(world, new_singles, "new_singles");
364 // if (ctype == CT_LRCCS or ctype == CT_LRCC2 or ctype == CT_ADC2) Nemo::normalize(new_singles, info.R);
365 // if (info.parameters.debug()) print_size(world, new_singles, "new_singles normalized");
366
367 for (size_t i = 0; i < GV.size(); i++) {
368 singles(i + info.parameters.freeze()).function = copy(new_singles[i]);
369 }
370
371 // update reg_residues of doubles
372 if (ctype==CT_CC2) update_reg_residues_gs(world, singles,gs_doubles, info);
373 else if(ctype==CT_LRCC2) update_reg_residues_ex(world, singles2,singles,ex_doubles, info);
374
375 if (world.rank()==0) CCPotentials::print_convergence(singles.name(0),rmsresidual,
376 rmsresidual,omega-old_omega,iter);
377 converged = (R2vector_error < info.parameters.dconv_3D());
378
379 // time.info();
380 if (converged) break;
381 if (ctype == CT_LRCCS) break; // for CCS just one iteration to check convergence
382 }
383 time_all.info();
384 print_size(world, singles.get_vecfunction(), "singles after iteration");
385
386 // Assign the overall changes
387 bool no_change = true;
388 if (world.rank() == 0)
389 std::cout << "Change in Singles functions after all the Microiterations" << std::endl;
390 for (auto& tmp : singles.functions) {
391 const double change = (tmp.second.function - old_singles(tmp.first).function).norm2();
392 tmp.second.current_error = change;
393 if (change > info.parameters.dconv_3D()) no_change = false;
394 if (world.rank() == 0)
395 std::cout << "Change of " << tmp.second.name() << "=" << tmp.second.current_error << std::endl;
396 }
397 // update reg_residues of doubles
398 if (ctype == CT_CC2) update_reg_residues_gs(world, singles, gs_doubles, info);
399 else if (ctype == CT_LRCC2) update_reg_residues_ex(world, singles2, singles, ex_doubles, info);
400
401 //CCOPS.plot(singles);
402 if (no_change) output("Change of Singles was below = " + std::to_string(info.parameters.dconv_3D()) + "!");
403 return no_change;
404 }
405
406 /// store singles to file
407 void store_singles(const CC_vecfunction& singles, const int ex = -1) const;
408
409 /// read singles from file or initialize new ones
410 CC_vecfunction initialize_singles(const FuncType type, const int ex = -1) const;
411
412 /// read pairs from file or initialize new ones
413 bool initialize_pairs(Pairs<CCPair>& pairs, const CCState ftype, const CalcType ctype, const CC_vecfunction& tau,
414 const CC_vecfunction& x, const size_t extitation, const Info& info) const;
415
416 static void
417 update_reg_residues_gs(World& world, const CC_vecfunction& singles, Pairs<CCPair>& doubles, const Info& info);
418
419 static void
420 update_reg_residues_ex(World& world, const CC_vecfunction& singles, const CC_vecfunction& response, Pairs<CCPair>& doubles,
421 const Info& info);
422
423 /// Iterates a pair of the CC2 doubles equations
424 bool
425 iterate_pair(CCPair& pair, const CC_vecfunction& singles = CC_vecfunction(UNDEFINED)) const;
426
427 bool
429
430 static bool
431 iterate_lrcc2_pairs(World& world, const CC_vecfunction& cc2_s, const CC_vecfunction lrcc2_s,
432 Pairs<CCPair>& lrcc2_d, const Info& info);
433
435 MADNESS_ASSERT(pair.ctype == CT_CC2);
437 // make screening Operator
438 real_convolution_6d Gscreen = BSHOperator<6>(world, sqrt(-2.0 * pair.bsh_eps), parameters.lo(),
440 Gscreen.modified() = true;
441
442 if (parameters.QtAnsatz())pair.constant_part = CCOPS.make_constant_part_cc2_Qt_gs(pair, tau, &Gscreen);
443 else pair.constant_part = CCOPS.make_constant_part_cc2_gs(pair, tau, &Gscreen);
444 save(pair.constant_part, pair.name() + "_const");
445 return true;
446 }
447
451 MADNESS_ASSERT(pair.bsh_eps == CCOPS.get_epsilon(pair.i, pair.j) + ccs.omega);
452 if (pair.constant_part.is_initialized()) return false; // the CIS(D) constant part does not change because there is no singles iteration (like MP2)
453 // make screening Operator
454 real_convolution_6d Gscreen = BSHOperator<6>(world, sqrt(-2.0 * pair.bsh_eps), parameters.lo(),
456 Gscreen.modified() = true;
457
458 if (parameters.QtAnsatz()) pair.constant_part = CCOPS.make_constant_part_cispd_Qt(pair, ccs, &Gscreen);
459 else pair.constant_part = CCOPS.make_constant_part_cispd(pair, ccs, &Gscreen);
460 save(pair.constant_part, pair.name() + "_const");
461 return true;
462
463 }
464
466 std::cout << assign_name(pair.ctype);
469 MADNESS_ASSERT(pair.bsh_eps == CCOPS.get_epsilon(pair.i, pair.j) + ccs.omega);
470 // make screening Operator
471 real_convolution_6d Gscreen = BSHOperator<6>(world, sqrt(-2.0 * pair.bsh_eps), parameters.lo(),
473 Gscreen.modified() = true;
474
475 if (parameters.QtAnsatz()) pair.constant_part = CCOPS.make_constant_part_cispd_Qt(pair, ccs, &Gscreen);
476 else pair.constant_part = CCOPS.make_constant_part_cispd(pair, ccs, &Gscreen);
477 save(pair.constant_part, pair.name() + "_const");
478 return true;
479
480 }
481
486
487 // make screening Operator
488 real_convolution_6d Gscreen = BSHOperator<6>(world, sqrt(-2.0 * pair.bsh_eps), parameters.lo(),
490 Gscreen.modified() = true;
491
492 if (parameters.QtAnsatz())pair.constant_part = CCOPS.make_constant_part_cc2_Qt_ex(pair, tau, x, &Gscreen);
493 else pair.constant_part = CCOPS.make_constant_part_cc2_ex(pair, tau, x, &Gscreen);
494 save(pair.constant_part, pair.name() + "_const");
495 return true;
496 }
497
498 /// forward to the other function (converting CCPair to real_function)
499 static Pairs<real_function_6d> compute_local_coupling(const std::vector<CCPair> &vpairs, const Info& info) {
500 // create new pairs structure
501 Pairs<CCPair> pairs;
502 for (auto& tmp_pair : vpairs) pairs.insert(tmp_pair.i, tmp_pair.j, tmp_pair);
503 auto ccpair2function = [](const CCPair& a) {return a.function();};
504 return compute_local_coupling(pairs.convert<real_function_6d>(pairs,ccpair2function), info);
505 };
506
507 /// compute the coupling of singles function if orbitals are localized
508
509 /// @return the coupling terms c_i = -\sum_(j\neq i) f_ij |\phi_j> (for whatever phi is)
510 static std::vector<real_function_3d> compute_local_coupling(const std::vector<real_function_3d>& singles,
511 const Info& info) {
512
513 MADNESS_CHECK_THROW(singles.size()>0,"compute_local_coupling: singles vector is empty");
514 World& world=singles.front().world();
515 auto active=Slice(info.parameters.freeze(),-1);
516 Tensor<double> Fact=info.fock(active,active);
517 for (int i=0; i<Fact.dim(0); ++i) Fact(i,i)=0.0;
518 vector_real_function_3d fock_coupling = madness::transform(world, singles, Fact);
519 return fock_coupling;
520 }
521
522 /// add the coupling terms for local MP2
523
524 /// \sum_{k\neq i} f_ki |u_kj> + \sum_{l\neq j} f_lj |u_il>
526
527
528 double solve_mp2_coupled(Pairs<CCPair> &doubles, Info& info);
529
530 bool check_core_valence_separation(const Tensor<double>& fmat) const;
531
532 /// @return the new fock matrix
534};
535
536
537} /* namespace madness */
538
539#endif /* CC2_H_ */
Definition test_derivative.cc:24
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
Definition CC2.h:28
CC_vecfunction initialize_singles(const FuncType type, const int ex=-1) const
read singles from file or initialize new ones
Definition CC2.cc:1053
double solve_cispd(Pairs< CCPair > &doubles, const Pairs< CCPair > &mp2_pairs, const CC_vecfunction &cis_singles)
Definition CC2.cc:621
CCMessenger & output
Formated Output (same as used in CC2Potentials structure)
Definition CC2.h:132
static bool iterate_singles(World &world, CC_vecfunction &singles, const CC_vecfunction singles2, Pairs< CCPair > &gs_doubles, Pairs< CCPair > &ex_doubles, const CalcType ctype, const std::size_t maxiter, Info &info)
Definition CC2.h:215
Tensor< double > enforce_core_valence_separation(const Tensor< double > &fmat)
Definition CC2.cc:347
bool iterate_ccs_singles(CC_vecfunction &x, Info &info) const
Definition CC2.h:198
void store_singles(const CC_vecfunction &singles, const int ex=-1) const
store singles to file
virtual bool selftest()
Definition CC2.h:112
double solve_mp2_coupled(Pairs< CCPair > &doubles, Info &info)
Definition CC2.cc:417
void output_calc_info_schema(const std::string model, const double &energy) const
Definition CC2.cc:327
World & world
The World.
Definition CC2.h:122
static void update_reg_residues_gs(World &world, const CC_vecfunction &singles, Pairs< CCPair > &doubles, const Info &info)
Definition CC2.cc:1132
static void help()
Definition CC2.h:85
CCParameters parameters
Structure holds all the parameters used in the CC2 calculation.
Definition CC2.h:124
double compute_mp3(const Pairs< CCPair > &mp2pairs) const
Definition CC2.h:143
void solve()
solve the CC2 ground state equations, returns the correlation energy
Definition CC2.cc:19
static void update_reg_residues_ex(World &world, const CC_vecfunction &singles, const CC_vecfunction &response, Pairs< CCPair > &doubles, const Info &info)
Definition CC2.cc:1150
static bool iterate_cc2_singles(World &world, CC_vecfunction &singles, Pairs< CCPair > &doubles, Info &info)
Definition CC2.h:169
std::tuple< Pairs< CCPair >, CC_vecfunction, double > solve_lrcc2(Pairs< CCPair > &gs_doubles, const CC_vecfunction &gs_singles, const CC_vecfunction &cis, const std::size_t excitation, Info &info) const
solve the excited state LR-CC2 equations for a given excitation
Definition CC2.cc:883
bool update_constant_part_adc2(const CC_vecfunction &ccs, CCPair &pair)
Definition CC2.h:465
bool update_constant_part_cispd(const CC_vecfunction &ccs, CCPair &pair)
Definition CC2.h:448
CC2(World &world_, const commandlineparser &parser, const std::shared_ptr< Nemo > nemo_)
Definition CC2.h:31
bool iterate_adc2_singles(Pairs< CCPair > &mp2, CC_vecfunction &singles, Pairs< CCPair > &x, Info &info)
Definition CC2.h:178
static void print_parameters()
Definition CC2.h:104
static Pairs< real_function_6d > compute_local_coupling(const std::vector< CCPair > &vpairs, const Info &info)
forward to the other function (converting CCPair to real_function)
Definition CC2.h:499
std::shared_ptr< Nemo > nemo
The SCF Calculation.
Definition CC2.h:126
double value()
Definition CC2.h:71
double solve_cc2(CC_vecfunction &tau, Pairs< CCPair > &u, Info &info) const
Definition CC2.cc:755
bool update_constant_part_cc2_gs(const CC_vecfunction &tau, CCPair &pair)
Definition CC2.h:434
std::vector< CC_vecfunction > solve_ccs() const
Definition CC2.cc:392
virtual ~CC2()
Definition CC2.h:68
PairVectorMap triangular_map
map Pair struct to vector
Definition CC2.h:134
static bool iterate_lrcc2_pairs(World &world, const CC_vecfunction &cc2_s, const CC_vecfunction lrcc2_s, Pairs< CCPair > &lrcc2_d, const Info &info)
Definition CC2.cc:676
static std::vector< real_function_3d > compute_local_coupling(const std::vector< real_function_3d > &singles, const Info &info)
compute the coupling of singles function if orbitals are localized
Definition CC2.h:510
CCPotentials CCOPS
The CC Operator Class.
Definition CC2.h:130
bool check_core_valence_separation(const Tensor< double > &fmat) const
Definition CC2.cc:339
static bool iterate_lrcc2_singles(World &world, const CC_vecfunction &cc2_s, Pairs< CCPair > &cc2_d, CC_vecfunction &lrcc2_s, Pairs< CCPair > lrcc2_d, Info &info)
Definition CC2.h:186
double value(const Tensor< double > &x)
Should return the value of the objective function.
Definition CC2.h:75
bool iterate_pair(CCPair &pair, const CC_vecfunction &singles=CC_vecfunction(UNDEFINED)) const
Iterates a pair of the CC2 doubles equations.
Definition CC2.cc:945
bool iterate_adc2_pairs(Pairs< CCPair > &cispd, const CC_vecfunction &ccs)
Definition CC2.cc:659
std::shared_ptr< TDHF > tdhf
The excited state cis calculation.
Definition CC2.h:128
std::string name() const
Definition CC2.h:83
bool update_constant_part_lrcc2(CCPair &pair, const CC_vecfunction &tau, const CC_vecfunction &x)
Definition CC2.h:482
void plot(const real_function_3d &f, const std::string &msg="unspecified function") const
Definition CC2.h:116
bool initialize_pairs(Pairs< CCPair > &pairs, const CCState ftype, const CalcType ctype, const CC_vecfunction &tau, const CC_vecfunction &x, const size_t extitation, const Info &info) const
read pairs from file or initialize new ones
Definition CC2.cc:1077
Definition CCStructures.h:956
std::string name() const
Definition CCStructures.h:1086
size_t i
Definition CCStructures.h:972
real_function_6d constant_part
the constant part
Definition CCStructures.h:1079
size_t j
Definition CCStructures.h:973
CCState type
Definition CCStructures.h:970
double bsh_eps
Definition CCStructures.h:1084
CalcType ctype
Definition CCStructures.h:971
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:204
static void set_truncate_mode(int value)
Sets the default truncation mode.
Definition funcdefaults.h:338
static void set_thresh(double value)
Sets the default threshold.
Definition funcdefaults.h:286
static void set_special_level(int value)
Existing functions are unaffected.
Definition funcdefaults.h:309
static void set_k(int value)
Sets the default wavelet order.
Definition funcdefaults.h:273
static void set_initial_level(int value)
Sets the default initial projection level.
Definition funcdefaults.h:303
bool is_initialized() const
Returns true if the function is initialized.
Definition mra.h:147
Definition mp3.h:21
double mp3_energy_contribution_macrotask_driver(const Pairs< CCPair > &mp2pairs) const
compute the MP3 energy contribution, macrotask version
Definition mp3.cc:928
static void print_parameters()
Definition molecule.cc:110
class implementing properties of QC models
Definition QCPropertyInterface.h:11
orthogonality projector
Definition projector.h:186
Convolutions in separated form (including Gaussian)
Definition operator.h:136
bool & modified()
Definition operator.h:176
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
Definition TDHF.h:24
A tensor is a multidimension array.
Definition tensor.h:317
T sum() const
Returns the sum of all elements of the tensor.
Definition tensor.h:1662
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:161
A parallel world class.
Definition world.h:132
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:318
WorldGopInterface & gop
Global operations.
Definition world.h:205
Generalized version of NonlinearSolver not limited to a single madness function.
Definition nonlinsol.h:202
double(* energy)()
Definition derivatives.cc:58
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
Implements (2nd generation) static load/data balancing for functions.
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
Main include file for MADNESS and defines Function interface.
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
CalcType
Calculation Types used by CC2.
Definition CCStructures.h:27
@ CT_CC2
Definition CCStructures.h:28
@ CT_LRCC2
Definition CCStructures.h:28
@ CT_LRCCS
Definition CCStructures.h:28
@ CT_CISPD
Definition CCStructures.h:28
@ CT_TEST
Definition CCStructures.h:28
@ CT_MP2
Definition CCStructures.h:28
@ CT_ADC2
Definition CCStructures.h:28
void print_header2(const std::string &s)
medium section heading
Definition print.cc:54
response_space scale(response_space a, double b)
Function< TENSOR_RESULT_TYPE(L, R), NDIM > sub(const Function< L, NDIM > &left, const Function< R, NDIM > &right, bool fence=true)
Same as operator- but with optional fence and no automatic compression.
Definition mra.h:1971
void truncate(World &world, response_space &v, double tol, bool fence)
Definition basic_operators.cc:30
CCState
Type of Pairs used by CC_Pair2 class.
Definition CCStructures.h:31
@ GROUND_STATE
Definition CCStructures.h:32
@ EXCITED_STATE
Definition CCStructures.h:32
FuncType
Definition ccpairfunction.h:26
@ RESPONSE
Definition ccpairfunction.h:26
@ UNDEFINED
Definition ccpairfunction.h:26
@ PARTICLE
Definition ccpairfunction.h:26
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition vmra.h:689
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition vmra.h:851
std::vector< real_function_3d > vector_real_function_3d
Definition functypedefs.h:79
void plot_plane(World &world, const Function< double, NDIM > &function, const std::string name)
Definition funcplot.h:621
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:225
static SeparatedConvolution< double, 3 > * BSHOperatorPtr3D(World &world, double mu, double lo, double eps, const BoundaryConditions< 3 > &bc=FunctionDefaults< 3 >::get_bc(), int k=FunctionDefaults< 3 >::get_k())
Factory function generating separated kernel for convolution with exp(-mu*r)/(4*pi*r) in 3D.
Definition operator.h:2023
void print_size(World &world, const std::vector< Function< T, NDIM > > &v, const std::string &msg="vectorfunction")
Definition vmra.h:1679
NDIM & f
Definition mra.h:2416
double inner(response_space &a, response_space &b)
Definition response_functions.h:442
std::string type(const PairType &n)
Definition PNOParameters.h:18
std::string assign_name(const CCState &input)
Assigns strings to enums for formated output.
Definition CCStructures.cc:383
void save(const Function< T, NDIM > &f, const std::string name)
Definition mra.h:2745
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2002
static const double a
Definition nonlinschro.cc:118
Implementation of Krylov-subspace nonlinear equation solver.
Implements most functionality of separated operators.
double Q(double a)
Definition relops.cc:20
void clear_response()
clears only potentials of the response
Definition CCStructures.h:1125
void clear_all()
deltes all stored potentials
Definition CCStructures.h:1115
Definition CCStructures.h:77
void warning(const std::string &msg) const
Definition CCStructures.cc:45
void subsection(const std::string &msg) const
Definition CCStructures.cc:34
void section(const std::string &msg) const
Definition CCStructures.cc:23
Definition CCStructures.h:199
std::size_t iter_max_3D() const
Definition CCStructures.h:315
bool kain() const
Definition CCStructures.h:343
double thresh_bsh_3D() const
Definition CCStructures.h:295
double thresh_bsh_6D() const
Definition CCStructures.h:297
double thresh_3D() const
Definition CCStructures.h:287
double dconv_3D() const
Definition CCStructures.h:309
double lo() const
Definition CCStructures.h:283
long freeze() const
Definition CCStructures.h:355
double thresh_6D() const
Definition CCStructures.h:291
bool QtAnsatz() const
Definition CCStructures.h:349
double dmin() const
Definition CCStructures.h:285
std::size_t output_prec() const
Definition CCStructures.h:351
bool debug() const
Definition CCStructures.h:339
void information(World &world) const
print out the parameters
Definition CCStructures.cc:195
void sanity_check(World &world) const
check if parameters are set correct
Definition CCStructures.cc:206
Timer Structure.
Definition CCStructures.h:122
void info(const bool debug=true, const double norm=12345.6789)
print out information about the passed time since the CC_TIMER object was created
Definition CCStructures.cc:52
A helper structure which holds a map of functions.
Definition CCStructures.h:509
FuncType type
Definition CCStructures.h:645
size_t size() const
Get the size vector (number of functions in the map)
Definition CCStructures.h:702
double omega
Definition CCStructures.h:646
vector_real_function_3d get_vecfunction() const
Returns all the functions of the map as vector.
Definition CCStructures.h:695
CC_functionmap functions
Definition CCStructures.h:643
std::string name(const int ex) const
excitation irrep (direct product of x function and corresponding orbital)
Definition CCStructures.h:652
POD holding some basic functions and some intermediates for the CC2 calculation.
Definition CCStructures.h:1207
std::vector< Function< double, 3 > > mo_ket
Definition CCStructures.h:1208
Tensor< double > fock
Definition CCStructures.h:1213
CCIntermediatePotentials intermediate_potentials
Definition CCStructures.h:1214
std::vector< double > orbital_energies
Definition CCStructures.h:1212
std::vector< Function< double, 3 > > mo_bra
Definition CCStructures.h:1209
CCParameters parameters
Definition CCStructures.h:1211
Function< double, 3 > R_square
Definition CCStructures.h:1215
The interface to be provided by functions to be optimized.
Definition solvers.h:176
Definition CCStructures.h:381
Definition CCStructures.h:421
Pairs< R > convert(const Pairs< T > arg, const opT op) const
convert Pairs<T> to another type
Definition CCStructures.h:430
void insert(int i, int j, const T &pair)
Definition CCStructures.h:471
very simple command line parser
Definition commandlineparser.h:15
Definition nonlinsol.h:169
static double V(const coordT &r)
Definition tdse.cc:288
InputParameters param
Definition tdse.cc:203
static const double omega
Definition tdse_example.cc:51
double norm(const T i1)
Definition test_cloud.cc:72
F residual(const F &f)
Definition testcomplexfunctionsolver.cc:69
Defines operations on vectors of Functions.