MADNESS  version 0.9
chem/SCF.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  $Id$
33 */
34 
38 
39 
40 #ifndef MADNESS_CHEM_SCF_H__INCLUDED
41 #define MADNESS_CHEM_SCF_H__INCLUDED
42 
43 //#define WORLD_INSTANTIATE_STATIC_TEMPLATES
44 
45 #include <madness/mra/mra.h>
46 
47 #include <chem/molecule.h>
48 #include <chem/molecularbasis.h>
49 #include <chem/corepotential.h>
50 #include <chem/xcfunctional.h>
51 #include <chem/potentialmanager.h>
53 
54 #include <madness/tensor/solvers.h>
56 
57 
58 namespace madness {
59 
61 typedef Vector<double,3> coordT;
64 typedef std::vector<functionT> vecfuncT;
65 typedef std::pair<vecfuncT,vecfuncT> pairvecfuncT;
66 typedef std::vector<pairvecfuncT> subspaceT;
67 typedef Tensor<double> tensorT;
73 typedef std::vector<complex_functionT> cvecfuncT;
75 
76  extern distmatT distributed_localize_PM(World & world,
77  const vecfuncT & mo,
78  const vecfuncT & ao,
79  const std::vector<int> & set,
80  const std::vector<int> & at_to_bf,
81  const std::vector<int> & at_nbf,
82  const double thresh = 1e-9,
83  const double thetamax = 0.5,
84  const bool randomize = true,
85  const bool doprint = false);
86 
87 inline double mask1(double x) {
88  /* Iterated first beta function to switch smoothly
89  from 0->1 in [0,1]. n iterations produce 2*n-1
90  zero derivatives at the end points. Order of polyn
91  is 3^n.
92 
93  Currently use one iteration so that first deriv.
94  is zero at interior boundary and is exactly representable
95  by low order multiwavelet without refinement */
96 
97  x = (x*x*(3.-2.*x));
98  return x;
99 }
100 
101 static double mask3(const coordT& ruser) {
102  coordT rsim;
103  user_to_sim(ruser, rsim);
104  double x= rsim[0], y=rsim[1], z=rsim[2];
105  double lo = 0.0625, hi = 1.0-lo, result = 1.0;
106  double rlo = 1.0/lo;
107 
108  if (x<lo)
109  result *= mask1(x*rlo);
110  else if (x>hi)
111  result *= mask1((1.0-x)*rlo);
112  if (y<lo)
113  result *= mask1(y*rlo);
114  else if (y>hi)
115  result *= mask1((1.0-y)*rlo);
116  if (z<lo)
117  result *= mask1(z*rlo);
118  else if (z>hi)
119  result *= mask1((1.0-z)*rlo);
120 
121  return result;
122 }
123 
125 private:
126  const Molecule& molecule;
127  const AtomicBasisSet& aobasis;
128 public:
129  MolecularGuessDensityFunctor(const Molecule& molecule, const AtomicBasisSet& aobasis)
130  : molecule(molecule), aobasis(aobasis) {}
131 
132  double operator()(const coordT& x) const {
133  return aobasis.eval_guess_density(molecule, x[0], x[1], x[2]);
134  }
135 
136  std::vector<coordT> special_points() const {return molecule.get_all_coords_vec();}
137 };
138 
139 
141 private:
142  const AtomicBasisFunction aofunc;
143 
144 public:
146  : aofunc(aofunc)
147  {}
148 
149  double operator()(const coordT& x) const {
150  return aofunc(x[0], x[1], x[2]);
151  }
152 
153  std::vector<coordT> special_points() const {
154  return std::vector<coordT>(1,aofunc.get_coords_vec());
155  }
156 };
157 
159 private:
160  const Molecule& molecule;
161  const int atom;
162  const int axis;
163 
164 public:
165  MolecularDerivativeFunctor(const Molecule& molecule, int atom, int axis)
166  : molecule(molecule), atom(atom), axis(axis)
167  {}
168 
169  double operator()(const coordT& x) const {
170  return molecule.nuclear_attraction_potential_derivative(atom, axis, x[0], x[1], x[2]);
171  }
172 
173  std::vector<coordT> special_points() const {
174  return std::vector<coordT>(1,molecule.get_atom(atom).get_coords());
175  }
176 };
177 
179 private:
180  const Molecule& molecule;
181  const int atom;
182  const int axis;
183  std::vector<coordT> specialpt;
184 public:
185  CorePotentialDerivativeFunctor(const Molecule& molecule, int atom, int axis)
186  : molecule(molecule), atom(atom), axis(axis) {}
187 
188  double operator()(const coordT& r) const {
189  return molecule.core_potential_derivative(atom, axis, r[0], r[1], r[2]);
190  }
191 };
192 
194 class DipoleFunctor : public FunctionFunctorInterface<double,3> {
195 private:
196  const int axis;
197 public:
198  DipoleFunctor(int axis) : axis(axis) {}
199  double operator()(const coordT& x) const {
200  return x[axis];
201  }
202 };
203 
204 
205 
207 class MomentFunctor : public FunctionFunctorInterface<double,3> {
208 private:
209  const int i, j, k;
210 public:
211  MomentFunctor(int i, int j, int k) : i(i), j(j), k(k) {}
212  MomentFunctor(const std::vector<int>& x) : i(x[0]), j(x[1]), k(x[2]) {}
213  double operator()(const coordT& r) const {
214  double xi=1.0, yj=1.0, zk=1.0;
215  for (int p=0; p<i; ++p) xi *= r[0];
216  for (int p=0; p<j; ++p) yj *= r[1];
217  for (int p=0; p<k; ++p) zk *= r[2];
218  return xi*yj*zk;
219  }
220 };
221 
223 template<typename T>
225  double _omega;
226  Function<T,3> _f;
227 public:
229 // const std::shared_ptr<FunctionFunctorInterface<T,3> >& functor,
230  const FunctionFunctorInterface<T,3>* functor,
231  double omega) : _omega(omega)
232  {
233 // _f = factoryT(world).functor(functor);
234  _f = factoryT(world).functor(functorT(new DipoleFunctor(2)));
235  }
236  Function<T,3> operator()(const double t) const {
237  return std::cos(_omega * t) * _f;
238  }
239 };
240 
241 
242 template <typename T, int NDIM>
243 struct lbcost {
244  double leaf_value;
245  double parent_value;
246  lbcost(double leaf_value=1.0, double parent_value=0.0) : leaf_value(leaf_value), parent_value(parent_value) {}
247  double operator()(const Key<NDIM>& key, const FunctionNode<T,NDIM>& node) const {
248  if (key.level() < 1) {
249  return 100.0*(leaf_value+parent_value);
250  }
251  else if (node.is_leaf()) {
252  return leaf_value;
253  }
254  else {
255  return parent_value;
256  }
257  }
258 };
259 
260 
262  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
263  // !!! !!!
264  // !!! If you add more data don't forget to add them to serialize method !!!
265  // !!! !!!
266  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
267 
268  // First list input parameters
269  double charge;
270  double smear;
271  double econv;
272  double dconv;
273  int k;
274  double L;
275  double maxrotn;
276  int nvalpha;
277  int nvbeta;
278  int nopen;
279  int maxiter;
280  int nio;
283  bool plotdens;
284  bool plotcoul;
285  bool localize;
286  bool localize_pm;
287  bool restart;
288  bool no_compute;
289  bool no_orient;
290  bool save;
291  unsigned int maxsub;
292  double orbitalshift;
293  int npt_plot;
294  tensorT plot_cell;
297  bool derivatives;
298  bool dipole;
300  // Next list inferred parameters
301  int nalpha;
302  int nbeta;
303  int nmo_alpha;
304  int nmo_beta;
305  double lo;
307  std::vector<double> protocol_data;
308  bool gopt;
309  double gtol;
310  bool gtest;
311  double gval;
312  double gprec;
313  int gmaxiter;
315  bool tdksprop;
317  bool psp_calc;
318  //bool absolvent; ///< If true calculate solvation effects
319  //double epsilon_2; ///< dielectric constant of solvent
320  //double Gamma; ///< surface tension of solvent
321  //double beta; ///switching parameter controles boundary conditions of solvent cavity
322  //double rho_0; /// threshold density--determines size of molecular cavity
323  //double sigma; ///switching parameter controles boundary conditions of solvent cavity-(SVPE)
324 
325  template <typename Archive>
326  void serialize(Archive& ar) {
327  ar & charge & smear & econv & dconv & k & L & maxrotn & nvalpha & nvbeta
328  & nopen & maxiter & nio & spin_restricted;
329  ar & plotlo & plothi & plotdens & plotcoul & localize & localize_pm
330  & restart & save & no_compute &no_orient & maxsub & orbitalshift & npt_plot & plot_cell & aobasis;
331  ar & nalpha & nbeta & nmo_alpha & nmo_beta & lo;
332  ar & core_type & derivatives & conv_only_dens & dipole;
333  ar & xc_data & protocol_data;
334  ar & gopt & gtol & gtest & gval & gprec & gmaxiter & algopt & tdksprop & psp_calc;
335  //ar & absolvent & epsilon_2 & Gamma & Gamma & beta & rho_0 & sigma;
336  }
337 
339  : charge(0.0)
340  , smear(0.0)
341  , econv(1e-5)
342  , dconv(1e-4)
343  , k(-1)
344  , L(0.0)
345  , maxrotn(0.25)
346  , nvalpha(0)
347  , nvbeta(0)
348  , nopen(0)
349  , maxiter(20)
350  , nio(1)
351  , spin_restricted(true)
352  , plotlo(0)
353  , plothi(-1)
354  , plotdens(false)
355  , plotcoul(false)
356  , localize(true)
357  , localize_pm(true)
358  , restart(false)
359  , no_compute(false)
360  , no_orient(false)
361  , save(true)
362  , maxsub(8)
363  , orbitalshift(0.0)
364  , npt_plot(101)
365  , aobasis("6-31g")
366  , core_type("")
367  , derivatives(false)
368  , dipole(false)
369  , conv_only_dens(false)
370  , nalpha(0)
371  , nbeta(0)
372  , nmo_alpha(0)
373  , nmo_beta(0)
374  , lo(1e-10)
375  , xc_data("lda")
376  , protocol_data(madness::vector_factory(1e-4, 1e-6))
377  , gopt(false)
378  , gtol(1e-3)
379  , gtest(false)
380  , gval(1e-5)
381  , gprec(1e-4)
382  , gmaxiter(20)
383  , algopt("BFGS")
384  , tdksprop(false)
385  , nuclear_corrfac("none")
386  , psp_calc(false)
387  //, absolvent(false)
388  //, epsilon_2(78.304)
389  //, Gamma(0.0719)
390  //, beta(1.3)
391  //, rho_0(0.00048)
392  //, sigma(0.3)
393  {}
394 
395 
396  void read_file(const std::string& filename) {
397  std::ifstream f(filename.c_str());
398  position_stream(f, "dft");
399  std::string s;
400  xc_data = "lda";
401  protocol_data = madness::vector_factory(1e-4, 1e-6);
402 
403  while (f >> s) {
404  if (s == "end") {
405  break;
406  }
407  else if (s == "charge") {
408  f >> charge;
409  }
410  else if (s == "smear") {
411  f >> smear;
412  }
413  else if (s == "econv") {
414  f >> econv;
415  }
416  else if (s == "dconv") {
417  f >> dconv;
418  }
419  else if (s == "k") {
420  f >> k;
421  }
422  else if (s == "L") {
423  f >> L;
424  }
425  else if (s == "maxrotn") {
426  f >> maxrotn;
427  }
428  else if (s == "nvalpha") {
429  f >> nvalpha;
430  }
431  else if (s == "nvbeta") {
432  f >> nvbeta;
433  }
434  else if (s == "nopen") {
435  f >> nopen;
436  }
437  else if (s == "unrestricted") {
438  spin_restricted = false;
439  }
440  else if (s == "restricted") {
441  spin_restricted = true;
442  }
443  else if (s == "maxiter") {
444  f >> maxiter;
445  }
446  else if (s == "nio") {
447  f >> nio;
448  }
449  else if (s == "xc") {
450  char buf[1024];
451  f.getline(buf,sizeof(buf));
452  xc_data = buf;
453  }
454  else if (s == "protocol") {
455  std::string buf;
456  std::getline(f,buf);
457  protocol_data = std::vector<double>();
458  double d;
459  std::stringstream s(buf);
460  while (s >> d) protocol_data.push_back(d);
461  }
462  else if (s == "plotmos") {
463  f >> plotlo >> plothi;
464  }
465  else if (s == "plotdens") {
466  plotdens = true;
467  }
468  // else if (s == "absolvent") {
469  // absolvent = true;
470  // }
471  // else if (s == "dielec") {
472  // f >> epsilon_2;
473  // }
474  // else if (s == "Gamma") {
475  // f >> Gamma;
476  // }
477  // else if (s == "beta") {
478  // f >> beta;
479  // }
480  // else if (s == "rho_0") {
481  // f >> rho_0;
482  // }
483  // else if (s == "sigma") {
484  // f >> sigma;
485  // }
486  else if (s == "plotcoul") {
487  plotcoul = true;
488  }
489  else if (s == "plotnpt") {
490  f >> npt_plot;
491  }
492  else if (s == "plotcell") {
493  plot_cell = tensorT(3L,2L);
494  f >> plot_cell(0,0) >> plot_cell(0,1) >> plot_cell(1,0) >> plot_cell(1,1) >> plot_cell(2,0) >> plot_cell(2,1);
495  }
496  else if (s == "aobasis") {
497  f >> aobasis;
498  if (aobasis!="sto-3g" && aobasis!="sto-6g" && aobasis!="6-31g") {
499  std::cout << "moldft: unrecognized aobasis (sto-3g or sto-6g or 6-31g only): " << aobasis << std::endl;
500  MADNESS_EXCEPTION("input_error", 0);
501  }
502  }
503  else if (s == "canon") {
504  localize = false;
505  }
506  else if (s == "local") {
507  localize = true;
508  }
509  else if (s == "pm") {
510  localize_pm = true;
511  }
512  else if (s == "boys") {
513  localize_pm = false;
514  }
515  else if (s == "restart") {
516  restart = true;
517  }
518  else if (s == "save") {
519  //can't redirect true/false as with other variables so create temporary variable
520  std::string tmp_save;
521  f >> tmp_save;
522  if (tmp_save=="true"){
523  save=true;
524  }
525  else if (tmp_save=="false"){
526  save=false;
527  }
528  else{
529  std::cout << "moldft: unrecognized value for save (true or false only): " << tmp_save << std::endl;
530  MADNESS_EXCEPTION("input_error", 0);
531  }
532  }
533  else if (s == "no_compute") {
534  no_compute = true;
535  }
536  else if (s == "no_orient") {
537  no_orient = true;
538  }
539  else if (s == "maxsub") {
540  f >> maxsub;
541  if (maxsub <= 0) maxsub = 1;
542  if (maxsub > 20) maxsub = 20;
543  }
544  else if (s == "orbitalshift") {
545  f >> orbitalshift;
546  }
547  else if (s == "core_type") {
548  f >> core_type;
549  }
550  else if (s == "derivatives") {
551  derivatives = true;
552  }
553  else if (s == "dipole") {
554  dipole = true;
555  }
556  else if (s == "convonlydens") {
557  conv_only_dens = true;
558  }
559  else if (s == "gopt") {
560  gopt = true;
561  }
562  else if (s == "gtol") {
563  f >> gtol;
564  }
565  else if (s == "gtest") {
566  gtest = true;
567  }
568  else if (s == "gval") {
569  f >> gval;
570  }
571  else if (s == "gprec") {
572  f >> gprec;
573  }
574  else if (s == "gmaxiter") {
575  f >> gmaxiter;
576  }
577  else if (s == "algopt") {
578  char buf[1024];
579  f.getline(buf,sizeof(buf));
580  algopt = buf;
581  }
582  else if (s == "tdksprop") {
583  tdksprop = true;
584  }
585  else if (s == "nuclear_corrfac") {
586  std::string str;
587  std::getline(f,str);
588  nuclear_corrfac=str;
589  }
590  else if (s == "psp_calc") {
591  psp_calc = true;
592  }
593  else {
594  std::cout << "moldft: unrecognized input keyword " << s << std::endl;
595  MADNESS_EXCEPTION("input error",0);
596  }
597  if (nopen != 0) spin_restricted = false;
598  }
599  }
600 
601  void set_molecular_info(const Molecule& molecule, const AtomicBasisSet& aobasis, unsigned int n_core) {
602  double z = molecule.total_nuclear_charge();
603  int nelec = int(z - charge - n_core*2);
604  if (fabs(nelec+charge+n_core*2-z) > 1e-6) {
605  error("non-integer number of electrons?", nelec+charge+n_core*2-z);
606  }
607  nalpha = (nelec + nopen)/2;
608  nbeta = (nelec - nopen)/2;
609  if (nalpha < 0) error("negative number of alpha electrons?", nalpha);
610  if (nbeta < 0) error("negative number of beta electrons?", nbeta);
611  if ((nalpha+nbeta) != nelec) error("nalpha+nbeta != nelec", nalpha+nbeta);
612  nmo_alpha = nalpha + nvalpha;
613  nmo_beta = nbeta + nvbeta;
614  if (nalpha != nbeta) spin_restricted = false;
615 
616  // Ensure we have enough basis functions to guess the requested
617  // number of states ... a minimal basis for a closed-shell atom
618  // might not have any functions for virtuals.
619  int nbf = aobasis.nbf(molecule);
620  nmo_alpha = std::min(nbf,nmo_alpha);
621  nmo_beta = std::min(nbf,nmo_beta);
622  if (nalpha>nbf || nbeta>nbf) error("too few basis functions?", nbf);
623  nvalpha = nmo_alpha - nalpha;
624  nvbeta = nmo_beta - nbeta;
625 
626  // Unless overridden by the user use a cell big enough to
627  // have exp(-sqrt(2*I)*r) decay to 1e-6 with I=1ev=0.037Eh
628  // --> need 50 a.u. either side of the molecule
629 
630  if (L == 0.0) {
631  L = molecule.bounding_cube() + 50.0;
632  }
633 
634  lo = molecule.smallest_length_scale();
635  }
636 
637  void print(World& world) const {
638  //time_t t = time((time_t *) 0);
639  //char *tmp = ctime(&t);
640  //tmp[strlen(tmp)-1] = 0; // lose the trailing newline
641 
642  //madness::print(" date of calculation ", tmp);
643  madness::print(" restart ", restart);
644  madness::print(" number of processes ", world.size());
645  madness::print(" no. of io servers ", nio);
646  madness::print(" simulation cube ", -L, L);
647  madness::print(" total charge ", charge);
648  madness::print(" smearing ", smear);
649  madness::print(" number of electrons ", nalpha, nbeta);
650  madness::print(" number of orbitals ", nmo_alpha, nmo_beta);
651  madness::print(" spin restricted ", spin_restricted);
652  madness::print(" xc functional ", xc_data);
653 #ifdef MADNESS_HAS_LIBXC
654  madness::print(" xc library ", "libxc");
655 #else
656  madness::print(" xc library ", "default (lda only)");
657 #endif
658  if (core_type != "")
659  madness::print(" core type ", core_type);
660  madness::print(" initial guess basis ", aobasis);
661  madness::print(" max krylov subspace ", maxsub);
662  madness::print(" compute protocol ", protocol_data);
663  madness::print(" energy convergence ", econv);
664  madness::print(" density convergence ", dconv);
665  madness::print(" maximum rotation ", maxrotn);
666  madness::print(" polynomial order ", k);
667  madness::print(" maximum iterations ", maxiter);
668  if (conv_only_dens)
669  madness::print(" Convergence criterion is only density delta.");
670  else
671  madness::print(" Convergence criteria are density delta & BSH residual.");
672  madness::print(" plot density ", plotdens);
673  madness::print(" plot coulomb ", plotcoul);
674  madness::print(" plot orbital ", plotlo, plothi);
675  madness::print(" plot npoints ", npt_plot);
676  if (plot_cell.size() > 0)
677  madness::print(" plot volume ", plot_cell(0,0), plot_cell(0,1),
678  plot_cell(1,0), plot_cell(1,1), plot_cell(2,0), plot_cell(2,1));
679  else
680  madness::print(" plot volume ", "default");
681 
682  std::string loctype = "pm";
683  if (!localize_pm) loctype = "boys";
684  if (localize)
685  madness::print(" localized orbitals ", loctype);
686  else
687  madness::print(" canonical orbitals ");
688  if (derivatives)
689  madness::print(" calc derivatives ");
690  if (dipole)
691  madness::print(" calc dipole ");
692  // if(absolvent){
693  // madness::print(" isodensity solvation ", absolvent);
694  // madness::print(" surface tension ", Gamma);
695  // madness::print(" switching param(beta)", beta);
696  // madness::print(" dielectric constant ", epsilon_2);
697  // madness::print(" threshold density ", rho_0);
698  // }
699  }
700 //};
701  void gprint(World& world) const {
702  madness::print(" Optimizer parameters: ");
703  madness::print(" Maximum iterations (gmaxiter) ", gmaxiter);
704  madness::print(" Tolerance (gtol) ", gtol);
705  madness::print(" Gradient value (gval) ", gval);
706  madness::print(" Gradient precision (gprec) ", gprec);
707  madness::print(" Optimization algorithm (algopt) ", algopt);
708  madness::print(" Gradient numerical test (gtest) ", gtest);
709  }
710 };
711 
712 class SCF {
713 public:
720  //functionT vacuo_rho;
721  //functionT rhoT;
722  //functionT rho_elec;
723  //functionT rhon;
724  //functionT mol_mask;
725  //functionT Uabinit;
726  functionT mask;
727 
729  vecfuncT amo, bmo;
730 
733  std::vector<int> aset, bset;
734 
736  vecfuncT ao;
737 
738 
739  std::vector<int> at_to_bf, at_nbf;
740 
742  tensorT aocc, bocc;
743 
745  tensorT aeps, beps;
746  poperatorT coulop;
747  std::vector< std::shared_ptr<real_derivative_3d> > gradop;
748  double vtol;
750  //double esol;//etot;
751  //double vacuo_energy;
752  static const int vnucextra = 12; // load balance parameter for nuclear pot.
753 
754  SCF(World & world, const char *filename);
755 
756  template<std::size_t NDIM>
757  void set_protocol(World & world, double thresh)
758  {
759  int k;
760  // Allow for imprecise conversion of threshold
761  if(thresh >= 0.9e-2)
762  k = 4;
763  else if(thresh >= 0.9e-4)
764  k = 6;
765  else if(thresh >= 0.9e-6)
766  k = 8;
767  else if(thresh >= 0.9e-8)
768  k = 10;
769  else
770  k = 12;
771 
772  // k defaults to make sense with thresh, override by providing k in input file
773  if (param.k == -1) {
775 // param.k=k;
776  } else {
778  }
779  // don't forget to adapt the molecular smoothing parameter!!
780  molecule.set_eprec(std::min(thresh,molecule.get_eprec()));
790  double safety = 0.1;
791  vtol = FunctionDefaults<NDIM>::get_thresh() * safety;
792  coulop = poperatorT(CoulombOperatorPtr(world, param.lo, thresh));
793  gradop = gradient_operator<double,3>(world);
794  mask = functionT(factoryT(world).f(mask3).initial_level(4).norefine());
795  if(world.rank() == 0){
796  print("\nSolving NDIM=",NDIM," with thresh", thresh, " k",
797  FunctionDefaults<NDIM>::get_k(), " conv", std::max(thresh, param.dconv), "\n");
798  }
799  }
800 
801  void save_mos(World& world);
802 
803  void load_mos(World& world);
804 
805  void do_plots(World& world);
806 
807  void project(World & world);
808 
809  void make_nuclear_potential(World & world);
810 
811  void project_ao_basis(World & world);
812 
814 
819  std::vector<int> group_orbital_sets(World& world, const tensorT& eps,
820  const tensorT& occ, const int nmo) const;
821 
823 
830  distmatT localize_PM(World & world, const vecfuncT & mo, const std::vector<int> & set,
831  const double thresh = 1e-9, const double thetamax = 0.5,
832  const bool randomize = true, const bool doprint = false) const;
833 
834 
835  void analyze_vectors(World & world, const vecfuncT & mo, const tensorT & occ = tensorT(),
836  const tensorT & energy = tensorT(), const std::vector<int> & set = std::vector<int>());
837 
838  inline double DIP(const tensorT & dip, int i, int j, int k, int l) {
839  return dip(i, j, 0) * dip(k, l, 0) + dip(i, j, 1) * dip(k, l, 1) + dip(i, j, 2) * dip(k, l, 2);
840  }
841 
842  // tensorT localize_boys(World & world, const vecfuncT & mo, const std::vector<int> & set,
843  // const double thresh = 1e-9, const double thetamax = 0.5, const bool randomize = true);
844 
845 
846  distmatT kinetic_energy_matrix(World & world, const vecfuncT & v) const;
847 
848 
849  vecfuncT core_projection(World & world, const vecfuncT & psi, const bool include_Bc = true);
850 
851  double core_projector_derivative(World & world, const vecfuncT & mo,
852  const tensorT & occ, int atom, int axis);
853 
854  void initial_guess(World & world);
855 
856  void initial_load_bal(World & world);
857 
858  functionT make_density(World & world, const tensorT & occ, const vecfuncT & v) const;
859 
860  functionT make_density(World & world, const tensorT & occ, const cvecfuncT & v);
861 
862  std::vector<poperatorT> make_bsh_operators(World & world, const tensorT & evals);
863 
865 
871  vecfuncT apply_hf_exchange(World & world, const tensorT & occ,
872  const vecfuncT & psi, const vecfuncT & f) const ;
873 
874  // Used only for initial guess that is always spin-restricted LDA
875  functionT make_lda_potential(World & world, const functionT & arho);
876 
877 
878  functionT make_dft_potential(World & world, const vecfuncT& vf, int ispin, int what)
879  {
880  return multiop_values<double, xc_potential, 3>(xc_potential(xc, ispin, what), vf);
881  }
882 
883  double make_dft_energy(World & world, const vecfuncT& vf, int ispin)
884  {
885  functionT vlda = multiop_values<double, xc_functional, 3>(xc_functional(xc, ispin), vf);
886  return vlda.trace();
887  }
888 
889  vecfuncT apply_potential(World & world, const tensorT & occ,
890  const vecfuncT & amo, const vecfuncT& vf, const vecfuncT& delrho,
891  const functionT & vlocal, double & exc, double & enl, int ispin);
892 
893  tensorT derivatives(World & world);
894 
895  tensorT dipole(World & world);
896 
897  void vector_stats(const std::vector<double> & v, double & rms,
898  double & maxabsval) const;
899 
900  vecfuncT compute_residual(World & world, tensorT & occ, tensorT & fock,
901  const vecfuncT & psi, vecfuncT & Vpsi, double & err);
902 
903  tensorT make_fock_matrix(World & world, const vecfuncT & psi,
904  const vecfuncT & Vpsi, const tensorT & occ,
905  double & ekinetic) const;
906 
907 
909  functionT make_coulomb_potential(const functionT& rho) const {
910  return apply(*coulop, rho);
911  }
912 
914 
917  Tensor<double> twoint(World& world, const vecfuncT& psi) const;
918 
919  tensorT matrix_exponential(const tensorT& A) const ;
920 
922 
930  tensorT get_fock_transformation(World& world, const tensorT& overlap,
931  tensorT& fock, tensorT& evals, const tensorT& occ,
932  const double thresh_degenerate) const;
933 
934 
936 
946  tensorT diag_fock_matrix(World& world, tensorT& fock,
947  vecfuncT& psi, vecfuncT& Vpsi, tensorT& evals,
948  const tensorT& occ, const double thresh) const;
949 
950 
951  void loadbal(World & world, functionT & arho, functionT & brho, functionT & arho_old,
952  functionT & brho_old, subspaceT & subspace);
953 
954 
955  void rotate_subspace(World& world, const tensorT& U, subspaceT& subspace,
956  int lo, int nfunc, double trantol) const;
957 
958  void rotate_subspace(World& world, const distmatT& U, subspaceT& subspace,
959  int lo, int nfunc, double trantol) const;
960 
961  void update_subspace(World & world,
962  vecfuncT & Vpsia, vecfuncT & Vpsib,
963  tensorT & focka, tensorT & fockb,
964  subspaceT & subspace, tensorT & Q,
965  double & bsh_residual, double & update_residual);
966 
968 
976  double do_step_restriction(World& world, const vecfuncT& mo,
977  vecfuncT& mo_new, std::string spin) const;
978 
979 
981 
984  void orthonormalize(World& world, vecfuncT& amo_new) const;
985 
986 
987  void propagate(World& world, double omega, int step0);
988 
989 
990  complex_functionT APPLY(const complex_operatorT* q1d, const complex_functionT& psi) {
991  complex_functionT r = psi; // Shallow copy violates constness !!!!!!!!!!!!!!!!!
992  coordT lo, hi;
993  lo[2] = -10;
994  hi[2] = +10;
995 
996  r.reconstruct();
997  r.broaden();
998  r.broaden();
999  r.broaden();
1000  r.broaden();
1001  r = apply_1d_realspace_push(*q1d, r, 2); r.sum_down();
1002  r = apply_1d_realspace_push(*q1d, r, 1); r.sum_down();
1003  r = apply_1d_realspace_push(*q1d, r, 0); r.sum_down();
1004 
1005  return r;
1006  }
1007 
1008 
1010  cvecfuncT& camo, cvecfuncT& cbmo, double t, double time_step,
1011  double thresh);
1012 
1013 
1014  // For given protocol, solve the DFT/HF/response equations
1015  void solve(World & world);
1016 
1017 };
1018 
1019 
1020 // Computes molecular energy as a function of the geometry
1021 // This is cludgy ... need better factorization of functionality
1022 // between calculation, main program and this ... or just merge it all.
1024  World& world;
1025  SCF& calc;
1026  mutable double coords_sum; // sum of square of coords at last solved geometry
1027 
1028 public:
1029  MolecularEnergy(World& world, SCF& calc)
1030  : world(world)
1031  , calc(calc)
1032  , coords_sum(-1.0)
1033  {}
1034 
1035  bool provides_gradient() const {return true;}
1036 
1037  double value(const Tensor<double>& x) {
1038  double xsq = x.sumsq();
1039  if (xsq == coords_sum) {
1040  return calc.current_energy;
1041  }
1042  calc.molecule.set_all_coords(x.reshape(calc.molecule.natom(),3));
1043  coords_sum = xsq;
1044 
1045  // read converged wave function from disk if there is one
1046  if (calc.param.no_compute) {
1047  calc.load_mos(world);
1048  calc.make_nuclear_potential(world);
1049  return calc.current_energy;
1050  }
1051 
1052  // The below is missing convergence test logic, etc.
1053 
1054  // Make the nuclear potential, initial orbitals, etc.
1055  for (unsigned int proto=0; proto<calc.param.protocol_data.size(); proto++) {
1056  calc.set_protocol<3>(world,calc.param.protocol_data[proto]);
1057  calc.make_nuclear_potential(world);
1058  calc.project_ao_basis(world);
1059 
1060  if (proto == 0) {
1061  if (calc.param.restart) {
1062  calc.load_mos(world);
1063  }
1064  else {
1065  calc.initial_guess(world);
1066  //calc.param.restart = true;
1067  }
1068  }
1069  else {
1070  calc.project(world);
1071  }
1072 
1073  // If the basis for the inital guess was not sto-3g
1074  // switch to sto-3g since this is needed for analysis
1075  // of the MOs and orbital localization
1076  if (calc.param.aobasis != "sto-3g") {
1077  calc.param.aobasis = "sto-3g";
1078  calc.project_ao_basis(world);
1079  }
1080  //if(proto==0){
1081  // if(calc.param.absolvent)//||calc.param.svpe)
1082  // calc.solve_gas_phase(world);// computes vacuo density and energy
1083  // //}// calc.save_mos(world); //debugging
1084 
1085  calc.solve(world);
1086  if (calc.param.save)
1087  calc.save_mos(world);
1088  }
1089  return calc.current_energy;
1090  }
1091 
1092  madness::Tensor<double> gradient(const Tensor<double>& x) {
1093  value(x); // Ensures DFT equations are solved at this geometry
1094 
1095  return calc.derivatives(world);
1096  }
1097 };
1098 }
1099 
1100 #endif /* SCF_H_ */
1101 
bool is_leaf() const
Returns true if this does not have children.
Definition: funcimpl.h:202
distmatT localize_PM(World &world, const vecfuncT &mo, const std::vector< int > &set, const double thresh=1e-9, const double thetamax=0.5, const bool randomize=true, const bool doprint=false) const
compute the unitary localization matrix according to Pipek-Mezey
Definition: chem/SCF.cc:483
int gmaxiter
optimization maxiter
Definition: chem/SCF.h:313
bool conv_only_dens
If true remove bsh_residual from convergence criteria how ugly name is...
Definition: chem/SCF.h:299
std::shared_ptr< PotentialManager > potentialmanager
Definition: chem/SCF.h:714
void error(const char *msg)
Definition: world.cc:128
double operator()(const coordT &x) const
Definition: chem/SCF.h:149
Definition: chem/SCF.h:243
Definition: chem/SCF.h:158
Molecule molecule
Definition: chem/SCF.h:716
Definition: shared_ptr_bits.h:38
double make_dft_energy(World &world, const vecfuncT &vf, int ispin)
Definition: chem/SCF.h:883
vecfuncT apply_hf_exchange(World &world, const tensorT &occ, const vecfuncT &psi, const vecfuncT &f) const
apply the HF exchange on a set of orbitals
Definition: chem/SCF.cc:1067
A MADNESS functor to compute the cartesian moment x^i * y^j * z^k (i, j, k integer and >= 0) ...
Definition: chem/SCF.h:207
double operator()(const coordT &x) const
Definition: chem/SCF.h:132
tensorT make_fock_matrix(World &world, const vecfuncT &psi, const vecfuncT &Vpsi, const tensorT &occ, double &ekinetic) const
Definition: chem/SCF.cc:1435
double DIP(const tensorT &dip, int i, int j, int k, int l)
Definition: chem/SCF.h:838
Main include file for MADNESS and defines Function interface.
bool no_orient
If true the molecule coordinates will not be reoriented.
Definition: chem/SCF.h:289
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:175
int nbeta
Number of beta spin electrons.
Definition: chem/SCF.h:302
MomentFunctor(const std::vector< int > &x)
Definition: chem/SCF.h:212
double core_projector_derivative(World &world, const vecfuncT &mo, const tensorT &occ, int atom, int axis)
Definition: chem/SCF.cc:746
static void set_autorefine(bool value)
Sets the default adaptive autorefinement flag.
Definition: funcdefaults.h:295
AtomicBasisFunctor(const AtomicBasisFunction &aofunc)
Definition: chem/SCF.h:145
double get_eprec() const
Definition: chem/molecule.h:178
const int NDIM
Definition: tdse1.cc:44
MolecularEnergy(World &world, SCF &calc)
Definition: chem/SCF.h:1029
double econv
Energy convergence.
Definition: chem/SCF.h:271
std::vector< madness::Vector< double, 3 > > get_all_coords_vec() const
Definition: chem/molecule.cc:188
double do_step_restriction(World &world, const vecfuncT &mo, vecfuncT &mo_new, std::string spin) const
perform step restriction following the KAIN solver
Definition: chem/SCF.cc:1851
std::istream & position_stream(std::istream &f, const std::string &tag)
Definition: position_stream.cc:37
int plothi
Range of MOs to print (for both spins if polarized)
Definition: chem/SCF.h:282
MolecularGuessDensityFunctor(const Molecule &molecule, const AtomicBasisSet &aobasis)
Definition: chem/SCF.h:129
CorePotentialDerivativeFunctor(const Molecule &molecule, int atom, int axis)
Definition: chem/SCF.h:185
tensorT aeps
orbital energies for alpha and beta orbitals
Definition: chem/SCF.h:745
Function< T, 3 > operator()(const double t) const
Definition: chem/SCF.h:236
::std::string string
Definition: gtest-port.h:872
functionT make_coulomb_potential(const functionT &rho) const
make the Coulomb potential given the total density
Definition: chem/SCF.h:909
unsigned int maxsub
Size of iterative subspace ... set to 0 or 1 to disable.
Definition: chem/SCF.h:291
const mpreal cos(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2255
std::shared_ptr< GTHPseudopotential< double > > gthpseudopotential
Definition: chem/SCF.h:715
poperatorT coulop
Definition: chem/SCF.h:746
MomentFunctor(int i, int j, int k)
Definition: chem/SCF.h:211
double smallest_length_scale() const
Definition: chem/molecule.cc:315
void load_mos(World &world)
Definition: chem/SCF.cc:277
double parent_value
Definition: chem/SCF.h:245
vecfuncT compute_residual(World &world, tensorT &occ, tensorT &fock, const vecfuncT &psi, vecfuncT &Vpsi, double &err)
Definition: chem/SCF.cc:1379
Definition: chem/SCF.h:712
void orthonormalize(World &world, vecfuncT &amo_new) const
orthonormalize the vectors
Definition: chem/SCF.cc:1882
A MADNESS functor to compute either x, y, or z.
Definition: chem/SCF.h:194
Function< TENSOR_RESULT_TYPE(typename opT::opT, R), NDIM > apply_1d_realspace_push(const opT &op, const Function< R, NDIM > &f, int axis, bool fence=true)
Definition: mra.h:2032
Tensor< double > twoint(World &world, const vecfuncT &psi) const
Compute the two-electron integrals over the provided set of orbitals.
Definition: chem/SCF.cc:1471
Provides the common functionality/interface of all 1D convolutions.
Definition: convolution1d.h:247
tensorT diag_fock_matrix(World &world, tensorT &fock, vecfuncT &psi, vecfuncT &Vpsi, tensorT &evals, const tensorT &occ, const double thresh) const
diagonalize the fock matrix, taking care of degenerate states
Definition: chem/SCF.cc:1641
static void set_initial_level(int value)
Sets the default initial projection level.
Definition: funcdefaults.h:244
bool gopt
geometry optimizer
Definition: chem/SCF.h:308
std::vector< pairvecfuncT > subspaceT
Definition: chem/SCF.h:66
int maxiter
Maximum number of iterations.
Definition: chem/SCF.h:279
int nmo_beta
Number of beta spin molecular orbitals.
Definition: chem/SCF.h:304
std::vector< int > at_to_bf
Definition: chem/SCF.h:739
CalculationParameters()
Definition: chem/SCF.h:338
void vector_stats(const std::vector< double > &v, double &rms, double &maxabsval) const
Definition: chem/SCF.cc:1368
FunctionFactory< double, 3 > factoryT
Definition: chem/corepotential.cc:60
double gtol
geometry tolerance
Definition: chem/SCF.h:309
std::string xc_data
XC input line.
Definition: chem/SCF.h:306
NDIM & f
Definition: mra.h:2179
void initial_guess(World &world)
Definition: chem/SCF.cc:788
madness::Vector< double, 3 > get_coords() const
Definition: chem/molecule.h:71
std::shared_ptr< operatorT > poperatorT
Definition: chem/SCF.h:71
static void set_refine(bool value)
Sets the default adaptive refinement flag.
Definition: funcdefaults.h:283
Definition: chem/SCF.h:124
ProcessID size() const
Returns the number of processes in this world (same as MPI_Comm_size())
Definition: worldfwd.h:533
static const double & get_thresh()
Returns the default threshold.
Definition: funcdefaults.h:225
Defines interfaces for optimization and non-linear equation solvers.
vecfuncT core_projection(World &world, const vecfuncT &psi, const bool include_Bc=true)
Definition: chem/SCF.cc:708
Vector< double, 3 > coordT
Definition: chem/corepotential.cc:57
madness::Tensor< double > gradient(const Tensor< double > &x)
Should return the derivative of the function.
Definition: chem/SCF.h:1092
Class to compute terms of the potential.
Definition: chem/xcfunctional.h:282
double L
User coordinates box size.
Definition: chem/SCF.h:274
double value(const Tensor< double > &x)
Should return the value of the objective function.
Definition: chem/SCF.h:1037
void solve(World &world)
Definition: chem/SCF.cc:2072
void read_file(const std::string &filename)
Definition: chem/SCF.h:396
void set_all_coords(const madness::Tensor< double > &newcoords)
Definition: chem/molecule.cc:199
AtomicBasisSet aobasis
Definition: chem/SCF.h:719
vecfuncT amo
alpha and beta molecular orbitals
Definition: chem/SCF.h:729
std::vector< int > aset
Definition: chem/SCF.h:733
double gval
value precision
Definition: chem/SCF.h:311
Definition: chem/SCF.h:140
double operator()(const Key< NDIM > &key, const FunctionNode< T, NDIM > &node) const
Definition: chem/SCF.h:247
static void set_project_randomize(bool value)
Sets the random load balancing for projection flag.
Definition: funcdefaults.h:340
madness::Vector< double, 3 > get_coords_vec() const
Definition: chem/molecularbasis.h:385
Function< std::complex< double >, 3 > complex_functionT
Definition: chem/SCF.h:72
functionT mask
Definition: chem/SCF.h:726
std::shared_ptr< FunctionFunctorInterface< double, 3 > > functorT
Definition: chem/corepotential.cc:58
tensorT beps
Definition: chem/SCF.h:745
static const int vnucextra
Definition: chem/SCF.h:752
int natom() const
Definition: chem/molecule.h:148
Definition: chem/SCF.h:261
A generic functor to compute external potential for TDDFT.
Definition: chem/SCF.h:224
int nbf(const Molecule &molecule) const
Given a molecule count the number of basis functions.
Definition: chem/molecularbasis.h:498
static void set_truncate_mode(int value)
Sets the default truncation mode.
Definition: funcdefaults.h:270
vecfuncT ao
MRA projection of the minimal basis set.
Definition: chem/SCF.h:736
pcomplex_operatorT G
Definition: tdse1d.cc:168
lbcost(double leaf_value=1.0, double parent_value=0.0)
Definition: chem/SCF.h:246
std::vector< coordT > special_points() const
Override this to return list of special points to be refined more deeply.
Definition: chem/SCF.h:136
#define max(a, b)
Definition: lda.h:53
bool no_compute
If true use orbitals on disk, set value to computed.
Definition: chem/SCF.h:288
functionT make_dft_potential(World &world, const vecfuncT &vf, int ispin, int what)
Definition: chem/SCF.h:878
int nvbeta
Number of beta virtuals to compute.
Definition: chem/SCF.h:277
void reconstruct(bool fence=true) const
Reconstructs the function, transforming into scaling function basis. Possible non-blocking comm...
Definition: mra.h:737
CalculationParameters param
Definition: chem/SCF.h:717
const int k
Definition: dielectric.cc:184
int nio
No. of io servers to use.
Definition: chem/SCF.h:280
functionT make_lda_potential(World &world, const functionT &arho)
Definition: chem/SCF.cc:1142
double dconv
Density convergence.
Definition: chem/SCF.h:272
bool tdksprop
time-dependent Kohn-Sham equation propagate
Definition: chem/SCF.h:315
Definition: chem/SCF.h:178
distmatT kinetic_energy_matrix(World &world, const vecfuncT &v) const
Definition: chem/SCF.cc:693
The interface to be provided by functions to be optimized.
Definition: solvers.h:176
DistributedMatrix< double > distributed_localize_PM(World &world, const vecfuncT &mo, const vecfuncT &ao, const std::vector< int > &set, const std::vector< int > &at_to_bf, const std::vector< int > &at_nbf, const double thresh=1e-9, const double thetamax=0.5, const bool randomize=true, const bool doprint=false)
Definition: chem/distpm.cc:269
Used to represent one basis function from a shell on a specific center.
Definition: chem/molecularbasis.h:335
double nuclear_attraction_potential_derivative(int atom, int axis, double x, double y, double z) const
Definition: chem/molecule.cc:602
tensorT dipole(World &world)
Definition: chem/SCF.cc:1335
T trace() const
Returns global value of int(f(x),x) ... global comm required.
Definition: mra.h:1034
double lo
Smallest length scale we need to resolve.
Definition: chem/SCF.h:305
void propagate(World &world, double omega, int step0)
Definition: chem/SCF.cc:1909
const mpreal min(const mpreal &x, const mpreal &y)
Definition: mpreal.h:2675
void make_nuclear_potential(World &world)
Definition: chem/SCF.cc:448
void iterate_trotter(World &world, Convolution1D< double_complex > *G, cvecfuncT &camo, cvecfuncT &cbmo, double t, double time_step, double thresh)
Definition: chem/SCF.cc:2004
int k
polynomial order
Definition: chem/SCF.h:273
double psi(const Vector< double, 3 > &r)
Definition: apps/ii/hatom_energy.cc:42
void gprint(World &world) const
Definition: chem/SCF.h:701
Function< double, 3 > functionT
Definition: chem/corepotential.cc:59
bool dipole
If true calculatio dipole moment.
Definition: chem/SCF.h:298
Level level() const
Definition: key.h:220
double operator()(const coordT &x) const
Definition: chem/SCF.h:199
std::vector< coordT > special_points() const
Override this to return list of special points to be refined more deeply.
Definition: chem/SCF.h:153
void loadbal(World &world, functionT &arho, functionT &brho, functionT &arho_old, functionT &brho_old, subspaceT &subspace)
Definition: chem/SCF.cc:1667
double total_nuclear_charge() const
Definition: chem/molecule.cc:560
double operator()(const coordT &r) const
Definition: chem/SCF.h:213
std::vector< int > bset
Definition: chem/SCF.h:733
vector< functionT > vecfuncT
Definition: chem/corepotential.cc:61
tensorT aocc
occupation numbers for alpha and beta orbitals
Definition: chem/SCF.h:742
Tensor< double > tensorT
Definition: chem/distpm.cc:13
double operator()(const coordT &x) const
Definition: chem/SCF.h:169
std::string core_type
core potential type ("" or "mcp")
Definition: chem/SCF.h:296
std::vector< std::shared_ptr< real_derivative_3d > > gradop
Definition: chem/SCF.h:747
void save_mos(World &world)
Definition: chem/SCF.cc:260
void set_eprec(double value)
updates rcuts with given eprec
Definition: chem/molecule.cc:209
double vtol
Definition: chem/SCF.h:748
vecfuncT apply_potential(World &world, const tensorT &occ, const vecfuncT &amo, const vecfuncT &vf, const vecfuncT &delrho, const functionT &vlocal, double &exc, double &enl, int ispin)
Definition: chem/SCF.cc:1149
bool provides_gradient() const
Override this to return true if the derivative is implemented.
Definition: chem/SCF.h:1035
int nvalpha
Number of alpha virtuals to compute.
Definition: chem/SCF.h:276
void update_subspace(World &world, vecfuncT &Vpsia, vecfuncT &Vpsib, tensorT &focka, tensorT &fockb, subspaceT &subspace, tensorT &Q, double &bsh_residual, double &update_residual)
Definition: chem/SCF.cc:1715
void set_molecular_info(const Molecule &molecule, const AtomicBasisSet &aobasis, unsigned int n_core)
Definition: chem/SCF.h:601
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
SeparatedConvolution< double, 3 > operatorT
Definition: chem/SCF.h:70
double orbitalshift
scf orbital shift: shift the occ orbitals to lower energies
Definition: chem/SCF.h:292
DipoleFunctor(int axis)
Definition: chem/SCF.h:198
double core_potential_derivative(int atom, int axis, double x, double y, double z) const
Definition: chem/molecule.cc:687
SCF(World &world, const char *filename)
Definition: chem/SCF.cc:214
double eval_guess_density(const Molecule &molecule, double x, double y, double z) const
Evaluates the guess density.
Definition: chem/molecularbasis.h:520
std::pair< vecfuncT, vecfuncT > pairvecfuncT
Definition: chem/SCF.h:65
std::vector< complex_functionT > cvecfuncT
Definition: chem/SCF.h:73
double operator()(const coordT &r) const
Definition: chem/SCF.h:188
XCfunctional xc
Definition: chem/SCF.h:718
void broaden(const BoundaryConditions< NDIM > &bc=FunctionDefaults< NDIM >::get_bc(), bool fence=true) const
Inplace broadens support in scaling function basis.
Definition: mra.h:779
void serialize(Archive &ar)
Definition: chem/SCF.h:326
static void set_thresh(double value)
Sets the default threshold.
Definition: funcdefaults.h:232
double bounding_cube() const
Returns the half width of the bounding cube.
Definition: chem/molecule.cc:550
double leaf_value
Definition: chem/SCF.h:244
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition: derivative.h:58
void initial_load_bal(World &world)
Definition: chem/SCF.cc:987
Abstract base class interface required for functors used as input to Functions.
Definition: function_interface.h:58
double mask1(double x)
Definition: chem/SCF.h:87
ProcessID rank() const
Returns the process rank in this world (same as MPI_Comm_rank()))
Definition: worldfwd.h:526
void analyze_vectors(World &world, const vecfuncT &mo, const tensorT &occ=tensorT(), const tensorT &energy=tensorT(), const std::vector< int > &set=std::vector< int >())
Definition: chem/SCF.cc:497
Convolution1D< double_complex > complex_operatorT
Definition: chem/SCF.h:74
Definition: chem/molecule.h:83
double energy(World &world, const Function< T, 3 > &psi, const Function< T, 3 > &potn)
Definition: extra.cc:272
complex_functionT APPLY(const complex_operatorT *q1d, const complex_functionT &psi)
Definition: chem/SCF.h:990
Definition: convolution1d.h:837
bool restart
If true restart from orbitals on disk.
Definition: chem/SCF.h:287
std::vector< int > at_nbf
Definition: chem/SCF.h:739
std::shared_ptr< WorldDCPmapInterface< Key< 3 > > > pmapT
Definition: chem/SCF.h:60
MolecularDerivativeFunctor(const Molecule &molecule, int atom, int axis)
Definition: chem/SCF.h:165
std::string aobasis
AO basis used for initial guess (6-31g or sto-3g)
Definition: chem/SCF.h:295
tensorT get_fock_transformation(World &world, const tensorT &overlap, tensorT &fock, tensorT &evals, const tensorT &occ, const double thresh_degenerate) const
compute the unitary transformation that diagonalizes the fock matrix
Definition: chem/SCF.cc:1536
static void set_apply_randomize(bool value)
Sets the random load balancing for integral operators flag.
Definition: funcdefaults.h:329
bool save
If true save orbitals to disk.
Definition: chem/SCF.h:290
std::vector< double > protocol_data
Calculation protocol.
Definition: chem/SCF.h:307
bool gtest
geometry tolerance
Definition: chem/SCF.h:310
static void set_cubic_cell(double lo, double hi)
Sets the user cell to be cubic with each dimension having range [lo,hi].
Definition: funcdefaults.h:384
VextCosFunctor(World &world, const FunctionFunctorInterface< T, 3 > *functor, double omega)
Definition: chem/SCF.h:228
void project(World &world)
Definition: chem/SCF.cc:427
functionT make_density(World &world, const tensorT &occ, const vecfuncT &v) const
Definition: chem/SCF.cc:999
double maxrotn
Step restriction used in autoshift algorithm.
Definition: chem/SCF.h:275
double smear
Smearing parameter.
Definition: chem/SCF.h:270
void sum_down(bool fence=true) const
Sums scaling coeffs down tree restoring state with coeffs only at leaves. Optional fence...
Definition: mra.h:746
std::vector< T > vector_factory(const T &v0)
Returns a std::vector initialized from the arguments.
Definition: vector_factory.h:50
tensorT matrix_exponential(const tensorT &A) const
Definition: chem/SCF.cc:1491
Class to compute the energy functional.
Definition: chem/xcfunctional.h:266
void print(const A &a)
Print a single item to std::cout terminating with new line.
Definition: print.h:122
Contracted Gaussian basis.
Definition: chem/molecularbasis.h:391
DistributedMatrix< double > distmatT
Definition: chem/SCF.h:68
int nmo_alpha
Number of alpha spin molecular orbitals.
Definition: chem/SCF.h:303
tensorT derivatives(World &world)
Definition: chem/SCF.cc:1255
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
void project_ao_basis(World &world)
Definition: chem/SCF.cc:459
bool plotdens
If true print the density at convergence.
Definition: chem/SCF.h:283
bool localize
If true solve for localized orbitals.
Definition: chem/SCF.h:285
Definition: chem/SCF.h:1023
std::string nuclear_corrfac
nuclear correlation factor
Definition: chem/SCF.h:316
bool derivatives
If true calculate derivatives.
Definition: chem/SCF.h:297
tensorT bocc
Definition: chem/SCF.h:742
bool localize_pm
If true use PM for localization.
Definition: chem/SCF.h:286
int plotlo
Definition: chem/SCF.h:282
Simplified interface to XC functionals.
Definition: chem/xcfunctional.h:41
FunctionFactory implements the named-parameter idiom for Function.
Definition: funcimpl.h:70
bool psp_calc
pseudopotential calculation or all electron
Definition: chem/SCF.h:317
int npt_plot
No. of points to use in each dim for plots.
Definition: chem/SCF.h:293
const mpreal fabs(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2187
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
double charge
Total molecular charge.
Definition: chem/SCF.h:269
void set_protocol(World &world, double thresh)
Definition: chem/SCF.h:757
Function< T, NDIM > apply(const Derivative< T, NDIM > &D, const Function< T, NDIM > &f, bool fence=true)
Applies derivative operator to function (for syntactic equivalence to integral operator apply) ...
Definition: derivative.h:613
bool plotcoul
If true plot the total coulomb potential at convergence.
Definition: chem/SCF.h:284
tensorT plot_cell
lo hi in each dimension for plotting (default is all space)
Definition: chem/SCF.h:294
int nalpha
Number of alpha spin electrons.
Definition: chem/SCF.h:301
std::vector< int > group_orbital_sets(World &world, const tensorT &eps, const tensorT &occ, const int nmo) const
group orbitals into sets of similar orbital energies for localization
Definition: chem/SCF.cc:964
int nopen
Number of unpaired electrons = napha-nbeta.
Definition: chem/SCF.h:278
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:69
std::vector< coordT > special_points() const
Override this to return list of special points to be refined more deeply.
Definition: chem/SCF.h:173
const Atom & get_atom(unsigned int i) const
Definition: chem/molecule.cc:223
static void set_k(int value)
Sets the default wavelet order.
Definition: funcdefaults.h:219
void rotate_subspace(World &world, const tensorT &U, subspaceT &subspace, int lo, int nfunc, double trantol) const
Definition: chem/SCF.cc:1695
std::string algopt
algorithm used for optimization
Definition: chem/SCF.h:314
double gprec
gradient precision
Definition: chem/SCF.h:312
void do_plots(World &world)
Definition: chem/SCF.cc:380
std::vector< poperatorT > make_bsh_operators(World &world, const tensorT &evals)
Definition: chem/SCF.cc:1040
void print(World &world) const
Definition: chem/SCF.h:637
double current_energy
Definition: chem/SCF.h:749
bool spin_restricted
True if spin restricted.
Definition: chem/SCF.h:281
vecfuncT bmo
Definition: chem/SCF.h:729