32#ifndef MADNESS_CHEM_MOLECULAR_BASIS_H__INCLUDED
33#define MADNESS_CHEM_MOLECULAR_BASIS_H__INCLUDED
39#include <madness/external/tinyxml/tinyxml.h>
69 int l_lim = 2*
type - 1;
71 for (
int n=l_lim; n>1; n-=2)
f *= n;
73 for (
int n=0; n<
np; ++n)
77 for (
int n1=0; n1<
np; ++n1) {
78 for (
int n2=0; n2<
np; ++n2) {
86 for (
int n=0; n<
np; ++n)
coeff[n] *=
f;
94 const std::vector<double>&
coeff,
95 const std::vector<double>&
expnt,
99 double minexpnt =
expnt[0];
100 for (
unsigned int i=1; i<
expnt.size(); ++i)
101 minexpnt = std::min(minexpnt,
expnt[i]);
114 if (rsq >
rsqmax)
return 0.0;
116 for (
unsigned int i=0; i<
coeff.size(); ++i) {
117 double ersq =
expnt[i]*rsq;
118 if (ersq < 27.6)
sum +=
coeff[i]*exp(-ersq);
125 double*
eval(
double rsq,
double x,
double y,
double z,
double* bf)
const {
127 if (fabs(
R) < 1
e-12) {
128 for (
int i=0; i<
numbf; ++i) bf[i] = 0.0;
143 static const double fac = 1.0;
166 throw "UNKNOWN ANGULAR MOMENTUM";
200 static const char* tags[4][10] = {
201 {
"s" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" } ,
202 {
"px" ,
"py" ,
"pz" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" } ,
203 {
"dxx" ,
"dxy" ,
"dxz" ,
"dyy" ,
"dyz" ,
"dzz" ,
"" ,
"" ,
"" ,
"" } ,
204 {
"fxxx",
"fxxy",
"fxxz",
"fxyy",
"fxyz",
"fxzz",
"fxzz",
"fyyy",
"fyzz",
"fzzz"}
207 return tags[
type][ibf];
210 template <
typename Archive>
218 std::vector<ContractedGaussianShell>
g;
230 for (
unsigned int i=0; i<
g.size(); ++i) {
264 const std::vector<ContractedGaussianShell>&
get_shells()
const {
273 double*
eval(
double x,
double y,
double z,
double* bf)
const {
274 double rsq = x*x + y*y + z*z;
276 for (
int i=0; i<
numbf; ++i) bf[i] = 0.0;
280 double* bfstart = bf;
281 for (
unsigned int i=0; i<
g.size(); ++i) {
282 bf =
g[i].eval(rsq, x, y, z, bf);
292 double rsq = x*x + y*y + z*z;
293 if (rsq >
rmaxsq)
return 0.0;
306 for (
int j=0; j<
numbf; ++j)
316 for (
unsigned int i=0; i<
g.size(); ++i) {
317 int nbf_in_shell =
g[i].
nbf();
318 if (ibf>=n && ibf<(n+nbf_in_shell)) {
319 ibf_in_shell = ibf-n;
401 template <
typename Archive>
435 double rsq = x*x + y*y + z*z;
440 void print_me(std::ostream& s)
const;
471 std::vector<AtomicBasis>
ag;
473 template <
typename T>
475 TiXmlElement* child = node->FirstChildElement(
name);
477 std::istringstream s(child->GetText());
479 for (
int i=0; i<n; ++i) {
486 template <
typename T>
488 TiXmlElement* child = node->FirstChildElement(
name);
490 std::istringstream s(child->GetText());
492 for (
int i=0; i<n; ++i) {
493 for (
int j=0; j<
m; ++j) {
531 for (
size_t i=0; i<
molecule.natom(); ++i) {
543 sh_to_bf = std::vector<int>();
544 sh_nbf = std::vector<int>();
547 for (
size_t i=0; i<
molecule.natom(); ++i) {
551 const auto& shells =
ag[atn].get_shells();
552 for (
const auto& sh : shells) {
555 sh_to_bf.push_back(
nbf);
567 return ag[atn].get_avec();
576 return ag[atn].get_aeps();
583 for (
size_t i=0; i<
molecule.natom(); ++i) {
588 const int nbf_on_atom =
ag[atn].nbf();
589 if (ibf >= n && (n+nbf_on_atom) > ibf) {
603 for (
size_t i=0; i<
molecule.natom(); ++i) {
608 const int nbf_on_atom =
ag[atn].nbf();
609 if (ibf >= n && (n+nbf_on_atom) > ibf) {
612 ag[atn].get_shell_from_basis_function(ibf-n, index);
626 for (
size_t i=0; i<
molecule.natom(); ++i) {
637 for (
size_t i=0; i<
molecule.natom(); ++i) {
640 bf =
ag[atn].eval(x-atom.
x, y-atom.
y, z-atom.
z, bf);
649 for (
size_t i=0; i<
molecule.natom(); ++i) {
656 sum +=
ag[atn].eval_guess_density(x-atom.
x, y-atom.
y, z-atom.
z, pspat);
662 return ag[atomic_number].nbf() > 0;
671 template <
typename T>
689 template <
typename T>
691 const double thresh = 0.2*
v.normf();
693 printf(
" zero vector\n");
696 long nbf = int(
v.dim(0));
697 std::vector<long> list(
nbf);
699 for (
long i=0; i<
nbf; ++i) {
708 format =
" %2s(%1d)%4s(%2ld)%6.3f ";
711 format =
" %2s(%2d)%4s(%3ld)%6.3f ";
714 format =
" %2s(%3d)%4s(%4ld)%6.3f ";
717 format =
" %2s(%4d)%4s(%5ld)%6.3f ";
720 for (
long ii=0; ii<ngot; ++ii) {
730 printf(format, element, iat, desc, ibf,
v[ibf]);
738 template <
typename Archive>
Declaration of utility class and functions for atom.
double y
Definition molecule.h:62
unsigned int atomic_number
Atomic number.
Definition molecule.h:63
double x
Definition molecule.h:62
double z
Definition molecule.h:62
bool pseudo_atom
Indicates if this atom uses a pseudopotential.
Definition molecule.h:65
Used to represent one basis function from a shell on a specific center.
Definition madness/chem/molecularbasis.h:409
void print_me(std::ostream &s) const
Definition molecularbasis.cc:85
int get_index() const
Definition madness/chem/molecularbasis.h:446
const double yy
Definition madness/chem/molecularbasis.h:411
const ContractedGaussianShell & get_shell() const
Definition madness/chem/molecularbasis.h:442
AtomicBasisFunction(double x, double y, double z, const ContractedGaussianShell &shell, int ibf)
Definition madness/chem/molecularbasis.h:417
madness::Vector< double, 3 > get_coords_vec() const
Definition madness/chem/molecularbasis.h:459
const ContractedGaussianShell & shell
Definition madness/chem/molecularbasis.h:412
void get_coords(double &x, double &y, double &z) const
Definition madness/chem/molecularbasis.h:454
const double xx
Definition madness/chem/molecularbasis.h:411
const int nbf
Definition madness/chem/molecularbasis.h:414
double operator()(double x, double y, double z) const
Definition madness/chem/molecularbasis.h:430
double rangesq() const
Definition madness/chem/molecularbasis.h:463
const char * get_desc() const
Definition madness/chem/molecularbasis.h:450
const double zz
Definition madness/chem/molecularbasis.h:411
const int ibf
Definition madness/chem/molecularbasis.h:413
AtomicBasisFunction(const AtomicBasisFunction &aofunc)
Definition madness/chem/molecularbasis.h:422
Definition madness/chem/molecularbasis.h:672
bool operator()(long i, long j) const
Definition madness/chem/molecularbasis.h:676
AnalysisSorter(const Tensor< T > &v)
Definition madness/chem/molecularbasis.h:675
const Tensor< T > v
Definition madness/chem/molecularbasis.h:673
Contracted Gaussian basis.
Definition madness/chem/molecularbasis.h:469
AtomicBasisSet(std::string filename)
Definition madness/chem/molecularbasis.h:505
void read_nw_file(std::string filename)
read the atomic basis set from file
Definition molecularbasis.cc:206
double eval_guess_density(const Molecule &molecule, double x, double y, double z) const
Evaluates the guess density.
Definition madness/chem/molecularbasis.h:646
AtomicBasisFunction get_atomic_basis_function(const Molecule &molecule, size_t ibf) const
Returns the ibf'th atomic basis function.
Definition madness/chem/molecularbasis.h:600
void read_file(std::string filename)
read the atomic basis set from file
Definition molecularbasis.cc:119
std::vector< T > load_tixml_vector(TiXmlElement *node, int n, const char *name)
Definition madness/chem/molecularbasis.h:474
bool is_supported(int atomic_number) const
Definition madness/chem/molecularbasis.h:661
int nbf(const Molecule &molecule) const
Given a molecule count the number of basis functions.
Definition madness/chem/molecularbasis.h:624
AtomicBasisSet()
Definition madness/chem/molecularbasis.h:502
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:562
std::vector< AtomicBasis > ag
Basis associated by atomic number = 1, 2, ...; 0=Bq.
Definition madness/chem/molecularbasis.h:471
void print(const Molecule &molecule) const
Print basis info for atoms in the molecule (once for each unique atom type)
Definition molecularbasis.cc:90
Tensor< T > load_tixml_matrix(TiXmlElement *node, int n, int m, const char *name)
Definition madness/chem/molecularbasis.h:487
std::string name
Definition madness/chem/molecularbasis.h:470
void serialize(Archive &ar)
Definition madness/chem/molecularbasis.h:739
std::string get_name() const
Definition madness/chem/molecularbasis.h:509
void modify_dmat_psp(int atn, double zeff)
Eliminates core orbitals from the density matrix for pseudopotential calculations.
Definition molecularbasis.cc:237
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:526
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:580
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:690
void print_all() const
Print basis info for all supported atoms.
Definition molecularbasis.cc:109
void eval(const Molecule &molecule, double x, double y, double z, double *bf) const
Evaluates the basis functions.
Definition madness/chem/molecularbasis.h:636
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:571
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:542
Represents multiple shells of contracted gaussians on a single center.
Definition madness/chem/molecularbasis.h:217
const Tensor< double > & get_dmatpsp() const
Definition madness/chem/molecularbasis.h:345
Tensor< double > beps
Definition madness/chem/molecularbasis.h:221
const std::vector< ContractedGaussianShell > & get_shells() const
Returns a const reference to the shells.
Definition madness/chem/molecularbasis.h:264
void set_aocc(Tensor< double > &occ)
Definition madness/chem/molecularbasis.h:377
Tensor< double > aocc
Definition madness/chem/molecularbasis.h:221
void set_dmatpsp(Tensor< double > &mat)
Definition madness/chem/molecularbasis.h:349
std::vector< ContractedGaussianShell > g
Definition madness/chem/molecularbasis.h:218
double rmaxsq
Definition madness/chem/molecularbasis.h:219
int nshell() const
Returns the number of shells on the center.
Definition madness/chem/molecularbasis.h:259
Tensor< double > bocc
Definition madness/chem/molecularbasis.h:221
void set_aoccpsp(Tensor< double > &occ)
Definition madness/chem/molecularbasis.h:393
int numbf
Definition madness/chem/molecularbasis.h:220
const Tensor< double > & get_aoccpsp() const
Definition madness/chem/molecularbasis.h:385
const Tensor< double > & get_aocc() const
Definition madness/chem/molecularbasis.h:369
Tensor< double > avec
Definition madness/chem/molecularbasis.h:221
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:236
void set_bocc(Tensor< double > &occ)
Definition madness/chem/molecularbasis.h:381
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:273
Tensor< double > dmatpsp
Definition madness/chem/molecularbasis.h:221
void set_dmat(Tensor< double > &mat)
Definition madness/chem/molecularbasis.h:337
Tensor< double > aeps
Definition madness/chem/molecularbasis.h:221
AtomicBasis(const std::vector< ContractedGaussianShell > &g)
Definition madness/chem/molecularbasis.h:226
AtomicBasis()
Definition madness/chem/molecularbasis.h:224
const Tensor< double > & get_aeps() const
Definition madness/chem/molecularbasis.h:361
int nbf() const
Returns the number of basis functions on the center.
Definition madness/chem/molecularbasis.h:254
Tensor< double > boccpsp
Definition madness/chem/molecularbasis.h:221
const Tensor< double > & get_dmat() const
Definition madness/chem/molecularbasis.h:333
void serialize(Archive &ar)
Definition madness/chem/molecularbasis.h:402
bool has_guess_info() const
Definition madness/chem/molecularbasis.h:329
const Tensor< double > & get_avec() const
Definition madness/chem/molecularbasis.h:353
Tensor< double > bvec
Definition madness/chem/molecularbasis.h:221
void set_boccpsp(Tensor< double > &occ)
Definition madness/chem/molecularbasis.h:397
bool has_guesspsp_info() const
Definition madness/chem/molecularbasis.h:341
const Tensor< double > & get_beps() const
Definition madness/chem/molecularbasis.h:365
const Tensor< double > & get_bocc() const
Definition madness/chem/molecularbasis.h:373
Tensor< double > aoccpsp
Definition madness/chem/molecularbasis.h:221
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:290
Tensor< double > dmat
Definition madness/chem/molecularbasis.h:221
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:314
const Tensor< double > & get_boccpsp() const
Definition madness/chem/molecularbasis.h:389
const Tensor< double > & get_bvec() const
Definition madness/chem/molecularbasis.h:357
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:211
static const int maxbf
Maximum number of basis functions in a shell.
Definition madness/chem/molecularbasis.h:54
int nbf() const
Returns the number of basis functions in the shell.
Definition madness/chem/molecularbasis.h:179
ContractedGaussianShell()
Definition madness/chem/molecularbasis.h:90
int numbf
Number of basis functions in shell (type+1)*(type+2)/2.
Definition madness/chem/molecularbasis.h:60
ContractedGaussianShell(int type, const std::vector< double > &coeff, const std::vector< double > &expnt, bool donorm=true)
Definition madness/chem/molecularbasis.h:93
double eval_radial(double rsq) const
Evaluates the radial part of the contracted function.
Definition madness/chem/molecularbasis.h:113
std::vector< double > coeff
Definition madness/chem/molecularbasis.h:57
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:125
const std::vector< double > & get_expnt() const
Returns a const reference to the exponents.
Definition madness/chem/molecularbasis.h:194
std::vector< double > expnt
Definition madness/chem/molecularbasis.h:58
const std::vector< double > & get_coeff() const
Returns a const reference to the coefficients.
Definition madness/chem/molecularbasis.h:189
int type
Angular momentum = 0, 1, 2, ...
Definition madness/chem/molecularbasis.h:56
int nprim() const
Returns the number of primitives in the contraction.
Definition madness/chem/molecularbasis.h:184
double rangesq() const
Returns square of the distance beyond which function is less than 1e-8.
Definition madness/chem/molecularbasis.h:107
int angular_momentum() const
Returns the shell angular momentum.
Definition madness/chem/molecularbasis.h:174
const char * get_desc(int ibf) const
Returns a string description of the basis function type.
Definition madness/chem/molecularbasis.h:199
static const int maxtype
Maximum angular momentum supported.
Definition madness/chem/molecularbasis.h:53
double rsqmax
Definition madness/chem/molecularbasis.h:59
void normalize()
Definition madness/chem/molecularbasis.h:62
Definition molecule.h:129
A tensor is a multidimensional array.
Definition tensor.h:317
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1825
A simple, fixed dimension vector.
Definition vector.h:64
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
static const double v
Definition hatom_sf_dirac.cc:20
static double pow(const double *a, const double *b)
Definition lda.h:74
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:182
#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
constexpr double pi
Mathematical constant .
Definition constants.h:48
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
static const char * filename
Definition legendre.cc:96
const AtomicData & get_atomic_data(unsigned int atomic_number)
Definition atomutil.cc:167
NDIM & f
Definition mra.h:2481
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:2066
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 m
Definition relops.cc:9
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.
AtomicInt sum
Definition test_atomicint.cc:46
void e()
Definition test_sig.cc:75
static Molecule molecule
Definition testperiodicdft.cc:39