MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
gaussbas.h
1//
2// gaussbas.h
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef _chemistry_qc_basis_gaussbas_h
29#define _chemistry_qc_basis_gaussbas_h
30
31#include <vector>
32#include <iostream>
33
34#include <util/state/state.h>
35#include <util/keyval/keyval.h>
36#include <math/scmat/matrix.h>
37#include <math/scmat/vector3.h>
38#include <chemistry/molecule/molecule.h>
39#include <chemistry/qc/basis/gaussshell.h>
40#include <math/mmisc/grid.h>
41
42#ifdef MPQC_NEW_FEATURES
43#include "mpqc/range.hpp"
44#endif
45
46namespace sc {
47
48class BasisFileSet;
49class Integral;
50
51class CartesianIter;
52class SphericalTransformIter;
53
56
141class GaussianBasisSet: virtual public SavableState
142#ifdef MPQC_NEW_FEATURES
143, virtual public DescribedXMLWritable
144#endif
145{
146 public:
147
149 class Shell : public GaussianShell {
150 public:
151 Shell(const GaussianBasisSet* basis, unsigned int center, const GaussianShell& shell);
152 Shell(const Shell& other) :
153 GaussianShell(static_cast<const GaussianShell&>(other)),
154 basis_(other.basis_),
155 center_(other.center_) {}
156 ~Shell() {}
157
158 Shell& operator=(const Shell& other) {
159 static_cast<GaussianShell&>(*this) = static_cast<const GaussianShell&>(other);
160 basis_ = other.basis_;
161 center_ = other.center_;
162 return *this;
163 }
164
166 bool equiv(const Shell& s) const;
167
168 const GaussianBasisSet* basis() const { return basis_; }
169 unsigned int center() const { return center_; }
170
171#ifdef MPQC_NEW_FEATURES
172 virtual boost::property_tree::ptree& write_xml(boost::property_tree::ptree& parent, const XMLWriter& writer);
173#endif
174
175 private:
176 friend class GaussianBasisSet;
177
178 static ClassDesc class_desc_;
179
180 const GaussianBasisSet* basis_;
181 unsigned int center_;
182 };
183
184
185 private:
186 friend class UnionBasisSet;
187
189 // primary data
191 std::string name_; // non-empty if keyword "name" was provided
192 std::string label_; // same as name_ if name_ non-empty, else something else
193
194 protected: Ref<Molecule> molecule_;
195 private: std::vector<Shell> shells_;
196
197 // computes secondary data from the primary data
198 void init2(int skip_ghosts=0,bool include_q=0);
199
201 // secondary data (expensive or convenient to have precomputed)
203 std::vector<int> shell_to_function_;
204 std::vector<int> function_to_shell_;
205 std::vector<int> shell_to_primitive_;
206 std::vector<int> center_to_shell_;
207 std::vector<unsigned int> center_to_nshell_;
208 std::vector<unsigned int> center_to_nfunction_;
209 unsigned int nbasis_;
210 unsigned int nprim_;
211 bool has_pure_;
212 // old-school SCMatrix stuff, may go away
213 Ref<SCMatrixKit> matrixkit_;
214 Ref<SCMatrixKit> so_matrixkit_;
215 RefSCDimension basisdim_;
216
217 // Counts shells in this basis for this chemical element
218 int count_shells_(Ref<KeyVal>& keyval, const char* elemname, const char* sbasisname, BasisFileSet& bases,
219 int havepure, int pure, bool missing_ok);
220 // constructs shells on @c atom
221 void get_shells_(unsigned int atom, Ref<KeyVal>& keyval, const char* elemname, const char* sbasisname, BasisFileSet& bases,
222 int havepure, int pure, bool missing_ok);
223 // Counts shells in an even-tempered primitive basis
224 int count_even_temp_shells_(Ref<KeyVal>& keyval, const char* elemname, const char* sbasisname,
225 int havepure, int pure);
226 // Constructs an even-tempered primitive basis
227 void get_even_temp_shells_(unsigned int atom, Ref<KeyVal>& keyval, const char* elemname, const char* sbasisname,
228 int havepure, int pure);
229 // Constructs basis set specified as an array of shells
230 void recursively_get_shell(unsigned int atom,Ref<KeyVal>&,
231 const char*,const char*,BasisFileSet&,
232 int,int,int,bool missing_ok);
233
234 // finishes up the KeyVal constructor
235 void init(Ref<Molecule>&,Ref<KeyVal>&,
236 BasisFileSet&,
237 int have_userkeyval,
238 int pure);
239
245 void validate_point_group() const;
246
247 protected:
248 /* This CTOR leaves it up to the derived class to completely
249 initialize the basis set. */
250 GaussianBasisSet();
251 virtual void set_matrixkit(const Ref<SCMatrixKit>&);
252
254 void init(std::string name,
255 std::string label,
256 const Ref<Molecule> &molecule,
257 const std::vector<Shell>& shell);
258
259 public:
261 class ValueData {
262 protected:
263 CartesianIter **civec_;
264 SphericalTransformIter **sivec_;
265 int maxam_;
266 public:
268 ~ValueData();
269 CartesianIter **civec() { return civec_; }
270 SphericalTransformIter **sivec() { return sivec_; }
271 };
272
275
437
447 const std::vector<GaussianShell>& shells,
448 const std::vector<unsigned int>& shell_to_center,
449 std::string name = std::string(),
450 std::string label = std::string());
451
453
458
460
463
468
469#ifdef MPQC_NEW_FEATURES
470 virtual boost::property_tree::ptree& write_xml(boost::property_tree::ptree& parent, const XMLWriter& writer);
471#endif
472
474
475 virtual ~GaussianBasisSet();
476
479 GaussianBasisSet& operator=(const GaussianBasisSet& A);
480
482 const std::string& name() const { return name_; }
486 const std::string& label() const { if (!name_.empty()) return name_; else return label_; }
487
489 Ref<Molecule> molecule() const { return molecule_; }
491 Ref<SCMatrixKit> matrixkit() { return matrixkit_; }
493 Ref<SCMatrixKit> so_matrixkit() { return so_matrixkit_; }
495 RefSCDimension basisdim() { return basisdim_; }
496
498 unsigned int ncenter() const;
500 unsigned int nshell() const { return shells_.size(); }
502 int nshell_on_center(int icenter) const;
506 int shell_on_center(int icenter, int shell) const;
507
509
512 int shell_to_center(int ishell) const { return shells_[ishell].center(); }
514 unsigned int nbasis() const { return nbasis_; }
516 unsigned int nbasis_on_center(int icenter) const;
518 unsigned int nprimitive() const { return nprim_; }
520 bool has_pure() const { return has_pure_; }
521
523 unsigned int max_nfunction_in_shell() const;
526 unsigned int max_ncartesian_in_shell(int aminc=0) const;
528 unsigned int max_nprimitive_in_shell() const;
530 unsigned int max_angular_momentum() const;
532 unsigned int max_ncontraction() const;
535 unsigned int max_am_for_contraction(int con) const;
537 unsigned int max_cartesian() const;
538
540 int shell_to_function(int i) const { return shell_to_function_[i]; }
542 int function_to_shell(int i) const;
543
544#ifdef MPQC_NEW_FEATURES
546 mpqc::range range(int s) const;
547#endif
548
550 const Shell& operator()(int i) const { return shells_[i]; }
552 Shell& operator()(int i) { return shells_[i]; }
554 const Shell& operator[](int i) const { return shells_[i]; }
556 Shell& operator[](int i) { return shells_[i]; }
558 const Shell& shell(int i) const { return shells_[i]; }
560 Shell& shell(int i) { return shells_[i]; }
561
563 const Shell& operator()(int icenter,int ishell) const;
565 Shell& operator()(int icenter,int ishell);
567 const Shell& shell(int i,int j) const { return operator()(i,j); }
569 Shell& shell(int i,int j) { return operator()(i,j); }
570
572 int find(int C, const GaussianShell& S) const;
573
576 double r(int icenter,int xyz) const;
577
580 int values(const SCVector3& r, ValueData *, double* basis_values) const;
586 double*g_values,double* basis_values=0) const;
591 int hessian_values(const SCVector3& r, ValueData *, double *h_values,
592 double*g_values=0,double* basis_values=0) const;
595 int shell_values(const SCVector3& r, int sh,
596 ValueData *, double* basis_values) const;
600 int grad_shell_values(const SCVector3& r, int sh,
601 ValueData *,
602 double*g_values, double* basis_values=0) const;
606 int hessian_shell_values(const SCVector3& r, int sh,
607 ValueData *, double *h_values,
608 double*g_values=0,double* basis_values=0) const;
609
612
614 void print_brief(std::ostream& =ExEnv::out0()) const;
616 virtual void print(std::ostream& =ExEnv::out0()) const;
617};
618
622
624int
626 const GaussianShell& A);
627
631
634std::vector<unsigned int> operator<<(const GaussianBasisSet& B, const GaussianBasisSet& A);
636std::vector<int> map(const GaussianBasisSet& B, const GaussianBasisSet& A);
637
641 public:
645
646 const Ref<GaussianBasisSet>& source() const { return source_; }
647 const Ref<GaussianBasisSet>& target() const { return target_; }
648
650 int map_shell(int s) const;
652 int map_function(int f) const;
656 int nfblock() const;
658 int fblock_to_function(int b) const;
660 int fblock_size(int b) const;
661
662 private:
663 Ref<GaussianBasisSet> source_;
664 Ref<GaussianBasisSet> target_;
665
667 // maps
670 std::vector<int> smap_;
672 std::vector<int> fmap_;
674 std::vector<int> fblock_to_function_;
676 std::vector<int> fblock_size_;
677
678};
679
681 private:
682 struct BasisFunctionMap : public DimensionMap {
683 std::vector<int> map;
684 int operator()(int o) const { return map[o]; }
685 std::size_t ndim() const { return map.size(); }
686 };
688 Ref<Integral> integral_;
689
690 protected:
691 BasisFunctionMap bfmap_;
692
693 void label(char* buffer);
694 Ref<Molecule> get_molecule() { return basis_->molecule(); }
695 void calculate_values(const std::vector<SCVector3>& Points, std::vector<double>& Values);
696 const DimensionMap& dimension_map() const { return bfmap_; }
697 std::size_t ndim() const { return bfmap_.ndim(); }
699
700 static Ref<KeyVal> process_keyval_for_base_class(const Ref<KeyVal>& kv);
701
702 public:
703
704 WriteBasisGrid(const Ref<KeyVal>& keyval);
706 const Ref<GaussianBasisSet>& basis,
707 const Ref<Grid>& grid,
708 std::string gridformat,
709 std::string gridfile
710 );
711
712 virtual ~WriteBasisGrid();
713
714#ifdef MPQC_NEW_FEATURES
715 virtual boost::property_tree::ptree& write_xml(boost::property_tree::ptree& parent, const XMLWriter& writer);
716#endif
717
718};
719
720
722// end of addtogroup ChemistryBasisGaussian
723
724} // end namespace sc
725
726
727#endif
728
729// Local Variables:
730// mode: c++
731// c-file-style: "CLJ"
732// End:
CartesianIter gives the ordering of the Cartesian functions within a shell for the particular integra...
Definition cartiter.h:35
This class is used to contain information about classes.
Definition class.h:147
Definition xml.h:50
static std::ostream & out0()
Return an ostream that writes from node 0.
A heavy-duty map from one GaussianBasisSet to another GaussianBasisSet.
Definition gaussbas.h:640
int fblock_to_function(int b) const
returns the Source index of the first basis function in fblock b
GaussianBasisSetMap(const Ref< GaussianBasisSet > &Source, const Ref< GaussianBasisSet > &Target)
will throw if Source is not contained in Target
int map_shell(int s) const
maps shell s in Source to its location in Target
int fblock_size(int b) const
the number of basis functions in fblock b
int nfblock() const
it is useful to organize sets of basis functions that are adjacent in Source and in Target.
int map_function(int f) const
maps function f in Source to its location in Target
Shell is a GaussianShell that is part of GaussianBasisSet, i.e. has a center on which it's centered.
Definition gaussbas.h:149
bool equiv(const Shell &s) const
Returns true if this and the argument are equivalent.
This holds scratch data needed to compute basis function values.
Definition gaussbas.h:261
The GaussianBasisSet class is used describe a basis set composed of atomic gaussian orbitals.
Definition gaussbas.h:145
Shell & operator()(int i)
Return a reference to Shell number i.
Definition gaussbas.h:552
const std::string & label() const
Return the label of the basis set.
Definition gaussbas.h:486
int hessian_values(const SCVector3 &r, ValueData *, double *h_values, double *g_values=0, double *basis_values=0) const
Like values(...), but computes first and second derivatives of the basis function values,...
const Shell & shell(int i) const
Return a reference to Shell number i.
Definition gaussbas.h:558
const Shell & operator()(int i) const
Return a reference to Shell number i.
Definition gaussbas.h:550
virtual void print(std::ostream &=ExEnv::out0()) const
Print a detailed description of the basis set.
GaussianBasisSet(const Ref< Molecule > &molecule, const std::vector< GaussianShell > &shells, const std::vector< unsigned int > &shell_to_center, std::string name=std::string(), std::string label=std::string())
Constructs GaussianBasisSet from a Molecule and a vector of GaussianShells.
int nshell_on_center(int icenter) const
Return the number of shells on the given center.
RefSCDimension basisdim()
Returns the SCDimension object for the dimension.
Definition gaussbas.h:495
bool has_pure() const
Return true if basis contains solid harmonics Gaussians.
Definition gaussbas.h:520
unsigned int max_nprimitive_in_shell() const
Return the maximum number of primitive Gaussian that any shell has.
int function_to_shell(int i) const
Return the shell to which the given function belongs.
unsigned int nprimitive() const
Return the number of primitive Gaussians (sum of number of primitives for each Shell)
Definition gaussbas.h:518
const Shell & operator()(int icenter, int ishell) const
Return a reference to Shell number ishell on center icenter.
unsigned int nshell() const
Return the number of shells.
Definition gaussbas.h:500
int shell_to_function(int i) const
Return the number of the first function in the given shell.
Definition gaussbas.h:540
unsigned int max_cartesian() const
Return the maximum number of Cartesian functions in any shell.
unsigned int nbasis() const
Return the number of basis functions.
Definition gaussbas.h:514
Ref< SCMatrixKit > matrixkit()
Returns the SCMatrixKit that is to be used for AO bases.
Definition gaussbas.h:491
unsigned int nbasis_on_center(int icenter) const
Return the number of basis functions on the given center.
int equiv(const Ref< GaussianBasisSet > &b)
Returns true if this and the argument are equivalent.
int grad_shell_values(const SCVector3 &r, int sh, ValueData *, double *g_values, double *basis_values=0) const
Like values(...), but computes gradients of the shell function values, too.
int values(const SCVector3 &r, ValueData *, double *basis_values) const
Compute the values for this basis set at position r.
void init(std::string name, std::string label, const Ref< Molecule > &molecule, const std::vector< Shell > &shell)
Initializes everything.
void save_data_state(StateOut &so)
saves this to so
Shell & operator[](int i)
Return a reference to Shell number i.
Definition gaussbas.h:556
int find(int C, const GaussianShell &S) const
Return the absolute index of shell S located at center C in this basis. If the shell is not found,...
int hessian_shell_values(const SCVector3 &r, int sh, ValueData *, double *h_values, double *g_values=0, double *basis_values=0) const
Like values(...), but computes first and second derivatives of the shell function values,...
double r(int icenter, int xyz) const
The location of center icenter.
void print_brief(std::ostream &=ExEnv::out0()) const
Print a brief description of the basis set.
Shell & shell(int i, int j)
Return a reference to Shell number j on center i.
Definition gaussbas.h:569
Shell & operator()(int icenter, int ishell)
Return a reference to Shell number ishell on center icenter.
int shell_on_center(int icenter, int shell) const
Return the overall shell number, given a center and the shell number on that center.
Ref< GaussianBasisSet > operator+(const Ref< GaussianBasisSet > &B)
Uses UnionBasisSet to construct the sum of this and B.
unsigned int max_ncontraction() const
Return the maximum number of Gaussians in a contraction in any shell.
unsigned int max_ncartesian_in_shell(int aminc=0) const
Return the maximum number of Cartesian functions that any shell has.
unsigned int max_nfunction_in_shell() const
Return the maximum number of functions that any shell has.
Ref< Molecule > molecule() const
Return the Molecule object.
Definition gaussbas.h:489
int shell_values(const SCVector3 &r, int sh, ValueData *, double *basis_values) const
Compute the values for the given shell functions at position r.
static Ref< GaussianBasisSet > unit()
This will produce a GaussianBasisSet object composed of a a single "unit" basis function,...
GaussianBasisSet(StateIn &si)
restores this from si
int grad_values(const SCVector3 &r, ValueData *, double *g_values, double *basis_values=0) const
Like values(...), but computes gradients of the basis function values, too.
unsigned int max_angular_momentum() const
Return the highest angular momentum in any shell.
Ref< SCMatrixKit > so_matrixkit()
Returns the SCMatrixKit that is to be used for SO bases.
Definition gaussbas.h:493
const std::string & name() const
Return the name of the basis set (is nonnull only if keyword "name" was provided)
Definition gaussbas.h:482
GaussianBasisSet(const Ref< KeyVal > &)
The KeyVal constructor.
const Shell & shell(int i, int j) const
Return a reference to Shell number j on center i.
Definition gaussbas.h:567
int shell_to_center(int ishell) const
Return the center on which the given shell is located.
Definition gaussbas.h:512
Shell & shell(int i)
Return a reference to Shell number i.
Definition gaussbas.h:560
unsigned int max_am_for_contraction(int con) const
Return the maximum angular momentum found in the given contraction number for any shell.
const Shell & operator[](int i) const
Return a reference to Shell number i.
Definition gaussbas.h:554
unsigned int ncenter() const
Return the number of centers.
A shell of Gaussian functions.
Definition gaussshell.h:57
The base class for all reference counted objects.
Definition ref.h:192
The RefSCDimension class is a smart pointer to an SCDimension specialization.
Definition dim.h:152
A template class that maintains references counts.
Definition ref.h:361
a 3-element version of SCVector
Definition vector3.h:44
Base class for objects that can save/restore state.
Definition state.h:45
This iterates through the components of a SphericalTransform.
Definition transform.h:138
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
Serializes fundamental and user-defined types.
Definition stateout.h:71
Definition gaussbas.h:680
void label(char *buffer)
A label that identifies the scalar function evaluated at the grid points, is written to the buffer ar...
const DimensionMap & dimension_map() const
dimension map
Definition gaussbas.h:696
void calculate_values(const std::vector< SCVector3 > &Points, std::vector< double > &Values)
Returns the value of the vector function at the given coordinate.
Ref< Molecule > get_molecule()
Returns the molecule around which the grid values are calculated.
Definition gaussbas.h:694
std::size_t ndim() const
number of dimensions of the vector
Definition gaussbas.h:697
void initialize()
Prepares some pre-calculated values before the repetitive grid calculations are perfomed.
WriteVectorGrid provides an interface for writing the value of a vector function evaluated at a given...
Definition grid.h:145
Definition xmlwriter.h:223
int ishell_on_center(int icenter, const Ref< GaussianBasisSet > &bs, const GaussianShell &A)
Find A in bs on center icenter and return its index.
std::vector< int > map(const GaussianBasisSet &B, const GaussianBasisSet &A)
same as operator<<, except A does not have to be contained in B, map[a] = -1 if function a is not in ...
Ref< GaussianBasisSet > operator+(const Ref< GaussianBasisSet > &A, const Ref< GaussianBasisSet > &B)
Nonmember operator+ is more convenient to use than the member operator+.
std::vector< unsigned int > operator<<(const GaussianBasisSet &B, const GaussianBasisSet &A)
computes a map from basis functions in A to the equivalent basis functions in B.
SpinCase1 other(SpinCase1 S)
given 1-spin return the other 1-spin
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
Definition range.hpp:25

Generated at Wed Sep 25 2024 02:45:29 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.