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