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 "gshell.h"
33 
34 #include "psi4/pragma.h"
35 #include "psi4/libmints/typedefs.h"
36 #include "psi4/psi4-dec.h"
37 
38 #include <cstdio>
39 #include <string>
40 #include <vector>
41 #include <map>
42  PRAGMA_WARNING_PUSH
43  PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
44  #include <memory>
46 
47 namespace psi {
48 
49 
50 
51 class Molecule;
52 class GaussianShell;
53 
54 class BasisSetParser;
55 class SOBasisSet;
56 class IntegralFactory;
57 
58 
61 
66 class BasisSet
67 {
68 protected:
69  friend class BasisSetParser;
70 
72  std::string name_;
73 
74  // Key and target information from constructing
75  std::string key_;
76  std::string target_;
77 
82 
84  std::vector<int> sorted_ao_shell_list_;
85 
87  std::map<std::string, int> ncore_;
88 
90  std::shared_ptr<Molecule> molecule_;
91 
92  // Has static information been initialized?
93  static bool initialized_shared_;
94 
95  /*
96  * Scalars
97  */
99  int nao_;
101  int nbf_;
115  int max_am_;
121  bool puream_;
122 
123  /*
124  * Arrays
125  */
150 
152  double *uexponents_;
154  double *ucoefficients_;
158  double *uecpexponents_;
162  int *uecpns_;
166  double *xyz_;
167 
168 
169 
170 
171 public:
172  BasisSet();
173 
174  BasisSet(const std::string &basistype, SharedMolecule mol,
175  std::map<std::string, std::map<std::string, std::vector<ShellInfo> > > &shell_map,
176  std::map<std::string, std::map<std::string, std::vector<ShellInfo> > > &ecp_shell_map);
177 
183  static std::shared_ptr<BasisSet> build(std::shared_ptr<Molecule> molecule,
184  const std::vector<ShellInfo> &shells);
185 
187  static void initialize_singletons();
188 
192  int nprimitive() const { return nprimitive_; }
196  int n_ecp_primitive() const { return n_ecp_primitive_; }
202  int max_nprimitive() const { return max_nprimitive_; }
206  int nshell() const { return n_shells_; }
210  int n_ecp_shell() const { return n_ecp_shells_; }
214  int nao() const { return nao_; }
218  int nbf() const { return nbf_; }
222  bool has_ECP() const { return n_ecp_shells_ > 0; }
226  int max_am() const { return max_am_; }
230  int max_ecp_am() const { return max_ecp_am_; }
234  bool has_puream() const { return puream_; }
238  int max_function_per_shell() const { return (puream_) ? 2*max_am_+1 : (max_am_+1)*(max_am_+2)/2; }
242  std::shared_ptr<Molecule> molecule() const;
247  int shell_to_ao_function(int i) const { return shell_first_ao_[i]; }
252  int shell_to_center(int i) const { return shell_center_[i]; }
258 
260  int function_to_shell(int i) const { return function_to_shell_[i]; }
265  int function_to_center(int i) const { return function_center_[i]; }
266 
268  int ao_to_shell(int i) const { return ao_to_shell_[i]; }
269 
274  const GaussianShell& shell(int si) const;
275 
280  const GaussianShell& ecp_shell(int si) const;
281 
287  const GaussianShell& shell(int center, int si) const;
288 
290  int n_ecp_core(const std::string &label) const { return ncore_.count(label) ? ncore_.at(label) : 0; }
291 
293  int n_ecp_core() const;
294 
296  void set_n_ecp_core(const std::string &label, int n) { ncore_[std::string(label)] = n; }
297 
299  int n_frozen_core(const std::string& depth = "", SharedMolecule mol=nullptr);
300 
305  void print(std::string out) const;
306  void print() const { print("outfile"); }
308 
310  const std::string & name() const { return name_; }
311  void set_name(const std::string str) {name_ = str;}
312 
314  const std::string & key() const { return key_; }
315  void set_key(const std::string str) {key_ = str;}
316  const std::string & target() const { return target_; }
317  void set_target(const std::string str) {target_ = str;}
318 
327  void print_by_level(std::string out = "outfile", int print_level = 2) const;
331  void print_summary(std::string out = "outfile") const;
332 
336  void print_detail(std::string out) const;
337  void print_detail() const { print_detail("outfile"); }
338 
342  std::string print_detail_cfour() const;
343 
348  void refresh();
349 
351  int nshell_on_center(int i) const { return center_to_nshell_[i]; }
353  int n_ecp_shell_on_center(int i) const { return center_to_ecp_nshell_[i]; }
355  int shell_on_center(int c, int n) const { return center_to_shell_[c] + n; }
357  int ecp_shell_on_center(int c, int n) const { return center_to_ecp_shell_[c] + n; }
358 
359 
366  static std::shared_ptr<BasisSet> zero_ao_basis_set();
367 
374  static std::shared_ptr<SOBasisSet> zero_so_basis_set(const std::shared_ptr<IntegralFactory>& factory);
375 
383  static std::pair<std::vector<std::string>, std::shared_ptr<BasisSet> > test_basis_set(int max_am);
384 
389  static std::string make_filename(const std::string& basisname);
390 
392  static std::vector<Vector3> exp_ao[];
393 
395  int get_ao_sorted_shell(const int &i) { return sorted_ao_shell_list_[i]; }
397  std::vector<int> get_ao_sorted_list() { return sorted_ao_shell_list_; }
398 
399  // Translate a given atom by a given amount. Used for debugging/finite difference purposes. Does NOT modify the underlying molecule object.
400  void move_atom(int atom, const Vector3 &trans);
401  // Returns the values of the basis functions at a point
402  void compute_phi(double *phi_ao, double x, double y, double z);
403 };
404 
405 }
406 
407 #endif
int n_ecp_uprimitive_
The number of unique ECP primitives.
Definition: basisset.h:105
int * center_to_nshell_
How many shells are there on each center?
Definition: basisset.h:143
int n_uprimitive_
The number of unique primitives.
Definition: basisset.h:103
int nprimitive_
The number of primitives.
Definition: basisset.h:111
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:296
double * ucoefficients_
The flattened lists of unique contraction coefficients (normalized)
Definition: basisset.h:154
static std::vector< Vector3 > exp_ao[]
Global arrays of x, y, z exponents.
Definition: basisset.h:392
int ao_to_shell(int i) const
Definition: basisset.h:268
int * function_center_
Which center is a given function on?
Definition: basisset.h:141
int * center_to_ecp_shell_
What&#39;s the first ECP shell on each center?
Definition: basisset.h:149
int n_shells_
The number of shells.
Definition: basisset.h:107
double * uoriginal_coefficients_
The flattened lists of unique contraction coefficients (as provided by the user)
Definition: basisset.h:156
std::vector< int > sorted_ao_shell_list_
vector of shells numbers sorted in ascending AM order.
Definition: basisset.h:84
const std::string & target() const
Definition: basisset.h:316
double * xyz_
The flattened list of Cartesian coordinates for each atom.
Definition: basisset.h:166
std::map< std::string, int > ncore_
The number of core electrons for each atom type.
Definition: basisset.h:87
double * uerd_coefficients_
The flattened lists of ERD normalized contraction coefficients.
Definition: basisset.h:164
int n_ecp_shell_on_center(int i) const
Return the number of ECP shells on a given center.
Definition: basisset.h:353
const GaussianShell & ecp_shell(int si) const
Definition: basisset.cc:588
int nbf() const
Definition: basisset.h:218
void set_name(const std::string str)
Definition: basisset.h:311
static bool initialized_shared_
Definition: basisset.h:93
int max_nprimitive_
The maximum number of primitives in a shell.
Definition: basisset.h:119
void print_by_level(std::string out="outfile", int print_level=2) const
Definition: basisset.cc:244
bool has_ECP() const
Definition: basisset.h:222
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:397
int * function_to_shell_
Which shell does a given (Cartesian / spherical) function belong to?
Definition: basisset.h:137
int nbf_
Number of basis functions (either cartesian or spherical)
Definition: basisset.h:101
void set_key(const std::string str)
Definition: basisset.h:315
int n_ecp_primitive_
The number of ECP primitives.
Definition: basisset.h:113
int n_ecp_shell() const
Definition: basisset.h:210
int * shell_first_ao_
The first (Cartesian) atomic orbital in each shell.
Definition: basisset.h:129
GaussianShell * ecp_shells_
Array of ECP shells.
Definition: basisset.h:81
double * uecpcoefficients_
The flattened lists of unique ECP contraction coefficients (normalized)
Definition: basisset.h:160
void print_summary(std::string out="outfile") const
Definition: basisset.cc:256
int max_am() const
Definition: basisset.h:226
int max_ecp_am() const
Definition: basisset.h:230
std::string target_
Definition: basisset.h:76
int shell_to_ao_function(int i) const
Definition: basisset.h:247
int * uecpns_
The flattened list of r exponenets for ECP calculations.
Definition: basisset.h:162
friend class BasisSetParser
Definition: basisset.h:69
int nao() const
Definition: basisset.h:214
int nprimitive() const
Definition: basisset.h:192
void print() const
Definition: basisset.h:306
int * shell_first_basis_function_
The first (Cartesian / spherical) basis function in each shell.
Definition: basisset.h:131
const std::string & name() const
Returns the name of this basis set.
Definition: basisset.h:310
int * shell_center_
Shell number to atomic center.
Definition: basisset.h:133
std::shared_ptr< Molecule > molecule_
Molecule object.
Definition: basisset.h:90
int get_ao_sorted_shell(const int &i)
Returns the value of the sorted shell list.
Definition: basisset.h:395
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:252
double * uecpexponents_
The flattened lists of unique ECP exponents.
Definition: basisset.h:158
static std::shared_ptr< BasisSet > build(std::shared_ptr< Molecule > molecule, const std::vector< ShellInfo > &shells)
Definition: basisset.cc:139
std::shared_ptr< Molecule > molecule() const
Definition: basisset.cc:174
int function_to_shell(int i) const
Definition: basisset.h:260
int n_ecp_primitive() const
Definition: basisset.h:196
int max_function_per_shell() const
Definition: basisset.h:238
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:357
double * uexponents_
The flattened lists of unique exponents.
Definition: basisset.h:152
static std::shared_ptr< SOBasisSet > zero_so_basis_set(const std::shared_ptr< IntegralFactory > &factory)
bool has_puream() const
Definition: basisset.h:234
void print_detail() const
Definition: basisset.h:337
std::shared_ptr< Molecule > SharedMolecule
Definition: typedefs.h:55
std::string key_
Definition: basisset.h:75
Gaussian orbital shell.
Definition: gshell.h:189
int function_to_center(int i) const
Definition: basisset.h:265
BasisSet()
Definition: basisset.cc:85
void refresh()
Definition: basisset.cc:907
Basis set container class.
Definition: basisset.h:66
int n_ecp_core() const
Return the total number of core electrons assocated with this (ECP) basisset.
Definition: basisset.cc:179
int shell_to_basis_function(int i) const
Definition: basisset.h:257
std::string print_detail_cfour() const
Definition: basisset.cc:459
CCTransform * trans
Definition: psimrcc/main.cc:80
int nao_
Number of atomic orbitals (Cartesian)
Definition: basisset.h:99
int * center_to_ecp_nshell_
How many ECP shells are there on each center?
Definition: basisset.h:147
int * ao_to_shell_
Which shell does a given Cartesian function belong to?
Definition: basisset.h:139
int * n_prim_per_shell_
The number of primitives (and exponents) in each shell.
Definition: basisset.h:127
void move_atom(int atom, const Vector3 &trans)
Definition: basisset.cc:1174
int * ecp_shell_center_
ECP Shell number to atomic center.
Definition: basisset.h:135
static std::pair< std::vector< std::string >, std::shared_ptr< BasisSet > > test_basis_set(int max_am)
Definition: basisset.cc:996
static std::shared_ptr< BasisSet > zero_ao_basis_set()
Definition: basisset.cc:604
const std::string & key() const
Return the construction key and target information.
Definition: basisset.h:314
std::string name_
The name of this basis set (e.g. &quot;BASIS&quot;, &quot;RI BASIS&quot;)
Definition: basisset.h:72
void set_target(const std::string str)
Definition: basisset.h:317
const GaussianShell & shell(int si) const
Definition: basisset.cc:577
void compute_phi(double *phi_ao, double x, double y, double z)
Definition: basisset.cc:1182
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:187
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:290
int max_nprimitive() const
Definition: basisset.h:202
static std::string make_filename(const std::string &basisname)
Definition: basisset.cc:864
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:355
int nshell_on_center(int i) const
Return the number of shells on a given center.
Definition: basisset.h:351
int nshell() const
Definition: basisset.h:206
int max_ecp_am_
The maximum ECP angular momentum.
Definition: basisset.h:117
bool puream_
Whether the basis set is uses spherical basis functions or not.
Definition: basisset.h:121
int * center_to_shell_
What&#39;s the first shell on each center?
Definition: basisset.h:145
static void initialize_singletons()
Definition: basisset.cc:152
int n_ecp_shells_
The number of ECP shells.
Definition: basisset.h:109
int max_am_
The maximum angular momentum.
Definition: basisset.h:115
GaussianShell * shells_
Array of gaussian shells.
Definition: basisset.h:79