MADNESS  0.10.1
madness/chem/molecularbasis.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 #ifndef MADNESS_CHEM_MOLECULAR_BASIS_H__INCLUDED
33 #define MADNESS_CHEM_MOLECULAR_BASIS_H__INCLUDED
34 
35 #include <madness/madness_config.h>
36 #include <madness/constants.h>
39 #include <madness/external/tinyxml/tinyxml.h>
40 #include <madness/tensor/tensor.h>
41 
42 #include <vector>
43 #include <algorithm>
44 #include <iostream>
45 #include <sstream>
46 #include <iomanip>
47 #include <cstdio>
48 
49 namespace madness {
50 /// Represents a single shell of contracted, Cartesian, Gaussian primitives
52  int type; ///< Angular momentum = 0, 1, 2, ...
53  std::vector<double> coeff;
54  std::vector<double> expnt;
55  double rsqmax;
56  int numbf; ///< Number of basis functions in shell (type+1)*(type+2)/2
57 
58  void normalize() {
59  // nwcchem cartesian normalization conventions
60  // translation of nmcoeff.F into python and thence to c++
61  int np = coeff.size();
62  if (np == 1) coeff[0] = 1.0e0;
63 
64  double pi32=pow(madness::constants::pi,1.5);
65  int l_lim = 2*type - 1;
66  double f = 1.0e00;
67  for (int n=l_lim; n>1; n-=2) f *= n;
68 
69  for (int n=0; n<np; ++n)
70  coeff[n] *= pow(2.e0*expnt[n]/madness::constants::pi,0.75e0)*pow(4.e0*expnt[n],0.5E0*type)/sqrt(f);
71 
72  double sum = 0.0;
73  for (int n1=0; n1<np; ++n1) {
74  for (int n2=0; n2<np; ++n2) {
75  double S =pi32/pow(expnt[n1]+expnt[n2],1.5e0+type)/pow(2e0,type);
76  sum = sum + coeff[n1]*coeff[n2]*S;
77  }
78  }
79  sum *= f;
80 
81  f = 1e0/sqrt(sum);
82  for (int n=0; n<np; ++n) coeff[n] *= f;
83  }
84 
85 public:
87  : type(-1), coeff(), expnt(), rsqmax(0.0), numbf(0) {};
88 
90  const std::vector<double>& coeff,
91  const std::vector<double>& expnt,
92  bool donorm=true)
93  : type(type), coeff(coeff), expnt(expnt), numbf((type+1)*(type+2)/2) {
94  if (donorm) normalize();
95  double minexpnt = expnt[0];
96  for (unsigned int i=1; i<expnt.size(); ++i)
97  minexpnt = std::min(minexpnt,expnt[i]);
98  rsqmax = 27.6/minexpnt; // 27.6 = log(1e12)
99  }
100 
101 
102  /// Returns square of the distance beyond which function is less than 1e-8.
103  double rangesq() const {
104  return rsqmax;
105  }
106 
107 
108  /// Evaluates the radial part of the contracted function
109  double eval_radial(double rsq) const {
110  if (rsq > rsqmax) return 0.0;
111  double sum = 0.0;
112  for (unsigned int i=0; i<coeff.size(); ++i) {
113  double ersq = expnt[i]*rsq;
114  if (ersq < 27.6) sum += coeff[i]*exp(-ersq); // 27.6 = log(1e12)
115  }
116  return sum;
117  }
118 
119 
120  /// Evaluates the entire shell returning the incremented result pointer
121  double* eval(double rsq, double x, double y, double z, double* bf) const {
122  double R = eval_radial(rsq);
123  if (fabs(R) < 1e-12) {
124  for (int i=0; i<numbf; ++i) bf[i] = 0.0;
125 
126  }
127  else {
128  switch (type) {
129  case 0:
130  bf[0] = R;
131  break;
132  case 1:
133  bf[0] = R*x;
134  bf[1] = R*y;
135  bf[2] = R*z;
136  break;
137  case 2:
138  { // braces need by some compilers to limit scope of fac
139  static const double fac = 1.0; //sqrt(3.0);
140  bf[0] = R*x*x;
141  bf[1] = R*x*y*fac;
142  bf[2] = R*x*z*fac;
143  bf[3] = R*y*y;
144  bf[4] = R*y*z*fac;
145  bf[5] = R*z*z;
146  }
147  break;
148  case 3:
149  bf[0] = R*x*x*x;
150  bf[1] = R*x*x*y;
151  bf[2] = R*x*x*z;
152  bf[3] = R*x*y*y;
153  bf[4] = R*x*y*z;
154  bf[5] = R*x*z*z;
155  bf[6] = R*y*y*y;
156  bf[7] = R*y*y*z;
157  bf[8] = R*y*z*z;
158  bf[9] = R*z*z*z;
159  break;
160 
161  default:
162  throw "UNKNOWN ANGULAR MOMENTUM";
163  }
164  }
165  return bf+numbf;
166  }
167 
168 
169  /// Returns the shell angular momentum
170  int angular_momentum() const {
171  return type;
172  }
173 
174  /// Returns the number of basis functions in the shell
175  int nbf() const {
176  return numbf;
177  }
178 
179  /// Returns the number of primitives in the contraction
180  int nprim() const {
181  return coeff.size();
182  }
183 
184  /// Returns a const reference to the coefficients
185  const std::vector<double>& get_coeff() const {
186  return coeff;
187  }
188 
189  /// Returns a const reference to the exponents
190  const std::vector<double>& get_expnt() const {
191  return expnt;
192  }
193 
194  /// Returns a string description of the basis function type
195  const char* get_desc(int ibf) const {
196  static const char* tags[4][10] = {
197  {"s" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" } ,
198  {"px" ,"py" ,"pz" ,"" ,"" ,"" ,"" ,"" ,"" ,"" } ,
199  {"dxx" ,"dxy" ,"dxz" ,"dyy" ,"dyz" ,"dzz" ,"" ,"" ,"" ,"" } ,
200  {"fxxx","fxxy","fxxz","fxyy","fxyz","fxzz","fxzz","fyyy","fyzz","fzzz"}
201  };
202  MADNESS_ASSERT(ibf<numbf && ibf >= 0);
203  return tags[type][ibf];
204  }
205 
206  template <typename Archive>
207  void serialize(Archive& ar) {
208  ar & type & coeff & expnt & rsqmax & numbf;
209  }
210 };
211 
212 /// Represents multiple shells of contracted gaussians on a single center
213 class AtomicBasis {
214  std::vector<ContractedGaussianShell> g;
215  double rmaxsq;
216  int numbf;
218 
219 public:
220  AtomicBasis() : g(), rmaxsq(0.0), numbf(0) {};
221 
222  AtomicBasis(const std::vector<ContractedGaussianShell>& g)
223  : g(g) {
224  rmaxsq = 0.0;
225  numbf = 0;
226  for (unsigned int i=0; i<g.size(); ++i) {
227  rmaxsq = std::max(rmaxsq, g[i].rangesq());
228  numbf += g[i].nbf();
229  }
230  }
231 
233  const Tensor<double>& avec, const Tensor<double>& bvec,
234  const Tensor<double>& aocc, const Tensor<double>& bocc,
235  const Tensor<double>& aeps, const Tensor<double>& beps,
236  const Tensor<double>& aoccpsp, const Tensor<double>& boccpsp) {
237  this->dmat = copy(dmat);
238  this->dmatpsp = copy(dmatpsp);
239  this->avec = copy(avec);
240  this->bvec = copy(bvec);
241  this->aocc = copy(aocc);
242  this->beps = copy(beps);
243  this->aeps = copy(aeps);
244  this->bocc = copy(bocc);
245  this->aoccpsp = copy(aoccpsp);
246  this->boccpsp = copy(boccpsp);
247  }
248 
249  /// Returns the number of basis functions on the center
250  int nbf() const {
251  return numbf;
252  }
253 
254  /// Returns the number of shells on the center
255  int nshell() const {
256  return g.size();
257  }
258 
259  /// Returns a const reference to the shells
260  const std::vector<ContractedGaussianShell>& get_shells() const {
261  return g;
262  };
263 
264  /// Evaluates the basis functions at point x, y, z relative to atomic center
265 
266  /// The array bf[] must be large enough to hold nbf() values.
267  ///
268  /// Returned is the incremented pointer.
269  double* eval(double x, double y, double z, double* bf) const {
270  double rsq = x*x + y*y + z*z;
271  if (rsq > rmaxsq) {
272  for (int i=0; i<numbf; ++i) bf[i] = 0.0;
273  return bf+numbf;
274  }
275 
276  double* bfstart = bf;
277  for (unsigned int i=0; i<g.size(); ++i) {
278  bf = g[i].eval(rsq, x, y, z, bf);
279  }
280  // paranoia is good
281  MADNESS_CHECK(bf-bfstart == numbf);
282  return bf;
283  }
284 
285  /// Evaluates the guess atomic density at point x, y, z relative to atomic center
286  double eval_guess_density(double x, double y, double z, bool pspat) const {
288  double rsq = x*x + y*y + z*z;
289  if (rsq > rmaxsq) return 0.0;
290 
291  double bf[numbf];
292  eval(x, y, z, bf);
293  const double* p;
294  // check if pseudo-atom
295  if (pspat){
296  p = dmatpsp.ptr();}
297  else{
298  p = dmat.ptr();}
299  double sum = 0.0;
300  for (int i=0; i<numbf; ++i, p+=numbf) {
301  double sumj = 0.0;
302  for (int j=0; j<numbf; ++j)
303  sumj += p[j]*bf[j];
304  sum += bf[i]*sumj;
305  }
306  return sum;
307  }
308 
309  /// Return shell that contains basis function ibf and also return index of function in the shell
310  const ContractedGaussianShell& get_shell_from_basis_function(int ibf, int& ibf_in_shell) const {
311  int n=0;
312  for (unsigned int i=0; i<g.size(); ++i) {
313  int nbf_in_shell = g[i].nbf();
314  if (ibf>=n && ibf<(n+nbf_in_shell)) {
315  ibf_in_shell = ibf-n;
316  return g[i];
317  }
318  else {
319  n += g[i].nbf();
320  }
321  }
322  MADNESS_EXCEPTION("AtomicBasis: get_shell_from_basis_function", ibf*100000 + nbf());
323  }
324 
325  bool has_guess_info() const {
326  return dmat.size()>0;
327  }
328 
329  const Tensor<double>& get_dmat() const {
330  return dmat;
331  };
332 
334  dmat = mat;
335  };
336 
337  bool has_guesspsp_info() const {
338  return dmatpsp.size()>0;
339  }
340 
341  const Tensor<double>& get_dmatpsp() const {
342  return dmatpsp;
343  };
344 
346  dmatpsp = mat;
347  };
348 
349  const Tensor<double>& get_avec() const {
350  return avec;
351  };
352 
353  const Tensor<double>& get_bvec() const {
354  return bvec;
355  };
356 
357  const Tensor<double>& get_aeps() const {
358  return aeps;
359  };
360 
361  const Tensor<double>& get_beps() const {
362  return beps;
363  };
364 
365  const Tensor<double>& get_aocc() const {
366  return aocc;
367  };
368 
369  const Tensor<double>& get_bocc() const {
370  return bocc;
371  };
372 
374  aocc = occ;
375  };
376 
378  bocc = occ;
379  };
380 
381  const Tensor<double>& get_aoccpsp() const {
382  return aoccpsp;
383  };
384 
385  const Tensor<double>& get_boccpsp() const {
386  return boccpsp;
387  };
388 
390  aoccpsp = occ;
391  };
392 
394  boccpsp = occ;
395  };
396 
397  template <typename Archive>
398  void serialize(Archive& ar) {
399  ar & g & rmaxsq & numbf & dmat & dmatpsp & avec & bvec & aocc & bocc & aeps & beps & aoccpsp & boccpsp;
400  }
401 
402 };
403 
404 /// Used to represent one basis function from a shell on a specific center
406 private:
407  const double xx, yy, zz; // Coordinates of the center
408  const ContractedGaussianShell& shell; // Reference to the underlying atomic shell
409  const int ibf; // Index of basis function in the shell (0, 1, ...)
410  const int nbf; // Number of functions in the shell
411 
412 public:
413  AtomicBasisFunction(double x, double y, double z,
414  const ContractedGaussianShell& shell, int ibf)
415  : xx(x), yy(y), zz(z), shell(shell), ibf(ibf), nbf(shell.nbf()) {}
416 
417 
419  : xx(aofunc.xx)
420  , yy(aofunc.yy)
421  , zz(aofunc.zz)
422  , shell(aofunc.shell)
423  , ibf(aofunc.ibf)
424  , nbf(aofunc.nbf) {}
425 
426  double operator()(double x, double y, double z) const {
427  double bf[nbf];
428  x-=xx;
429  y-=yy;
430  z-=zz;
431  double rsq = x*x + y*y + z*z;
432  shell.eval(rsq, x, y, z, bf);
433  return bf[ibf];
434  }
435 
436  void print_me(std::ostream& s) const;
437 
439  return shell;
440  }
441 
442  int get_index() const {
443  return ibf;
444  }
445 
446  const char* get_desc() const {
447  return shell.get_desc(ibf);
448  }
449 
450  void get_coords(double& x, double& y, double& z) const {
451  x=xx; y=yy; z=zz;
452  return;
453  }
454 
456  return madness::Vector<double,3>{xx, yy, zz};
457  }
458 
459  double rangesq() const {
460  return shell.rangesq();
461  }
462 };
463 
464 /// Contracted Gaussian basis
466  std::string name;
467  std::vector<AtomicBasis> ag; ///< Basis associated by atomic number = 1, 2, ...; 0=Bq.
468 
469  template <typename T>
470  std::vector<T> load_tixml_vector(TiXmlElement* node, int n, const char* name) {
471  TiXmlElement* child = node->FirstChildElement(name);
472  MADNESS_ASSERT(child);
473  std::istringstream s(child->GetText());
474  std::vector<T> r(n);
475  for (int i=0; i<n; ++i) {
476  s >> r[i];
477  MADNESS_ASSERT(s);
478  }
479  return r;
480  }
481 
482  template <typename T>
483  Tensor<T> load_tixml_matrix(TiXmlElement* node, int n, int m, const char* name) {
484  TiXmlElement* child = node->FirstChildElement(name);
485  MADNESS_ASSERT(child);
486  std::istringstream s(child->GetText());
487  Tensor<T> r(n,m);
488  for (int i=0; i<n; ++i) {
489  for (int j=0; j<m; ++j) {
490  s >> r(i,j);
491  MADNESS_ASSERT(s);
492  }
493  }
494  return r;
495  }
496 
497 public:
498  AtomicBasisSet() : name("unknown"), ag(110) {}
499 
500 
501  AtomicBasisSet(std::string filename) : name(""), ag(110) {
503  }
504 
505  std::string get_name() const {return name;}
506 
507  /// read the atomic basis set from file
508 
509  /// use the default location MRA_CHEMDATA_DIR as defined in the Makefile.am
510  /// unless it is overridden by the environment variable MRA_CHEMDATA_DIR
511  /// @param[in] filename the name of the basis set (sto-3g, 6-31g, etc)
512  void read_file(std::string filename);
513 
514  /// read the atomic basis set from file
515 
516  /// @param[in] filename the base name of nwchem files (.out and .movecs)
517  void read_nw_file(std::string filename);
518 
519 
520 
521  /// Makes map from atoms to first basis function on atom and number of basis functions on atom
522  void atoms_to_bfn(const Molecule& molecule, std::vector<int>& at_to_bf, std::vector<int>& at_nbf) const {
523  at_to_bf = std::vector<int>(molecule.natom());
524  at_nbf = std::vector<int>(molecule.natom());
525 
526  int n = 0;
527  for (size_t i=0; i<molecule.natom(); ++i) {
528  const Atom& atom = molecule.get_atom(i);
529  const int atn = atom.atomic_number;
531  at_to_bf[i] = n;
532  at_nbf[i] = ag[atn].nbf();
533  n += at_nbf[i];
534  }
535  }
536 
537  /// Makes map from shells to first basis function on she and number of basis functions on sh
538  void shells_to_bfn(const Molecule& molecule, std::vector<int>& sh_to_bf, std::vector<int>& sh_nbf) const {
539  sh_to_bf = std::vector<int>();
540  sh_nbf = std::vector<int>();
541 
542  int nbf = 0;
543  for (size_t i=0; i<molecule.natom(); ++i) {
544  const Atom& atom = molecule.get_atom(i);
545  const int atn = atom.atomic_number;
547  const auto& shells = ag[atn].get_shells();
548  for (const auto& sh : shells) {
549  int n = sh.nbf();
550  sh_nbf.push_back(n);
551  sh_to_bf.push_back(nbf);
552  nbf += n;
553  }
554  }
555  }
556 
557  /// Returns the atomic alpha eigenvectors for atom iat
558  const Tensor<double>& get_avec(const Molecule& molecule, size_t iat) const {
559  MADNESS_ASSERT(iat>=0 && iat<molecule.natom());
560  const Atom& atom = molecule.get_atom(iat);
561  const int atn = atom.atomic_number;
563  return ag[atn].get_avec();
564  }
565 
566  /// Returns the atomic alpha eigenvalues for atom iat
567  const Tensor<double>& get_aeps(const Molecule& molecule, size_t iat) const {
568  MADNESS_ASSERT(iat>=0 && iat<molecule.natom());
569  const Atom& atom = molecule.get_atom(iat);
570  const int atn = atom.atomic_number;
572  return ag[atn].get_aeps();
573  }
574 
575  /// Returns the number of the atom the ibf'th basis function is on
576  int basisfn_to_atom(const Molecule& molecule, size_t ibf) const {
577  MADNESS_ASSERT(ibf >= 0);
578  size_t n = 0;
579  for (size_t i=0; i<molecule.natom(); ++i) {
580  // Is the desired function on this atom?
581  const Atom& atom = molecule.get_atom(i);
582  const int atn = atom.atomic_number;
584  const int nbf_on_atom = ag[atn].nbf();
585  if (ibf >= n && (n+nbf_on_atom) > ibf) {
586  return i;
587  }
588  else {
589  n += nbf_on_atom;
590  }
591  }
592  MADNESS_EXCEPTION("AtomicBasisSet: get_atomic_basis_function: confused?", ibf);
593  }
594 
595  /// Returns the ibf'th atomic basis function
597  MADNESS_ASSERT(ibf >= 0);
598  size_t n = 0;
599  for (size_t i=0; i<molecule.natom(); ++i) {
600  // Is the desired function on this atom?
601  const Atom& atom = molecule.get_atom(i);
602  const int atn = atom.atomic_number;
604  const int nbf_on_atom = ag[atn].nbf();
605  if (ibf >= n && (n+nbf_on_atom) > ibf) {
606  int index;
607  const ContractedGaussianShell& shell =
608  ag[atn].get_shell_from_basis_function(ibf-n, index);
609  return AtomicBasisFunction(atom.x, atom.y, atom.z, shell, index);
610  }
611  else {
612  n += nbf_on_atom;
613  }
614  }
615  MADNESS_EXCEPTION("AtomicBasisSet: get_atomic_basis_function: confused?", ibf);
616  }
617 
618 
619  /// Given a molecule count the number of basis functions
620  int nbf(const Molecule& molecule) const {
621  int n = 0;
622  for (size_t i=0; i<molecule.natom(); ++i) {
623  const Atom& atom = molecule.get_atom(i);
624  const int atn = atom.atomic_number;
626  n += ag[atn].nbf();
627  }
628  return n;
629  }
630 
631  /// Evaluates the basis functions
632  void eval(const Molecule& molecule, double x, double y, double z, double *bf) const {
633  for (size_t i=0; i<molecule.natom(); ++i) {
634  const Atom& atom = molecule.get_atom(i);
635  const int atn = atom.atomic_number;
636  bf = ag[atn].eval(x-atom.x, y-atom.y, z-atom.z, bf);
637  }
638  }
639 
640 
641  /// Evaluates the guess density
642  double eval_guess_density(const Molecule& molecule, double x, double y, double z) const {
643  double sum = 0.0;
644  bool pspat;
645  for (size_t i=0; i<molecule.natom(); ++i) {
646  const Atom& atom = molecule.get_atom(i);
647  if (atom.pseudo_atom){
648  pspat=true;}
649  else{
650  pspat=false;}
651  const int atn = atom.atomic_number;
652  sum += ag[atn].eval_guess_density(x-atom.x, y-atom.y, z-atom.z, pspat);
653  }
654  return sum;
655  }
656 
657  bool is_supported(int atomic_number) const {
658  return ag[atomic_number].nbf() > 0;
659  }
660 
661  /// Print basis info for atoms in the molecule (once for each unique atom type)
662  void print(const Molecule& molecule) const;
663 
664  /// Eliminates core orbitals from the density matrix for pseudopotential calculations
665  void modify_dmat_psp(int atn, double zeff);
666 
667  template <typename T>
669  const Tensor<T> v;
670  public:
671  AnalysisSorter(const Tensor<T>& v) : v(v) {}
672  bool operator()(long i, long j) const {
673  return std::abs(v[i]) > std::abs(v[j]);
674  }
675  };
676 
677  /// Given a vector of AO coefficients prints an analysis
678 
679  /// For each significant coeff it prints
680  /// - atomic symbol
681  /// - atom number
682  /// - basis function type (e.g., dxy)
683  /// - basis function number
684  /// - MO coeff
685  template <typename T>
686  void print_anal(const Molecule& molecule, const Tensor<T>& v) const {
687  const double thresh = 0.2*v.normf();
688  if (thresh == 0.0) {
689  printf(" zero vector\n");
690  return;
691  }
692  long nbf = int(v.dim(0));
693  long list[nbf];
694  long ngot=0;
695  for (long i=0; i<nbf; ++i) {
696  if (std::abs(v(i)) > thresh) {
697  list[ngot++] = i;
698  }
699  }
700  std::sort(list,list+ngot,AnalysisSorter<T>(v));
701 
702  const char* format;
703  if (molecule.natom() < 10) {
704  format = " %2s(%1d)%4s(%2ld)%6.3f ";
705  }
706  else if (molecule.natom() < 100) {
707  format = " %2s(%2d)%4s(%3ld)%6.3f ";
708  }
709  else if (molecule.natom() < 1000) {
710  format = " %2s(%3d)%4s(%4ld)%6.3f ";
711  }
712  else {
713  format = " %2s(%4d)%4s(%5ld)%6.3f ";
714  }
715  printf(" ");
716  for (long ii=0; ii<ngot; ++ii) {
717  long ibf = list[ii];
718 
719  const int iat = basisfn_to_atom(molecule, ibf);
720  const Atom& atom = molecule.get_atom(iat);
722  const char* desc = ao.get_desc();
723  const char* element = get_atomic_data(atom.atomic_number).symbol;
724 
725  // This will need wrapping in a template for a complex MO vector
726  printf(format, element, iat, desc, ibf, v[ibf]);
727  }
728  printf("\n");
729  }
730 
731  /// Print basis info for all supported atoms
732  void print_all() const;
733 
734  template <typename Archive>
735  void serialize(Archive& ar) {
736  ar & name & ag;
737  }
738 };
739 }
740 
741 
742 #endif
Declaration of utility class and functions for atom.
Definition: molecule.h:58
double y
Definition: molecule.h:60
unsigned int atomic_number
Atomic number.
Definition: molecule.h:61
double x
Definition: molecule.h:60
double z
Definition: molecule.h:60
bool pseudo_atom
Indicates if this atom uses a pseudopotential.
Definition: molecule.h:63
Used to represent one basis function from a shell on a specific center.
Definition: madness/chem/molecularbasis.h:405
void print_me(std::ostream &s) const
Definition: molecularbasis.cc:84
int get_index() const
Definition: madness/chem/molecularbasis.h:442
const double yy
Definition: madness/chem/molecularbasis.h:407
madness::Vector< double, 3 > get_coords_vec() const
Definition: madness/chem/molecularbasis.h:455
const char * get_desc() const
Definition: madness/chem/molecularbasis.h:446
AtomicBasisFunction(double x, double y, double z, const ContractedGaussianShell &shell, int ibf)
Definition: madness/chem/molecularbasis.h:413
const ContractedGaussianShell & shell
Definition: madness/chem/molecularbasis.h:408
void get_coords(double &x, double &y, double &z) const
Definition: madness/chem/molecularbasis.h:450
const double xx
Definition: madness/chem/molecularbasis.h:407
const int nbf
Definition: madness/chem/molecularbasis.h:410
double operator()(double x, double y, double z) const
Definition: madness/chem/molecularbasis.h:426
double rangesq() const
Definition: madness/chem/molecularbasis.h:459
const ContractedGaussianShell & get_shell() const
Definition: madness/chem/molecularbasis.h:438
const double zz
Definition: madness/chem/molecularbasis.h:407
const int ibf
Definition: madness/chem/molecularbasis.h:409
AtomicBasisFunction(const AtomicBasisFunction &aofunc)
Definition: madness/chem/molecularbasis.h:418
Definition: madness/chem/molecularbasis.h:668
bool operator()(long i, long j) const
Definition: madness/chem/molecularbasis.h:672
AnalysisSorter(const Tensor< T > &v)
Definition: madness/chem/molecularbasis.h:671
const Tensor< T > v
Definition: madness/chem/molecularbasis.h:669
Contracted Gaussian basis.
Definition: madness/chem/molecularbasis.h:465
AtomicBasisSet(std::string filename)
Definition: madness/chem/molecularbasis.h:501
void read_nw_file(std::string filename)
read the atomic basis set from file
Definition: molecularbasis.cc:205
double eval_guess_density(const Molecule &molecule, double x, double y, double z) const
Evaluates the guess density.
Definition: madness/chem/molecularbasis.h:642
AtomicBasisFunction get_atomic_basis_function(const Molecule &molecule, size_t ibf) const
Returns the ibf'th atomic basis function.
Definition: madness/chem/molecularbasis.h:596
void read_file(std::string filename)
read the atomic basis set from file
Definition: molecularbasis.cc:118
std::vector< T > load_tixml_vector(TiXmlElement *node, int n, const char *name)
Definition: madness/chem/molecularbasis.h:470
bool is_supported(int atomic_number) const
Definition: madness/chem/molecularbasis.h:657
int nbf(const Molecule &molecule) const
Given a molecule count the number of basis functions.
Definition: madness/chem/molecularbasis.h:620
AtomicBasisSet()
Definition: madness/chem/molecularbasis.h:498
std::vector< AtomicBasis > ag
Basis associated by atomic number = 1, 2, ...; 0=Bq.
Definition: madness/chem/molecularbasis.h:467
void print(const Molecule &molecule) const
Print basis info for atoms in the molecule (once for each unique atom type)
Definition: molecularbasis.cc:89
const Tensor< double > & get_aeps(const Molecule &molecule, size_t iat) const
Returns the atomic alpha eigenvalues for atom iat.
Definition: madness/chem/molecularbasis.h:567
std::string name
Definition: madness/chem/molecularbasis.h:466
void serialize(Archive &ar)
Definition: madness/chem/molecularbasis.h:735
std::string get_name() const
Definition: madness/chem/molecularbasis.h:505
void modify_dmat_psp(int atn, double zeff)
Eliminates core orbitals from the density matrix for pseudopotential calculations.
Definition: molecularbasis.cc:236
void atoms_to_bfn(const Molecule &molecule, std::vector< int > &at_to_bf, std::vector< int > &at_nbf) const
Makes map from atoms to first basis function on atom and number of basis functions on atom.
Definition: madness/chem/molecularbasis.h:522
Tensor< T > load_tixml_matrix(TiXmlElement *node, int n, int m, const char *name)
Definition: madness/chem/molecularbasis.h:483
int basisfn_to_atom(const Molecule &molecule, size_t ibf) const
Returns the number of the atom the ibf'th basis function is on.
Definition: madness/chem/molecularbasis.h:576
void print_anal(const Molecule &molecule, const Tensor< T > &v) const
Given a vector of AO coefficients prints an analysis.
Definition: madness/chem/molecularbasis.h:686
void print_all() const
Print basis info for all supported atoms.
Definition: molecularbasis.cc:108
void eval(const Molecule &molecule, double x, double y, double z, double *bf) const
Evaluates the basis functions.
Definition: madness/chem/molecularbasis.h:632
const Tensor< double > & get_avec(const Molecule &molecule, size_t iat) const
Returns the atomic alpha eigenvectors for atom iat.
Definition: madness/chem/molecularbasis.h:558
void shells_to_bfn(const Molecule &molecule, std::vector< int > &sh_to_bf, std::vector< int > &sh_nbf) const
Makes map from shells to first basis function on she and number of basis functions on sh.
Definition: madness/chem/molecularbasis.h:538
Represents multiple shells of contracted gaussians on a single center.
Definition: madness/chem/molecularbasis.h:213
const Tensor< double > & get_dmatpsp() const
Definition: madness/chem/molecularbasis.h:341
const Tensor< double > & get_aeps() const
Definition: madness/chem/molecularbasis.h:357
Tensor< double > beps
Definition: madness/chem/molecularbasis.h:217
const std::vector< ContractedGaussianShell > & get_shells() const
Returns a const reference to the shells.
Definition: madness/chem/molecularbasis.h:260
void set_aocc(Tensor< double > &occ)
Definition: madness/chem/molecularbasis.h:373
Tensor< double > aocc
Definition: madness/chem/molecularbasis.h:217
double * eval(double x, double y, double z, double *bf) const
Evaluates the basis functions at point x, y, z relative to atomic center.
Definition: madness/chem/molecularbasis.h:269
void set_dmatpsp(Tensor< double > &mat)
Definition: madness/chem/molecularbasis.h:345
std::vector< ContractedGaussianShell > g
Definition: madness/chem/molecularbasis.h:214
const Tensor< double > & get_beps() const
Definition: madness/chem/molecularbasis.h:361
double rmaxsq
Definition: madness/chem/molecularbasis.h:215
int nshell() const
Returns the number of shells on the center.
Definition: madness/chem/molecularbasis.h:255
const Tensor< double > & get_dmat() const
Definition: madness/chem/molecularbasis.h:329
Tensor< double > bocc
Definition: madness/chem/molecularbasis.h:217
void set_aoccpsp(Tensor< double > &occ)
Definition: madness/chem/molecularbasis.h:389
const Tensor< double > & get_aocc() const
Definition: madness/chem/molecularbasis.h:365
int numbf
Definition: madness/chem/molecularbasis.h:216
Tensor< double > avec
Definition: madness/chem/molecularbasis.h:217
void set_guess_info(const Tensor< double > &dmat, const Tensor< double > &dmatpsp, const Tensor< double > &avec, const Tensor< double > &bvec, const Tensor< double > &aocc, const Tensor< double > &bocc, const Tensor< double > &aeps, const Tensor< double > &beps, const Tensor< double > &aoccpsp, const Tensor< double > &boccpsp)
Definition: madness/chem/molecularbasis.h:232
void set_bocc(Tensor< double > &occ)
Definition: madness/chem/molecularbasis.h:377
Tensor< double > dmatpsp
Definition: madness/chem/molecularbasis.h:217
void set_dmat(Tensor< double > &mat)
Definition: madness/chem/molecularbasis.h:333
const Tensor< double > & get_avec() const
Definition: madness/chem/molecularbasis.h:349
const Tensor< double > & get_aoccpsp() const
Definition: madness/chem/molecularbasis.h:381
Tensor< double > aeps
Definition: madness/chem/molecularbasis.h:217
AtomicBasis(const std::vector< ContractedGaussianShell > &g)
Definition: madness/chem/molecularbasis.h:222
AtomicBasis()
Definition: madness/chem/molecularbasis.h:220
int nbf() const
Returns the number of basis functions on the center.
Definition: madness/chem/molecularbasis.h:250
Tensor< double > boccpsp
Definition: madness/chem/molecularbasis.h:217
void serialize(Archive &ar)
Definition: madness/chem/molecularbasis.h:398
bool has_guess_info() const
Definition: madness/chem/molecularbasis.h:325
Tensor< double > bvec
Definition: madness/chem/molecularbasis.h:217
const Tensor< double > & get_boccpsp() const
Definition: madness/chem/molecularbasis.h:385
void set_boccpsp(Tensor< double > &occ)
Definition: madness/chem/molecularbasis.h:393
bool has_guesspsp_info() const
Definition: madness/chem/molecularbasis.h:337
Tensor< double > aoccpsp
Definition: madness/chem/molecularbasis.h:217
const Tensor< double > & get_bocc() const
Definition: madness/chem/molecularbasis.h:369
double eval_guess_density(double x, double y, double z, bool pspat) const
Evaluates the guess atomic density at point x, y, z relative to atomic center.
Definition: madness/chem/molecularbasis.h:286
const ContractedGaussianShell & get_shell_from_basis_function(int ibf, int &ibf_in_shell) const
Return shell that contains basis function ibf and also return index of function in the shell.
Definition: madness/chem/molecularbasis.h:310
Tensor< double > dmat
Definition: madness/chem/molecularbasis.h:217
const Tensor< double > & get_bvec() const
Definition: madness/chem/molecularbasis.h:353
long size() const
Returns the number of elements in the tensor.
Definition: basetensor.h:138
Represents a single shell of contracted, Cartesian, Gaussian primitives.
Definition: madness/chem/molecularbasis.h:51
void serialize(Archive &ar)
Definition: madness/chem/molecularbasis.h:207
int nbf() const
Returns the number of basis functions in the shell.
Definition: madness/chem/molecularbasis.h:175
ContractedGaussianShell()
Definition: madness/chem/molecularbasis.h:86
int numbf
Number of basis functions in shell (type+1)*(type+2)/2.
Definition: madness/chem/molecularbasis.h:56
const std::vector< double > & get_expnt() const
Returns a const reference to the exponents.
Definition: madness/chem/molecularbasis.h:190
ContractedGaussianShell(int type, const std::vector< double > &coeff, const std::vector< double > &expnt, bool donorm=true)
Definition: madness/chem/molecularbasis.h:89
double eval_radial(double rsq) const
Evaluates the radial part of the contracted function.
Definition: madness/chem/molecularbasis.h:109
std::vector< double > coeff
Definition: madness/chem/molecularbasis.h:53
std::vector< double > expnt
Definition: madness/chem/molecularbasis.h:54
int type
Angular momentum = 0, 1, 2, ...
Definition: madness/chem/molecularbasis.h:52
int nprim() const
Returns the number of primitives in the contraction.
Definition: madness/chem/molecularbasis.h:180
const char * get_desc(int ibf) const
Returns a string description of the basis function type.
Definition: madness/chem/molecularbasis.h:195
double * eval(double rsq, double x, double y, double z, double *bf) const
Evaluates the entire shell returning the incremented result pointer.
Definition: madness/chem/molecularbasis.h:121
double rangesq() const
Returns square of the distance beyond which function is less than 1e-8.
Definition: madness/chem/molecularbasis.h:103
int angular_momentum() const
Returns the shell angular momentum.
Definition: madness/chem/molecularbasis.h:170
const std::vector< double > & get_coeff() const
Returns a const reference to the coefficients.
Definition: madness/chem/molecularbasis.h:185
double rsqmax
Definition: madness/chem/molecularbasis.h:55
void normalize()
Definition: madness/chem/molecularbasis.h:58
Definition: molecule.h:124
T * ptr()
Returns a pointer to the internal data.
Definition: tensor.h:1824
Defines common mathematical and physical constants.
static const double R
Definition: csqrt.cc:46
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition: derivatives.cc:72
const double m
Definition: gfit.cc:199
static const double v
Definition: hatom_sf_dirac.cc:20
static double pow(const double *a, const double *b)
Definition: lda.h:74
#define max(a, b)
Definition: lda.h:51
Macros and tools pertaining to the configuration of 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:190
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition: madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition: madness_exception.h:134
const double pi
Mathematical constant .
Definition: constants.h:48
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static const char * filename
Definition: legendre.cc:96
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition: mra.h:2002
const AtomicData & get_atomic_data(unsigned int atomic_number)
Definition: atomutil.cc:167
Function< T, NDIM > sum(World &world, const std::vector< Function< T, NDIM > > &f, bool fence=true)
Returns new function — q = sum_i f[i].
Definition: vmra.h:1421
NDIM & f
Definition: mra.h:2416
static long abs(long a)
Definition: tensor.h:218
static std::vector< int > at_to_bf
Definition: preal.cc:19
static std::vector< int > at_nbf
Definition: preal.cc:19
static const double thresh
Definition: rk.cc:45
const char *const symbol
Definition: atomutil.h:54
int np
Definition: tdse1d.cc:165
Defines and implements most of Tensor.
void e()
Definition: test_sig.cc:75
static Molecule molecule
Definition: testperiodicdft.cc:38