32 #ifndef MADNESS_CHEM_MOLECULAR_BASIS_H__INCLUDED
33 #define MADNESS_CHEM_MOLECULAR_BASIS_H__INCLUDED
39 #include <madness/external/tinyxml/tinyxml.h>
65 int l_lim = 2*
type - 1;
67 for (
int n=l_lim; n>1; n-=2)
f *= n;
69 for (
int n=0; n<
np; ++n)
73 for (
int n1=0; n1<
np; ++n1) {
74 for (
int n2=0; n2<
np; ++n2) {
82 for (
int n=0; n<
np; ++n)
coeff[n] *=
f;
90 const std::vector<double>&
coeff,
91 const std::vector<double>&
expnt,
95 double minexpnt =
expnt[0];
96 for (
unsigned int i=1; i<
expnt.size(); ++i)
97 minexpnt = std::min(minexpnt,
expnt[i]);
110 if (rsq >
rsqmax)
return 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);
121 double*
eval(
double rsq,
double x,
double y,
double z,
double* bf)
const {
123 if (fabs(
R) < 1
e-12) {
124 for (
int i=0; i<
numbf; ++i) bf[i] = 0.0;
139 static const double fac = 1.0;
162 throw "UNKNOWN ANGULAR MOMENTUM";
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"}
203 return tags[
type][ibf];
206 template <
typename Archive>
214 std::vector<ContractedGaussianShell>
g;
226 for (
unsigned int i=0; i<
g.size(); ++i) {
260 const std::vector<ContractedGaussianShell>&
get_shells()
const {
269 double*
eval(
double x,
double y,
double z,
double* bf)
const {
270 double rsq = x*x + y*y + z*z;
272 for (
int i=0; i<
numbf; ++i) bf[i] = 0.0;
276 double* bfstart = bf;
277 for (
unsigned int i=0; i<
g.size(); ++i) {
278 bf =
g[i].eval(rsq, x, y, z, bf);
288 double rsq = x*x + y*y + z*z;
289 if (rsq >
rmaxsq)
return 0.0;
302 for (
int j=0; j<
numbf; ++j)
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;
397 template <
typename Archive>
431 double rsq = x*x + y*y + z*z;
436 void print_me(std::ostream& s)
const;
467 std::vector<AtomicBasis>
ag;
469 template <
typename T>
471 TiXmlElement* child = node->FirstChildElement(
name);
473 std::istringstream s(child->GetText());
475 for (
int i=0; i<n; ++i) {
482 template <
typename T>
484 TiXmlElement* child = node->FirstChildElement(
name);
486 std::istringstream s(child->GetText());
488 for (
int i=0; i<n; ++i) {
489 for (
int j=0; j<
m; ++j) {
527 for (
size_t i=0; i<
molecule.natom(); ++i) {
539 sh_to_bf = std::vector<int>();
540 sh_nbf = std::vector<int>();
543 for (
size_t i=0; i<
molecule.natom(); ++i) {
547 const auto& shells =
ag[atn].get_shells();
548 for (
const auto& sh : shells) {
551 sh_to_bf.push_back(
nbf);
563 return ag[atn].get_avec();
572 return ag[atn].get_aeps();
579 for (
size_t i=0; i<
molecule.natom(); ++i) {
584 const int nbf_on_atom =
ag[atn].nbf();
585 if (ibf >= n && (n+nbf_on_atom) > ibf) {
599 for (
size_t i=0; i<
molecule.natom(); ++i) {
604 const int nbf_on_atom =
ag[atn].nbf();
605 if (ibf >= n && (n+nbf_on_atom) > ibf) {
608 ag[atn].get_shell_from_basis_function(ibf-n, index);
622 for (
size_t i=0; i<
molecule.natom(); ++i) {
633 for (
size_t i=0; i<
molecule.natom(); ++i) {
636 bf =
ag[atn].eval(x-atom.
x, y-atom.
y, z-atom.
z, bf);
645 for (
size_t i=0; i<
molecule.natom(); ++i) {
652 sum +=
ag[atn].eval_guess_density(x-atom.
x, y-atom.
y, z-atom.
z, pspat);
658 return ag[atomic_number].nbf() > 0;
667 template <
typename T>
685 template <
typename T>
687 const double thresh = 0.2*
v.normf();
689 printf(
" zero vector\n");
692 long nbf = int(
v.dim(0));
695 for (
long i=0; i<
nbf; ++i) {
704 format =
" %2s(%1d)%4s(%2ld)%6.3f ";
707 format =
" %2s(%2d)%4s(%3ld)%6.3f ";
710 format =
" %2s(%3d)%4s(%4ld)%6.3f ";
713 format =
" %2s(%4d)%4s(%5ld)%6.3f ";
716 for (
long ii=0; ii<ngot; ++ii) {
726 printf(format, element, iat, desc, ibf,
v[ibf]);
734 template <
typename Archive>
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