Psi4
basisset.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef _psi_src_lib_libmints_basisset_h_
30 #define _psi_src_lib_libmints_basisset_h_
31 
32 #include <cstdio>
33 #include <string>
34 #include <vector>
35 
36 #include "gshell.h"
37 #include "molecule.h"
38 
39  #include "psi4/pragma.h"
40  PRAGMA_WARNING_PUSH
41  PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
42  #include <memory>
44 #include "psi4/psi4-dec.h"
45 namespace psi {
46 
47 
48 
49 class Molecule;
50 class GaussianShell;
51 
52 class BasisSetParser;
53 class SOBasisSet;
54 class IntegralFactory;
55 
56 
59 
64 class BasisSet
65 {
66 protected:
67  friend class BasisSetParser;
68 
70  std::string name_;
71 
72  // Key and target information from constructing
73  std::string key_;
74  std::string target_;
75 
80 
82  std::vector<int> sorted_ao_shell_list_;
83 
85  std::map<std::string, int> ncore_;
86 
88  std::shared_ptr<Molecule> molecule_;
89 
90  // Has static information been initialized?
91  static bool initialized_shared_;
92 
93  /*
94  * Scalars
95  */
97  int nao_;
99  int nbf_;
113  int max_am_;
119  bool puream_;
120 
121  /*
122  * Arrays
123  */
148 
150  double *uexponents_;
152  double *ucoefficients_;
156  double *uecpexponents_;
160  int *uecpns_;
164  double *xyz_;
165 
166 
167 
168 
169 public:
170  BasisSet();
171 
172  BasisSet(const std::string &basistype, SharedMolecule mol,
173  std::map<std::string, std::map<std::string, std::vector<ShellInfo> > > &shell_map,
174  std::map<std::string, std::map<std::string, std::vector<ShellInfo> > > &ecp_shell_map);
175 
181  static std::shared_ptr<BasisSet> build(std::shared_ptr<Molecule> molecule,
182  const std::vector<ShellInfo> &shells);
183 
185  static void initialize_singletons();
186 
190  int nprimitive() const { return nprimitive_; }
194  int n_ecp_primitive() const { return n_ecp_primitive_; }
200  int max_nprimitive() const { return max_nprimitive_; }
204  int nshell() const { return n_shells_; }
208  int n_ecp_shell() const { return n_ecp_shells_; }
212  int nao() const { return nao_; }
216  int nbf() const { return nbf_; }
220  bool has_ECP() const { return n_ecp_shells_ > 0; }
224  int max_am() const { return max_am_; }
228  int max_ecp_am() const { return max_ecp_am_; }
232  bool has_puream() const { return puream_; }
236  int max_function_per_shell() const { return (puream_) ? 2*max_am_+1 : (max_am_+1)*(max_am_+2)/2; }
240  std::shared_ptr<Molecule> molecule() const;
245  int shell_to_ao_function(int i) const { return shell_first_ao_[i]; }
250  int shell_to_center(int i) const { return shell_center_[i]; }
256 
258  int function_to_shell(int i) const { return function_to_shell_[i]; }
263  int function_to_center(int i) const { return function_center_[i]; }
264 
266  int ao_to_shell(int i) const { return ao_to_shell_[i]; }
267 
272  const GaussianShell& shell(int si) const;
273 
278  const GaussianShell& ecp_shell(int si) const;
279 
285  const GaussianShell& shell(int center, int si) const;
286 
288  int n_ecp_core(const std::string &label) const { return ncore_.count(label) ? ncore_.at(label) : 0; }
289 
291  int n_ecp_core() const;
292 
294  void set_n_ecp_core(const std::string &label, int n) { ncore_[std::string(label)] = n; }
295 
297  int n_frozen_core(const std::string& depth = "", SharedMolecule mol=nullptr);
298 
303  void print(std::string out) const;
304  void print() const { print("outfile"); }
306 
308  const std::string & name() const { return name_; }
309  void set_name(const std::string str) {name_ = str;}
310 
312  const std::string & key() const { return key_; }
313  const std::string & target() const { return target_; }
314 
323  void print_by_level(std::string out = "outfile", int print_level = 2) const;
327  void print_summary(std::string out = "outfile") const;
328 
332  void print_detail(std::string out) const;
333  void print_detail() const { print_detail("outfile"); }
334 
338  std::string print_detail_cfour() const;
339 
344  void refresh();
345 
347  int nshell_on_center(int i) const { return center_to_nshell_[i]; }
349  int n_ecp_shell_on_center(int i) const { return center_to_ecp_nshell_[i]; }
351  int shell_on_center(int c, int n) const { return center_to_shell_[c] + n; }
353  int ecp_shell_on_center(int c, int n) const { return center_to_ecp_shell_[c] + n; }
354 
355 
362  static std::shared_ptr<BasisSet> zero_ao_basis_set();
363 
370  static std::shared_ptr<SOBasisSet> zero_so_basis_set(const std::shared_ptr<IntegralFactory>& factory);
371 
379  static std::pair<std::vector<std::string>, std::shared_ptr<BasisSet> > test_basis_set(int max_am);
380 
381 
389  static std::shared_ptr<BasisSet> construct_from_pydict(const std::shared_ptr <Molecule> &mol, py::dict pybs, const int forced_puream);
390 
395  static std::string make_filename(const std::string& basisname);
396 
398  static std::vector<Vector3> exp_ao[];
399 
401  int get_ao_sorted_shell(const int &i) { return sorted_ao_shell_list_[i]; }
403  std::vector<int> get_ao_sorted_list() { return sorted_ao_shell_list_; }
404 
405  // Translate a given atom by a given amount. Used for debugging/finite difference purposes. Does NOT modify the underlying molecule object.
406  void move_atom(int atom, const Vector3 &trans);
407  // Returns the values of the basis functions at a point
408  void compute_phi(double *phi_ao, double x, double y, double z);
409 };
410 
411 }
412 
413 #endif
int n_ecp_uprimitive_
The number of unique ECP primitives.
Definition: basisset.h:103
int * center_to_nshell_
How many shells are there on each center?
Definition: basisset.h:141
int n_uprimitive_
The number of unique primitives.
Definition: basisset.h:101
int nprimitive_
The number of primitives.
Definition: basisset.h:109
void set_n_ecp_core(const std::string &label, int n)
Set the number of electrons associated with the given atom label, for an ECP basis set...
Definition: basisset.h:294
double * ucoefficients_
The flattened lists of unique contraction coefficients (normalized)
Definition: basisset.h:152
static std::vector< Vector3 > exp_ao[]
Global arrays of x, y, z exponents.
Definition: basisset.h:398
int ao_to_shell(int i) const
Definition: basisset.h:266
int * function_center_
Which center is a given function on?
Definition: basisset.h:139
int * center_to_ecp_shell_
What&#39;s the first ECP shell on each center?
Definition: basisset.h:147
int n_shells_
The number of shells.
Definition: basisset.h:105
double * uoriginal_coefficients_
The flattened lists of unique contraction coefficients (as provided by the user)
Definition: basisset.h:154
std::vector< int > sorted_ao_shell_list_
vector of shells numbers sorted in ascending AM order.
Definition: basisset.h:82
const std::string & target() const
Definition: basisset.h:313
double * xyz_
The flattened list of Cartesian coordinates for each atom.
Definition: basisset.h:164
std::map< std::string, int > ncore_
The number of core electrons for each atom type.
Definition: basisset.h:85
double * uerd_coefficients_
The flattened lists of ERD normalized contraction coefficients.
Definition: basisset.h:162
int n_ecp_shell_on_center(int i) const
Return the number of ECP shells on a given center.
Definition: basisset.h:349
const GaussianShell & ecp_shell(int si) const
Definition: basisset.cc:591
int nbf() const
Definition: basisset.h:216
void set_name(const std::string str)
Definition: basisset.h:309
static bool initialized_shared_
Definition: basisset.h:91
int max_nprimitive_
The maximum number of primitives in a shell.
Definition: basisset.h:117
void print_by_level(std::string out="outfile", int print_level=2) const
Definition: basisset.cc:247
bool has_ECP() const
Definition: basisset.h:220
Definition: vector3.h:37
Definition: pointgrp.h:106
std::vector< int > get_ao_sorted_list()
Returns the vector of sorted shell list.
Definition: basisset.h:403
int * function_to_shell_
Which shell does a given (Cartesian / spherical) function belong to?
Definition: basisset.h:135
int nbf_
Number of basis functions (either cartesian or spherical)
Definition: basisset.h:99
int n_ecp_primitive_
The number of ECP primitives.
Definition: basisset.h:111
int n_ecp_shell() const
Definition: basisset.h:208
static std::shared_ptr< BasisSet > construct_from_pydict(const std::shared_ptr< Molecule > &mol, py::dict pybs, const int forced_puream)
Definition: basisset.cc:614
int * shell_first_ao_
The first (Cartesian) atomic orbital in each shell.
Definition: basisset.h:127
GaussianShell * ecp_shells_
Array of ECP shells.
Definition: basisset.h:79
double * uecpcoefficients_
The flattened lists of unique ECP contraction coefficients (normalized)
Definition: basisset.h:158
void print_summary(std::string out="outfile") const
Definition: basisset.cc:259
int max_am() const
Definition: basisset.h:224
int max_ecp_am() const
Definition: basisset.h:228
std::string target_
Definition: basisset.h:74
int shell_to_ao_function(int i) const
Definition: basisset.h:245
int * uecpns_
The flattened list of r exponenets for ECP calculations.
Definition: basisset.h:160
friend class BasisSetParser
Definition: basisset.h:67
int nao() const
Definition: basisset.h:212
int nprimitive() const
Definition: basisset.h:190
void print() const
Definition: basisset.h:304
int * shell_first_basis_function_
The first (Cartesian / spherical) basis function in each shell.
Definition: basisset.h:129
const std::string & name() const
Returns the name of this basis set.
Definition: basisset.h:308
int * shell_center_
Shell number to atomic center.
Definition: basisset.h:131
std::shared_ptr< Molecule > molecule_
Molecule object.
Definition: basisset.h:88
int get_ao_sorted_shell(const int &i)
Returns the value of the sorted shell list.
Definition: basisset.h:401
PRAGMA_WARNING_PUSH PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS PRAGMA_WARNING_POP
Definition: integraliter.cc:43
int shell_to_center(int i) const
Definition: basisset.h:250
double * uecpexponents_
The flattened lists of unique ECP exponents.
Definition: basisset.h:156
static std::shared_ptr< BasisSet > build(std::shared_ptr< Molecule > molecule, const std::vector< ShellInfo > &shells)
Definition: basisset.cc:142
std::shared_ptr< Molecule > molecule() const
Definition: basisset.cc:177
int function_to_shell(int i) const
Definition: basisset.h:258
int n_ecp_primitive() const
Definition: basisset.h:194
int max_function_per_shell() const
Definition: basisset.h:236
int ecp_shell_on_center(int c, int n) const
Return the overall ECP shell number of the n&#39;th ECP shell on the c&#39;th center.
Definition: basisset.h:353
double * uexponents_
The flattened lists of unique exponents.
Definition: basisset.h:150
static std::shared_ptr< SOBasisSet > zero_so_basis_set(const std::shared_ptr< IntegralFactory > &factory)
bool has_puream() const
Definition: basisset.h:232
void print_detail() const
Definition: basisset.h:333
std::shared_ptr< Molecule > SharedMolecule
Definition: typedefs.h:53
std::string key_
Definition: basisset.h:73
Gaussian orbital shell.
Definition: gshell.h:189
int function_to_center(int i) const
Definition: basisset.h:263
BasisSet()
Definition: basisset.cc:88
void refresh()
Definition: basisset.cc:1021
Basis set container class.
Definition: basisset.h:64
int n_ecp_core() const
Return the total number of core electrons assocated with this (ECP) basisset.
Definition: basisset.cc:182
int shell_to_basis_function(int i) const
Definition: basisset.h:255
std::string print_detail_cfour() const
Definition: basisset.cc:462
CCTransform * trans
Definition: psimrcc/main.cc:80
int nao_
Number of atomic orbitals (Cartesian)
Definition: basisset.h:97
int * center_to_ecp_nshell_
How many ECP shells are there on each center?
Definition: basisset.h:145
int * ao_to_shell_
Which shell does a given Cartesian function belong to?
Definition: basisset.h:137
int * n_prim_per_shell_
The number of primitives (and exponents) in each shell.
Definition: basisset.h:125
void move_atom(int atom, const Vector3 &trans)
Definition: basisset.cc:1288
int * ecp_shell_center_
ECP Shell number to atomic center.
Definition: basisset.h:133
static std::pair< std::vector< std::string >, std::shared_ptr< BasisSet > > test_basis_set(int max_am)
Definition: basisset.cc:1110
static std::shared_ptr< BasisSet > zero_ao_basis_set()
Definition: basisset.cc:607
const std::string & key() const
Return the construction key and target information.
Definition: basisset.h:312
std::string name_
The name of this basis set (e.g. &quot;BASIS&quot;, &quot;RI BASIS&quot;)
Definition: basisset.h:70
const GaussianShell & shell(int si) const
Definition: basisset.cc:580
void compute_phi(double *phi_ao, double x, double y, double z)
Definition: basisset.cc:1296
int n_frozen_core(const std::string &depth="", SharedMolecule mol=nullptr)
Number of frozen core for molecule given freezing state, accounting for any ECP present.
Definition: basisset.cc:190
int n_ecp_core(const std::string &label) const
Return the number of core electrons associated with this (ECP) basisset, for the specified label...
Definition: basisset.h:288
int max_nprimitive() const
Definition: basisset.h:200
static std::string make_filename(const std::string &basisname)
Definition: basisset.cc:978
int shell_on_center(int c, int n) const
Return the overall shell number of the n&#39;th shell on the c&#39;th center.
Definition: basisset.h:351
int nshell_on_center(int i) const
Return the number of shells on a given center.
Definition: basisset.h:347
int nshell() const
Definition: basisset.h:204
int max_ecp_am_
The maximum ECP angular momentum.
Definition: basisset.h:115
bool puream_
Whether the basis set is uses spherical basis functions or not.
Definition: basisset.h:119
int * center_to_shell_
What&#39;s the first shell on each center?
Definition: basisset.h:143
static void initialize_singletons()
Definition: basisset.cc:155
int n_ecp_shells_
The number of ECP shells.
Definition: basisset.h:107
int max_am_
The maximum angular momentum.
Definition: basisset.h:113
GaussianShell * shells_
Array of gaussian shells.
Definition: basisset.h:77