MADNESS  version 0.9
hf/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 "mentity.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  bf[0] = R*x*x;
139  bf[1] = R*x*y;
140  bf[2] = R*x*z ;
141  bf[3] = R*y*y ;
142  bf[4] = R*y*z ;
143  bf[5] = R*z*z;
144  break;
145  case 3:
146  bf[0] = R*x*x*x;
147  bf[1] = R*x*x*y;
148  bf[2] = R*x*x*z;
149  bf[3] = R*x*y*y;
150  bf[4] = R*x*y*z;
151  bf[5] = R*x*z*z;
152  bf[6] = R*y*y*y;
153  bf[7] = R*y*y*z;
154  bf[8] = R*y*z*z;
155  bf[9] = R*z*z*z;
156  break;
157 
158  default:
159  throw "UNKNOWN ANGULAR MOMENTUM";
160  }
161  }
162  return bf+numbf;
163  }
164 
165 
167  int angular_momentum() const {
168  return type;
169  }
170 
172  int nbf() const {
173  return numbf;
174  }
175 
177  int nprim() const {
178  return coeff.size();
179  }
180 
182  const std::vector<double>& get_coeff() const {
183  return coeff;
184  }
185 
187  const std::vector<double>& get_expnt() const {
188  return expnt;
189  }
190 
192  const char* get_desc(int ibf) const {
193  static const char* tags[4][10] = {
194  {"s" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" } ,
195  {"px" ,"py" ,"pz" ,"" ,"" ,"" ,"" ,"" ,"" ,"" } ,
196  {"dxx" ,"dxy" ,"dxz" ,"dyy" ,"dyz" ,"dzz" ,"" ,"" ,"" ,"" } ,
197  {"fxxx","fxxy","fxxz","fxyy","fxyz","fxzz","fxzz","fyyy","fyzz","fzzz"}
198  };
199  MADNESS_ASSERT(ibf<numbf && ibf >= 0);
200  return tags[type][ibf];
201  }
202 
203  template <typename Archive>
204  void serialize(Archive& ar) {
205  ar & type & coeff & expnt & rsqmax & numbf;
206  }
207 };
208 
209 
210 std::ostream& operator<<(std::ostream& s, const ContractedGaussianShell& c) {
211  static const char* tag[] = {"s","p","d","f","g"};
212  char buf[32768];
213  char* p = buf;
214  const std::vector<double>& coeff = c.get_coeff();
215  const std::vector<double>& expnt = c.get_expnt();
216 
217  p += sprintf(p,"%s [",tag[c.angular_momentum()]);
218  for (int i=0; i<c.nprim(); i++) {
219  p += sprintf(p, "%.6f(%.6f)",coeff[i],expnt[i]);
220  if (i != (c.nprim()-1)) p += sprintf(p, ", ");
221  }
222  p += sprintf(p, "]");
223  s << buf;
224  return s;
225 }
226 
227 
229 class AtomicBasis {
230  std::vector<ContractedGaussianShell> g;
231  double rmaxsq;
232  int numbf;
233  Tensor<double> dmat, avec, bvec;
234 
235 public:
236  AtomicBasis() : g(), rmaxsq(0.0), numbf(0) {};
237 
238  AtomicBasis(const std::vector<ContractedGaussianShell>& g)
239  : g(g) {
240  rmaxsq = 0.0;
241  numbf = 0;
242  for (unsigned int i=0; i<g.size(); i++) {
243  rmaxsq = std::max(rmaxsq, g[i].rangesq());
244  numbf += g[i].nbf();
245  }
246  }
247 
248  void set_guess_info(const Tensor<double>& dmat,
249  const Tensor<double>& avec, const Tensor<double>& bvec) {
250  this->dmat = copy(dmat);
251  this->avec = copy(avec);
252  this->bvec = copy(bvec);
253  }
254 
256  int nbf() const {
257  return numbf;
258  }
259 
261  int nshell() const {
262  return g.size();
263  }
264 
266  const std::vector<ContractedGaussianShell>& get_shells() const {
267  return g;
268  };
269 
271 
275  double* eval(double x, double y, double z, double* bf) const {
276  double rsq = x*x + y*y + z*z;
277  if (rsq > rmaxsq) {
278  for (int i=0; i<numbf; i++) bf[i] = 0.0;
279  return bf+numbf;
280  }
281 
282  double* bfstart = bf;
283  for (unsigned int i=0; i<g.size(); i++) {
284  bf = g[i].eval(rsq, x, y, z, bf);
285  }
286  // paranoia is good
287  MADNESS_ASSERT(bf-bfstart == numbf);
288  return bf;
289  }
290 
292  double eval_guess_density(double x, double y, double z) const {
293  MADNESS_ASSERT(has_guess_info());
294  double rsq = x*x + y*y + z*z;
295  if (rsq > rmaxsq) return 0.0;
296 
297  double bf[numbf];
298  eval(x, y, z, bf);
299  const double* p = dmat.ptr();
300  double sum = 0.0;
301  for (int i=0; i<numbf; i++, p+=numbf) {
302  double sumj = 0.0;
303  for (int j=0; j<numbf; ++j)
304  sumj += p[j]*bf[j];
305  sum += bf[i]*sumj;
306  }
307  return sum;
308  }
309 
311  const ContractedGaussianShell& get_shell_from_basis_function(int ibf, int& ibf_in_shell) const {
312  int n=0;
313  for (unsigned int i=0; i<g.size(); i++) {
314  int nbf_in_shell = g[i].nbf();
315  if (ibf>=n && ibf<(n+nbf_in_shell)) {
316  ibf_in_shell = ibf-n;
317  return g[i];
318  }
319  else {
320  n += g[i].nbf();
321  }
322  }
323  MADNESS_EXCEPTION("AtomicBasis: get_shell_from_basis_function", ibf*100000 + nbf());
324  }
325 
326  bool has_guess_info() const {
327  return dmat.size()>0;
328  }
329 
330  const Tensor<double>& get_dmat() const {
331  return dmat;
332  };
333 
334  const Tensor<double>& get_avec() const {
335  return avec;
336  };
337 
338  const Tensor<double>& get_bvec() const {
339  return bvec;
340  };
341 
342  template <typename Archive>
343  void serialize(Archive& ar) {
344  ar & g & rmaxsq & numbf & dmat & avec & bvec;
345  }
346 
347 };
348 
349 std::ostream& operator<<(std::ostream& s, const AtomicBasis& c) {
350  const std::vector<ContractedGaussianShell>& shells = c.get_shells();
351  for (int i=0; i<c.nshell(); i++) {
352  s << " " << shells[i] << std::endl;
353  }
354  if (c.has_guess_info()) {
355  s << " " << "Guess density matrix" << std::endl;
356  s << c.get_dmat();
357  }
358 
359  return s;
360 }
361 
363 class AtomicBasisFunction {
364 private:
365  const double xx, yy, zz; // Coordinates of the center
366  const ContractedGaussianShell& shell; // Reference to the underlying atomic shell
367  const int ibf; // Index of basis function in the shell (0, 1, ...)
368  const int nbf; // Number of functions in the shell
369 
370 public:
371  AtomicBasisFunction(double x, double y, double z,
372  const ContractedGaussianShell& shell, int ibf)
373  : xx(x), yy(y), zz(z), shell(shell), ibf(ibf), nbf(shell.nbf()) {}
374 
375 
377  : xx(aofunc.xx)
378  , yy(aofunc.yy)
379  , zz(aofunc.zz)
380  , shell(aofunc.shell)
381  , ibf(aofunc.ibf)
382  , nbf(aofunc.nbf) {}
383 
384  double operator()(double x, double y, double z) const {
385  double bf[nbf];
386  x-=xx;
387  y-=yy;
388  z-=zz;
389  double rsq = x*x + y*y + z*z;
390  shell.eval(rsq, x, y, z, bf);
391  return bf[ibf];
392  }
393 
394  void print_me(std::ostream& s) const {
395  s << "atomic basis function: center " << xx << " " << yy << " " << zz << " : ibf " << ibf << " nbf " << nbf << " : shell " << shell << std::endl;
396  }
397 
399  return shell;
400  }
401 
402  int get_index() const {
403  return ibf;
404  }
405 
406  const char* get_desc() const {
407  return shell.get_desc(ibf);
408  }
409 
410  void get_coords(double& x, double& y, double& z) const {
411  x=xx; y=yy; z=zz;
412  return;
413  }
414 
415  double rangesq() const {
416  return shell.rangesq();
417  }
418 };
419 
420 std::ostream& operator<<(std::ostream& s, const AtomicBasisFunction& a) {
421  a.print_me(s);
422  return s;
423 };
424 
426 class AtomicBasisSet {
427  std::string name;
428  std::vector<AtomicBasis> ag; //< Basis associated by atomic number = 1, 2, ...; 0=Bq.
429 
430  template <typename T>
431  std::vector<T> load_tixml_vector(TiXmlElement* node, int n, const char* name) {
432  TiXmlElement* child = node->FirstChildElement(name);
433  MADNESS_ASSERT(child);
434  std::istringstream s(child->GetText());
435  std::vector<T> r(n);
436  for (int i=0; i<n; i++) {
437  MADNESS_ASSERT(s >> r[i]);
438  }
439  return r;
440  }
441 
442  template <typename T>
443  Tensor<T> load_tixml_matrix(TiXmlElement* node, int n, int m, const char* name) {
444  TiXmlElement* child = node->FirstChildElement(name);
445  MADNESS_ASSERT(child);
446  std::istringstream s(child->GetText());
447  Tensor<T> r(n,m);
448  for (int i=0; i<n; i++) {
449  for (int j=0; j<m; j++) {
450  MADNESS_ASSERT(s >> r(i,j));
451  }
452  }
453  return r;
454  }
455 
456 public:
457  AtomicBasisSet() : name("unknown"), ag(110) {}
458 
459 
460  AtomicBasisSet(std::string filename) : name(""), ag(110) {
461  read_file(filename);
462  }
463 
464  void read_file(std::string filename) {
465  static const bool debug = false;
466  TiXmlDocument doc(filename);
467  if (!doc.LoadFile()) {
468  std::cout << "AtomicBasisSet: Failed loading from file " << filename
469  << " : ErrorDesc " << doc.ErrorDesc()
470  << " : Row " << doc.ErrorRow()
471  << " : Col " << doc.ErrorCol() << std::endl;
472  MADNESS_EXCEPTION("AtomicBasisSet: Failed loading basis set",0);
473  }
474  for (TiXmlElement* node=doc.FirstChildElement(); node; node=node->NextSiblingElement()) {
475  if (strcmp(node->Value(),"name") == 0) {
476  name = node->GetText();
477  if (debug) std::cout << "Loading basis set " << name << std::endl;
478  }
479  else if (strcmp(node->Value(), "basis") == 0) {
480  const char* symbol = node->Attribute("symbol");
481  if (debug) std::cout << " found basis set for " << symbol << std::endl;
482  int atn = symbol_to_atomic_number(symbol);
483  std::vector<ContractedGaussianShell> g;
484  for (TiXmlElement* shell=node->FirstChildElement(); shell; shell=shell->NextSiblingElement()) {
485  const char* type = shell->Attribute("type");
486  int nprim=-1;
487  shell->Attribute("nprim",&nprim);
488  if (debug) std::cout << " found shell " << type << " " << nprim << std::endl;
489  std::vector<double> expnt = load_tixml_vector<double>(shell, nprim, "exponents");
490  if (strcmp(type,"L") == 0) {
491  std::vector<double> scoeff = load_tixml_vector<double>(shell, nprim, "scoefficients");
492  std::vector<double> pcoeff = load_tixml_vector<double>(shell, nprim, "pcoefficients");
493  g.push_back(ContractedGaussianShell(0,scoeff,expnt));
494  g.push_back(ContractedGaussianShell(1,pcoeff,expnt));
495  }
496  else {
497  static const char* tag[] = {"S","P","D","F","G"};
498  int i;
499  for (i=0; i<5; i++) {
500  if (strcmp(type,tag[i]) == 0) goto foundit;
501  }
502  MADNESS_EXCEPTION("Loading atomic basis set: bad shell type?",0);
503 foundit:
504  std::vector<double> coeff = load_tixml_vector<double>(shell, nprim, "coefficients");
505  g.push_back(ContractedGaussianShell(i, coeff, expnt));
506  }
507  }
508  ag[atn] = AtomicBasis(g);
509  }
510  else if (strcmp(node->Value(), "atomicguess") == 0) {
511  const char* symbol = node->Attribute("symbol");
512  if (debug) std::cout << " atomic guess info for " << symbol << std::endl;
513  int atn = symbol_to_atomic_number(symbol);
514  MADNESS_ASSERT(is_supported(atn));
515  int nbf = ag[atn].nbf();
516  Tensor<double> dmat = load_tixml_matrix<double>(node, nbf, nbf, "guessdensitymatrix");
517  Tensor<double> avec = load_tixml_matrix<double>(node, nbf, nbf, "alphavectors");
518  Tensor<double> bvec = load_tixml_matrix<double>(node, nbf, nbf, "betavectors");
519  ag[atn].set_guess_info(dmat, avec, bvec);
520  }
521  else {
522  MADNESS_EXCEPTION("Loading atomic basis set: unexpected XML element", 0);
523  }
524  }
525 
526  }
527 
528 
530  void atoms_to_bfn(const MolecularEntity& mentity, std::vector<int>& at_to_bf, std::vector<int>& at_nbf) {
531  at_to_bf = std::vector<int>(mentity.natom());
532  at_nbf = std::vector<int>(mentity.natom());
533 
534  int n = 0;
535  for (int i=0; i<mentity.natom(); i++) {
536  const Atom& atom = mentity.get_atom(i);
537  const int atn = atom.atomic_number;
538  MADNESS_ASSERT(is_supported(atn));
539  at_to_bf[i] = n;
540  at_nbf[i] = ag[atn].nbf();
541  n += at_nbf[i];
542  }
543  }
544 
545 
547  int basisfn_to_atom(const MolecularEntity& mentity, int ibf) const {
548  MADNESS_ASSERT(ibf >= 0);
549  int n = 0;
550  for (int i=0; i<mentity.natom(); i++) {
551  // Is the desired function on this atom?
552  const Atom& atom = mentity.get_atom(i);
553  const int atn = atom.atomic_number;
554  MADNESS_ASSERT(is_supported(atn));
555  const int nbf_on_atom = ag[atn].nbf();
556  if (ibf >= n && (n+nbf_on_atom) > ibf) {
557  return i;
558  }
559  else {
560  n += nbf_on_atom;
561  }
562  }
563  MADNESS_EXCEPTION("AtomicBasisSet: get_atomic_basis_function: confused?", ibf);
564  }
565 
568  MADNESS_ASSERT(ibf >= 0);
569  int n = 0;
570  for (int i=0; i<mentity.natom(); i++) {
571  // Is the desired function on this atom?
572  const Atom& atom = mentity.get_atom(i);
573  const int atn = atom.atomic_number;
574  MADNESS_ASSERT(is_supported(atn));
575  const int nbf_on_atom = ag[atn].nbf();
576  if (ibf >= n && (n+nbf_on_atom) > ibf) {
577  int index;
578  const ContractedGaussianShell& shell =
579  ag[atn].get_shell_from_basis_function(ibf-n, index);
580  return AtomicBasisFunction(atom.x, atom.y, atom.z, shell, index);
581  }
582  else {
583  n += nbf_on_atom;
584  }
585  }
586  MADNESS_EXCEPTION("AtomicBasisSet: get_atomic_basis_function: confused?", ibf);
587  }
588 
589 
591  int nbf(const MolecularEntity& mentity) const {
592  int n = 0;
593  for (int i=0; i<mentity.natom(); i++) {
594  const Atom& atom = mentity.get_atom(i);
595  const int atn = atom.atomic_number;
596  MADNESS_ASSERT(is_supported(atn));
597  n += ag[atn].nbf();
598  }
599  return n;
600  }
601 
603  void eval(const MolecularEntity& mentity, double x, double y, double z, double *bf) const {
604  for (int i=0; i<mentity.natom(); i++) {
605  const Atom& atom = mentity.get_atom(i);
606  const int atn = atom.atomic_number;
607  bf = ag[atn].eval(x-atom.x, y-atom.y, z-atom.z, bf);
608  }
609  }
610 
611 
613  double eval_guess_density(const MolecularEntity& mentity, double x, double y, double z) const {
614  double sum = 0.0;
615  for (int i=0; i<mentity.natom(); i++) {
616  const Atom& atom = mentity.get_atom(i);
617  const int atn = atom.atomic_number;
618  sum += ag[atn].eval_guess_density(x-atom.x, y-atom.y, z-atom.z);
619  }
620  return sum;
621  }
622 
623  bool is_supported(int atomic_number) const {
624  return ag[atomic_number].nbf() > 0;
625  }
626 
628  void print(const MolecularEntity& mentity) const {
629  std::cout << "\n " << name << " atomic basis set" << std::endl;
630  for (int i=0; i<mentity.natom(); i++) {
631  const Atom& atom = mentity.get_atom(i);
632  const unsigned int atn = atom.atomic_number;
633  for (int j=0; j<i; j++) {
634  if (mentity.get_atom(j).atomic_number == atn)
635  goto doneitalready;
636  }
637  std::cout << std::endl;
638  std::cout << " " << get_atomic_data(i).symbol << std::endl;
639  std::cout << ag[atn];
640 doneitalready:
641  ;
642  }
643  }
644 
645  template <typename T>
646  class AnalysisSorter {
647  const Tensor<T> v;
648  public:
649  AnalysisSorter(const Tensor<T>& v) : v(v) {}
650  bool operator()(long i, long j) const {
651  return std::abs(v[i]) > std::abs(v[j]);
652  }
653  };
654 
656 
663  template <typename T>
664  void print_anal(const MolecularEntity& mentity, const Tensor<T>& v) {
665  const double thresh = 0.2*v.normf();
666  if (thresh == 0.0) {
667  printf(" zero vector\n");
668  return;
669  }
670  long nbf = int(v.dim[0]);
671  long list[nbf];
672  long ngot=0;
673  for (long i=0; i<nbf; i++) {
674  if (std::abs(v(i)) > thresh) {
675  list[ngot++] = i;
676  }
677  }
678  std::sort(list,list+ngot,AnalysisSorter<T>(v));
679 
680  const char* format;
681  if (mentity.natom() < 10) {
682  format = " %2s(%1d)%4s(%2ld)%6.3f ";
683  }
684  else if (mentity.natom() < 100) {
685  format = " %2s(%2d)%4s(%3ld)%6.3f ";
686  }
687  else if (mentity.natom() < 1000) {
688  format = " %2s(%3d)%4s(%4ld)%6.3f ";
689  }
690  else {
691  format = " %2s(%4d)%4s(%5ld)%6.3f ";
692  }
693  for (long ii=0; ii<ngot; ii++) {
694  long ibf = list[ii];
695 
696  const int iat = basisfn_to_atom(mentity, ibf);
697  const Atom& atom = mentity.get_atom(iat);
698  const AtomicBasisFunction ao = get_atomic_basis_function(mentity, ibf);
699  const char* desc = ao.get_desc();
700  const char* element = get_atomic_data(atom.atomic_number).symbol;
701 
702  // This will need wrapping in a template for a complex MO vector
703  printf(format, element, iat, desc, ibf, v[ibf]);
704  }
705  printf("\n");
706  }
707 
709  void print_all() const {
710  std::cout << "\n " << name << " atomic basis set" << std::endl;
711  for (unsigned int i=0; i<ag.size(); i++) {
712  if (ag[i].nbf() > 0) {
713  std::cout << " " << get_atomic_data(i).symbol << std::endl;
714  std::cout << ag[i];
715  }
716  }
717  }
718 
719  template <typename Archive>
720  void serialize(Archive& ar) {
721  ar & name & ag;
722  }
723 };
724 
725 
726 
727 #endif
int np
Definition: tdse1d.cc:166
int nbf() const
Returns the number of basis functions on the center.
Definition: hf/molecularbasis.h:256
double eval_radial(double rsq) const
Evaluates the radial part of the contracted function.
Definition: hf/molecularbasis.h:109
const double thresh
Definition: dielectric.cc:185
const Tensor< double > & get_dmat() const
Definition: hf/molecularbasis.h:330
NDIM const Function< R, NDIM > & g
Definition: mra.h:2179
bool is_supported(int atomic_number) const
Definition: hf/molecularbasis.h:623
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: hf/molecularbasis.h:167
void atoms_to_bfn(const MolecularEntity &mentity, 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: hf/molecularbasis.h:530
const double R
Definition: dielectric.cc:191
void serialize(Archive &ar)
Definition: hf/molecularbasis.h:204
double rangesq() const
Returns square of the distance beyond which function is less than 1e-8.
Definition: hf/molecularbasis.h:103
double operator()(double x, double y, double z) const
Definition: hf/molecularbasis.h:384
ContractedGaussianShell()
Definition: hf/molecularbasis.h:86
int basisfn_to_atom(const MolecularEntity &mentity, int ibf) const
Returns the number of the atom the ibf'th basis function is on.
Definition: hf/molecularbasis.h:547
const mpreal pow(const mpreal &a, const unsigned int b, mp_rnd_t rnd_mode=mpreal::default_rnd)
Definition: mpreal.h:2788
void serialize(Archive &ar)
Definition: hf/molecularbasis.h:720
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: hf/molecularbasis.h:292
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: hf/molecularbasis.h:311
const char *const symbol
Definition: chem/atomutil.h:54
void print(const MolecularEntity &mentity) const
Print basis info for atoms in the molecule (once for each unique atom type)
Definition: hf/molecularbasis.h:628
double z
Definition: chem/molecule.h:57
double rangesq() const
Returns square of the distance beyond which function is less than 1e-8.
Definition: chem/molecularbasis.h:104
::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
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: hf/molecularbasis.h:177
int nprim() const
Returns the number of primitives in the contraction.
Definition: chem/molecularbasis.h:181
NDIM & f
Definition: mra.h:2179
bool operator()(long i, long j) const
Definition: hf/molecularbasis.h:650
int nbf() const
Returns the number of basis functions in the shell.
Definition: hf/molecularbasis.h:172
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: hf/molecularbasis.h:238
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1475
void print_me(std::ostream &s) const
Definition: hf/molecularbasis.h:394
AtomicBasis()
Definition: hf/molecularbasis.h:236
Represents multiple shells of contracted gaussians on a single center.
Definition: chem/molecularbasis.h:214
double rangesq() const
Definition: hf/molecularbasis.h:415
const char * get_desc(int ibf) const
Returns a string description of the basis function type.
Definition: hf/molecularbasis.h:192
void print_anal(const MolecularEntity &mentity, const Tensor< T > &v)
Given a vector of AO coefficients prints an analysis.
Definition: hf/molecularbasis.h:664
Defines and implements most of Tensor.
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 nshell() const
Returns the number of shells on the center.
Definition: chem/molecularbasis.h:246
const std::vector< double > & get_expnt() const
Returns a const reference to the exponents.
Definition: chem/molecularbasis.h:191
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: hf/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: hf/molecularbasis.h:248
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: hf/molecularbasis.h:275
int get_index() const
Definition: hf/molecularbasis.h:402
const std::vector< double > & get_expnt() const
Returns a const reference to the exponents.
Definition: hf/molecularbasis.h:187
const std::vector< double > & get_coeff() const
Returns a const reference to the coefficients.
Definition: hf/molecularbasis.h:182
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
int nbf(const MolecularEntity &mentity) const
Given a molecule count the number of basis functions.
Definition: hf/molecularbasis.h:591
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
Definition: mentity.h:95
AtomicBasisSet()
Definition: hf/molecularbasis.h:457
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
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: hf/molecularbasis.h:410
const Tensor< double > & get_bvec() const
Definition: hf/molecularbasis.h:338
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
double eval_guess_density(const MolecularEntity &mentity, double x, double y, double z) const
Evaluates the guess density.
Definition: hf/molecularbasis.h:613
const char * get_desc() const
Definition: hf/molecularbasis.h:406
void eval(const MolecularEntity &mentity, double x, double y, double z, double *bf) const
Evaluates the basis functions.
Definition: hf/molecularbasis.h:603
AtomicBasisFunction(double x, double y, double z, const ContractedGaussianShell &shell, int ibf)
Definition: hf/molecularbasis.h:371
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
const Atom & get_atom(unsigned int i) const
Definition: mentity.cc:369
void read_file(std::string filename)
Definition: hf/molecularbasis.h:464
const std::vector< ContractedGaussianShell > & get_shells() const
Returns a const reference to the shells.
Definition: hf/molecularbasis.h:266
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: hf/molecularbasis.h:376
const double m
Definition: gfit.cc:199
unsigned int symbol_to_atomic_number(const std::string &symbol)
Definition: chem/atomutil.cc:166
void print_all() const
Print basis info for all supported atoms.
Definition: hf/molecularbasis.h:709
std::ostream & operator<<(std::ostream &s, const ContractedGaussianShell &c)
Definition: chem/molecularbasis.cc:38
Definition: DFcode/molecularbasis.h:597
const Tensor< double > & get_avec() const
Definition: hf/molecularbasis.h:334
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: hf/molecularbasis.h:343
AnalysisSorter(const Tensor< T > &v)
Definition: hf/molecularbasis.h:649
Contracted Gaussian basis.
Definition: chem/molecularbasis.h:391
const Tensor< double > & get_dmat() const
Definition: chem/molecularbasis.h:315
double E0(double p)
Definition: gfit.cc:203
const std::vector< double > & get_coeff() const
Returns a const reference to the coefficients.
Definition: chem/molecularbasis.h:186
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
int nshell() const
Returns the number of shells on the center.
Definition: hf/molecularbasis.h:261
const char * GetText() const
Definition: tinyxml.cc:871
AtomicBasisFunction get_atomic_basis_function(const MolecularEntity &mentity, int ibf) const
Returns the ibf'th atomic basis function.
Definition: hf/molecularbasis.h:567
const std::vector< ContractedGaussianShell > & get_shells() const
Returns a const reference to the shells.
Definition: chem/molecularbasis.h:251
const mpreal fabs(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2187
AtomicBasisSet(std::string filename)
Definition: hf/molecularbasis.h:460
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
const double c
Definition: gfit.cc:200
const char * Attribute(const char *name) const
Definition: tinyxml.cc:555
int angular_momentum() const
Returns the shell angular momentum.
Definition: chem/molecularbasis.h:171
const ContractedGaussianShell & get_shell() const
Definition: hf/molecularbasis.h:398
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
bool has_guess_info() const
Definition: hf/molecularbasis.h:326
int natom() const
Definition: mentity.h:112
ContractedGaussianShell(int type, const std::vector< double > &coeff, const std::vector< double > &expnt, bool donorm=true)
Definition: hf/molecularbasis.h:89
Definition: tinyxml.h:945
int nbf() const
Returns the number of basis functions in the shell.
Definition: chem/molecularbasis.h:176