MADNESS  version 0.9
DFcode/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  $Id$
32 */
33 #ifndef MOLECULAR_BASIS_H
34 #define MOLECULAR_BASIS_H
35 
36 #include <madness/madness_config.h>
37 #include <madness/constants.h>
38 #include <moldft/molecule.h>
40 #include <madness/tensor/tensor.h>
41 using namespace madness;
42 
43 #include <vector>
44 #include <algorithm>
45 #include <iostream>
46 #include <sstream>
47 #include <iomanip>
48 #include <cstdio>
49 
52  int type;
53  std::vector<double> coeff;
54  std::vector<double> expnt;
55  double rsqmax;
56  int numbf;
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 = 18.4/minexpnt; // 18.4 = 8*ln(10)
99  }
100 
101 
103  double rangesq() const {
104  return rsqmax;
105  }
106 
107 
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 < 18.4) sum += coeff[i]*exp(-ersq);
115  }
116  return sum;
117  }
118 
119 
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-8) {
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 
170  int angular_momentum() const {
171  return type;
172  }
173 
175  int nbf() const {
176  return numbf;
177  }
178 
180  int nprim() const {
181  return coeff.size();
182  }
183 
185  const std::vector<double>& get_coeff() const {
186  return coeff;
187  }
188 
190  const std::vector<double>& get_expnt() const {
191  return expnt;
192  }
193 
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 
213 class AtomicBasis {
214  std::vector<ContractedGaussianShell> g;
215  double rmaxsq;
216  int numbf;
217  Tensor<double> dmat, avec, bvec;
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 
232  void set_guess_info(const Tensor<double>& dmat,
233  const Tensor<double>& avec, const Tensor<double>& bvec) {
234  this->dmat = copy(dmat);
235  this->avec = copy(avec);
236  this->bvec = copy(bvec);
237  }
238 
240  int nbf() const {
241  return numbf;
242  }
243 
245  int nshell() const {
246  return g.size();
247  }
248 
250  const std::vector<ContractedGaussianShell>& get_shells() const {
251  return g;
252  };
253 
255 
259  double* eval(double x, double y, double z, double* bf) const {
260  double rsq = x*x + y*y + z*z;
261  if (rsq > rmaxsq) {
262  for (int i=0; i<numbf; ++i) bf[i] = 0.0;
263  return bf+numbf;
264  }
265 
266  double* bfstart = bf;
267  for (unsigned int i=0; i<g.size(); ++i) {
268  bf = g[i].eval(rsq, x, y, z, bf);
269  }
270  // paranoia is good
271  MADNESS_ASSERT(bf-bfstart == numbf);
272  return bf;
273  }
274 
276  double eval_guess_density(double x, double y, double z) const {
277  MADNESS_ASSERT(has_guess_info());
278  double rsq = x*x + y*y + z*z;
279  if (rsq > rmaxsq) return 0.0;
280 
281  double bf[numbf];
282  eval(x, y, z, bf);
283  const double* p = dmat.ptr();
284  double sum = 0.0;
285  for (int i=0; i<numbf; ++i, p+=numbf) {
286  double sumj = 0.0;
287  for (int j=0; j<numbf; ++j)
288  sumj += p[j]*bf[j];
289  sum += bf[i]*sumj;
290  }
291  return sum;
292  }
293 
295  const ContractedGaussianShell& get_shell_from_basis_function(int ibf, int& ibf_in_shell) const {
296  int n=0;
297  for (unsigned int i=0; i<g.size(); ++i) {
298  int nbf_in_shell = g[i].nbf();
299  if (ibf>=n && ibf<(n+nbf_in_shell)) {
300  ibf_in_shell = ibf-n;
301  return g[i];
302  }
303  else {
304  n += g[i].nbf();
305  }
306  }
307  MADNESS_EXCEPTION("AtomicBasis: get_shell_from_basis_function", ibf*100000 + nbf());
308  }
309 
310  bool has_guess_info() const {
311  return dmat.size()>0;
312  }
313 
314  const Tensor<double>& get_dmat() const {
315  return dmat;
316  };
317 
318  const Tensor<double>& get_avec() const {
319  return avec;
320  };
321 
322  const Tensor<double>& get_bvec() const {
323  return bvec;
324  };
325 
326  template <typename Archive>
327  void serialize(Archive& ar) {
328  ar & g & rmaxsq & numbf & dmat & avec & bvec;
329  }
330 
331 };
332 
335 private:
336  const double xx, yy, zz; // Coordinates of the center
337  const ContractedGaussianShell& shell; // Reference to the underlying atomic shell
338  const int ibf; // Index of basis function in the shell (0, 1, ...)
339  const int nbf; // Number of functions in the shell
340 
341 public:
342  AtomicBasisFunction(double x, double y, double z,
343  const ContractedGaussianShell& shell, int ibf)
344  : xx(x), yy(y), zz(z), shell(shell), ibf(ibf), nbf(shell.nbf()) {}
345 
346 
348  : xx(aofunc.xx)
349  , yy(aofunc.yy)
350  , zz(aofunc.zz)
351  , shell(aofunc.shell)
352  , ibf(aofunc.ibf)
353  , nbf(aofunc.nbf) {}
354 
355  double operator()(double x, double y, double z) const {
356  double bf[nbf];
357  x-=xx;
358  y-=yy;
359  z-=zz;
360  double rsq = x*x + y*y + z*z;
361  shell.eval(rsq, x, y, z, bf);
362  return bf[ibf];
363  }
364 
365  void print_me(std::ostream& s) const;
366 
368  return shell;
369  }
370 
371  int get_index() const {
372  return ibf;
373  }
374 
375  const char* get_desc() const {
376  return shell.get_desc(ibf);
377  }
378 
379  void get_coords(double& x, double& y, double& z) const {
380  x=xx; y=yy; z=zz;
381  return;
382  }
383 
385  return madness::vec(xx, yy, zz);
386  }
387 };
388 
391  std::string name;
392  std::vector<AtomicBasis> ag; //< Basis associated by atomic number = 1, 2, ...; 0=Bq.
393 
394  template <typename T>
395  std::vector<T> load_tixml_vector(TiXmlElement* node, int n, const char* name) {
396  TiXmlElement* child = node->FirstChildElement(name);
397  MADNESS_ASSERT(child);
398  std::istringstream s(child->GetText());
399  std::vector<T> r(n);
400  for (int i=0; i<n; ++i) {
401  MADNESS_ASSERT(s >> r[i]);
402  }
403  return r;
404  }
405 
406  template <typename T>
407  Tensor<T> load_tixml_matrix(TiXmlElement* node, int n, int m, const char* name) {
408  TiXmlElement* child = node->FirstChildElement(name);
409  MADNESS_ASSERT(child);
410  std::istringstream s(child->GetText());
411  Tensor<T> r(n,m);
412  for (int i=0; i<n; ++i) {
413  for (int j=0; j<m; ++j) {
414  MADNESS_ASSERT(s >> r(i,j));
415  }
416  }
417  return r;
418  }
419 
420 public:
421  AtomicBasisSet() : name("unknown"), ag(110) {}
422 
423 
424  AtomicBasisSet(std::string filename) : name(""), ag(110) {
425  read_file(filename);
426  }
427 
428  void read_file(std::string filename) {
429  static const bool debug = false;
430  TiXmlDocument doc(filename);
431  if (!doc.LoadFile()) {
432  std::cout << "AtomicBasisSet: Failed loading from file " << filename
433  << " : ErrorDesc " << doc.ErrorDesc()
434  << " : Row " << doc.ErrorRow()
435  << " : Col " << doc.ErrorCol() << std::endl;
436  MADNESS_EXCEPTION("AtomicBasisSet: Failed loading basis set",0);
437  }
438  for (TiXmlElement* node=doc.FirstChildElement(); node; node=node->NextSiblingElement()) {
439  if (strcmp(node->Value(),"name") == 0) {
440  name = node->GetText();
441  if (debug) std::cout << "Loading basis set " << name << std::endl;
442  }
443  else if (strcmp(node->Value(), "basis") == 0) {
444  const char* symbol = node->Attribute("symbol");
445  if (debug) std::cout << " found basis set for " << symbol << std::endl;
446  int atn = symbol_to_atomic_number(symbol);
447  std::vector<ContractedGaussianShell> g;
448  for (TiXmlElement* shell=node->FirstChildElement(); shell; shell=shell->NextSiblingElement()) {
449  const char* type = shell->Attribute("type");
450  int nprim=-1;
451  shell->Attribute("nprim",&nprim);
452  if (debug) std::cout << " found shell " << type << " " << nprim << std::endl;
453  std::vector<double> expnt = load_tixml_vector<double>(shell, nprim, "exponents");
454  if (strcmp(type,"L") == 0) {
455  std::vector<double> scoeff = load_tixml_vector<double>(shell, nprim, "scoefficients");
456  std::vector<double> pcoeff = load_tixml_vector<double>(shell, nprim, "pcoefficients");
457  g.push_back(ContractedGaussianShell(0,scoeff,expnt));
458  g.push_back(ContractedGaussianShell(1,pcoeff,expnt));
459  }
460  else {
461  static const char* tag[] = {"S","P","D","F","G"};
462  int i;
463  for (i=0; i<5; ++i) {
464  if (strcmp(type,tag[i]) == 0) goto foundit;
465  }
466  MADNESS_EXCEPTION("Loading atomic basis set: bad shell type?",0);
467 foundit:
468  std::vector<double> coeff = load_tixml_vector<double>(shell, nprim, "coefficients");
469  g.push_back(ContractedGaussianShell(i, coeff, expnt));
470  }
471  }
472  ag[atn] = AtomicBasis(g);
473  }
474  else if (strcmp(node->Value(), "atomicguess") == 0) {
475  const char* symbol = node->Attribute("symbol");
476  if (debug) std::cout << " atomic guess info for " << symbol << std::endl;
477  int atn = symbol_to_atomic_number(symbol);
478  MADNESS_ASSERT(is_supported(atn));
479  int nbf = ag[atn].nbf();
480  Tensor<double> dmat = load_tixml_matrix<double>(node, nbf, nbf, "guessdensitymatrix");
481  Tensor<double> avec = load_tixml_matrix<double>(node, nbf, nbf, "alphavectors");
482  Tensor<double> bvec = load_tixml_matrix<double>(node, nbf, nbf, "betavectors");
483  ag[atn].set_guess_info(dmat, avec, bvec);
484  }
485  else {
486  MADNESS_EXCEPTION("Loading atomic basis set: unexpected XML element", 0);
487  }
488  }
489 
490  }
491 
492 
494  void atoms_to_bfn(const Molecule& molecule, std::vector<int>& at_to_bf, std::vector<int>& at_nbf) {
495  at_to_bf = std::vector<int>(molecule.natom());
496  at_nbf = std::vector<int>(molecule.natom());
497 
498  int n = 0;
499  for (int i=0; i<molecule.natom(); ++i) {
500  const Atom& atom = molecule.get_atom(i);
501  const int atn = atom.atomic_number;
502  MADNESS_ASSERT(is_supported(atn));
503  at_to_bf[i] = n;
504  at_nbf[i] = ag[atn].nbf();
505  n += at_nbf[i];
506  }
507  }
508 
509 
511  int basisfn_to_atom(const Molecule& molecule, int ibf) const {
512  MADNESS_ASSERT(ibf >= 0);
513  int n = 0;
514  for (int i=0; i<molecule.natom(); ++i) {
515  // Is the desired function on this atom?
516  const Atom& atom = molecule.get_atom(i);
517  const int atn = atom.atomic_number;
518  MADNESS_ASSERT(is_supported(atn));
519  const int nbf_on_atom = ag[atn].nbf();
520  if (ibf >= n && (n+nbf_on_atom) > ibf) {
521  return i;
522  }
523  else {
524  n += nbf_on_atom;
525  }
526  }
527  MADNESS_EXCEPTION("AtomicBasisSet: get_atomic_basis_function: confused?", ibf);
528  }
529 
531  AtomicBasisFunction get_atomic_basis_function(const Molecule& molecule, int ibf) const {
532  MADNESS_ASSERT(ibf >= 0);
533  int n = 0;
534  for (int i=0; i<molecule.natom(); ++i) {
535  // Is the desired function on this atom?
536  const Atom& atom = molecule.get_atom(i);
537  const int atn = atom.atomic_number;
538  MADNESS_ASSERT(is_supported(atn));
539  const int nbf_on_atom = ag[atn].nbf();
540  if (ibf >= n && (n+nbf_on_atom) > ibf) {
541  int index;
542  const ContractedGaussianShell& shell =
543  ag[atn].get_shell_from_basis_function(ibf-n, index);
544  return AtomicBasisFunction(atom.x, atom.y, atom.z, shell, index);
545  }
546  else {
547  n += nbf_on_atom;
548  }
549  }
550  MADNESS_EXCEPTION("AtomicBasisSet: get_atomic_basis_function: confused?", ibf);
551  }
552 
553 
555  int nbf(const Molecule& molecule) const {
556  int n = 0;
557  for (int i=0; i<molecule.natom(); ++i) {
558  const Atom& atom = molecule.get_atom(i);
559  const int atn = atom.atomic_number;
560  MADNESS_ASSERT(is_supported(atn));
561  n += ag[atn].nbf();
562  }
563  return n;
564  }
565 
567  void eval(const Molecule& molecule, double x, double y, double z, double *bf) const {
568  for (int i=0; i<molecule.natom(); ++i) {
569  const Atom& atom = molecule.get_atom(i);
570  const int atn = atom.atomic_number;
571  bf = ag[atn].eval(x-atom.x, y-atom.y, z-atom.z, bf);
572  }
573  }
574 
575 
577  double eval_guess_density(const Molecule& molecule, double x, double y, double z) const {
578  double sum = 0.0;
579  for (int i=0; i<molecule.natom(); ++i) {
580  const Atom& atom = molecule.get_atom(i);
581  const int atn = atom.atomic_number;
582  sum += ag[atn].eval_guess_density(x-atom.x, y-atom.y, z-atom.z);
583  }
584  return sum;
585  }
586 
587  bool is_supported(int atomic_number) const {
588  //vama return ag[atomic_number].nbf() > 0;
589  return ag[atomic_number].nbf() > 0;
590  //vama return true;
591  }
592 
594  void print(const Molecule& molecule) const;
595 
596  template <typename T>
598  const Tensor<T> v;
599  public:
600  AnalysisSorter(const Tensor<T>& v) : v(v) {}
601  bool operator()(long i, long j) const {
602  return std::abs(v[i]) > std::abs(v[j]);
603  }
604  };
605 
607 
614  template <typename T>
615  void print_anal(const Molecule& molecule, const Tensor<T>& v) {
616  const double thresh = 0.2*v.normf();
617  if (thresh == 0.0) {
618  printf(" zero vector\n");
619  return;
620  }
621  long nbf = int(v.dim(0));
622  long list[nbf];
623  long ngot=0;
624  for (long i=0; i<nbf; ++i) {
625  if (std::abs(v(i)) > thresh) {
626  list[ngot++] = i;
627  }
628  }
629  std::sort(list,list+ngot,AnalysisSorter<T>(v));
630 
631  const char* format;
632  if (molecule.natom() < 10) {
633  format = " %2s(%1d)%4s(%2ld)%6.3f ";
634  }
635  else if (molecule.natom() < 100) {
636  format = " %2s(%2d)%4s(%3ld)%6.3f ";
637  }
638  else if (molecule.natom() < 1000) {
639  format = " %2s(%3d)%4s(%4ld)%6.3f ";
640  }
641  else {
642  format = " %2s(%4d)%4s(%5ld)%6.3f ";
643  }
644  printf(" ");
645  for (long ii=0; ii<ngot; ++ii) {
646  long ibf = list[ii];
647 
648  const int iat = basisfn_to_atom(molecule, ibf);
649  const Atom& atom = molecule.get_atom(iat);
650  const AtomicBasisFunction ao = get_atomic_basis_function(molecule, ibf);
651  const char* desc = ao.get_desc();
652  const char* element = get_atomic_data(atom.atomic_number).symbol;
653 
654  // This will need wrapping in a template for a complex MO vector
655  printf(format, element, iat, desc, ibf, v[ibf]);
656  }
657  printf("\n");
658  }
659 
661  void print_all() const;
662 
663  template <typename Archive>
664  void serialize(Archive& ar) {
665  ar & name & ag;
666  }
667 };
668 
669 
670 
671 #endif
int np
Definition: tdse1d.cc:166
int nbf() const
Returns the number of basis functions on the center.
Definition: DFcode/molecularbasis.h:240
double eval_radial(double rsq) const
Evaluates the radial part of the contracted function.
Definition: DFcode/molecularbasis.h:109
const double thresh
Definition: dielectric.cc:185
void print_anal(const Molecule &molecule, const Tensor< T > &v)
Given a vector of AO coefficients prints an analysis.
Definition: DFcode/molecularbasis.h:615
const Tensor< double > & get_dmat() const
Definition: DFcode/molecularbasis.h:314
NDIM const Function< R, NDIM > & g
Definition: mra.h:2179
bool is_supported(int atomic_number) const
Definition: DFcode/molecularbasis.h:587
const mpreal exp(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2234
const double pi
Mathematical constant pi.
Definition: constants.h:44
int angular_momentum() const
Returns the shell angular momentum.
Definition: DFcode/molecularbasis.h:170
const double R
Definition: dielectric.cc:191
void atoms_to_bfn(const Molecule &molecule, std::vector< int > &at_to_bf, std::vector< int > &at_nbf)
Makes map from atoms to first basis function on atom and number of basis functions on atom...
Definition: DFcode/molecularbasis.h:494
double eval_guess_density(const Molecule &molecule, double x, double y, double z) const
Evaluates the guess density.
Definition: DFcode/molecularbasis.h:577
void serialize(Archive &ar)
Definition: DFcode/molecularbasis.h:207
double rangesq() const
Returns square of the distance beyond which function is less than 1e-8.
Definition: DFcode/molecularbasis.h:103
double operator()(double x, double y, double z) const
Definition: DFcode/molecularbasis.h:355
ContractedGaussianShell()
Definition: DFcode/molecularbasis.h:86
void serialize(Archive &ar)
Definition: DFcode/molecularbasis.h:664
double eval_guess_density(double x, double y, double z) const
Evaluates the guess atomic density at point x, y, z relative to atomic center.
Definition: DFcode/molecularbasis.h:276
const bool debug
Definition: tdse1.cc:45
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: DFcode/molecularbasis.h:295
const char *const symbol
Definition: chem/atomutil.h:54
double z
Definition: chem/molecule.h:57
::std::string string
Definition: gtest-port.h:872
Defines common mathematical and physical constants.
void print_me(std::ostream &s) const
Definition: chem/molecularbasis.cc:73
madness::Vector< double, 3 > get_coords_vec() const
Definition: DFcode/molecularbasis.h:384
double eval_radial(double rsq) const
Evaluates the radial part of the contracted function.
Definition: chem/molecularbasis.h:110
int nprim() const
Returns the number of primitives in the contraction.
Definition: DFcode/molecularbasis.h:180
int nbf(const Molecule &molecule) const
Given a molecule count the number of basis functions.
Definition: DFcode/molecularbasis.h:555
NDIM & f
Definition: mra.h:2179
bool operator()(long i, long j) const
Definition: DFcode/molecularbasis.h:601
int nbf() const
Returns the number of basis functions in the shell.
Definition: DFcode/molecularbasis.h:175
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Definition: tinyxml.cc:924
AtomicBasisFunction get_atomic_basis_function(const Molecule &molecule, int ibf) const
Returns the ibf'th atomic basis function.
Definition: chem/molecularbasis.h:474
AtomicBasis(const std::vector< ContractedGaussianShell > &g)
Definition: DFcode/molecularbasis.h:222
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1475
AtomicBasis()
Definition: DFcode/molecularbasis.h:220
Represents multiple shells of contracted gaussians on a single center.
Definition: chem/molecularbasis.h:214
void eval(const Molecule &molecule, double x, double y, double z, double *bf) const
Evaluates the basis functions.
Definition: DFcode/molecularbasis.h:567
const char * get_desc(int ibf) const
Returns a string description of the basis function type.
Definition: DFcode/molecularbasis.h:195
Defines and implements most of Tensor.
int natom() const
Definition: chem/molecule.h:148
Represents a single shell of contracted, Cartesian, Gaussian primitives.
Definition: chem/molecularbasis.h:52
int ErrorRow() const
Definition: tinyxml.h:1474
const AtomicData & get_atomic_data(unsigned int atomic_number)
Definition: chem/atomutil.cc:160
int nbf(const Molecule &molecule) const
Given a molecule count the number of basis functions.
Definition: chem/molecularbasis.h:498
double * eval(double rsq, double x, double y, double z, double *bf) const
Evaluates the entire shell returning the incremented result pointer.
Definition: DFcode/molecularbasis.h:121
#define max(a, b)
Definition: lda.h:53
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1460
void set_guess_info(const Tensor< double > &dmat, const Tensor< double > &avec, const Tensor< double > &bvec)
Definition: DFcode/molecularbasis.h:232
Vector< T, 1 > vec(T x)
Your friendly neighborhood factory function.
Definition: array.h:456
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: DFcode/molecularbasis.h:259
int get_index() const
Definition: DFcode/molecularbasis.h:371
const std::vector< double > & get_expnt() const
Returns a const reference to the exponents.
Definition: DFcode/molecularbasis.h:190
const std::vector< double > & get_coeff() const
Returns a const reference to the coefficients.
Definition: DFcode/molecularbasis.h:185
const char * get_desc(int ibf) const
Returns a string description of the basis function type.
Definition: chem/molecularbasis.h:196
Used to represent one basis function from a shell on a specific center.
Definition: chem/molecularbasis.h:335
void read_file(std::string filename)
read the atomic basis set from file
Definition: chem/molecularbasis.cc:107
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:1835
const mpreal min(const mpreal &x, const mpreal &y)
Definition: mpreal.h:2675
Definition: tinyxml.h:1386
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition: tinyxml.cc:431
AtomicBasisSet()
Definition: DFcode/molecularbasis.h:421
unsigned int atomic_number
Atomic number.
Definition: chem/molecule.h:58
const char * get_desc() const
Definition: chem/molecularbasis.h:376
void get_coords(double &x, double &y, double &z) const
Definition: DFcode/molecularbasis.h:379
const Tensor< double > & get_bvec() const
Definition: DFcode/molecularbasis.h:322
int basisfn_to_atom(const Molecule &molecule, int ibf) const
Returns the number of the atom the ibf'th basis function is on.
Definition: chem/molecularbasis.h:454
bool is_supported(int atomic_number) const
Definition: chem/molecularbasis.h:530
const char * get_desc() const
Definition: DFcode/molecularbasis.h:375
AtomicBasisFunction(double x, double y, double z, const ContractedGaussianShell &shell, int ibf)
Definition: DFcode/molecularbasis.h:342
tensorT sqrt(const tensorT &s, double tol=1e-8)
Computes matrix square root (not used any more?)
Definition: DFcode/moldft.cc:446
bool has_guess_info() const
Definition: chem/molecularbasis.h:311
void read_file(std::string filename)
Definition: DFcode/molecularbasis.h:428
const std::vector< ContractedGaussianShell > & get_shells() const
Returns a const reference to the shells.
Definition: DFcode/molecularbasis.h:250
double x
Definition: chem/molecule.h:57
Definition: chem/molecule.h:55
const TiXmlElement * NextSiblingElement() const
Definition: tinyxml.cc:461
double * eval(double rsq, double x, double y, double z, double *bf) const
Evaluates the entire shell returning the incremented result pointer.
Definition: chem/molecularbasis.h:122
double y
Definition: chem/molecule.h:57
const mpreal sum(const mpreal tab[], unsigned long int n, mp_rnd_t rnd_mode)
Definition: mpreal.cc:241
AtomicBasisFunction(const AtomicBasisFunction &aofunc)
Definition: DFcode/molecularbasis.h:347
const double m
Definition: gfit.cc:199
unsigned int symbol_to_atomic_number(const std::string &symbol)
Definition: chem/atomutil.cc:166
AtomicBasisFunction get_atomic_basis_function(const Molecule &molecule, int ibf) const
Returns the ibf'th atomic basis function.
Definition: DFcode/molecularbasis.h:531
Definition: chem/molecule.h:83
Definition: DFcode/molecularbasis.h:597
const Tensor< double > & get_avec() const
Definition: DFcode/molecularbasis.h:318
const char * Value() const
Definition: tinyxml.h:489
int nbf() const
Returns the number of basis functions on the center.
Definition: chem/molecularbasis.h:241
void serialize(Archive &ar)
Definition: DFcode/molecularbasis.h:327
AnalysisSorter(const Tensor< T > &v)
Definition: DFcode/molecularbasis.h:600
void print_all() const
Print basis info for all supported atoms.
Definition: chem/molecularbasis.cc:97
Contracted Gaussian basis.
Definition: chem/molecularbasis.h:391
double E0(double p)
Definition: gfit.cc:203
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
int nshell() const
Returns the number of shells on the center.
Definition: DFcode/molecularbasis.h:245
const char * GetText() const
Definition: tinyxml.cc:871
const mpreal fabs(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2187
AtomicBasisSet(std::string filename)
Definition: DFcode/molecularbasis.h:424
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
const char * Attribute(const char *name) const
Definition: tinyxml.cc:555
const ContractedGaussianShell & get_shell() const
Definition: DFcode/molecularbasis.h:367
void print(const Molecule &molecule) const
Print basis info for atoms in the molecule (once for each unique atom type)
Definition: chem/molecularbasis.cc:78
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: chem/molecularbasis.h:260
const Atom & get_atom(unsigned int i) const
Definition: chem/molecule.cc:223
bool has_guess_info() const
Definition: DFcode/molecularbasis.h:310
ContractedGaussianShell(int type, const std::vector< double > &coeff, const std::vector< double > &expnt, bool donorm=true)
Definition: DFcode/molecularbasis.h:89
Definition: tinyxml.h:945
int basisfn_to_atom(const Molecule &molecule, int ibf) const
Returns the number of the atom the ibf'th basis function is on.
Definition: DFcode/molecularbasis.h:511
int nbf() const
Returns the number of basis functions in the shell.
Definition: chem/molecularbasis.h:176