MPQC  3.0.0-alpha
gaussshell.h
1 //
2 // gaussshell.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_gaussshell_h
29 #define _chemistry_qc_basis_gaussshell_h
30 
31 #include <iostream>
32 #include <util/state/state.h>
33 #include <math/scmat/vector3.h>
34 #include <util/keyval/keyval.h>
35 #ifdef MPQC_NEW_FEATURES
36 # include <util/misc/xml.h>
37 #endif
38 
39 namespace sc {
40 
41 class CartesianIter;
42 class SphericalTransformIter;
43 class Integral;
44 
47 
52 #ifdef MPQC_NEW_FEATURES
53  : public DescribedXMLWritable
54 #else // MPQC_NEW_FEATURES
55  : public DescribedClass
56 #endif // MPQC_NEW_FEATURES
57 {
58  public:
59  enum PrimitiveType { Normalized, Unnormalized };
60  enum GaussianType { Cartesian, Pure };
63  static double epsilon() { return 1.0e-13; }
64  private:
65  // primary data
66  std::vector<unsigned int> l;
67  std::vector<bool> puream;
68  std::vector<double> exp;
69  std::vector<double> coef_blk;
70 
71  // computes secondary data; may also chomp coefs and exponents using epsilon(), hence may modify exp and coef_blk
72  void init_computed_data();
73  static void chomp(std::vector<double>& exp, std::vector<double>& coef_blk,
74  unsigned int ncontr, double epsilon = GaussianShell::epsilon());
75 
76  // secondary data:
77  std::vector<double*> coef;
78  int nfunc;
79  int min_am_;
80  int max_am_;
81  int ncart_;
82  int has_pure_;
83  int has_cartesian_;
84  std::vector<int> contr_to_func_;
85  std::vector<int> func_to_contr_;
86 
87  double shell_normalization(int);
88  void convert_coef();
89  void normalize_shell();
90  PrimitiveType keyval_init(const Ref<KeyVal>&,int,int);
91  int test_monobound(double &r, double &bound) const;
92 
93  friend void ToStateOut(const GaussianShell &s, StateOut &so, int &count);
94  friend void FromStateIn(GaussianShell &s, StateIn &si, int &count);
95 
96  public:
97 
98  // Default constructor needed to work with sc::SavableState
99  GaussianShell(){}
100 
101  static const char* amtypes;
102  static const char* AMTYPES;
103 
117  GaussianShell(const std::vector<unsigned int>& am,
118  const std::vector<bool>& puream,
119  const std::vector<double>& exps,
120  const std::vector<double>& contr_coefs,
121  PrimitiveType pt = GaussianShell::Normalized,
122  bool normalize_shell = true);
123 
132  GaussianShell(const Ref<KeyVal>& kv, int pure=-1);
134  GaussianShell(const GaussianShell& other);
135 
157  DEPRECATED GaussianShell(
158  int ncn,
159  int nprm,
160  double* e,
161  int* am,
162  int* pure,
163  double** c,
164  PrimitiveType pt = GaussianShell::Normalized,
165  bool do_normalize_shell = true);
170  DEPRECATED GaussianShell(
171  int ncn,
172  int nprm,
173  double* e,
174  int* am,
175  GaussianType pure,
176  double** c,
177  PrimitiveType pt = GaussianShell::Normalized);
178 
183  static GaussianShell unit();
184 
185  ~GaussianShell();
187  unsigned int nprimitive() const { return exp.size(); }
189  unsigned int ncontraction() const { return l.size(); }
191  unsigned int nfunction() const { return nfunc; }
193  int max_angular_momentum() const { return max_am_; }
195  int min_angular_momentum() const { return min_am_; }
197  int max_cartesian() const;
199  const std::vector<unsigned int>& am() const { return l; }
201  unsigned int am(int con) const { return l[con]; }
203  unsigned int max_am() const { return max_am_; }
205  unsigned int min_am() const { return min_am_; }
207  char amchar(int con) const { return amtypes[l[con]]; }
209  unsigned int nfunction(int con) const;
211  unsigned int ncartesian() const { return ncart_; }
214  unsigned int ncartesian_with_aminc(int aminc) const;
216  unsigned int ncartesian(int con) const { return ((l[con]+2)*(l[con]+1))>>1; }
218  bool is_cartesian(int con) const { return !puream[con]; }
220  bool has_cartesian() const { return has_cartesian_; }
222  bool is_pure(int con) const { return puream[con]; }
224  const std::vector<bool>& is_pure() const { return puream; }
226  bool has_pure() const { return has_pure_; }
228  int contraction_to_function(int c) const { return contr_to_func_[c]; }
230  int function_to_contraction(int f) const { return func_to_contr_[f]; }
232  double coefficient_unnorm(int con,int prim) const {return coef[con][prim];}
234  double coefficient_norm(int con,int prim) const;
236  const std::vector<double>& coefficient_unnorm_block() const { return coef_blk; }
238  double exponent(int iprim) const { return exp[iprim]; }
240  const std::vector<double>& exponents() const { return this->exp; }
241 
245  const SCVector3& r, double* basis_values);
249  const SCVector3& R,
250  double* g_values,
251  double* basis_values=0) const;
255  const SCVector3& R,
256  double* h_values, double* g_values=0,
257  double* basis_values=0) const;
258 
262  double relative_overlap(const Ref<Integral>&,
263  int con, int func1, int func2) const;
268  double relative_overlap(int con,
269  int a1, int b1, int c1,
270  int a2, int b2, int c2) const;
271 
273  bool equiv(const GaussianShell& s) const;
274 
275 
278  double extent(double threshold) const;
279 
283  double monobound(double r) const;
284 
285  void print(std::ostream& =ExEnv::out0()) const;
286 
287 #if MPQC_NEW_FEATURES
288  virtual boost::property_tree::ptree& write_xml(
289  boost::property_tree::ptree& parent, const XMLWriter& writer
290  );
291 #endif
292 };
293 
301  template <typename Filter>
303  Filter f) {
304 
305  std::vector<unsigned int> am;
306  std::vector<bool> pure;
307 
308  for(unsigned int c=0; c<shell.ncontraction(); ++c) {
309  if (f(shell, c)) {
310  am.push_back(shell.am(c));
311  pure.push_back(shell.is_pure(c));
312  }
313  }
314 
315  // filter the coefficients also
316  const size_t nprim = shell.nprimitive();
317  std::vector<double> coefs(am.size() * shell.nprimitive());
318  for(size_t c=0, cp=0; c<shell.ncontraction(); ++c) {
319  if (f(shell, c)) {
320  std::copy(shell.coefficient_unnorm_block().begin() + c*nprim,
321  shell.coefficient_unnorm_block().begin() + (c+1)*nprim,
322  coefs.begin() + cp);
323  cp += nprim;
324  }
325  }
326 
327  return GaussianShell(am, pure, shell.exponents(), coefs, GaussianShell::Unnormalized);
328  }
329 
331 void ToStateOut(const GaussianShell &s, StateOut &so, int &count);
332 
334 void FromStateIn(GaussianShell &s, StateIn &si, int &count);
335 
337 // end of addtogroup ChemistryBasisGaussian
338 
339 } // namespace sc
340 
341 #endif
342 
343 // Local Variables:
344 // mode: c++
345 // c-file-style: "CLJ"
346 // End:
sc::GaussianShell::am
unsigned int am(int con) const
The angular momentum of the given contraction.
Definition: gaussshell.h:201
sc::filter
GaussianShell filter(const GaussianShell &shell, Filter f)
constructs a new GaussianShell from shell by applying Filter filter
Definition: gaussshell.h:302
sc::GaussianShell::ncartesian
unsigned int ncartesian(int con) const
The number of Cartesian functions for the given contraction.
Definition: gaussshell.h:216
sc::ToStateOut
void ToStateOut(const Atom &a, StateOut &so, int &count)
writes Atom to sc::StateOut
sc::GaussianShell::nprimitive
unsigned int nprimitive() const
The number of primitive Gaussian shells.
Definition: gaussshell.h:187
sc::GaussianShell::is_pure
const std::vector< bool > & is_pure() const
Vector of booleans that indicate whether each contraction is solid harmonics.
Definition: gaussshell.h:224
sc::GaussianShell::monobound
double monobound(double r) const
Returns a bound for the basis function.
sc::CartesianIter
CartesianIter gives the ordering of the Cartesian functions within a shell for the particular integra...
Definition: cartiter.h:35
sc::GaussianShell::FromStateIn
friend void FromStateIn(GaussianShell &s, StateIn &si, int &count)
reads GaussianShell from sc::StateIn
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::GaussianShell::amchar
char amchar(int con) const
The character symbol for the angular momentum of the given contraction.
Definition: gaussshell.h:207
sc::GaussianShell::is_pure
bool is_pure(int con) const
Returns true if contraction con is solid harmonics.
Definition: gaussshell.h:222
sc::GaussianShell::equiv
bool equiv(const GaussianShell &s) const
Returns true if this and the argument are equivalent.
sc::GaussianShell::coefficient_unnorm
double coefficient_unnorm(int con, int prim) const
Returns the contraction coef for unnormalized primitives.
Definition: gaussshell.h:232
sc::GaussianShell::ncartesian
unsigned int ncartesian() const
The total number of functions if this shell was Cartesian.
Definition: gaussshell.h:211
sc::GaussianShell::epsilon
static double epsilon()
Definition: gaussshell.h:63
sc::SphericalTransformIter
This iterates through the components of a SphericalTransform.
Definition: transform.h:136
sc::StateIn
Definition: statein.h:79
sc::GaussianShell::min_am
unsigned int min_am() const
The minimum angular momentum of any contraction.
Definition: gaussshell.h:205
sc::DescribedXMLWritable
Definition: xml.h:50
sc::GaussianShell::extent
double extent(double threshold) const
Returns a radius.
sc::GaussianShell::ToStateOut
friend void ToStateOut(const GaussianShell &s, StateOut &so, int &count)
writes GaussianShell to sc::StateOut
sc::GaussianShell::contraction_to_function
int contraction_to_function(int c) const
Returns the number of the first function in the given contraction.
Definition: gaussshell.h:228
sc::GaussianShell::hessian_values
int hessian_values(CartesianIter **, SphericalTransformIter **, const SCVector3 &R, 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,...
sc::other
SpinCase1 other(SpinCase1 S)
given 1-spin return the other 1-spin
sc::GaussianShell::ncontraction
unsigned int ncontraction() const
The number of contractions formed from the primitives.
Definition: gaussshell.h:189
sc::StateOut
Definition: stateout.h:71
sc::GaussianShell::has_cartesian
bool has_cartesian() const
Returns nonzero if any contraction is Cartesian.
Definition: gaussshell.h:220
sc::XMLWriter
Definition: xmlwriter.h:215
sc::GaussianShell::am
const std::vector< unsigned int > & am() const
The angular momenta of contractions.
Definition: gaussshell.h:199
sc::GaussianShell::relative_overlap
double relative_overlap(const Ref< Integral > &, int con, int func1, int func2) const
Returns the intra-generalized-contraction overlap matrix element <con func1|con func2> within an arbi...
sc::GaussianShell::function_to_contraction
int function_to_contraction(int f) const
Returns the contraction to which this function belongs.
Definition: gaussshell.h:230
sc::GaussianShell::values
int values(CartesianIter **, SphericalTransformIter **, const SCVector3 &r, double *basis_values)
Compute the values for this shell at position r.
sc::GaussianShell::max_am
unsigned int max_am() const
The maximum angular momentum of any contraction.
Definition: gaussshell.h:203
sc::GaussianShell::grad_values
int grad_values(CartesianIter **, SphericalTransformIter **, const SCVector3 &R, double *g_values, double *basis_values=0) const
Like values(...), but computes gradients of the basis function values, too.
sc::GaussianShell::nfunction
unsigned int nfunction() const
The number of basis functions.
Definition: gaussshell.h:191
sc::GaussianShell::min_angular_momentum
int min_angular_momentum() const
The minimum angular momentum in the shell.
Definition: gaussshell.h:195
sc::DescribedClass
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:233
sc::GaussianShell::exponents
const std::vector< double > & exponents() const
Returns the exponents.
Definition: gaussshell.h:240
sc::SCVector3
a 3-element version of SCVector
Definition: vector3.h:43
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::GaussianShell::coefficient_norm
double coefficient_norm(int con, int prim) const
Returns the contraction coef for normalized primitives.
sc::GaussianShell::unit
static GaussianShell unit()
sc::GaussianShell::is_cartesian
bool is_cartesian(int con) const
Returns nonzero if contraction con is Cartesian.
Definition: gaussshell.h:218
sc::GaussianShell::max_cartesian
int max_cartesian() const
The maximum number of Cartesian functions in any contraction.
sc::GaussianShell::max_angular_momentum
int max_angular_momentum() const
The maximum angular momentum in the shell.
Definition: gaussshell.h:193
sc::GaussianShell::has_pure
bool has_pure() const
Returns true if any contraction is solid harmonics.
Definition: gaussshell.h:226
sc::FromStateIn
void FromStateIn(Atom &a, StateIn &si, int &count)
reads Atom from sc::StateIn
sc::GaussianShell::exponent
double exponent(int iprim) const
Returns the exponents of the given primitive.
Definition: gaussshell.h:238
sc::GaussianShell::coefficient_unnorm_block
const std::vector< double > & coefficient_unnorm_block() const
returns coefficients for unnormalization primitives, in block form
Definition: gaussshell.h:236
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::GaussianShell::print
void print(std::ostream &=ExEnv::out0()) const
Print the object.
sc::GaussianShell
A shell of Gaussian functions.
Definition: gaussshell.h:51
sc::GaussianShell::ncartesian_with_aminc
unsigned int ncartesian_with_aminc(int aminc) const
The total number of Cartesian functions if this shift is applied to all of the angular momentums.

Generated at Sun Jan 26 2020 23:23:57 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.