MADNESS 0.10.1
SCFOperators.h
Go to the documentation of this file.
1/*
2 This file is part of MADNESS.
3
4 Copyright (C) 2007,2010 Oak Ridge National Laboratory
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 For more information please contact:
21
22 Robert J. Harrison
23 Oak Ridge National Laboratory
24 One Bethel Valley Road
25 P.O. Box 2008, MS-6367
26
27 email: harrisonrj@ornl.gov
28 tel: 865-241-3937
29 fax: 865-572-0680
30*/
31
32/// \file SCFOperators.h
33/// \brief Operators for the molecular HF and DFT code
34/// \defgroup chem The molecular density functional and Hartree-Fock code
35
36
37#ifndef MADNESS_CHEM_SCFOPERATORS_H_
38#define MADNESS_CHEM_SCFOPERATORS_H_
39
40#include <madness.h>
41#include <madness/mra/macrotaskq.h> // otherwise issues with install
42
43namespace madness {
44
45// forward declaration
46class SCF;
47class Nemo;
48class NemoBase;
49class OEP;
50class NuclearCorrelationFactor;
51class XCfunctional;
52class MacroTaskQ;
53class Molecule;
54
55typedef std::vector<real_function_3d> vecfuncT;
56
57template<typename T, std::size_t NDIM>
59
60public:
62 typedef std::vector<functionT> vecfuncT;
64
65 SCFOperatorBase() = default;
66 SCFOperatorBase(std::shared_ptr<MacroTaskQ> taskq) : taskq(taskq) {}
67
68 virtual ~SCFOperatorBase() {}
69
70 std::shared_ptr<MacroTaskQ> taskq=0;
71
72 /// print some information about this operator
73 virtual std::string info() const = 0;
74
75 /// apply this operator on the argument function
76 ///
77 /// \param ket the argument function
78 /// \return op(ket)
79 virtual functionT operator()(const functionT& ket) const = 0;
80
81 /// apply this operator on the argument vector of functions
82
83 /// \param vket argument vector
84 /// \return op(vket)
85 virtual vecfuncT operator()(const vecfuncT& vket) const = 0;
86
87 /// compute the matrix element <bra | op | ket>
88
89 /// \param bra bra state
90 /// \param ket ket state
91 /// \return the matrix element <bra | op | ket>
92 virtual T operator()(const functionT& bra, const functionT& ket) const = 0;
93
94 /// compute the matrix <vbra | op | vket>
95
96 /// \param vbra vector of bra states
97 /// \param vket vector of ket states
98 /// \return the matrix <vbra | op | vket>
99 virtual tensorT operator()(const vecfuncT& vbra, const vecfuncT& vket) const = 0;
100
101};
102
103template<typename T, std::size_t NDIM>
104class Exchange : public SCFOperatorBase<T,NDIM> {
105public:
106
107 class ExchangeImpl;
108 using implT = std::shared_ptr<ExchangeImpl>;
110 typedef std::vector<functionT> vecfuncT;
112private:
114
115public:
119
120 /// default ctor
121// Exchange() = default;
122
123 Exchange(World& world, const double lo, const double thresh=FunctionDefaults<NDIM>::get_thresh());
124
125// Exchange(std::shared_ptr<MacroTaskQ> taskq) : SCFOperatorBase<T, NDIM>(taskq) {}
126
127 /// ctor with a conventional calculation
128 Exchange(World& world, const SCF *calc, const int ispin);
129
130 /// ctor with a nemo calculation
131 Exchange(World& world, const Nemo *nemo, const int ispin);
132
133 std::string info() const {return "K";}
134
135 bool is_symmetric() const;
136
137 Exchange& set_symmetric(const bool flag);
138
139 Exchange& set_algorithm(const Algorithm& alg);
140
141 Exchange& set_printlevel(const long& level);
142
143 Exchange& set_taskq(std::shared_ptr<MacroTaskQ> taskq1) {
144 this->taskq=taskq1;
145 return *this;
146 }
147
148 Exchange& set_bra_and_ket(const vecfuncT& bra, const vecfuncT& ket);
149
151 vecfuncT vket(1, ket);
152 vecfuncT vKket = this->operator()(vket);
153 return vKket[0];
154 }
155
156 /// apply the exchange operator on a vector of functions
157
158 /// note that only one spin is used (either alpha or beta orbitals)
159 /// @param[in] vket the orbitals |i> that the operator is applied on
160 /// @return a vector of orbitals K| i>
161 vecfuncT operator()(const vecfuncT& vket) const;
162
163 /// compute the matrix element <bra | K | ket>
164
165 /// @param[in] bra real_function_3d, the bra state
166 /// @param[in] ket real_function_3d, the ket state
167 T operator()(const Function<T, NDIM>& bra, const Function<T, NDIM>& ket) const {
168 return inner(bra, this->operator()(ket));
169 }
170
171 /// compute the matrix < vbra | K | vket >
172
173 /// @param[in] vbra vector of real_function_3d, the set of bra states
174 /// @param[in] vket vector of real_function_3d, the set of ket states
175 /// @return K_ij
176 Tensor<T> operator()(const vecfuncT& vbra, const vecfuncT& vket) const {
177 vecfuncT vKket = this->operator()(vket);
178 World& world=vket[0].world();
179 auto result = matrix_inner(world, vbra, vKket);
180 return result;
181 }
182
183
184};
185
186
187template<typename T, std::size_t NDIM>
188class Kinetic : public SCFOperatorBase<T,NDIM> {
191 typedef std::vector<functionT> vecfuncT;
193
194public:
196 gradop = gradient_operator<T,NDIM>(world);
197 }
198
199 std::string info() const {return "T";}
200
201 functionT operator()(const functionT& ket) const {
202 MADNESS_EXCEPTION("do not apply the kinetic energy operator on a function!",1);
203 return ket;
204 }
205
206 vecfuncT operator()(const vecfuncT& vket) const {
207 MADNESS_EXCEPTION("do not apply the kinetic energy operator on a function!",1);
208 return vket;
209 }
210
211 T operator()(const functionT& bra, const functionT& ket) const {
212 vecfuncT vbra(1,bra), vket(1,ket);
213 Tensor<T> tmat=this->operator()(vbra,vket);
214 return tmat(0l,0l);
215 }
216
217 tensorT operator()(const vecfuncT& vbra, const vecfuncT& vket) const {
218 distmatT dkinetic;
219 if (&vbra==&vket) {
220 dkinetic = kinetic_energy_matrix(world,vbra);
221 } else {
222 dkinetic = kinetic_energy_matrix(world,vbra,vket);
223 }
224 tensorT kinetic(vbra.size(),vket.size());
225 dkinetic.copy_to_replicated(kinetic);
226 return kinetic;
227 }
228
229private:
231 std::vector< std::shared_ptr<Derivative<T,NDIM> > > gradop;
232
235 const vecfuncT & vket) const;
236
237};
238
239
240template<typename T, std::size_t NDIM>
241class DerivativeOperator : public SCFOperatorBase<T,NDIM> {
243 typedef std::vector<functionT> vecfuncT;
245
246public:
247
248 DerivativeOperator(World& world, const int axis1) : world(world), axis(axis1) {
249 gradop = free_space_derivative<T,NDIM>(world, axis);
250 }
251
252 std::string info() const {return "D";}
253
254 functionT operator()(const functionT& ket) const {
255 vecfuncT vket(1,ket);
256 return this->operator()(vket)[0];
257 }
258
259 vecfuncT operator()(const vecfuncT& vket) const {
260 vecfuncT dvket=apply(world, gradop, vket, false);
261 world.gop.fence();
262 return dvket;
263 }
264
265 T operator()(const functionT& bra, const functionT& ket) const {
266 vecfuncT vbra(1,bra), vket(1,ket);
267 Tensor<T> tmat=this->operator()(vbra,vket);
268 return tmat(0l,0l);
269 }
270
271 tensorT operator()(const vecfuncT& vbra, const vecfuncT& vket) const {
272 const auto bra_equiv_ket = &vbra == &vket;
273 vecfuncT dvket=this->operator()(vket);
274 return matrix_inner(world,vbra,dvket, bra_equiv_ket);
275 }
276
277private:
279 int axis;
281
282};
283
284
285/// the Laplacian operator: \sum_i \nabla^2_i
286
287/// note that the application of the Laplacian operator is in general
288/// unstable and very sensitive to noise and cusps in the argument.
289///
290/// !!! BE SURE YOU KNOW WHAT YOU ARE DOING !!!
291///
292/// For computing matrix elements, which is reasonably stable, we refer
293template<typename T, std::size_t NDIM>
294class Laplacian : public SCFOperatorBase<T,NDIM> {
296 typedef std::vector<functionT> vecfuncT;
298
299public:
300
301 Laplacian(World& world, const double e=0.0) : world(world), eps(e) {
302 gradop = gradient_operator<T,NDIM>(world);
303 }
304
305 std::string info() const {return "D^2";}
306
307 functionT operator()(const functionT& ket) const {
308 vecfuncT vket(1,ket);
309 return this->operator()(vket)[0];
310 }
311
312 vecfuncT operator()(const vecfuncT& vket) const;
313
314 T operator()(const functionT& bra, const functionT& ket) const {
315 vecfuncT vbra(1,bra), vket(1,ket);
316 Tensor<T> tmat=this->operator()(vbra,vket);
317 return tmat(0l,0l);
318 }
319
320 tensorT operator()(const vecfuncT& vbra, const vecfuncT& vket) const {
322 return -2.0*t(vbra,vket);
323 }
324
325private:
327 std::vector< std::shared_ptr< Derivative<T,NDIM> > > gradop;
328 double eps;
329};
330
331
332
333template<typename T, std::size_t NDIM>
334class Coulomb : public SCFOperatorBase<T,NDIM> {
335public:
336
338 public:
339 // you need to define the exact argument(s) of operator() as tuple
340 typedef std::tuple<const Function<double,NDIM>&, const std::vector<Function<T,NDIM>> &> argtupleT;
341
342 using resultT = std::vector<Function<T,NDIM>>;
343
345 public:
346 partitionT do_partitioning(const std::size_t& vsize1, const std::size_t& vsize2,
347 const std::string policy) const override {
348 partitionT p={std::pair(Batch(_,_),1.0)};
349 return p;
350 }
351 };
352
356
357 // you need to define an empty constructor for the result
358 // resultT must implement operator+=(const resultT&)
359 resultT allocator(World &world, const argtupleT &argtuple) const {
360 std::size_t n = std::get<1>(argtuple).size();
361 resultT result = zero_functions_compressed<T,NDIM>(world, n);
362 return result;
363 }
364
366 return truncate(vcoul * arg);
367 }
368 };
369
370 /// default empty ctor
372
373 /// default empty ctor
377
378 /// ctor with an SCF calculation providing the MOs and density
379 Coulomb(World& world, const SCF* calc);
380
381 /// ctor with a Nemo calculation providing the MOs and density
382 Coulomb(World& world, const Nemo* nemo);
383
384 std::string info() const {return "J";}
385
386 Coulomb& set_taskq(std::shared_ptr<MacroTaskQ> taskq1) {
387 this->taskq=taskq1;
388 return *this;
389 }
390
391 void reset_poisson_operator_ptr(const double lo, const double econv);
392
394 std::vector<Function<T,NDIM> > vket(1,ket);
395 return this->operator()(vket)[0];
396 }
397
398 std::vector<Function<T,NDIM> > operator()(const std::vector<Function<T,NDIM> >& vket) const {
400 World& world=vket.front().world();
401 MacroTask task(world, t, this->taskq);
402 auto result=task(vcoul,vket);
403 return result;
404 }
405
406 T operator()(const Function<T,NDIM>& bra, const Function<T,NDIM>& ket) const {
407 return inner(bra,vcoul*ket);
408 }
409
410 Tensor<T> operator()(const std::vector<Function<T,NDIM> >& vbra,
411 const std::vector<Function<T,NDIM> >& vket) const {
412 const auto bra_equiv_ket = &vbra == &vket;
413 std::vector<Function<T,NDIM> > vJket;
414 for (std::size_t i=0; i<vket.size(); ++i) {
415 vJket.push_back(this->operator()(vket[i]));
416 }
417 return matrix_inner(world,vbra,vJket,bra_equiv_ket);
418 }
419
420 /// getter for the Coulomb potential
421 const real_function_3d& potential() const {return vcoul;}
422
423 /// setter for the Coulomb potential
425
426 real_function_3d compute_density(const SCF* calc) const;
427
428 /// given a density compute the Coulomb potential
429
430 /// this function uses a newly constructed Poisson operator. Note that
431 /// the accuracy parameters must be consistent with the exchange operator.
433 return (*poisson)(density).truncate();
434 }
435
436 /// given a set of MOs in an SCF calculation, compute the Coulomb potential
437
438 /// this function uses the Poisson operator of the SCF calculation
439 real_function_3d compute_potential(const SCF* calc) const;
440
441 /// given a set of MOs in an SCF calculation, compute the Coulomb potential
442
443 /// this function uses the Poisson operator of the SCF calculation
444 real_function_3d compute_potential(const Nemo* nemo) const;
445
446private:
448 std::shared_ptr<real_convolution_3d> poisson;
449 double lo=1.e-4;
450 real_function_3d vcoul; ///< the coulomb potential
451};
452
453
454template<typename T, std::size_t NDIM>
455class Nuclear : public SCFOperatorBase<T,NDIM> {
456public:
457
458 Nuclear(World& world, const SCF* calc);
459
460 Nuclear(World& world, const NemoBase* nemo);
461
462 /// simple constructor takes a molecule, no nuclear correlation factor or core potentials
464
465 Nuclear(World& world, std::shared_ptr<NuclearCorrelationFactor> ncf)
466 : world(world), ncf(ncf) {}
467
468 std::string info() const {return "Vnuc";}
469
471 std::vector<Function<T,NDIM> > vket(1,ket);
472 return this->operator()(vket)[0];
473 }
474
475 std::vector<Function<T,NDIM> > operator()(const std::vector<Function<T,NDIM> >& vket) const;
476
477 T operator()(const Function<T,NDIM>& bra, const Function<T,NDIM>& ket) const {
478 return inner(bra,this->operator()(ket));
479 }
480
481 Tensor<T> operator()(const std::vector<Function<T,NDIM> >& vbra,
482 const std::vector<Function<T,NDIM> >& vket) const {
483 const auto bra_equiv_ket = &vbra == &vket;
484 std::vector<Function<T,NDIM> > vVket=this->operator()(vket);
485 return matrix_inner(world,vbra,vVket,bra_equiv_ket);
486 }
487
488private:
490 std::shared_ptr<NuclearCorrelationFactor> ncf;
491
492};
493
494
495/// the z component of the angular momentum
496
497/// takes real and complex functions as input, will return complex functions
498template<typename T, std::size_t NDIM>
499class Lz : public SCFOperatorBase<T,NDIM> {
500private:
502public:
503
504 bool use_bsplines=true;
505
506 Lz(World& world, bool use_bspline_derivative=true) : world(world), use_bsplines(use_bspline_derivative) {};
507
508 std::string info() const {return "Lz";}
509
510
512 std::vector<Function<T,NDIM> > vket(1,ket);
513 return this->operator()(vket)[0];
514 }
515
516 std::vector<Function<T,NDIM> > operator()(const std::vector<Function<T,NDIM> >& vket) const {
517
518 // the operator in cartesian components as
519 // L_z = - i (x del_y - y del_x)
520
521 if (vket.size()==0) return std::vector<complex_function_3d>(0);
522
523 real_function_3d x=real_factory_3d(world).functor([] (const coord_3d& r) {return r[0];});
524 real_function_3d y=real_factory_3d(world).functor([] (const coord_3d& r) {return r[1];});
525
526 Derivative<T,NDIM> Dx = free_space_derivative<T,NDIM>(world, 0);
527 Derivative<T,NDIM> Dy = free_space_derivative<T,NDIM>(world, 1);
528 if (use_bsplines) {
529 Dx.set_bspline1();
530 Dy.set_bspline1();
531 }
532
533 reconstruct(world,vket,true);
534 std::vector<Function<T,NDIM> > delx=apply(world,Dx,vket,false);
535 std::vector<Function<T,NDIM> > dely=apply(world,Dy,vket,true);
536
537 std::vector<Function<T,NDIM> > result1=x*dely - y*delx;
538 std::vector<complex_function_3d> cresult1=convert<T,double_complex,NDIM>(world,result1);
539 std::vector<complex_function_3d> result=double_complex(0.0,-1.0)*cresult1;
540 return result;
541 }
542
543 T operator()(const Function<T,NDIM>& bra, const Function<T,NDIM>& ket) const {
544 return inner(bra,this->operator()(ket));
545 }
546
547 Tensor<T> operator()(const std::vector<Function<T,NDIM> >& vbra,
548 const std::vector<Function<T,NDIM> >& vket) const {
549 const auto bra_equiv_ket = &vbra == &vket;
550 std::vector<complex_function_3d> vVket=this->operator()(vket);
551 return matrix_inner(world,vbra,vVket,bra_equiv_ket);
552 }
553
554};
555
556
557
558/// derivative of the (regularized) nuclear potential wrt nuclear displacements
559template<typename T, std::size_t NDIM>
560class DNuclear : public SCFOperatorBase<T,NDIM> {
561public:
562
563 DNuclear(World& world, const SCF* calc, const int iatom, const int iaxis);
564
565 DNuclear(World& world, const Nemo* nemo, const int iatom, const int iaxis);
566
567 DNuclear(World& world, std::shared_ptr<NuclearCorrelationFactor> ncf,
568 const int iatom, const int iaxis)
569 : world(world), ncf(ncf), iatom(iatom), iaxis(iaxis) {}
570
571 std::string info() const {return "DVnuc";}
572
574 std::vector<Function<T,NDIM>> vket(1,ket);
575 return this->operator()(vket)[0];
576 }
577
578 std::vector<Function<T,NDIM>> operator()(const std::vector<Function<T,NDIM>>& vket) const;
579
580 T operator()(const Function<T,NDIM>& bra, const Function<T,NDIM>& ket) const {
581 return inner(bra,this->operator()(ket));
582 }
583
584 Tensor<T> operator()(const std::vector<Function<T,NDIM>>& vbra, const std::vector<Function<T,NDIM>>& vket) const {
585 const auto bra_equiv_ket = &vbra == &vket;
586 std::vector<Function<T,NDIM>> vVket=this->operator()(vket);
587 return matrix_inner(world,vbra,vVket,bra_equiv_ket);
588 }
589
590private:
592 std::shared_ptr<NuclearCorrelationFactor> ncf;
593 int iatom; ///< index of the atom which is displaced
594 int iaxis; ///< x,y,z component of the atom
595
596};
597
598template<typename T, std::size_t NDIM>
600public:
604
605 std::string info() const {return info_str;}
606
607 void set_info(const std::string new_info) {
608 info_str=new_info;
609 }
610
611 void set_potential(const Function<T,NDIM>& new_potential) {
612 potential=copy(new_potential);
613 }
614
616 return (potential*ket).truncate();
617 }
618
619 std::vector<Function<T,NDIM> > operator()(const std::vector<Function<T,NDIM> >& vket) const {
620 return truncate(potential*vket);
621 }
622
623 T operator()(const Function<T,NDIM>& bra, const Function<T,NDIM>& ket) const {
624 return inner(bra,potential*ket);
625 }
626
627 Tensor<T> operator()(const std::vector<Function<T,NDIM> >& vbra,
628 const std::vector<Function<T,NDIM> >& vket) const {
629 const auto bra_equiv_ket = &vbra == &vket;
630 return matrix_inner(world,vbra,potential*vket,bra_equiv_ket);
631 }
632
633private:
635 std::string info_str="Vlocal";
637};
638
639/// operator class for the handling of DFT exchange-correlation functionals
640template<typename T, std::size_t NDIM>
641class XCOperator : public SCFOperatorBase<T,NDIM> {
642public:
643
644 /// default ctor without information about the XC functional
646 extra_truncation(FunctionDefaults<3>::get_thresh()*0.01) {}
647
648 /// custom ctor with information about the XC functional
649 XCOperator(World& world, std::string xc_data, const bool spin_polarized,
650 const real_function_3d& arho, const real_function_3d& brho,
651 std::string deriv="abgv");
652
653 /// ctor with an SCF calculation, will initialize the necessary intermediates
654 XCOperator(World& world, const SCF* scf, int ispin=0, std::string deriv="abgv");
655
656 /// ctor with a Nemo calculation, will initialize the necessary intermediates
657 XCOperator(World& world, const Nemo* nemo, int ispin=0);
658
659 /// ctor with an SCF calculation, will initialize the necessary intermediates
660 XCOperator(World& world, const SCF* scf, const real_function_3d& arho,
661 const real_function_3d& brho, int ispin=0, std::string deriv="abgv");
662
663 /// ctor with an Nemo calculation, will initialize the necessary intermediates
664 XCOperator(World& world, const Nemo* scf, const real_function_3d& arho,
665 const real_function_3d& brho, int ispin=0);
666
667 std::string info() const {return "Vxc";}
668
669 XCOperator& set_extra_truncation(const double& fac) {
671 if (world.rank()==0)
672 print("set extra truncation in XCOperator to", extra_truncation);
673 return *this;
674 }
675
676 /// set the spin state this operator is acting on
677 void set_ispin(const int i) const {ispin=i;}
678
679 /// apply the xc potential on a set of orbitals
680 std::vector<Function<T,NDIM> > operator()(const std::vector<Function<T,NDIM> >& vket) const;
681
682 /// apply the xc potential on an orbitals
684 std::vector<Function<T,3> > vket(1,ket);
685 std::vector<Function<T,3> > vKket=this->operator()(vket);
686 return vKket[0];
687 }
688
689 T operator()(const Function<T,NDIM>& bra, const Function<T,NDIM>& ket) const {
690 MADNESS_EXCEPTION("no implementation of matrix elements of the xc operator",1);
691 };
692
693 Tensor<T> operator()(const std::vector<Function<T,NDIM>>& vbra, const std::vector<Function<T,NDIM>>& vket) const {
694 MADNESS_EXCEPTION("no implementation of matrix elements of the xc operator", 1);
695 }
696
697 /// compute the xc energy using the precomputed intermediates vf and delrho
698 double compute_xc_energy() const;
699
700 /// return the local xc potential
702
703 /// construct the xc kernel and apply it directly on the (response) density
704
705 /// the xc kernel is the second derivative of the xc functions wrt the density
706 /// @param[in] density the (response) density on which the kernel is applied
707 /// @return kernel * density
709 const vecfuncT grad_dens_pt=vecfuncT()) const;
710
711private:
712
713 /// the world
715
716 /// which derivative operator to use
717 std::string dft_deriv;
718
719public:
720 /// interface to the actual XC functionals
721 std::shared_ptr<XCfunctional> xc;
722
723private:
724 /// number of beta orbitals
725 int nbeta;
726
727 /// the XC functionals depend on the spin of the orbitals they act on
728 mutable int ispin;
729
730 /// additional truncation for the densities in the XC kernel
731
732 /// the densities in the DFT kernal are processed as their inverses,
733 /// so noise in the small density regions might amplify and lead to inaccurate
734 /// results. Extra truncation will tighten the truncation threshold by a
735 /// specified factor, default is 0.01.
737
738 /// the nuclear correlation factor, if it exists, for computing derivatives for GGA
739 std::shared_ptr<NuclearCorrelationFactor> ncf;
740
741 /// functions that are need for the computation of the XC operator
742
743 /// the ordering of the intermediates is fixed, but the code can handle
744 /// non-initialized functions, so if e.g. no GGA is requested, all the
745 /// corresponding vector components may be left empty.
746 /// For the ordering of the intermediates see xcfunctional::xc_arg
748
749 /// compute the intermediates for the XC functionals
750
751 /// @param[in] arho density of the alpha orbitals
752 /// @param[in] brho density of the beta orbitals (necessary only if spin-polarized)
753 /// @return xc_args vector of intermediates as described above
754 vecfuncT prep_xc_args(const real_function_3d& arho, const real_function_3d& brho) const;
755
756 /// compute the intermediates for the XC functionals
757
758 /// @param[in] dens_pt perturbed densities from CPHF or TDDFT equations
759 /// @param[in,out] xc_args vector of intermediates as described above
760 /// @param[out] ddens_pt xyz-derivatives of dens_pt
761 void prep_xc_args_response(const real_function_3d& dens_pt,
762 vecfuncT& xc_args, vecfuncT& ddens_pt) const;
763
764 /// check if the intermediates are initialized
765 bool is_initialized() const {
766 return (xc_args.size()>0);
767 }
768
769 /// simple structure to take the pointwise logarithm of a function, shifted by +14
770 struct logme{
771 typedef double resultT;
772 struct logme1 {
773 double operator()(const double& val) {return log(std::max(1.e-14,val))+14.0;}
774 };
775 Tensor<double> operator()(const Key<3>& key, const Tensor<double>& val) const {
776 Tensor<double> result=copy(val);
777 logme1 op;
778 return result.unaryop(op);
779 }
780
781 template <typename Archive>
782 void serialize(Archive& ar) {}
783 };
784
785 /// simple structure to take the pointwise exponential of a function, shifted by +14
786 struct expme{
787 typedef double resultT;
788 struct expme1 {
789 double operator()(const double& val) {return exp(val-14.0);}
790 };
791 Tensor<double> operator()(const Key<3>& key, const Tensor<double>& val) const {
792 Tensor<double> result=copy(val);
793 expme1 op;
794 return result.unaryop(op);
795 }
796
797 template <typename Archive>
798 void serialize(Archive& ar) {}
799
800 };
801};
802
803/// Computes matrix representation of the Fock operator
804template<typename T, std::size_t NDIM>
805class Fock : public SCFOperatorBase<T,NDIM> {
806public:
808
809 Fock(World& world, const Nemo* nemo);
810 Fock(World& world, const OEP* nemo);
811 Fock(World& world, const NemoBase* nemo);
812
813 /// pretty print what this is actually computing
814 std::string info() const {
815 std::string s;
816 for (auto& op : operators) {
817 double number=std::get<0>(op.second);
818 if (number==-1.0) {
819 s+=" - ";
820 } else if (number!=1.0) {
821 std::stringstream snumber;
822 snumber << std::fixed << std::setw(2) << number;
823 s+=" "+snumber.str()+ " ";
824 } else {
825 MADNESS_CHECK(number==1.0);
826 s+=" + ";
827 }
828 s+=op.first;
829 }
830 return s;
831 }
832
833 /// add an operator with default prefactor 1.0
834 void add_operator(std::string name, std::shared_ptr<SCFOperatorBase<T,NDIM>> new_op) {
835 operators.insert({name,valueT(1.0,new_op)});
836 }
837
838 /// add an operator with custom prefactor (e.g. -1.0 for the exchange, supposedly)
839 void add_operator(std::string name, std::tuple<double,std::shared_ptr<SCFOperatorBase<T,NDIM>>> new_op) {
840 operators.insert({name,new_op});
841 }
842
843 /// remove operator, returns 0 if no operator was found
844 int remove_operator(std::string name) {
845 return operators.erase(name);
846 }
847
849 MADNESS_EXCEPTION("Fock(ket) not yet implemented",1);
850 Function<T,NDIM> result;
851 return result;
852 }
853
854 std::vector<Function<T,NDIM>> operator()(const std::vector<Function<T,NDIM>>& vket) const {
855 // make sure T is not part of the Fock operator, it's numerically unstable!
856 MADNESS_CHECK(operators.count("T")==0);
857 std::vector<Function<T,NDIM>> result = zero_functions_compressed<T, NDIM>(world, vket.size());
858 for (const auto& op : operators) {
859 result+=std::get<0>(op.second) * (*std::get<1>(op.second))(vket);
860 }
861 return result;
862 }
863
864 T operator()(const Function<T,NDIM>& bra, const Function<T,NDIM>& ket) const {
865 std::vector<Function<T,NDIM>> vbra(1,bra), vket(1,ket);
866 return (*this)(vbra,vket)(0,0);
867 }
868
869 /// compute the Fock matrix by summing up all contributions
870 Tensor<T> operator()(const std::vector<Function<T,NDIM>>& vbra, const std::vector<Function<T,NDIM>>& vket) const {
871 return this->operator()(vbra,vket,false);
872 }
873
874 /// compute the Fock matrix by summing up all contributions
875 Tensor<T> operator()(const std::vector<Function<T,NDIM>>& vbra, const std::vector<Function<T,NDIM>>& vket,
876 const bool symmetric) const {
877 Tensor<T> fock(vbra.size(),vket.size());
878 for (const auto& op : operators) {
879 Tensor<T> tmp=std::get<0>(op.second) * (*std::get<1>(op.second))(vbra,vket);
880// print("Operator",std::get<1>(op.second)->info());
881// print(tmp);
882 fock+=tmp;
883 }
884 return fock;
885 }
886
887
888private:
889 /// the world
891
892 /// type defining Fock operator contribution including prefactor
893 typedef std::tuple<double,std::shared_ptr<SCFOperatorBase<T,NDIM> > > valueT;
894
895 /// all the Fock operator contribution
896 std::map<std::string,valueT> operators;
897};
898
899}
900#endif /* MADNESS_CHEM_SCFOPERATORS_H_ */
std::complex< double > double_complex
Definition cfft.h:14
partitionT do_partitioning(const std::size_t &vsize1, const std::size_t &vsize2, const std::string policy) const override
override this if you want your own partitioning
Definition SCFOperators.h:346
Definition SCFOperators.h:337
std::vector< Function< T, NDIM > > resultT
Definition SCFOperators.h:342
MacroTaskCoulomb()
Definition SCFOperators.h:353
resultT allocator(World &world, const argtupleT &argtuple) const
Definition SCFOperators.h:359
std::tuple< const Function< double, NDIM > &, const std::vector< Function< T, NDIM > > & > argtupleT
Definition SCFOperators.h:340
resultT operator()(const Function< double, NDIM > &vcoul, const std::vector< Function< T, NDIM > > &arg) const
Definition SCFOperators.h:365
Definition SCFOperators.h:334
Function< T, NDIM > compute_potential(const Function< T, NDIM > &density) const
given a density compute the Coulomb potential
Definition SCFOperators.h:432
real_function_3d compute_density(const SCF *calc) const
Definition SCFOperators.cc:204
Coulomb & set_taskq(std::shared_ptr< MacroTaskQ > taskq1)
Definition SCFOperators.h:386
real_function_3d & potential()
setter for the Coulomb potential
Definition SCFOperators.h:424
World & world
Definition SCFOperators.h:447
Coulomb(World &world)
default empty ctor
Definition SCFOperators.h:371
Coulomb(World &world, const double lo, const double thresh=FunctionDefaults< 3 >::get_thresh())
default empty ctor
Definition SCFOperators.h:374
const real_function_3d & potential() const
getter for the Coulomb potential
Definition SCFOperators.h:421
std::string info() const
print some information about this operator
Definition SCFOperators.h:384
std::vector< Function< T, NDIM > > operator()(const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:398
std::shared_ptr< real_convolution_3d > poisson
Definition SCFOperators.h:448
real_function_3d vcoul
the coulomb potential
Definition SCFOperators.h:450
double lo
Definition SCFOperators.h:449
Tensor< T > operator()(const std::vector< Function< T, NDIM > > &vbra, const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:410
Function< T, NDIM > operator()(const Function< T, NDIM > &ket) const
Definition SCFOperators.h:393
void reset_poisson_operator_ptr(const double lo, const double econv)
Definition SCFOperators.cc:199
T operator()(const Function< T, NDIM > &bra, const Function< T, NDIM > &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:406
derivative of the (regularized) nuclear potential wrt nuclear displacements
Definition SCFOperators.h:560
World & world
Definition SCFOperators.h:591
std::string info() const
print some information about this operator
Definition SCFOperators.h:571
DNuclear(World &world, std::shared_ptr< NuclearCorrelationFactor > ncf, const int iatom, const int iaxis)
Definition SCFOperators.h:567
T operator()(const Function< T, NDIM > &bra, const Function< T, NDIM > &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:580
std::shared_ptr< NuclearCorrelationFactor > ncf
Definition SCFOperators.h:592
Tensor< T > operator()(const std::vector< Function< T, NDIM > > &vbra, const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:584
int iatom
index of the atom which is displaced
Definition SCFOperators.h:593
Function< T, NDIM > operator()(const Function< T, NDIM > &ket) const
Definition SCFOperators.h:573
int iaxis
x,y,z component of the atom
Definition SCFOperators.h:594
Definition SCFOperators.h:241
tensorT operator()(const vecfuncT &vbra, const vecfuncT &vket) const
compute the matrix <vbra | op | vket>
Definition SCFOperators.h:271
functionT operator()(const functionT &ket) const
Definition SCFOperators.h:254
int axis
Definition SCFOperators.h:279
DerivativeOperator(World &world, const int axis1)
Definition SCFOperators.h:248
T operator()(const functionT &bra, const functionT &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:265
std::string info() const
print some information about this operator
Definition SCFOperators.h:252
Derivative< T, NDIM > gradop
Definition SCFOperators.h:280
Tensor< T > tensorT
Definition SCFOperators.h:244
Function< T, NDIM > functionT
Definition SCFOperators.h:242
vecfuncT operator()(const vecfuncT &vket) const
apply this operator on the argument vector of functions
Definition SCFOperators.h:259
World & world
Definition SCFOperators.h:278
std::vector< functionT > vecfuncT
Definition SCFOperators.h:243
Implements derivatives operators with variety of boundary conditions on simulation domain.
Definition derivative.h:266
void set_bspline1()
Definition derivative.h:612
Manages data associated with a row/column/block distributed array.
Definition distributed_matrix.h:388
Definition exchangeoperator.h:17
Definition SCFOperators.h:104
Function< T, NDIM > functionT
Definition SCFOperators.h:109
Exchange & set_taskq(std::shared_ptr< MacroTaskQ > taskq1)
Definition SCFOperators.h:143
Exchange & set_printlevel(const long &level)
Definition SCFOperators.cc:727
T operator()(const Function< T, NDIM > &bra, const Function< T, NDIM > &ket) const
compute the matrix element <bra | K | ket>
Definition SCFOperators.h:167
Algorithm
Definition SCFOperators.h:116
@ multiworld_efficient
Definition SCFOperators.h:117
@ small_memory
Definition SCFOperators.h:117
@ large_memory
Definition SCFOperators.h:117
Tensor< T > tensorT
Definition SCFOperators.h:111
bool is_symmetric() const
Definition SCFOperators.cc:710
Function< T, NDIM > operator()(const Function< T, NDIM > &ket) const
Definition SCFOperators.h:150
Exchange & set_symmetric(const bool flag)
Definition SCFOperators.cc:715
implT impl
Definition SCFOperators.h:113
std::shared_ptr< ExchangeImpl > implT
Definition SCFOperators.h:108
Exchange & set_algorithm(const Algorithm &alg)
Definition SCFOperators.cc:721
Tensor< T > operator()(const vecfuncT &vbra, const vecfuncT &vket) const
compute the matrix < vbra | K | vket >
Definition SCFOperators.h:176
Exchange & set_bra_and_ket(const vecfuncT &bra, const vecfuncT &ket)
Definition SCFOperators.cc:699
std::vector< functionT > vecfuncT
Definition SCFOperators.h:110
vecfuncT operator()(const vecfuncT &vket) const
apply the exchange operator on a vector of functions
std::string info() const
print some information about this operator
Definition SCFOperators.h:133
Computes matrix representation of the Fock operator.
Definition SCFOperators.h:805
int remove_operator(std::string name)
remove operator, returns 0 if no operator was found
Definition SCFOperators.h:844
Fock(World &world)
Definition SCFOperators.h:807
World & world
the world
Definition SCFOperators.h:890
Tensor< T > operator()(const std::vector< Function< T, NDIM > > &vbra, const std::vector< Function< T, NDIM > > &vket) const
compute the Fock matrix by summing up all contributions
Definition SCFOperators.h:870
Tensor< T > operator()(const std::vector< Function< T, NDIM > > &vbra, const std::vector< Function< T, NDIM > > &vket, const bool symmetric) const
compute the Fock matrix by summing up all contributions
Definition SCFOperators.h:875
Fock(World &world, const OEP *nemo)
Fock(World &world, const NemoBase *nemo)
Fock(World &world, const Nemo *nemo)
std::map< std::string, valueT > operators
all the Fock operator contribution
Definition SCFOperators.h:896
T operator()(const Function< T, NDIM > &bra, const Function< T, NDIM > &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:864
std::tuple< double, std::shared_ptr< SCFOperatorBase< T, NDIM > > > valueT
type defining Fock operator contribution including prefactor
Definition SCFOperators.h:893
void add_operator(std::string name, std::tuple< double, std::shared_ptr< SCFOperatorBase< T, NDIM > > > new_op)
add an operator with custom prefactor (e.g. -1.0 for the exchange, supposedly)
Definition SCFOperators.h:839
Function< T, NDIM > operator()(const Function< T, NDIM > &ket) const
Definition SCFOperators.h:848
std::string info() const
pretty print what this is actually computing
Definition SCFOperators.h:814
void add_operator(std::string name, std::shared_ptr< SCFOperatorBase< T, NDIM > > new_op)
add an operator with default prefactor 1.0
Definition SCFOperators.h:834
std::vector< Function< T, NDIM > > operator()(const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:854
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:204
A multiresolution adaptive numerical function.
Definition mra.h:122
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:66
Definition SCFOperators.h:188
Tensor< T > tensorT
Definition SCFOperators.h:192
std::vector< std::shared_ptr< Derivative< T, NDIM > > > gradop
Definition SCFOperators.h:231
tensorT operator()(const vecfuncT &vbra, const vecfuncT &vket) const
compute the matrix <vbra | op | vket>
Definition SCFOperators.h:217
World & world
Definition SCFOperators.h:230
Kinetic(World &world)
Definition SCFOperators.h:195
std::vector< functionT > vecfuncT
Definition SCFOperators.h:191
Function< T, NDIM > functionT
Definition SCFOperators.h:190
std::string info() const
print some information about this operator
Definition SCFOperators.h:199
distmatT kinetic_energy_matrix(World &world, const vecfuncT &v) const
Definition SCFOperators.cc:51
DistributedMatrix< T > distmatT
Definition SCFOperators.h:189
vecfuncT operator()(const vecfuncT &vket) const
apply this operator on the argument vector of functions
Definition SCFOperators.h:206
T operator()(const functionT &bra, const functionT &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:211
functionT operator()(const functionT &ket) const
Definition SCFOperators.h:201
the Laplacian operator: \sum_i \nabla^2_i
Definition SCFOperators.h:294
T operator()(const functionT &bra, const functionT &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:314
double eps
Definition SCFOperators.h:328
Tensor< T > tensorT
Definition SCFOperators.h:297
functionT operator()(const functionT &ket) const
Definition SCFOperators.h:307
Function< T, NDIM > functionT
Definition SCFOperators.h:295
std::string info() const
print some information about this operator
Definition SCFOperators.h:305
tensorT operator()(const vecfuncT &vbra, const vecfuncT &vket) const
compute the matrix <vbra | op | vket>
Definition SCFOperators.h:320
std::vector< functionT > vecfuncT
Definition SCFOperators.h:296
vecfuncT operator()(const vecfuncT &vket) const
apply this operator on the argument vector of functions
Laplacian(World &world, const double e=0.0)
Definition SCFOperators.h:301
std::vector< std::shared_ptr< Derivative< T, NDIM > > > gradop
Definition SCFOperators.h:327
World & world
Definition SCFOperators.h:326
Definition SCFOperators.h:599
Tensor< T > operator()(const std::vector< Function< T, NDIM > > &vbra, const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:627
std::string info() const
print some information about this operator
Definition SCFOperators.h:605
T operator()(const Function< T, NDIM > &bra, const Function< T, NDIM > &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:623
void set_info(const std::string new_info)
Definition SCFOperators.h:607
std::vector< Function< T, NDIM > > operator()(const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:619
Function< T, NDIM > operator()(const Function< T, NDIM > &ket) const
Definition SCFOperators.h:615
Function< T, NDIM > potential
Definition SCFOperators.h:636
LocalPotentialOperator(World &world)
Definition SCFOperators.h:601
World & world
Definition SCFOperators.h:634
std::string info_str
Definition SCFOperators.h:635
LocalPotentialOperator(World &world, const std::string info, const Function< T, NDIM > potential)
Definition SCFOperators.h:602
void set_potential(const Function< T, NDIM > &new_potential)
Definition SCFOperators.h:611
the z component of the angular momentum
Definition SCFOperators.h:499
T operator()(const Function< T, NDIM > &bra, const Function< T, NDIM > &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:543
Lz(World &world, bool use_bspline_derivative=true)
Definition SCFOperators.h:506
Tensor< T > operator()(const std::vector< Function< T, NDIM > > &vbra, const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:547
std::vector< Function< T, NDIM > > operator()(const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:516
World & world
Definition SCFOperators.h:501
std::string info() const
print some information about this operator
Definition SCFOperators.h:508
Function< T, NDIM > operator()(const Function< T, NDIM > &ket) const
Definition SCFOperators.h:511
bool use_bsplines
Definition SCFOperators.h:504
Definition macrotaskq.h:716
std::shared_ptr< MacroTaskPartitioner > partitioner
Definition macrotaskq.h:720
partition one (two) vectors into 1D (2D) batches.
Definition macrotaskpartitioner.h:190
std::string policy
how to partition the batches
Definition macrotaskpartitioner.h:198
std::list< std::pair< Batch, double > > partitionT
Definition macrotaskpartitioner.h:194
friend class Batch
Definition macrotaskpartitioner.h:191
Definition macrotaskq.h:463
Definition molecule.h:124
Definition nemo.h:69
The Nemo class.
Definition nemo.h:326
Definition SCFOperators.h:455
Function< T, NDIM > operator()(const Function< T, NDIM > &ket) const
Definition SCFOperators.h:470
T operator()(const Function< T, NDIM > &bra, const Function< T, NDIM > &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:477
Tensor< T > operator()(const std::vector< Function< T, NDIM > > &vbra, const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:481
std::string info() const
print some information about this operator
Definition SCFOperators.h:468
World & world
Definition SCFOperators.h:489
Nuclear(World &world, std::shared_ptr< NuclearCorrelationFactor > ncf)
Definition SCFOperators.h:465
std::shared_ptr< NuclearCorrelationFactor > ncf
Definition SCFOperators.h:490
Definition oep.h:144
Definition SCFOperators.h:58
std::vector< functionT > vecfuncT
Definition SCFOperators.h:62
Tensor< T > tensorT
Definition SCFOperators.h:63
virtual std::string info() const =0
print some information about this operator
std::shared_ptr< MacroTaskQ > taskq
Definition SCFOperators.h:70
Function< T, NDIM > functionT
Definition SCFOperators.h:61
SCFOperatorBase(std::shared_ptr< MacroTaskQ > taskq)
Definition SCFOperators.h:66
virtual ~SCFOperatorBase()
Definition SCFOperators.h:68
virtual tensorT operator()(const vecfuncT &vbra, const vecfuncT &vket) const =0
compute the matrix <vbra | op | vket>
virtual vecfuncT operator()(const vecfuncT &vket) const =0
apply this operator on the argument vector of functions
virtual functionT operator()(const functionT &ket) const =0
virtual T operator()(const functionT &bra, const functionT &ket) const =0
compute the matrix element <bra | op | ket>
Definition SCF.h:187
A tensor is a multidimension array.
Definition tensor.h:317
Tensor< T > & unaryop(opT &op)
Inplace apply a unary function to each element of the tensor.
Definition tensor.h:1792
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
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:328
WorldGopInterface & gop
Global operations.
Definition world.h:205
operator class for the handling of DFT exchange-correlation functionals
Definition SCFOperators.h:641
XCOperator(World &world)
default ctor without information about the XC functional
Definition SCFOperators.h:645
vecfuncT xc_args
functions that are need for the computation of the XC operator
Definition SCFOperators.h:747
Tensor< T > operator()(const std::vector< Function< T, NDIM > > &vbra, const std::vector< Function< T, NDIM > > &vket) const
Definition SCFOperators.h:693
bool is_initialized() const
check if the intermediates are initialized
Definition SCFOperators.h:765
double compute_xc_energy() const
compute the xc energy using the precomputed intermediates vf and delrho
Definition SCFOperators.cc:445
std::string info() const
print some information about this operator
Definition SCFOperators.h:667
real_function_3d make_xc_potential() const
return the local xc potential
Definition SCFOperators.cc:461
XCOperator & set_extra_truncation(const double &fac)
Definition SCFOperators.h:669
Function< T, NDIM > operator()(const Function< T, NDIM > &ket) const
apply the xc potential on an orbitals
Definition SCFOperators.h:683
void prep_xc_args_response(const real_function_3d &dens_pt, vecfuncT &xc_args, vecfuncT &ddens_pt) const
compute the intermediates for the XC functionals
Definition SCFOperators.cc:625
T operator()(const Function< T, NDIM > &bra, const Function< T, NDIM > &ket) const
compute the matrix element <bra | op | ket>
Definition SCFOperators.h:689
std::vector< Function< T, NDIM > > operator()(const std::vector< Function< T, NDIM > > &vket) const
apply the xc potential on a set of orbitals
Definition SCFOperators.cc:438
std::string dft_deriv
which derivative operator to use
Definition SCFOperators.h:717
std::shared_ptr< NuclearCorrelationFactor > ncf
the nuclear correlation factor, if it exists, for computing derivatives for GGA
Definition SCFOperators.h:739
void set_ispin(const int i) const
set the spin state this operator is acting on
Definition SCFOperators.h:677
double extra_truncation
additional truncation for the densities in the XC kernel
Definition SCFOperators.h:736
std::shared_ptr< XCfunctional > xc
interface to the actual XC functionals
Definition SCFOperators.h:721
vecfuncT prep_xc_args(const real_function_3d &arho, const real_function_3d &brho) const
compute the intermediates for the XC functionals
Definition SCFOperators.cc:575
World & world
the world
Definition SCFOperators.h:714
real_function_3d apply_xc_kernel(const real_function_3d &density, const vecfuncT grad_dens_pt=vecfuncT()) const
construct the xc kernel and apply it directly on the (response) density
Definition SCFOperators.cc:536
int ispin
the XC functionals depend on the spin of the orbitals they act on
Definition SCFOperators.h:728
int nbeta
number of beta orbitals
Definition SCFOperators.h:725
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
static double lo
Definition dirac-hatom.cc:23
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
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:2502
static const double v
Definition hatom_sf_dirac.cc:20
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
Declares the macrotaskq and MacroTaskBase classes.
General header file for using MADNESS.
#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
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
void truncate(World &world, response_space &v, double tol, bool fence)
Definition basic_operators.cc:30
const std::vector< Function< T, NDIM > > & reconstruct(const std::vector< Function< T, NDIM > > &v)
reconstruct a vector of functions
Definition vmra.h:156
static const Slice _(0,-1, 1)
FunctionFactory< double, 3 > real_factory_3d
Definition functypedefs.h:93
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
response_space apply(World &world, std::vector< std::vector< std::shared_ptr< real_convolution_3d > > > &op, response_space &f)
Definition basic_operators.cc:39
double inner(response_space &a, response_space &b)
Definition response_functions.h:442
vector< functionT > vecfuncT
Definition corepotential.cc:58
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
void matrix_inner(DistributedMatrix< T > &A, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< T, NDIM > > &g, bool sym=false)
Definition distpm.cc:46
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 thresh
Definition rk.cc:45
Definition SCFOperators.h:788
double operator()(const double &val)
Definition SCFOperators.h:789
simple structure to take the pointwise exponential of a function, shifted by +14
Definition SCFOperators.h:786
Tensor< double > operator()(const Key< 3 > &key, const Tensor< double > &val) const
Definition SCFOperators.h:791
void serialize(Archive &ar)
Definition SCFOperators.h:798
double resultT
Definition SCFOperators.h:787
Definition SCFOperators.h:772
double operator()(const double &val)
Definition SCFOperators.h:773
simple structure to take the pointwise logarithm of a function, shifted by +14
Definition SCFOperators.h:770
Tensor< double > operator()(const Key< 3 > &key, const Tensor< double > &val) const
Definition SCFOperators.h:775
void serialize(Archive &ar)
Definition SCFOperators.h:782
double resultT
Definition SCFOperators.h:771
Definition dirac-hatom.cc:108
int task(int i)
Definition test_runtime.cpp:4
void e()
Definition test_sig.cc:75
static Molecule molecule
Definition testperiodicdft.cc:38