MADNESS 0.10.1
CCStructures.h
Go to the documentation of this file.
1/*
2 * CCStructures.h
3 *
4 * Created on: Sep 3, 2015
5 * Author: kottmanj
6 */
7
8
9/// File holds all helper structures necessary for the CC_Operator and CC2 class
10#ifndef CCSTRUCTURES_H_
11#define CCSTRUCTURES_H_
12
13#include <madness/mra/mra.h>
17#include <algorithm>
18#include <iomanip>
19#include <iostream>
21
22#include "lowrankfunction.h"
23
24namespace madness {
25
26/// Type of Pairs used by CC_Pair2 class
30
31/// CC2 Singles Potentials
51
52/// Assigns strings to enums for formated output
53std::string
54assign_name(const CCState& input);
55
56/// Assigns enum to string
58assign_calctype(const std::string name);
59
60/// Assigns strings to enums for formated output
61std::string
62assign_name(const CalcType& inp);
63
64/// Assigns strings to enums for formated output
65std::string
66assign_name(const PotentialType& inp);
67
68/// Assigns strings to enums for formated output
69std::string
70assign_name(const FuncType& inp);
71
72/// check memory usage using getrusage
73inline void print_memory_usage(const World& world) {
74 long mem=get_memory_usage();
75 std::string hostname=get_hostname();
76 std::stringstream ss;
77 ss << "memory usage of process "<< world.rank()<< " on "<< hostname<< ": "<< mem/1024/1024<<"MB";
78 std::string msg=ss.str();
79 auto memusage=world.gop.concat0(std::vector<std::string>(1,msg));
80 std::sort(memusage.begin(),memusage.end());
81 if (world.rank()==0) for (const auto& msg : memusage) print(msg);
82}
83
84// Little structure for formated output and to collect warnings
85// much room to improve
87 CCMessenger(World& world) : world(world), output_prec(10), scientific(true), debug(false), os(std::cout) {}
88
92 bool debug;
93
94 void operator()(const std::string& msg) const { output(msg); }
95
96 void debug_output(const std::string& msg) const {
97 if (debug) output(msg);
98 }
99
100 void
101 output(const std::string& msg) const;
102
103 void
104 section(const std::string& msg) const;
105
106 void
107 subsection(const std::string& msg) const;
108
109 void
110 warning(const std::string& msg) const;
111
112 void print_warnings() const {
113 for (const auto& x:warnings) if (world.rank() == 0) std::cout << x << "\n";
114 }
115
116 template<class T>
117 CCMessenger operator<<(const T& t) const {
118 using madness::operators::operator<<;
119 if (world.rank() == 0) os << t;
120 return *this;
121 }
122
123 /// collect all warnings that occur to print out at the end of the job
124 mutable std::vector<std::string> warnings;
125 /// output stream
126 std::ostream& os;
127};
128
129
130/// Timer Structure
131struct CCTimer {
132 /// TDA_TIMER constructor
133 /// @param[in] world the world
134 /// @param[in] msg a string that contains the desired printout when info function is called
136 operation(msg), end_wall(0.0), end_cpu(0.0), time_wall(-1.0),
137 time_cpu(-1.0) {}
138
141 double start_cpu;
142 std::string operation;
143 double end_wall;
144 double end_cpu;
145 double time_wall;
146 double time_cpu;
147
152
153public:
154 /// print out information about the passed time since the CC_TIMER object was created
155 void
156 info(const bool debug = true, const double norm = 12345.6789);
157
161 return *this;
162 }
163
166 end_cpu = cpu_time();
169 return *this;
170 }
171
172 double reset() {
173 stop();
174 double wtime=time_wall;
175 start();
176 return wtime;
177 }
178
179
180 double get_wall_time_diff() const { return end_wall; }
181
182 double get_cpu_time_diff() const { return end_cpu; }
183
184 std::pair<double, double> current_time(bool printout = false) {
185 if (time_wall < 0.0 or time_cpu < 0.0) stop();
186 return std::make_pair(time_wall, time_cpu);
187 }
188
189 void print() {
191 }
192
193 void print() const {
194 print(std::make_pair(time_wall, time_cpu));
195 }
196
197 void print(const std::pair<double, double>& times) const {
198 if (world.rank() == 0) {
199 std::cout << std::setfill(' ') << std::scientific << std::setprecision(2)
200 << "Timer: " << times.first << " (Wall), " << times.second << " (CPU)" << ", (" + operation + ")"
201 << "\n";
202 }
203 }
204};
205
207
208 std::vector<std::pair<int, int>> map; ///< maps pair index (i,j) to vector index k
209 PairVectorMap() = default;
210 PairVectorMap(const std::vector<std::pair<int, int>> map1) : map(map1) {}
211
212 static PairVectorMap triangular_map(const int nfreeze, const int nocc) {
213 std::vector<std::pair<int, int>> map; ///< maps pair index (i,j) to vector index k
214 for (int i=nfreeze; i<nocc; ++i) {
215 for (int j=i; j<nocc; ++j) {
216 map.push_back(std::make_pair(i,j));
217 }
218 }
219 return PairVectorMap(map);
220 }
221
222 static PairVectorMap quadratic_map(const int nfreeze, const int nocc) {
223 std::vector<std::pair<int, int>> map; ///< maps pair index (i,j) to vector index k
224 for (int i=nfreeze; i<nocc; ++i) {
225 for (int j=nfreeze; j<nocc; ++j) {
226 map.push_back(std::make_pair(i,j));
227 }
228 }
229 return PairVectorMap(map);
230 }
231
232 void print(const std::string msg="PairVectorMap") const {
233 madness::print(msg);
234 madness::print("vector element <-> pair index");
235 for (size_t i=0; i<map.size(); ++i) {
236 madness::print(i, " <-> ",map[i]);
237 }
238 }
239
240};
241
242/// POD holding all electron pairs with easy access
243/// Similar strucutre than the Pair structure from MP2 but with some additional features (merge at some point)
244/// This structure will also be used for intermediates
245template<typename T>
246struct Pairs {
247
248 typedef std::map<std::pair<int, int>, T> pairmapT;
250
251 /// convert Pairs<T> to another type
252
253 /// opT op takes an object of T and returns the result type
254 template<typename R, typename opT>
255 Pairs<R> convert(const Pairs<T> arg, const opT op) const {
256 Pairs<R> result;
257 for (auto& p : arg.allpairs) {
258 int i=p.first.first;
259 int j=p.first.second;
260 result.insert(i,j,op(p.second));
261 }
262 return result;
263 }
264
265 static Pairs vector2pairs(const std::vector<T>& argument, const PairVectorMap map) {
266 Pairs<T> pairs;
267 for (size_t i=0; i<argument.size(); ++i) {
268 pairs.insert(map.map[i].first,map.map[i].second,argument[i]);
269 }
270 return pairs;
271 }
272
273 static std::vector<T> pairs2vector(const Pairs<T>& argument, const PairVectorMap map) {
274 std::vector<T> vector;
275 for (size_t i=0; i<argument.allpairs.size(); ++i) {
276 vector.push_back(argument(map.map[i].first,map.map[i].second));
277 }
278 return vector;
279 }
280
281 /// getter
282 const T& operator()(int i, int j) const {
283 return allpairs.at(std::make_pair(i, j));
284 }
285
286 /// getter
287 // at instead of [] operator bc [] inserts new element if nothing is found while at throws out of range error
288 // back to before
289 T& operator()(int i, int j) {
290 // return allpairs.at(std::make_pair(i, j));
291 return allpairs[std::make_pair(i, j)];
292 }
293
294 /// setter
295 /// can NOT replace elements (for this construct new pair map and swap the content)
296 void insert(int i, int j, const T& pair) {
297 std::pair<int, int> key = std::make_pair(i, j);
298 allpairs.insert(std::make_pair(key, pair));
299 }
300
301 /// swap the contant of the pairmap
302 void swap(Pairs<T>& other) {
303 allpairs.swap(other.allpairs);
304 }
305
306 bool empty() const {
307 if (allpairs.size() == 0) return true;
308 else return false;
309 }
310};
311
312/// f12 and g12 intermediates of the form <f1|op|f2> (with op=f12 or op=g12) will be saved using the pair structure
313template <typename T, std::size_t NDIM>
315
316/// Returns the size of an intermediate
317//double
318//size_of(const intermediateT& im);
319/// Returns the size of an intermediate
320template<typename T, std::size_t NDIM>
321double
323 double size = 0.0;
324 for (const auto& tmp : im.allpairs) {
325 size += get_size<T, NDIM>(tmp.second);
326 }
327 return size;
328}
329
330
331
332// structure for CC Vectorfunction
333/// A helper structure which holds a map of functions
335
337
338 CC_vecfunction(const FuncType type_) : type(type_), omega(0.0), current_error(99.9), delta(0.0) {}
339
341 for (size_t i = 0; i < v.size(); i++) {
342 CCFunction<double,3> tmp(v[i], i, type);
343 functions.insert(std::make_pair(i, tmp));
344 }
345 }
346
347 CC_vecfunction(const std::vector<CCFunction<double,3>>& v) : type(UNDEFINED), omega(0.0), current_error(99.9), delta(0.0) {
348 for (size_t i = 0; i < v.size(); i++) {
349 functions.insert(std::make_pair(v[i].i, v[i]));
350 }
351 }
352
354 current_error(99.9), delta(0.0) {
355 for (size_t i = 0; i < v.size(); i++) {
356 CCFunction<double,3> tmp(v[i], i, type);
357 functions.insert(std::make_pair(i, tmp));
358 }
359 }
360
361 CC_vecfunction(const vector_real_function_3d& v, const FuncType& type, const size_t& freeze) : type(type),
362 omega(0.0),
363 current_error(99.9),
364 delta(0.0) {
365 for (size_t i = 0; i < v.size(); i++) {
366 CCFunction<double,3> tmp(v[i], freeze + i, type);
367 functions.insert(std::make_pair(freeze + i, tmp));
368 }
369 }
370
371 CC_vecfunction(const std::vector<CCFunction<double,3>>& v, const FuncType type_)
372 : type(type_), omega(0.0), current_error(99.9), delta(0.0) {
373 for (auto x:v) functions.insert(std::make_pair(x.i, x));
374 }
375
376 /// copy ctor (shallow)
378 : functions(other.functions), type(other.type), omega(other.omega),
380 delta(other.delta), irrep(other.irrep) {
381 }
382
383 /// assignment operator, shallow wrt the functions
384// CC_vecfunction& operator=(const CC_vecfunction& other) = default;
386 if (this == &other) return *this;
387 functions = other.functions;
388 type = other.type;
389 omega = other.omega;
391 delta = other.delta;
392 irrep = other.irrep;
393 return *this;
394 }
395
396
397 /// returns a deep copy (void shallow copy errors)
398 friend CC_vecfunction
399 copy(const CC_vecfunction& other) {
400 CC_vecfunction tmp=other;
401 tmp.functions.clear();
402 for (const auto& x : other.functions) {
403 tmp.functions.insert(std::make_pair(x.first, copy(x.second)));
404 }
405 return tmp;
406 }
407
408 void reconstruct() const {
409 for (auto& x : functions) x.second.function.reconstruct();
410 }
411
412//madness::CC_vecfunction
413//CC_vecfunction::copy() const {
414// std::vector<CCFunction<double,3>> vn;
415// for (auto x : functions) {
416// const CCFunction<double,3> fn(madness::copy(x.second.function), x.second.i, x.second.type);
417// vn.push_back(fn);
418// }
419// CC_vecfunction result(vn, type);
420// result.irrep = irrep;
421// return result;
422//}
423//
424
425 static CC_vecfunction load_restartdata(World& world, std::string filename) {
427 CC_vecfunction tmp;
428 ar & tmp;
429 return tmp;
430 }
431
432 void save_restartdata(World& world, std::string filename) const {
434 ar & *this;
435 }
436
437 template<typename Archive>
438 void serialize(const Archive& ar) {
439 typedef std::vector<std::pair<std::size_t, CCFunction<double,3>>> CC_functionvec;
440
441 auto map2vector = [] (const CC_functionmap& map) {
442 return CC_functionvec(map.begin(), map.end());
443 };
444 auto vector2map = [] (const CC_functionvec& vec) {
445 return CC_functionmap(vec.begin(), vec.end());
446 };
447
448 ar & type & omega & current_error & delta & irrep ;
449 if (ar.is_input_archive) {
450 std::size_t size=0; // set to zero to silence compiler warning
451 ar & size;
452 CC_functionvec tmp(size);
453
454 for (auto& t : tmp) ar & t.first & t.second;
455 functions=vector2map(tmp);
456 } else if (ar.is_output_archive) {
457 auto tmp=map2vector(functions);
458 ar & tmp.size();
459 for (auto& t : tmp) ar & t.first & t.second;
460 }
461 }
462
463 hashT hash() const {
464 hashT hashval = std::hash<FuncType>{}(type);
465 for (const auto& f : functions) hash_combine(hashval, hash_value(f.second.f().get_impl()->id()));
466
467 return hashval;
468 }
469
470 typedef std::map<std::size_t, CCFunction<double,3>> CC_functionmap;
472
474 double omega; /// excitation energy
476 double delta; // Last difference in Energy
477 std::string irrep = "null"; /// excitation irrep (direct product of x function and corresponding orbital)
478
479 std::string
480 name(const int ex) const {
481 return madness::name(type,ex);
482 };
483
484 bool is_converged(const double econv, const double dconv) const {
485 return (current_error<dconv) and (std::fabs(delta)<econv);
486 }
487
488 /// getter
490 return functions.find(i.i)->second;
491 }
492
493 /// getter
494 const CCFunction<double,3>& operator()(const size_t& i) const {
495 return functions.find(i)->second;
496 }
497
498 /// getter
502
503 /// getter
505 return functions[i];
506 }
507
508 /// setter
509 void insert(const size_t& i, const CCFunction<double,3>& f) {
510 functions.insert(std::make_pair(i, f));
511 }
512
513 /// setter
514 void set_functions(const vector_real_function_3d& v, const FuncType& type, const size_t& freeze) {
515 functions.clear();
516 for (size_t i = 0; i < v.size(); i++) {
517 CCFunction<double,3> tmp(v[i], freeze + i, type);
518 functions.insert(std::make_pair(freeze + i, tmp));
519 }
520 }
521
522 /// Returns all the functions of the map as vector
525 for (auto x:functions) tmp.push_back(x.second.function);
526 return tmp;
527 }
528
529 /// Get the size vector (number of functions in the map)
530 size_t size() const {
531 return functions.size();
532 }
533
534 /// Print the memory of which is used by all the functions in the map
535 void
536 print_size(const std::string& msg = "!?not assigned!?") const;
537
538 /// scalar multiplication
539 CC_vecfunction operator*(const double& fac) const {
541 const size_t freeze = functions.cbegin()->first;
542 return CC_vecfunction(vnew, type, freeze);
543 }
544
545 /// scaling (inplace)
546 void scale(const double& factor) {
547 for (auto& ktmp:functions) {
548 ktmp.second.function.scale(factor);
549 }
550 }
551
552 /// operator needed for sort operation (sorted by omega values)
553 bool operator<(const CC_vecfunction& b) const { return omega < b.omega; }
554
555 // plotting
556 void plot(const std::string& msg = "") const {
557 for (auto& ktmp:functions) {
558 ktmp.second.plot(msg);
559 }
560 }
561public:
562 NLOHMANN_DEFINE_TYPE_INTRUSIVE(CC_vecfunction, omega, irrep, current_error)
563
564};
565
566/// Helper Structure that carries out operations on CC_functions
567/// The structure can hold intermediates for g12 and f12 of type : <mo_bra_k|op|type> with type=HOLE,PARTICLE or RESPONSE
568/// some 6D operations are also included
569/// The structure does not know if nuclear correlation facors are used, so the corresponding bra states have to be prepared beforehand
570template<typename T=double, std::size_t NDIM=3>
572public:
573
574 /// parameter class
575 struct Parameters {
577
578 Parameters(const Parameters& other) :
579 thresh_op(other.thresh_op),
580 lo(other.lo),
581 freeze(other.freeze),
582 gamma(other.gamma) {
583 }
584
585 Parameters(const CCParameters& param) : thresh_op(param.thresh_poisson()), lo(param.lo()),
587 gamma(param.gamma()) {};
589 double lo = 1.e-6;
590 int freeze = 0;
591 double gamma = 1.0; /// f12 exponent
592
593 template<typename archiveT>
594 void serialize(archiveT& ar) {
595 ar & thresh_op & lo & freeze & gamma;
596 }
597 };
598
599
600 /// @param[in] world
601 /// @param[in] optype: the operatortype (can be g12_ or f12_)
602 /// @param[in] param: the parameters of the current CC-Calculation (including function and operator thresholds and the exponent for f12)
606
608
609 static inline
610 std::shared_ptr<CCConvolutionOperator> CCConvolutionOperatorPtr(World& world, const OpType type, Parameters param) {
611 return std::shared_ptr<CCConvolutionOperator>(new CCConvolutionOperator(world, type, param));
612 }
613
614protected:
615
617 auto info= SeparatedConvolution<T,NDIM>::combine_OT((*a.get_op()),(*b.get_op()));
619 param.gamma=info.mu;
620 param.thresh_op=info.thresh;
621 param.lo=info.lo;
622 param.freeze=a.parameters.freeze;
623 return CCConvolutionOperator(a.world, info.type, param);
624 }
625
626 friend std::shared_ptr<CCConvolutionOperator> combine(const std::shared_ptr<CCConvolutionOperator>& a,
627 const std::shared_ptr<CCConvolutionOperator>& b) {
628 if (a and (not b)) return a;
629 if ((not a) and b) return b;
630 if ((not a) and (not b)) return nullptr;
631 return std::shared_ptr<CCConvolutionOperator>(new CCConvolutionOperator(combine(*a,*b)));
632 }
633
634public:
635 /// @param[in] f: a 3D function
636 /// @param[out] the convolution op(f), no intermediates are used
638 if (op) return ((*op)(f)).truncate();
639 return f;
640 }
641
642 /// @param[in] bra a CC_vecfunction
643 /// @param[in] ket a CC_function
644 /// @param[out] vector[i] = <bra[i]|op|ket>
645 std::vector<Function<T,NDIM>> operator()(const CC_vecfunction& bra, const CCFunction<T,NDIM>& ket) const {
647 std::vector<Function<T, NDIM>> result;
648 if constexpr (NDIM == 3) {
649 if (bra.type == HOLE) {
650 for (const auto& ktmp: bra.functions) {
651 const CCFunction<T, NDIM>& brai = ktmp.second;
652 const Function<T, NDIM> tmpi = this->operator()(brai, ket);
653 result.push_back(tmpi);
654 }
655 } else {
656 std::vector<Function<T, NDIM>> tmp = mul(world, ket.function, bra.get_vecfunction());
657 result = apply(world, (*op), tmp);
658 truncate(world, result);
659 }
660 } else {
661 MADNESS_EXCEPTION("not implemented", 1);
662 }
663
664 return result;
665 }
666
667 // @param[in] f: a vector of 3D functions
668 // @param[out] the convolution of op with each function, no intermeditates are used
669 std::vector<Function<T,NDIM>> operator()(const std::vector<Function<T,NDIM>>& f) const {
671 return apply<T,T,NDIM,NDIM>(world, (*op), f);
672 }
673
674 // @param[in] bra: a 3D CC_function, if nuclear-correlation factors are used they have to be applied before
675 // @param[in] ket: a 3D CC_function,
676 // @param[in] use_im: default is true, if false then no intermediates are used
677 // @param[out] the convolution <bra|op|ket> = op(bra*ket), if intermediates were calculated before the operator uses them
678 Function<T,NDIM> operator()(const CCFunction<T,NDIM>& bra, const CCFunction<T,NDIM>& ket, const bool use_im = true) const;
679
680 // @param[in] u: a 6D-function
681 // @param[out] the convolution \int g(r,r') u(r,r') dr' (if particle==2) and g(r,r') u(r',r) dr' (if particle==1)
682 // @param[in] particle: specifies on which particle of u the operator will act (particle ==1 or particle==2)
683 Function<T,2*NDIM> operator()(const Function<T,2*NDIM>& u, const size_t particle) const;
684
685 // @param[in] bra: a 3D-CC_function, if nuclear-correlation factors are used they have to be applied before
686 // @param[in] u: a 6D-function
687 // @param[in] particle: specifies on which particle of u the operator will act (particle ==1 or particle==2)
688 // @param[out] the convolution <bra|g12|u>_particle
689 Function<T,NDIM> operator()(const CCFunction<T,NDIM>& bra, const Function<T,2*NDIM>& u, const size_t particle) const;
690
691 /// @param[in] bra: a vector of CC_functions, the type has to be HOLE
692 /// @param[in] ket: a vector of CC_functions, the type can be HOLE,PARTICLE,RESPONSE
693 /// updates intermediates of the type <bra|op|ket>
694 void update_elements(const CC_vecfunction& bra, const CC_vecfunction& ket);
695
696 /// @param[out] prints the name of the operator (convenience) which is g12 or f12 or maybe other things like gf in the future
697 std::string name() const {
698 std::stringstream ss;
699 ss << type();
700 return ss.str();
701 }
702
703 /// @param[in] the type of which intermediates will be deleted
704 /// e.g if(type==HOLE) then all intermediates of type <mo_bra_k|op|HOLE> will be deleted
705 void clear_intermediates(const FuncType& type);
706
707 /// prints out information (operatorname, number of stored intermediates ...)
708 size_t info() const;
709
711 hashT h = 0;
712 hash_combine(h, op.parameters.thresh_op);
713 hash_combine(h, op.parameters.lo);
714 hash_combine(h, op.parameters.freeze);
715 hash_combine(h, op.parameters.gamma);
716 hash_combine(h, int(op.type()));
717 return h;
718 }
719
720 /// sanity check .. doens not do so much
721 void sanity() const { print_intermediate(HOLE); }
722
723 /// @param[in] type: the type of intermediates which will be printed, can be HOLE,PARTICLE or RESPONSE
724 void print_intermediate(const FuncType type) const {
725 if (type == HOLE)
726 for (const auto& tmp:imH.allpairs)
727 tmp.second.print_size("<H" + std::to_string(tmp.first.first) + "|" + name() + "|H" +
728 std::to_string(tmp.first.second) + "> intermediate");
729 else if (type == PARTICLE)
730 for (const auto& tmp:imP.allpairs)
731 tmp.second.print_size("<H" + std::to_string(tmp.first.first) + "|" + name() + "|P" +
732 std::to_string(tmp.first.second) + "> intermediate");
733 else if (type == RESPONSE)
734 for (const auto& tmp:imR.allpairs)
735 tmp.second.print_size("<H" + std::to_string(tmp.first.first) + "|" + name() + "|R" +
736 std::to_string(tmp.first.second) + "> intermediate");
737 }
738
739 /// create a TwoElectronFactory with the operatorkernel
742 factory.set_info(op->info);
743 return factory;
744 }
745
746 OpType type() const { return get_op()->info.type; }
747
749
750 std::shared_ptr<SeparatedConvolution<T,NDIM>> get_op() const {return op;};
751
752private:
753 /// the world
755
756 /// @param[in] optype: can be f12_ or g12_ depending on which operator shall be intitialzied
757 /// @param[in] parameters: parameters (thresholds etc)
758 /// initializes the operators
760
761 std::shared_ptr<SeparatedConvolution<T,NDIM>> op;
765
766 /// @param[in] msg: output message
767 /// the function will throw an MADNESS_EXCEPTION
768 void error(const std::string& msg) const {
769 if (world.rank() == 0)
770 std::cout << "\n\n!!!!ERROR in CCConvolutionOperator " << name() << ": " << msg
771 << "!!!!!\n\n" << std::endl;
772 MADNESS_EXCEPTION(msg.c_str(), 1);
773 }
774public:
775};
776
777template<typename T, std::size_t NDIM>
778std::shared_ptr<CCConvolutionOperator<T,NDIM>> CCConvolutionOperatorPtr(World& world, const OpType type,
780 return std::shared_ptr<CCConvolutionOperator<T,NDIM>>(new CCConvolutionOperator<T,NDIM>(world,type,param));
781}
782
783/// little helper structure which manages the stored singles potentials
789
790 /// check if the intermediate potential exists
792 return potential_exists(type,f.type);
793 }
794
795 /// check if the intermediate potential exists
796 bool potential_exists(const PotentialType& type,const FuncType& ftype) const {
797 bool exists=get_potential(type,ftype,false).size()>0;
798 return exists;
799 }
800
801 /// return a vector of the intermediate potentials
802
803 /// @param[in] ptype: the potential type (POT_SINGLES, POT_S2B, ..)
804 /// @param[in] ftype: the function type (HOLE, PARTICLE, RESPONSE)
806 get_potential(const PotentialType& ptype, const FuncType& ftype, const bool throw_if_empty) const;
807
808 /// fetches the correct stored potential or throws an exception
810 operator()(const CC_vecfunction& f, const PotentialType& type, const bool throw_if_empty) const;
811
812 /// fetch the potential for a single function
814 operator()(const CCFunction<double,3>& f, const PotentialType& type, const bool throw_if_empty) const;
815
825
826 /// deltes all stored potentials
835
836 /// clears only potentials of the response
842
843 /// insert potential
844 void
846
849 records+=cloud.store(world,parameters);
850 records+=cloud.store(world,current_s2b_potential_ex_);
851 records+=cloud.store(world,current_s2b_potential_gs_);
852 records+=cloud.store(world,current_s2c_potential_ex_);
853 records+=cloud.store(world,current_s2c_potential_gs_);
854 records+=cloud.store(world,current_singles_potential_ex_);
855 records+=cloud.store(world,current_singles_potential_gs_);
856 records+=cloud.store(world,unprojected_cc2_projector_response_);
857 return records;
858 }
859
870
872 auto hash_vector_of_functions =[](const vector_real_function_3d& v) {
873 hashT h;
874 for (const auto& f : v) {
875 hash_combine(h, hash_value(f.get_impl()->id()));
876 }
877 return h;
878 };
879 hashT h;
880 hash_combine(h, hash_vector_of_functions(ip.current_s2b_potential_ex_));
881 hash_combine(h, hash_vector_of_functions(ip.current_s2b_potential_gs_));
882 hash_combine(h, hash_vector_of_functions(ip.current_s2c_potential_ex_));
883 hash_combine(h, hash_vector_of_functions(ip.current_s2c_potential_gs_));
884 hash_combine(h, hash_vector_of_functions(ip.current_singles_potential_ex_));
885 hash_combine(h, hash_vector_of_functions(ip.current_singles_potential_gs_));
886 hash_combine(h, hash_vector_of_functions(ip.unprojected_cc2_projector_response_));
887 return h;
888 }
889
891private:
892 // World& world;
893 /// whole ground state singles potential without fock-residue
895 /// whole excited state singles potential without fock-residue
897 /// s2b_potential for the pure 6D-part of the ground-state (expensive and constant during singles iterations)
899 /// s2b_potential for the pure 6D-part of the excited-state (expensive and constant during singles iterations)
901 /// s2c_potential for the pure 6D-part of the ground-state (expensive and constant during singles iterations)
903 /// s2c_potential for the pure 6D-part of the excited_state (expensive and constant during singles iterations)
905 /// unprojected S3c + S5c + S2b + S2c potential of CC2 singles
906 /// for the projector response of the CC2 singles potential
908
909 /// structured output
910 void output(const std::string& msg) const {
911 if (parameters.debug())
912 std::cout << "Intermediate Potential Manager: " << msg << "\n";
913 }
914};
915
916/// POD holding some basic functions and some intermediates for the CC2 calculation
917
918/// the class is cloud-serializable and can be used in MacroTasks
919struct Info {
920 std::vector<Function<double,3>> mo_ket;
921 std::vector<Function<double,3>> mo_bra;
922 std::vector<madness::Vector<double,3>> molecular_coordinates;
924 std::vector<double> orbital_energies;
928 std::vector<Function<double,3>> U1;
929 std::vector<Function<double,3>> ao;
930
933 for (size_t i = parameters.freeze(); i < mo_ket.size(); i++) result.push_back(mo_ket[i]);
934 return result;
935 }
936
939 for (size_t i = parameters.freeze(); i < mo_bra.size(); i++) result.push_back(mo_bra[i]);
940 return result;
941 }
942
943 void reconstruct() const {
947 R_square.reconstruct();
949 U2.reconstruct();
950 intermediate_potentials.reconstruct();
951
952 }
953
954 /// customized function to store this to the cloud
955
956 /// functions and constant_part can be very large and we want to split them and store them in different records
959 records+=cloud.store(world,mo_bra);
960 records+=cloud.store(world,mo_ket);
961 records+=cloud.store(world,parameters);
962 records+=cloud.store(world,orbital_energies);
963 records+=cloud.store(world,fock);
964 records+=cloud.store(world,intermediate_potentials);
965 records+=cloud.store(world,R_square);
966 records+=cloud.store(world,molecular_coordinates);
967 records+=cloud.store(world,U2);
968 records+=cloud.store(world,U1);
969 records+=cloud.store(world,ao);
970 return records;
971 }
972
973 /// customized function to load this from the cloud
974
975 /// functions and constant_part can be very large and we want to split them and store them in different records
976 /// @param[inout] recordlist: containing the keys of the member variables -> will be reduced by the keys which are used
977 void cloud_load(World& world, const Cloud& cloud, Recordlist<Cloud::keyT>& recordlist) {
978 // load bookkeeping stuff in a vector
979 mo_bra=cloud.forward_load<std::vector<Function<double,3>>>(world,recordlist);
980 mo_ket=cloud.forward_load<std::vector<Function<double,3>>>(world,recordlist);
981 parameters=cloud.forward_load<CCParameters>(world,recordlist);
982 orbital_energies=cloud.forward_load<std::vector<double>>(world,recordlist);
983 fock=cloud.forward_load<Tensor<double>>(world,recordlist);
985 R_square=cloud.forward_load<Function<double,3>>(world,recordlist);
986 molecular_coordinates=cloud.forward_load<std::vector<madness::Vector<double,3>>>(world,recordlist);
987 U2=cloud.forward_load<Function<double,3>>(world,recordlist);
988 U1=cloud.forward_load<std::vector<Function<double,3>>>(world,recordlist);
989 ao=cloud.forward_load<std::vector<Function<double,3>>>(world,recordlist);
990 }
991
992};
993
994
996public:
997 CCPair() = default;
998
999 CCPair(const size_t ii, const size_t jj, const CCState t, const CalcType c)
1000 : type(t), ctype(c), i(ii), j(jj), bsh_eps(12345.6789) {};
1001
1002 CCPair(const size_t ii, const size_t jj, const CCState t, const CalcType c,
1003 const std::vector<CCPairFunction<double,6>>& f)
1004 : type(t), ctype(c), i(ii), j(jj), functions(f), bsh_eps(12345.6789) {};
1005
1006 CCPair(const CCPair& other) : type(other.type), ctype(other.ctype), i(other.i), j(other.j),
1008 bsh_eps(other.bsh_eps) {};
1009
1012 size_t i;
1013 size_t j;
1014
1015 /// customized function to store this to the cloud
1016
1017 /// functions and constant_part can be very large and we want to split them and store them in different records
1018 /// *NOTE* only the 6d function and the constant part are stored in the cloud, not the 3d functions *NOTE*
1020 // save bookkeeping stuff in a vector
1021 std::vector<unsigned char> v;
1023 bool function_is_assigned=(functions.size()>0 && functions[0].is_assigned());
1024 arout & type & ctype & i & j & bsh_eps & function_is_assigned & constant_part.is_initialized();
1025
1027 records+=cloud.store(world,v);
1028 if (function_is_assigned) records+=cloud.store(world,functions[0]);
1029 if (constant_part.is_initialized()) records+=cloud.store(world,constant_part);
1030 return records;
1031 }
1032
1033 /// customized function to load this from the cloud
1034
1035 /// functions and constant_part can be very large and we want to split them and store them in different records
1036 /// @param[inout] recordlist: containing the keys of the member variables -> will be reduced by the keys which are used
1037 void cloud_load(World& world, const Cloud& cloud, Recordlist<Cloud::keyT>& recordlist) {
1038 // load bookkeeping stuff in a vector
1039 std::vector<unsigned char> v=cloud.forward_load<std::vector<unsigned char>>(world,recordlist);
1041 bool function_is_assigned = false, constant_part_is_initialized=false;
1042 arin & type & ctype & i & j & bsh_eps & function_is_assigned & constant_part_is_initialized;
1043 functions.clear();
1044 constant_part.clear();
1045
1046 if (function_is_assigned) functions.emplace_back(cloud.forward_load<CCPairFunction<double,6>>(world,recordlist));
1047 if (constant_part_is_initialized) constant_part=cloud.forward_load<real_function_6d>(world,recordlist);
1048 }
1049
1050 /// return the world of the function
1051 World& world() const {
1052 MADNESS_CHECK_THROW(function_exists(), "no function assigned in CCPair::world()");
1053 return function().world();
1054 }
1055
1056 /// check if the pair has a function assigned
1057 bool function_exists() const {
1058 return (functions.size()>0 and functions[0].is_assigned() and functions[0].is_pure());
1059 }
1060
1061 /// gives back the pure 6D part of the pair function
1063 MADNESS_CHECK_THROW(not functions.empty(), "no function assigned in CCPair::function()");
1064 MADNESS_CHECK_THROW(functions[0].is_pure(),"function is not pure in CCPair::function()");
1065 return functions[0].get_function();
1066 }
1067
1068 /// updates the pure 6D part of the pair function
1070 // print("updating u(",i,j,")");
1071 CCPairFunction tmp(u);
1072 if (functions.size() == 0) functions.push_back(tmp);
1073 else { //(functions.size() > 1) {
1074 MADNESS_CHECK_THROW(functions[0].is_pure(),"function is not pure in CCPair::update_u()");
1075 functions[0]=tmp;
1076 }
1077 }
1078
1079 template<typename Archive>
1080 void serialize(const Archive& ar) {
1081 size_t f_size = functions.size();
1082 bool fexist = (f_size > 0) && (functions[0].get_function().is_initialized());
1083 bool cexist = constant_part.is_initialized();
1084 ar & type & ctype & i & j & bsh_eps & fexist & cexist & f_size;
1085 if constexpr (Archive::is_input_archive) {
1086 if (fexist) {
1088 ar & func;
1090 functions.push_back(f1);
1091 }
1092 } else {
1093 if (fexist) ar & functions[0].get_function();
1094 }
1095 if (cexist) ar & constant_part;
1096 }
1097
1098 /// reconstruct constant part and all functions
1099 void reconstruct() const {
1100 constant_part.reconstruct();
1101 for (auto& f : functions) {
1102 if (f.is_assigned() and f.is_pure()) f.get_function().reconstruct();
1103 }
1104 }
1105
1106 bool load_pair(World& world, const bool verbose=false) {
1107 std::string fname=this->name();
1108 if (verbose and world.rank()==0) print("loading pair from file", fname);
1110 if (exists) {
1112 ar & *this;
1113 if (functions[0].get_function().is_initialized()) functions[0].get_function().set_thresh(FunctionDefaults<6>::get_thresh());
1114 if (constant_part.is_initialized()) constant_part.set_thresh(FunctionDefaults<6>::get_thresh());
1115 }
1116 return exists;
1117 }
1118
1119 void store_pair(World& world, const bool verbose=false) {
1120 std::string fname =this->name();
1121 if (verbose and world.rank()==0) print("loading pair from file", fname);
1122 this->reconstruct();
1124 ar & *this;
1125 }
1126
1127 hashT hash() const {
1128 hashT hash_i = std::hash<std::size_t>{}(i);
1129 hash_combine(hash_i, std::hash<std::size_t>{}(j));
1130 if (constant_part.is_initialized()) {
1131 hash_combine(hash_i, hash_value(constant_part.get_impl()->id()));
1132 }
1133 return hash_i;
1134 }
1135
1136 /// the functions which belong to the pair
1137 std::vector<CCPairFunction<double,6>> functions;
1138
1139 /// the constant part
1141
1142 /// Energy for the BSH Operator
1143 /// Ground State: e_i + e_j
1144 /// Excited State: e_i + e_j + omega
1145 /// default to positive value to make sure this is set somewhere
1146 double bsh_eps=1.0;
1147
1148 /// return the base name like "MP2_pair_u" or "CC2_pair_x"
1149 std::string basename() const {
1150 std::string name = "???";
1151 if (type == GROUND_STATE) name = assign_name(ctype) + "_pair_u";
1152 if (type == EXCITED_STATE) name = assign_name(ctype) + "_pair_x";
1153 return name;
1154
1155 }
1156 std::string name() const {
1157 return basename() +"_" + stringify(i) + stringify(j);
1158 }
1159
1160 void
1161 info() const;
1162
1163};
1164
1165/// build an MP2 or CC2 or LRCC2 etc pair, possibly including the lo-rank parts
1167public:
1169
1170 /// provide ground-state singles, needed for CC2 and LRCC2 wave function ansatz
1172 gs_singles = gs;
1173 return *this;
1174 }
1175
1176 /// provide excited state singles, needed for CC2 and LRCC2 wave function ansatz
1178 ex_singles = ex;
1179 return *this;
1180 }
1181
1183 ctype = type;
1184 return *this;
1185 }
1186
1187 /// make a CCPair without the 6d function and some bookkeeping information
1188 CCPair make_bare_pair(const int i, const int j) const;
1189
1190 /// make a CCPair with the 6d function only and some bookkeeping information
1191 CCPair make_bare_pair_from_file(const int i, const int j) const;
1192
1193 /// make a CCPair
1194 CCPair make_pair(const int i, const int j, const std::vector<CCPairFunction<double,6>>& u) const;
1195
1196 inline static CCState cc_state(const CalcType& type) {
1197 if (type==CT_MP2 or type==CT_CC2 or type==CT_MP3) return GROUND_STATE;
1198 else if (type==CT_LRCC2 or type==CT_ADC2 or type==CT_CISPD) return EXCITED_STATE;
1199 else {
1200 MADNESS_EXCEPTION("unknown cc-state",1);
1201 }
1202 }
1203
1204 /// make a CCPair with the 6d function only and some bookkeeping information
1206 Pairs<CCPair> pairs;
1207 for (size_t i = info.parameters.freeze(); i < info.mo_bra.size(); i++) {
1208 for (size_t j = info.parameters.freeze(); j < info.mo_ket.size(); j++) {
1209 pairs.insert(i,j,make_bare_pair(i, j));
1210 }
1211 }
1212 return pairs;
1213 }
1214
1215 /// complete the given pair with the low-rank parts
1216
1217 /// will use pair's ctype, while builder's ctype is ignored
1219
1220
1221 /// Function to load a function from disk
1222
1223 /// @param[in] name of the file in which the function was stored
1224 /// @param do_print
1225 /// @return the function, possibly not initialized if not found on disk
1226 template <typename T, size_t NDIM>
1227 Function<T,NDIM> load_function(const std::string name, bool do_print) const {
1229 bool exists = archive::ParallelInputArchive<
1231 if (exists) {
1232 if ((world.rank() == 0) and do_print) print("loading function", name);
1234 ar & f;
1235 if (do_print) f.print_size(name);
1236 if (f.is_compressed()) {
1237 if (world.rank()==0 and do_print) print("function is compressed -- reconstructing");
1238 f.change_tree_state(reconstructed);
1239 if (do_print) f.print_size(name+" reconstructed");
1240 save(f, name);
1241 }
1243 f.truncate();
1244 f.print_size(name);
1245 } else {
1246 if ((world.rank()==0) and do_print) print("could not find function",name);
1247 }
1248 return f;
1249 }
1250
1252 const Info& info;
1255
1256};
1257
1258
1259/// print accumulated size of all functions
1260struct CCSize {
1261 double size_local=0;
1262
1263 CCSize() = default;
1264
1265 template<typename T, std::size_t NDIM>
1266 void add_helper(const std::vector<Function<T,NDIM>>& v) {
1267 if (v.size()>0) size_local+=get_size_local(v.front().world(),v);
1268 }
1269
1270 void add_helper(const std::vector<CCPair>& vp) {
1271 if (vp.empty()) return;
1272 for (const auto& p : vp) {
1273 size_local+=get_size(p.constant_part);
1274 if (p.function_exists()) size_local+=get_size_local(p.function());
1275 }
1276 }
1277
1278 /// variadic template parameters to add the size of all functions and pairs
1279 template<typename... Args>
1280 void add(const Args&... args) {
1281 (add_helper(args), ...);
1282 }
1283
1284 void print(World& world, const std::string msg="") const {
1285 double size_global=size_local;
1286 world.gop.sum(size_global);
1287 if (msg.size()>0 and world.rank()==0) madness::print(msg);
1288 world.gop.fence();
1289 madness::print("size of all functions on rank",world.rank(),size_local);
1290 world.gop.fence();
1291 if (world.rank()==0) madness::print("total size of all functions",size_global);
1292
1293 }
1294};
1295
1296/// compute the "constant" part of MP2, CC2, or LR-CC2
1297///
1298/// the constant part is
1299/// result = G [F,f] |ij> for MP2
1300/// result = G [F,f] |t_i t_j> for CC2
1301/// result = G [F,f] |t_i x_j> + |x_i t_j> for LR-CC2
1303
1304public:
1306 partitioner->set_max_batch_size(1);
1307 name="ConstantPart";
1308 }
1309
1310 typedef std::tuple<const std::vector<CCPair>&,
1311 const std::vector<Function<double,3>>&, const std::vector<Function<double,3>>&,
1314
1315 using resultT = std::vector<real_function_6d>;
1316
1317 /// compute the priority based on the sum of orbital energies:
1318
1319 /// heuristically the lower the energy the more localized the functions are and thus the faster
1320 /// diagonal elements are more important than off-diagonal elements
1321 double compute_priority(const Batch& batch, const argtupleT& argtuple) const {
1322 const std::vector<CCPair>& pairs = std::get<0>(argtuple);
1323 const int i=batch.input[0].begin;
1324 bool diagonal=pairs[i].i==pairs[i].j;
1325 double priority=std::abs(1.0/pairs[i].bsh_eps);
1326 if (diagonal) priority+=10.0;
1327 // print("setting priority to 1");
1328 return 1.0;
1329 return priority;
1330 }
1331
1332 resultT allocator(World& world, const argtupleT& argtuple) const {
1333 std::size_t n = std::get<0>(argtuple).size();
1335 return result;
1336 }
1337 resultT operator() (const std::vector<CCPair>& pair,
1338 const std::vector<Function<double,3>>& gs_singles,
1339 const std::vector<Function<double,3>>& ex_singles,
1340 const LowRankFunction<double,6>& exchange_op,
1341 const Info& info) const;
1342};
1343
1344
1346public:
1348 partitioner->set_max_batch_size(1);
1349 name="IteratePair";
1350 }
1351
1352 typedef std::tuple<
1353 const std::vector<CCPair>&, // pair
1354 const std::vector<real_function_6d>&, // local coupling
1355 const CC_vecfunction&, // gs singles
1356 const CC_vecfunction&, // ex singles
1357 const Info&,
1358 const std::size_t&
1360
1361 using resultT = std::vector<real_function_6d>;
1362
1363 /// compute priority based on the size of the pair function
1364 double compute_priority(const Batch& batch, const argtupleT& argtuple) const {
1365 const std::vector<CCPair>& pairs = std::get<0>(argtuple);
1366 const int i=batch.input[0].begin;
1367 double sz=pairs[i].function().size();
1368 // print("computing priority for",i,sz);
1369 return sz;
1370 }
1371
1372 resultT allocator(World& world, const argtupleT& argtuple) const {
1373 std::size_t n = std::get<0>(argtuple).size();
1375 return result;
1376 }
1377
1378 /// iterate a given pair of the MP2, CC2 or LRCC2 calculation
1379
1380 /// will *NOT* compute the local coupling,
1381 /// will apply the Fock operators (J-K+V)|pair> and use
1382 /// the (excited) singles vectors to update the pair
1383 /// @param[in] pair: the pair which will be updated
1384 /// @param[in] gs_singles: the ground state singles, may be dummy for MP2
1385 /// @param[in] ex_singles: the excited state singles, may be dummy for MP2, CC2
1386 /// @param[in] all_coords_vec: the coordinates of the atoms
1387 /// @param[in] info: the info structure
1388 /// @param[in] maxiter: the maximal number of iterations
1389 resultT operator() (const std::vector<CCPair>& pair,
1390 const std::vector<real_function_6d>& local_coupling,
1391 const CC_vecfunction& gs_singles,
1392 const CC_vecfunction& ex_singles,
1393 const Info& info,
1394 const std::size_t& maxiter) const;
1395};
1396
1397
1399public:
1400 std::string basename="SinglesPotentialEx";
1402 name="SinglesPotentialEx";
1403 partitioner->max_batch_size=2;
1404 partitioner->min_batch_size=2;
1405 }
1406
1407 typedef std::tuple<
1408 const std::vector<int>&, // result_index,
1409 const CC_vecfunction&, // singles_gs,
1410 const std::vector<CCPair>&, // doubles_gs,
1411 const CC_vecfunction&, // singles_ex,
1412 const std::vector<CCPair>&, // doubles_ex,
1413 const int&, // name,
1414 const Info& // info
1416
1417 using resultT = std::tuple<std::vector<real_function_3d>,std::vector<real_function_3d>>;
1418
1419 resultT allocator(World& world, const argtupleT& argtuple) const {
1420 std::size_t n = std::get<0>(argtuple).size();
1421 std::vector<real_function_3d> result = zero_functions_auto_tree_state<double, 3>(world, n);
1422 std::vector<real_function_3d> intermediate = zero_functions_auto_tree_state<double, 3>(world, n);
1423 const_cast<std::string&>(name) =basename+"_"+assign_name(PotentialType(std::get<5>(argtuple)));
1424 return std::make_tuple(result,intermediate);
1425 }
1426
1427 resultT operator() (const std::vector<int>& result_index,
1428 const CC_vecfunction& singles_gs,
1429 const std::vector<CCPair>& doubles_gs,
1430 const CC_vecfunction& singles_ex,
1431 const std::vector<CCPair>& doubles_ex,
1432 const int& name,
1433 const Info& info);
1434};
1435
1437public:
1438 std::string basename="SinglesPotentialGs";
1440 name="SinglesPotentialGs";
1441 }
1442
1443 typedef std::tuple<
1444 const std::vector<int>&, // result_index,
1445 const CC_vecfunction&, // singles_gs,
1446 const std::vector<CCPair>&, // doubles_gs,
1447 const int&, // name,
1448 const Info& // info
1450
1451 /// first vector is the potential, second is an intermediate (if applicable, e.g. for s2b and s2c potentials)
1452 using resultT = std::tuple<std::vector<real_function_3d>,std::vector<real_function_3d>>;
1453
1454 /// allocate the result and set the name of this task
1455 resultT allocator(World& world, const argtupleT& argtuple) const {
1456 std::size_t n = std::get<0>(argtuple).size();
1457 std::vector<real_function_3d> result = zero_functions_auto_tree_state<double, 3>(world, n);
1458 std::vector<real_function_3d> intermediate = zero_functions_auto_tree_state<double, 3>(world, n);
1459 const_cast<std::string&>(name) =basename+"_"+assign_name(PotentialType(std::get<3>(argtuple)));
1460 return std::make_tuple(result,intermediate);
1461 }
1462
1463 resultT operator() (const std::vector<int>& result_index,
1464 const CC_vecfunction& singles_gs,
1465 const std::vector<CCPair>& doubles_gs,
1466 const int& name,
1467 const Info& info);
1468};
1469
1470
1472public:
1473 std::string basename="CorrelationEnergy";
1475 name="CorrelationEnergy";
1476 }
1477
1478 typedef std::tuple<
1479 const std::vector<CCPair>&,
1480 const CC_vecfunction&,
1481 const Info&
1483
1484 /// first vector is the potential, second is an intermediate (if applicable, e.g. for s2b and s2c potentials)
1485 typedef std::vector<ScalarResult<double>> resultT;
1486
1487
1488 /// allocate the result and set the name of this task
1489 resultT allocator(World &world, const argtupleT &argtuple) const {
1490 std::size_t n = std::get<0>(argtuple).size();
1491 return scalar_result_vector<double>(world,n);
1492 }
1493
1494 resultT operator() (const std::vector<CCPair>& pairs,
1495 const CC_vecfunction& singles_gs,
1496 const Info& info) const;
1497};
1498
1499}//namespace madness
1500
1501#endif /* CCSTRUCTURES_H_ */
double potential(const coord_3d &r)
Definition 3dharmonic.cc:132
a batch consists of a 2D-input batch and a 1D-output batch: K-batch <- (I-batch, J-batch)
Definition macrotaskpartitioner.h:124
Definition CCStructures.h:571
intermediateT< T, NDIM > imH
Definition CCStructures.h:762
CCConvolutionOperator(const CCConvolutionOperator &other)=default
friend hashT hash_value(CCConvolutionOperator< T, NDIM > &op)
Definition CCStructures.h:710
static std::shared_ptr< CCConvolutionOperator > CCConvolutionOperatorPtr(World &world, const OpType type, Parameters param)
Definition CCStructures.h:610
Function< T, NDIM > operator()(const Function< T, NDIM > &f) const
Definition CCStructures.h:637
SeparatedConvolution< T, NDIM > * init_op(const OpType &type, const Parameters &parameters) const
Definition CCStructures.cc:370
size_t info() const
prints out information (operatorname, number of stored intermediates ...)
Definition CCStructures.cc:352
std::shared_ptr< SeparatedConvolution< T, NDIM > > op
Definition CCStructures.h:761
std::vector< Function< T, NDIM > > operator()(const std::vector< Function< T, NDIM > > &f) const
Definition CCStructures.h:669
OpType type() const
Definition CCStructures.h:746
void clear_intermediates(const FuncType &type)
Definition CCStructures.cc:330
World & world
the world
Definition CCStructures.h:754
void sanity() const
sanity check .. doens not do so much
Definition CCStructures.h:721
std::string name() const
Definition CCStructures.h:697
friend std::shared_ptr< CCConvolutionOperator > combine(const std::shared_ptr< CCConvolutionOperator > &a, const std::shared_ptr< CCConvolutionOperator > &b)
Definition CCStructures.h:626
void update_elements(const CC_vecfunction &bra, const CC_vecfunction &ket)
Definition CCStructures.cc:298
intermediateT< T, NDIM > imP
Definition CCStructures.h:763
void error(const std::string &msg) const
Definition CCStructures.h:768
const Parameters parameters
Definition CCStructures.h:748
CCConvolutionOperator(World &world, const OpType type, Parameters param)
Definition CCStructures.h:603
std::vector< Function< T, NDIM > > operator()(const CC_vecfunction &bra, const CCFunction< T, NDIM > &ket) const
Definition CCStructures.h:645
std::shared_ptr< SeparatedConvolution< T, NDIM > > get_op() const
Definition CCStructures.h:750
void print_intermediate(const FuncType type) const
Definition CCStructures.h:724
intermediateT< T, NDIM > imR
Definition CCStructures.h:764
TwoElectronFactory< T, 2 *NDIM > get_kernel() const
create a TwoElectronFactory with the operatorkernel
Definition CCStructures.h:740
friend CCConvolutionOperator combine(const CCConvolutionOperator &a, const CCConvolutionOperator &b)
Definition CCStructures.h:616
structure for a CC Function 3D which holds an index and a type
Definition ccpairfunction.h:45
Function< T, NDIM > function
Definition ccpairfunction.h:70
size_t i
Definition ccpairfunction.h:78
CCPairBuilder & set_ex_singles(const CC_vecfunction &ex)
provide excited state singles, needed for CC2 and LRCC2 wave function ansatz
Definition CCStructures.h:1177
CCPairBuilder(World &world, const Info &info)
Definition CCStructures.h:1168
CC_vecfunction gs_singles
Definition CCStructures.h:1253
const Info & info
Definition CCStructures.h:1252
CCPair make_bare_pair(const int i, const int j) const
make a CCPair without the 6d function and some bookkeeping information
Definition CCStructures.cc:506
CCPairBuilder & set_gs_singles(const CC_vecfunction &gs)
provide ground-state singles, needed for CC2 and LRCC2 wave function ansatz
Definition CCStructures.h:1171
static CCState cc_state(const CalcType &type)
Definition CCStructures.h:1196
CCPair make_bare_pair_from_file(const int i, const int j) const
make a CCPair with the 6d function only and some bookkeeping information
Definition CCStructures.cc:529
World & world
Definition CCStructures.h:1251
Function< T, NDIM > load_function(const std::string name, bool do_print) const
Function to load a function from disk.
Definition CCStructures.h:1227
CCPair make_pair(const int i, const int j, const std::vector< CCPairFunction< double, 6 > > &u) const
make a CCPair
Definition CCStructures.cc:520
CalcType ctype
Definition CCStructures.h:1254
CC_vecfunction ex_singles
Definition CCStructures.h:1253
CCPairBuilder & set_ctype(const CalcType &type)
Definition CCStructures.h:1182
CCPair complete_pair_with_low_rank_parts(const CCPair &pair) const
complete the given pair with the low-rank parts
Definition CCStructures.cc:545
Pairs< CCPair > make_all_bare_pairs() const
make a CCPair with the 6d function only and some bookkeeping information
Definition CCStructures.h:1205
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 reconstruct() const
reconstruct constant part and all functions
Definition CCStructures.h:1099
hashT hash() const
Definition CCStructures.h:1127
void info() const
Definition CCStructures.cc:84
std::string basename() const
return the base name like "MP2_pair_u" or "CC2_pair_x"
Definition CCStructures.h:1149
CCPair(const CCPair &other)
Definition CCStructures.h:1006
World & world() const
return the world of the function
Definition CCStructures.h:1051
void store_pair(World &world, const bool verbose=false)
Definition CCStructures.h:1119
Recordlist< Cloud::keyT > cloud_store(World &world, Cloud &cloud) const
customized function to store this to the cloud
Definition CCStructures.h:1019
bool function_exists() const
check if the pair has a function assigned
Definition CCStructures.h:1057
std::string name() const
Definition CCStructures.h:1156
CCPair(const size_t ii, const size_t jj, const CCState t, const CalcType c, const std::vector< CCPairFunction< double, 6 > > &f)
Definition CCStructures.h:1002
size_t i
Definition CCStructures.h:1012
bool load_pair(World &world, const bool verbose=false)
Definition CCStructures.h:1106
real_function_6d function() const
gives back the pure 6D part of the pair function
Definition CCStructures.h:1062
real_function_6d constant_part
the constant part
Definition CCStructures.h:1140
std::vector< CCPairFunction< double, 6 > > functions
the functions which belong to the pair
Definition CCStructures.h:1137
CCPair(const size_t ii, const size_t jj, const CCState t, const CalcType c)
Definition CCStructures.h:999
void update_u(const real_function_6d &u)
updates the pure 6D part of the pair function
Definition CCStructures.h:1069
size_t j
Definition CCStructures.h:1013
CCState type
Definition CCStructures.h:1010
CCPair()=default
double bsh_eps
Definition CCStructures.h:1146
void serialize(const Archive &ar)
Definition CCStructures.h:1080
CalcType ctype
Definition CCStructures.h:1011
void cloud_load(World &world, const Cloud &cloud, Recordlist< Cloud::keyT > &recordlist)
customized function to load this from the cloud
Definition CCStructures.h:1037
cloud class
Definition cloud.h:338
recordlistT store(madness::World &world, const T &source)
Definition cloud.h:821
T forward_load(madness::World &world, recordlistT &recordlist) const
load a single object from the cloud, recordlist is consumed while loading elements
Definition cloud.h:761
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:183
A multiresolution adaptive numerical function.
Definition mra.h:141
World & world() const
Returns the world.
Definition mra.h:764
LowRankFunction represents a hi-dimensional (NDIM) function as a sum of products of low-dimensional (...
Definition lowrankfunction.h:752
resultT operator()(const std::vector< CCPair > &pairs, const CC_vecfunction &singles_gs, const Info &info) const
Definition CCStructures.cc:722
std::tuple< const std::vector< CCPair > &, const CC_vecfunction &, const Info & > argtupleT
Definition CCStructures.h:1482
MacroTaskComputeCorrelationEnergy()
Definition CCStructures.h:1474
resultT allocator(World &world, const argtupleT &argtuple) const
allocate the result and set the name of this task
Definition CCStructures.h:1489
std::vector< ScalarResult< double > > resultT
first vector is the potential, second is an intermediate (if applicable, e.g. for s2b and s2c potenti...
Definition CCStructures.h:1485
std::string basename
Definition CCStructures.h:1473
std::tuple< const std::vector< CCPair > &, const std::vector< Function< double, 3 > > &, const std::vector< Function< double, 3 > > &, const LowRankFunction< double, 6 > &, const madness::Info & > argtupleT
Definition CCStructures.h:1313
std::vector< real_function_6d > resultT
Definition CCStructures.h:1315
MacroTaskConstantPart()
Definition CCStructures.h:1305
double compute_priority(const Batch &batch, const argtupleT &argtuple) const
compute the priority based on the sum of orbital energies:
Definition CCStructures.h:1321
resultT operator()(const std::vector< CCPair > &pair, const std::vector< Function< double, 3 > > &gs_singles, const std::vector< Function< double, 3 > > &ex_singles, const LowRankFunction< double, 6 > &exchange_op, const Info &info) const
Definition CCStructures.cc:600
resultT allocator(World &world, const argtupleT &argtuple) const
Definition CCStructures.h:1332
std::tuple< const std::vector< CCPair > &, const std::vector< real_function_6d > &, const CC_vecfunction &, const CC_vecfunction &, const Info &, const std::size_t & > argtupleT
Definition CCStructures.h:1359
resultT operator()(const std::vector< CCPair > &pair, const std::vector< real_function_6d > &local_coupling, const CC_vecfunction &gs_singles, const CC_vecfunction &ex_singles, const Info &info, const std::size_t &maxiter) const
iterate a given pair of the MP2, CC2 or LRCC2 calculation
Definition CCStructures.cc:622
MacroTaskIteratePair()
Definition CCStructures.h:1347
double compute_priority(const Batch &batch, const argtupleT &argtuple) const
compute priority based on the size of the pair function
Definition CCStructures.h:1364
resultT allocator(World &world, const argtupleT &argtuple) const
Definition CCStructures.h:1372
std::vector< real_function_6d > resultT
Definition CCStructures.h:1361
MacroTaskOperationBase()
Definition macrotaskq.h:1642
Batch batch
Definition macrotaskq.h:1635
std::shared_ptr< MacroTaskPartitioner > partitioner
Definition macrotaskq.h:1641
std::string name
Definition macrotaskq.h:1640
resultT allocator(World &world, const argtupleT &argtuple) const
Definition CCStructures.h:1419
std::tuple< const std::vector< int > &, const CC_vecfunction &, const std::vector< CCPair > &, const CC_vecfunction &, const std::vector< CCPair > &, const int &, const Info & > argtupleT
Definition CCStructures.h:1415
std::string basename
Definition CCStructures.h:1400
MacroTaskSinglesPotentialEx()
Definition CCStructures.h:1401
std::tuple< std::vector< real_function_3d >, std::vector< real_function_3d > > resultT
Definition CCStructures.h:1417
resultT operator()(const std::vector< int > &result_index, const CC_vecfunction &singles_gs, const std::vector< CCPair > &doubles_gs, const CC_vecfunction &singles_ex, const std::vector< CCPair > &doubles_ex, const int &name, const Info &info)
convenience function
Definition CCStructures.cc:648
std::string basename
Definition CCStructures.h:1438
std::tuple< std::vector< real_function_3d >, std::vector< real_function_3d > > resultT
first vector is the potential, second is an intermediate (if applicable, e.g. for s2b and s2c potenti...
Definition CCStructures.h:1452
std::tuple< const std::vector< int > &, const CC_vecfunction &, const std::vector< CCPair > &, const int &, const Info & > argtupleT
Definition CCStructures.h:1449
resultT operator()(const std::vector< int > &result_index, const CC_vecfunction &singles_gs, const std::vector< CCPair > &doubles_gs, const int &name, const Info &info)
Definition CCStructures.cc:690
MacroTaskSinglesPotentialGs()
Definition CCStructures.h:1439
resultT allocator(World &world, const argtupleT &argtuple) const
allocate the result and set the name of this task
Definition CCStructures.h:1455
Definition operator.h:158
static OperatorInfo combine_OT(const SeparatedConvolution< Q, NDIM > &left, const SeparatedConvolution< Q, NDIM > &right)
return operator type and other info of the combined operator (e.g. fg = f(1,2)* g(1,...
Definition operator.h:1834
A tensor is a multidimensional array.
Definition tensor.h:313
factory for generating TwoElectronInterfaces
Definition function_factory.h:443
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:177
std::vector< T > concat0(const std::vector< T > &v, size_t bufsz=1024 *1024)
Concatenate an STL vector of serializable stuff onto node 0.
Definition worldgop.h:973
void sum(T *buf, size_t nelem)
Inplace global sum while still processing AM & tasks.
Definition worldgop.h:890
A parallel world class.
Definition world.h:134
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
WorldGopInterface & gop
Global operations.
Definition world.h:216
static std::enable_if_t< std::is_same< X, BinaryFstreamInputArchive >::value||std::is_same< X, BinaryFstreamOutputArchive >::value, bool > exists(World &world, const char *filename)
Definition parallel_archive.h:224
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
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition parallel_archive.h:321
Objects that implement their own parallel archive interface should derive from this class.
Definition parallel_archive.h:58
Wraps an archive around an STL vector for input.
Definition vector_archive.h:101
Wraps an archive around an STL vector for output.
Definition vector_archive.h:55
double(* f1)(const coord_3d &)
Definition derivatives.cc:55
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
Tensor< typename Tensor< T >::scalar_type > arg(const Tensor< T > &t)
Return a new tensor holding the argument of each element of t (complex types only).
Definition tensor.h:2761
const int maxiter
Definition gygi_soltion.cc:68
static const double v
Definition hatom_sf_dirac.cc:20
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
Declares the macrotaskq and MacroTaskBase classes.
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:182
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#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.
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
long get_memory_usage()
Definition unique_filename.cc:29
std::vector< ScalarResult< T > > scalar_result_vector(World &world, std::size_t n)
helper function to create a vector of ScalarResultImpl, circumventing problems with the constructors
Definition macrotaskq.h:162
static const char * filename
Definition legendre.cc:96
CalcType
Calculation Types used by CC2.
Definition CCParameters.h:14
@ CT_CC2
Definition CCParameters.h:15
@ CT_LRCC2
Definition CCParameters.h:15
@ CT_MP3
Definition CCParameters.h:15
@ CT_UNDEFINED
Definition CCParameters.h:15
@ CT_CISPD
Definition CCParameters.h:15
@ CT_MP2
Definition CCParameters.h:15
@ CT_ADC2
Definition CCParameters.h:15
static std::string stringify(T arg)
Definition funcplot.h:1066
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition timers.h:128
void print_memory_usage(const World &world)
check memory usage using getrusage
Definition CCStructures.h:73
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
Pairs< Function< T, NDIM > > intermediateT
f12 and g12 intermediates of the form <f1|op|f2> (with op=f12 or op=g12) will be saved using the pair...
Definition CCStructures.h:314
CCState
Type of Pairs used by CC_Pair2 class.
Definition CCStructures.h:27
@ CCSTATE_UNDEFINED
Definition CCStructures.h:28
@ GROUND_STATE
Definition CCStructures.h:28
@ EXCITED_STATE
Definition CCStructures.h:28
FuncType
Definition ccpairfunction.h:26
@ RESPONSE
Definition ccpairfunction.h:26
@ HOLE
Definition ccpairfunction.h:26
@ UNDEFINED
Definition ccpairfunction.h:26
@ PARTICLE
Definition ccpairfunction.h:26
@ reconstructed
s coeffs at the leaves only
Definition funcdefaults.h:61
CalcType assign_calctype(const std::string name)
Assigns enum to string.
Definition CCStructures.cc:396
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
const std::vector< Function< T, NDIM > > & reconstruct(const std::vector< Function< T, NDIM > > &v)
reconstruct a vector of functions
Definition vmra.h:163
std::shared_ptr< CCConvolutionOperator< T, NDIM > > CCConvolutionOperatorPtr(World &world, const OpType type, typename CCConvolutionOperator< T, NDIM >::Parameters param)
Definition CCStructures.h:778
void hash_combine(hashT &seed, const T &v)
Combine hash values.
Definition worldhash.h:261
double size_of(const intermediateT< T, NDIM > &im)
Returns the size of an intermediate.
Definition CCStructures.h:322
std::vector< real_function_3d > vector_real_function_3d
Definition functypedefs.h:94
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< double > > > GaussianConvolution1DCache< double >::map
Definition convolution1d.h:1073
OpType
operator types
Definition operatorinfo.h:11
Function< double, 6 > real_function_6d
Definition functypedefs.h:83
std::string get_hostname()
Definition ranks_and_hosts.cpp:106
bool FunctionDefaults< NDIM >::debug
Definition mraimpl.h:3886
NDIM & f
Definition mra.h:2817
std::size_t hashT
The hash value type.
Definition worldhash.h:146
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition timers.cc:48
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
CCPairFunction< T, NDIM > apply(const SeparatedConvolution< T, NDIM/2 > &op, const CCPairFunction< T, NDIM > &arg)
apply the operator to the argument
Definition ccpairfunction.h:901
constexpr Vector< T, sizeof...(Ts)+1 > vec(T t, Ts... ts)
Factory function for creating a madness::Vector.
Definition vector.h:750
PotentialType
CC2 Singles Potentials.
Definition CCStructures.h:32
@ POT_singles_
Definition CCStructures.h:49
@ POT_s2b_
Definition CCStructures.h:41
@ POT_F3D_
Definition CCStructures.h:34
@ POT_s5b_
Definition CCStructures.h:39
@ POT_s4c_
Definition CCStructures.h:45
@ POT_s5c_
Definition CCStructures.h:40
@ POT_s6_
Definition CCStructures.h:46
@ POT_s4b_
Definition CCStructures.h:44
@ POT_ccs_
Definition CCStructures.h:47
@ POT_s3c_
Definition CCStructures.h:37
@ POT_s4a_
Definition CCStructures.h:43
@ POT_s5a_
Definition CCStructures.h:38
@ POT_s3b_
Definition CCStructures.h:36
@ POT_s2c_
Definition CCStructures.h:42
@ POT_cis_
Definition CCStructures.h:48
@ POT_UNDEFINED
Definition CCStructures.h:33
@ POT_s3a_
Definition CCStructures.h:35
std::vector< Function< T, NDIM > > zero_functions_auto_tree_state(World &world, int n, bool fence=true)
Generates a vector of zero functions, either compressed or reconstructed, depending on tensor type.
Definition vmra.h:457
std::string assign_name(const CCState &input)
Assigns strings to enums for formated output.
Definition CCStructures.cc:379
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
madness::hashT hash_value(const std::array< T, N > &a)
Hash std::array with madness hash.
Definition array_addons.h:78
void save(const Function< T, NDIM > &f, const std::string name)
Definition mra.h:3175
double get_size(World &world, const std::vector< Function< T, NDIM > > &v)
Definition vmra.h:2183
double get_size_local(World &world, const std::vector< Function< T, NDIM > > &v)
return the size of a vector of functions for each rank
Definition vmra.h:2164
Definition mraimpl.h:53
static long abs(long a)
Definition tensor.h:214
static const double b
Definition nonlinschro.cc:119
static const double a
Definition nonlinschro.cc:118
static const double c
Definition relops.cc:10
parameter class
Definition CCStructures.h:575
int freeze
Definition CCStructures.h:590
Parameters()
Definition CCStructures.h:576
void serialize(archiveT &ar)
f12 exponent
Definition CCStructures.h:594
double lo
Definition CCStructures.h:589
double gamma
Definition CCStructures.h:591
Parameters(const CCParameters &param)
Definition CCStructures.h:585
double thresh_op
Definition CCStructures.h:588
Parameters(const Parameters &other)
Definition CCStructures.h:578
little helper structure which manages the stored singles potentials
Definition CCStructures.h:784
CCParameters parameters
Definition CCStructures.h:890
vector_real_function_3d current_s2c_potential_ex_
s2c_potential for the pure 6D-part of the excited_state (expensive and constant during singles iterat...
Definition CCStructures.h:904
bool potential_exists(const CC_vecfunction &f, const PotentialType &type) const
check if the intermediate potential exists
Definition CCStructures.h:791
Recordlist< Cloud::keyT > cloud_store(World &world, Cloud &cloud) const
Definition CCStructures.h:847
void reconstruct() const
Definition CCStructures.h:816
vector_real_function_3d operator()(const CC_vecfunction &f, const PotentialType &type, const bool throw_if_empty) const
fetches the correct stored potential or throws an exception
Definition CCStructures.cc:125
vector_real_function_3d current_singles_potential_gs_
whole ground state singles potential without fock-residue
Definition CCStructures.h:894
CCIntermediatePotentials & operator=(const CCIntermediatePotentials &other)=default
void clear_response()
clears only potentials of the response
Definition CCStructures.h:837
vector_real_function_3d current_s2c_potential_gs_
s2c_potential for the pure 6D-part of the ground-state (expensive and constant during singles iterati...
Definition CCStructures.h:902
vector_real_function_3d current_singles_potential_ex_
whole excited state singles potential without fock-residue
Definition CCStructures.h:896
bool potential_exists(const PotentialType &type, const FuncType &ftype) const
check if the intermediate potential exists
Definition CCStructures.h:796
void cloud_load(World &world, const Cloud &cloud, Recordlist< Cloud::keyT > &recordlist)
Definition CCStructures.h:860
CCIntermediatePotentials(const CCIntermediatePotentials &other)=default
CCIntermediatePotentials(const CCParameters &p)
Definition CCStructures.h:786
vector_real_function_3d unprojected_cc2_projector_response_
Definition CCStructures.h:907
friend hashT hash_value(const CCIntermediatePotentials &ip)
Definition CCStructures.h:871
vector_real_function_3d current_s2b_potential_gs_
s2b_potential for the pure 6D-part of the ground-state (expensive and constant during singles iterati...
Definition CCStructures.h:898
vector_real_function_3d current_s2b_potential_ex_
s2b_potential for the pure 6D-part of the excited-state (expensive and constant during singles iterat...
Definition CCStructures.h:900
void insert(const vector_real_function_3d &potential, const CC_vecfunction &f, const PotentialType &type)
insert potential
Definition CCStructures.cc:140
void clear_all()
deltes all stored potentials
Definition CCStructures.h:827
vector_real_function_3d get_potential(const PotentialType &ptype, const FuncType &ftype, const bool throw_if_empty) const
return a vector of the intermediate potentials
Definition CCStructures.cc:97
void output(const std::string &msg) const
structured output
Definition CCStructures.h:910
void print_warnings() const
Definition CCStructures.h:112
void warning(const std::string &msg) const
Definition CCStructures.cc:45
void debug_output(const std::string &msg) const
Definition CCStructures.h:96
bool debug
Definition CCStructures.h:92
void subsection(const std::string &msg) const
Definition CCStructures.cc:34
CCMessenger operator<<(const T &t) const
Definition CCStructures.h:117
World & world
Definition CCStructures.h:89
bool scientific
Definition CCStructures.h:91
std::vector< std::string > warnings
collect all warnings that occur to print out at the end of the job
Definition CCStructures.h:124
std::ostream & os
output stream
Definition CCStructures.h:126
void section(const std::string &msg) const
Definition CCStructures.cc:23
void output(const std::string &msg) const
Definition CCStructures.cc:14
CCMessenger(World &world)
Definition CCStructures.h:87
size_t output_prec
Definition CCStructures.h:90
void operator()(const std::string &msg) const
Definition CCStructures.h:94
Definition CCParameters.h:20
void print(World &world, const std::string msg="") const
Definition CCStructures.h:1284
CCSize()=default
double size_local
Definition CCStructures.h:1261
void add_helper(const std::vector< CCPair > &vp)
Definition CCStructures.h:1270
void add(const Args &... args)
variadic template parameters to add the size of all functions and pairs
Definition CCStructures.h:1280
void add_helper(const std::vector< Function< T, NDIM > > &v)
Definition CCStructures.h:1266
std::pair< double, double > current_time(bool printout=false)
Definition CCStructures.h:184
CCTimer(World &world, std::string msg)
Definition CCStructures.h:135
void print() const
Definition CCStructures.h:193
std::string operation
Definition CCStructures.h:142
double start_cpu
Definition CCStructures.h:141
double time_wall
Definition CCStructures.h:145
double get_wall_time_diff() const
Definition CCStructures.h:180
void update_time()
Definition CCStructures.h:148
CCTimer stop()
Definition CCStructures.h:164
CCTimer start()
Definition CCStructures.h:158
void print()
Definition CCStructures.h:189
double time_cpu
Definition CCStructures.h:146
double start_wall
Definition CCStructures.h:140
double get_cpu_time_diff() const
Definition CCStructures.h:182
void print(const std::pair< double, double > &times) const
Definition CCStructures.h:197
double reset()
Definition CCStructures.h:172
World & world
Definition CCStructures.h:139
double end_wall
Definition CCStructures.h:143
double end_cpu
Definition CCStructures.h:144
A helper structure which holds a map of functions.
Definition CCStructures.h:334
std::string irrep
Definition CCStructures.h:477
hashT hash() const
Definition CCStructures.h:463
CC_vecfunction(const vector_real_function_3d &v, const FuncType &type, const size_t &freeze)
Definition CCStructures.h:361
std::map< std::size_t, CCFunction< double, 3 > > CC_functionmap
Definition CCStructures.h:470
CC_vecfunction(const CC_vecfunction &other)
copy ctor (shallow)
Definition CCStructures.h:377
const CCFunction< double, 3 > & operator()(const CCFunction< double, 3 > &i) const
getter
Definition CCStructures.h:489
void insert(const size_t &i, const CCFunction< double, 3 > &f)
setter
Definition CCStructures.h:509
CC_vecfunction(const vector_real_function_3d &v, const FuncType &type)
Definition CCStructures.h:353
static CC_vecfunction load_restartdata(World &world, std::string filename)
Definition CCStructures.h:425
const CCFunction< double, 3 > & operator()(const size_t &i) const
getter
Definition CCStructures.h:494
CC_vecfunction operator*(const double &fac) const
scalar multiplication
Definition CCStructures.h:539
double delta
Definition CCStructures.h:476
CCFunction< double, 3 > & operator()(const size_t &i)
getter
Definition CCStructures.h:504
void print_size(const std::string &msg="!?not assigned!?") const
Print the memory of which is used by all the functions in the map.
Definition CCStructures.cc:69
CC_vecfunction(const std::vector< CCFunction< double, 3 > > &v)
Definition CCStructures.h:347
bool operator<(const CC_vecfunction &b) const
operator needed for sort operation (sorted by omega values)
Definition CCStructures.h:553
CC_vecfunction(const FuncType type_)
Definition CCStructures.h:338
void serialize(const Archive &ar)
Definition CCStructures.h:438
CC_vecfunction(const std::vector< CCFunction< double, 3 > > &v, const FuncType type_)
Definition CCStructures.h:371
CC_vecfunction(const vector_real_function_3d &v)
Definition CCStructures.h:340
CC_vecfunction()
Definition CCStructures.h:336
void set_functions(const vector_real_function_3d &v, const FuncType &type, const size_t &freeze)
setter
Definition CCStructures.h:514
CCFunction< double, 3 > & operator()(const CCFunction< double, 3 > &i)
getter
Definition CCStructures.h:499
void scale(const double &factor)
scaling (inplace)
Definition CCStructures.h:546
void plot(const std::string &msg="") const
Definition CCStructures.h:556
FuncType type
Definition CCStructures.h:473
double current_error
excitation energy
Definition CCStructures.h:475
friend CC_vecfunction copy(const CC_vecfunction &other)
returns a deep copy (void shallow copy errors)
Definition CCStructures.h:399
size_t size() const
Get the size vector (number of functions in the map).
Definition CCStructures.h:530
CC_vecfunction & operator=(const CC_vecfunction &other)
assignment operator, shallow wrt the functions
Definition CCStructures.h:385
double omega
Definition CCStructures.h:474
bool is_converged(const double econv, const double dconv) const
Definition CCStructures.h:484
vector_real_function_3d get_vecfunction() const
Returns all the functions of the map as vector.
Definition CCStructures.h:523
void save_restartdata(World &world, std::string filename) const
Definition CCStructures.h:432
CC_functionmap functions
Definition CCStructures.h:471
std::string name(const int ex) const
excitation irrep (direct product of x function and corresponding orbital)
Definition CCStructures.h:480
void reconstruct() const
Definition CCStructures.h:408
POD holding some basic functions and some intermediates for the CC2 calculation.
Definition CCStructures.h:919
void reconstruct() const
Definition CCStructures.h:943
std::vector< Function< double, 3 > > mo_ket
Definition CCStructures.h:920
Recordlist< Cloud::keyT > cloud_store(World &world, Cloud &cloud) const
customized function to store this to the cloud
Definition CCStructures.h:957
std::vector< Function< double, 3 > > ao
Definition CCStructures.h:929
Tensor< double > fock
Definition CCStructures.h:925
Function< double, 3 > R
Definition CCStructures.h:927
std::vector< Function< double, 3 > > U1
Definition CCStructures.h:928
CCIntermediatePotentials intermediate_potentials
Definition CCStructures.h:926
Function< double, 3 > U2
Definition CCStructures.h:927
std::vector< madness::Vector< double, 3 > > molecular_coordinates
Definition CCStructures.h:922
std::vector< double > orbital_energies
Definition CCStructures.h:924
std::vector< Function< double, 3 > > mo_bra
Definition CCStructures.h:921
CCParameters parameters
Definition CCStructures.h:923
vector_real_function_3d get_active_mo_bra() const
Definition CCStructures.h:937
void cloud_load(World &world, const Cloud &cloud, Recordlist< Cloud::keyT > &recordlist)
customized function to load this from the cloud
Definition CCStructures.h:977
Function< double, 3 > R_square
Definition CCStructures.h:927
vector_real_function_3d get_active_mo_ket() const
Definition CCStructures.h:931
Definition CCStructures.h:206
static PairVectorMap triangular_map(const int nfreeze, const int nocc)
Definition CCStructures.h:212
void print(const std::string msg="PairVectorMap") const
Definition CCStructures.h:232
std::vector< std::pair< int, int > > map
maps pair index (i,j) to vector index k
Definition CCStructures.h:208
static PairVectorMap quadratic_map(const int nfreeze, const int nocc)
Definition CCStructures.h:222
PairVectorMap(const std::vector< std::pair< int, int > > map1)
Definition CCStructures.h:210
Definition CCStructures.h:246
void swap(Pairs< T > &other)
swap the contant of the pairmap
Definition CCStructures.h:302
pairmapT allpairs
Definition CCStructures.h:249
static Pairs vector2pairs(const std::vector< T > &argument, const PairVectorMap map)
Definition CCStructures.h:265
Pairs< R > convert(const Pairs< T > arg, const opT op) const
convert Pairs<T> to another type
Definition CCStructures.h:255
std::map< std::pair< int, int >, T > pairmapT
Definition CCStructures.h:248
bool empty() const
Definition CCStructures.h:306
T & operator()(int i, int j)
getter
Definition CCStructures.h:289
void insert(int i, int j, const T &pair)
Definition CCStructures.h:296
const T & operator()(int i, int j) const
getter
Definition CCStructures.h:282
static std::vector< T > pairs2vector(const Pairs< T > &argument, const PairVectorMap map)
Definition CCStructures.h:273
Definition cloud.h:70
Definition lowrankfunction.h:387
static double current_time
Definition tdse1d.cc:160
InputParameters param
Definition tdse.cc:203
static const double omega
Definition tdse_example.cc:51
double norm(const T i1)
Definition test_cloud.cc:85
constexpr std::size_t NDIM
Definition testgconv.cc:54
double h(const coord_1d &r)
Definition testgconv.cc:175