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