MPQC  3.0.0-alpha
integrator.h
1 //
2 // integrator.h --- definition of the electron density integrator
3 //
4 // Copyright (C) 1997 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_dft_integrator_h
29 #define _chemistry_qc_dft_integrator_h
30 
31 #include <util/state/state.h>
32 #include <util/group/thread.h>
33 #include <chemistry/qc/dft/functional.h>
34 #include <chemistry/qc/basis/extent.h>
35 #include <chemistry/qc/wfn/density.h>
36 
37 namespace sc {
38 
40 class DenIntegrator: virtual public SavableState {
41  protected:
42  Ref<GaussianBasisSet> basis_;
43  Ref<Integral> integral_;
44 
45 //clj Ref<ShellExtent> extent_;
47 
48  Ref<ThreadGrp> threadgrp_;
49  Ref<MessageGrp> messagegrp_;
50 
51  double value_;
52  double accuracy_;
53 
54  double *alpha_vmat_;
55  double *beta_vmat_;
56 
57 //clj double *alpha_dmat_;
58 //clj double *beta_dmat_;
59 //clj double *dmat_bound_;
60 
61  int spin_polarized_;
62 
63  int need_density_; // specialization must set to 1 if it needs density_
64  double density_;
65  int nbasis_;
66  int nshell_;
67  int n_integration_center_;
68  int natom_;
69  int compute_potential_integrals_; // 1 if potential integrals are needed
70 
71  int linear_scaling_;
72  int use_dmat_bound_;
73 
74  void init_integration(const Ref<DenFunctional> &func,
75  const RefSymmSCMatrix& densa,
76  const RefSymmSCMatrix& densb,
77  double *nuclear_gradient);
78  void done_integration();
79 
80  void init_object();
81  public:
83  DenIntegrator();
85  DenIntegrator(const Ref<KeyVal> &);
88  ~DenIntegrator();
89  void save_data_state(StateOut &);
90 
92  const Ref<GaussianBasisSet> &basis() const { return basis_; }
95  const Ref<Integral> &integral() const { return integral_; }
97  double value() const { return value_; }
98 
100  void set_accuracy(double a);
101  double get_accuracy(void) {return accuracy_; }
107  const double *alpha_vmat() const { return alpha_vmat_; }
110  const double *beta_vmat() const { return beta_vmat_; }
111 
115  virtual void init(const Ref<Wavefunction> &);
118  virtual void init(const Ref<GaussianBasisSet> &,
119  const Ref<Integral> &);
121  virtual void done();
125  virtual void integrate(const Ref<DenFunctional> &,
126  const RefSymmSCMatrix& densa =0,
127  const RefSymmSCMatrix& densb =0,
128  double *nuclear_grad = 0) = 0;
129 
131  bool spin_polarized() const { return spin_polarized_; }
132 };
133 
134 
136 class IntegrationWeight: virtual public SavableState {
137 
138  protected:
139 
140  Ref<Molecule> mol_;
141  double tol_;
142 
143  void fd_w(int icenter, SCVector3 &point, double *fd_grad_w);
144 
145  public:
150  void save_data_state(StateOut &);
151 
152  void test(int icenter, SCVector3 &point);
153  void test();
154 
156  virtual void init(const Ref<Molecule> &, double tolerance);
158  virtual void done();
163  virtual double w(int center, SCVector3 &point, double *grad_w = 0) = 0;
164 };
165 
166 
169 
170  int n_integration_centers;
171  SCVector3 *centers;
172  double *atomic_radius;
173 
174  double **a_mat;
175  double **oorab;
176 
177  void compute_grad_p(int gc, int ic, int wc, SCVector3&r, double p,
178  SCVector3&g);
179  void compute_grad_nu(int gc, int bc, SCVector3 &point, SCVector3 &grad);
180 
181  double compute_t(int ic, int jc, SCVector3 &point);
182  double compute_p(int icenter, SCVector3&point);
183 
184  public:
189  void save_data_state(StateOut &);
190 
191  void init(const Ref<Molecule> &, double tolerance);
192  void done();
193  double w(int center, SCVector3 &point, double *grad_w = 0);
194 };
195 
197 class RadialIntegrator: virtual public SavableState {
198  protected:
199  int nr_;
200  public:
202  RadialIntegrator(const Ref<KeyVal> &);
204  ~RadialIntegrator();
205  void save_data_state(StateOut &);
206 
208  virtual int nr() const = 0;
212  virtual double radial_value(int ir, int nr, double radii,
213  double &multiplier) = 0;
214 };
215 
216 
218 class AngularIntegrator: virtual public SavableState{
219  protected:
220  public:
225  void save_data_state(StateOut &);
226 
227  virtual int nw(void) const = 0;
228  virtual int num_angular_points(double r_value, int ir) = 0;
229  virtual double angular_point_cartesian(int iangular, double r,
230  SCVector3 &integration_point) const = 0;
231 };
232 
233 
237  public:
246  void save_data_state(StateOut &);
247 
248  int nr() const;
249  double radial_value(int ir, int nr, double radii, double &multiplier);
250 
251  void print(std::ostream & =ExEnv::out0()) const;
252 };
253 
296  protected:
297  int npoint_;
298  double *x_, *y_, *z_, *w_;
299 
300  void init(int n);
301  public:
312  void save_data_state(StateOut &);
313 
314  int nw(void) const;
315  int num_angular_points(double r_value, int ir);
316  double angular_point_cartesian(int iangular, double r,
317  SCVector3 &integration_point) const;
318  void print(std::ostream & =ExEnv::out0()) const;
319 };
320 
324  protected:
325  int ntheta_;
326  int nphi_;
327  int Ktheta_;
328  int ntheta_r_;
329  int nphi_r_;
330  int Ktheta_r_;
331  double *theta_quad_weights_;
332  double *theta_quad_points_;
333 
334  int get_ntheta(void) const;
335  void set_ntheta(int i);
336  int get_nphi(void) const;
337  void set_nphi(int i);
338  int get_Ktheta(void) const;
339  void set_Ktheta(int i);
340  int get_ntheta_r(void) const;
341  void set_ntheta_r(int i);
342  int get_nphi_r(void) const;
343  void set_nphi_r(int i);
344  int get_Ktheta_r(void) const;
345  void set_Ktheta_r(int i);
346  int nw(void) const;
347  double sin_theta(SCVector3 &point) const;
348  void gauleg(double x1, double x2, int n);
349  public:
360  void save_data_state(StateOut &);
361 
362  int num_angular_points(double r_value, int ir);
363  double angular_point_cartesian(int iangular, double r,
364  SCVector3 &integration_point) const;
365  void print(std::ostream & =ExEnv::out0()) const;
366 };
367 
371  private:
372  int prune_grid_;
373  double **Alpha_coeffs_;
374  int gridtype_;
375  int **nr_points_, *xcoarse_l_;
376  int npruned_partitions_;
377  double *grid_accuracy_;
378  int dynamic_grids_;
379  int natomic_rows_;
380  int max_gridtype_;
381  protected:
382  Ref<IntegrationWeight> weight_;
383  Ref<RadialIntegrator> radial_user_;
384  Ref<AngularIntegrator> angular_user_;
385  Ref<AngularIntegrator> ***angular_grid_;
386  Ref<RadialIntegrator> **radial_grid_;
387  public:
432  void save_data_state(StateOut &);
433 
434  void integrate(const Ref<DenFunctional> &,
435  const RefSymmSCMatrix& densa =0,
436  const RefSymmSCMatrix& densb =0,
437  double *nuclear_gradient = 0);
438  void print(std::ostream & =ExEnv::out0()) const;
439  AngularIntegrator *get_angular_grid(double radius, double atomic_radius,
440  int charge, int deriv_order);
441  RadialIntegrator *get_radial_grid(int charge, int deriv_order);
442  void init_default_grids(void);
443  int angular_grid_offset(int i);
444  void set_grids(void);
445  int get_atomic_row(int i);
446  void init_parameters(void);
447  void init_parameters(const Ref<KeyVal>& keyval);
448  void init_pruning_coefficients(const Ref<KeyVal>& keyval);
449  void init_pruning_coefficients(void);
450  void init_alpha_coefficients(void);
451  int select_dynamic_grid(void);
452  Ref<IntegrationWeight> weight() { return weight_; }
453 };
454 
455 }
456 
457 #endif
458 
459 // Local Variables:
460 // mode: c++
461 // c-file-style: "CLJ"
462 // End:
sc::DenIntegrator
An abstract base class for integrating the electron density.
Definition: integrator.h:40
sc::BeckeIntegrationWeight::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::EulerMaclaurinRadialIntegrator::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::RefSymmSCMatrix
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition: matrix.h:265
sc::DenIntegrator::integrate
virtual void integrate(const Ref< DenFunctional > &, const RefSymmSCMatrix &densa=0, const RefSymmSCMatrix &densb=0, double *nuclear_grad=0)=0
Performs the integration of the given functional using the given alpha and beta density matrices.
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::IntegrationWeight::w
virtual double w(int center, SCVector3 &point, double *grad_w=0)=0
Computes the weight for a given center at a given point in space.
sc::DenIntegrator::set_accuracy
void set_accuracy(double a)
Sets the accuracy to use in the integration.
sc::DenIntegrator::init
virtual void init(const Ref< Wavefunction > &)
Calls the overloaded init routine with a GaussianBasisSet and a Integral object extracted from the gi...
sc::DenIntegrator::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::LebedevLaikovIntegrator::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::IntegrationWeight
An abstract base class for computing grid weights.
Definition: integrator.h:136
sc::RadialIntegrator::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::GaussLegendreAngularIntegrator::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::BeckeIntegrationWeight::w
double w(int center, SCVector3 &point, double *grad_w=0)
Computes the weight for a given center at a given point in space.
sc::EulerMaclaurinRadialIntegrator::radial_value
double radial_value(int ir, int nr, double radii, double &multiplier)
returns the radius for the quadrature point ir.
sc::LebedevLaikovIntegrator
An implementation of a Lebedev angular integrator.
Definition: integrator.h:295
sc::DenIntegrator::alpha_vmat
const double * alpha_vmat() const
Returns the alpha potential integrals.
Definition: integrator.h:107
sc::DenIntegrator::integral
const Ref< Integral > & integral() const
Returns the integral object that defines the basis function ordering, etc.
Definition: integrator.h:95
sc::AngularIntegrator::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::StateIn
Definition: statein.h:79
sc::RadialAngularIntegrator
An implementation of an integrator using any combination of a RadialIntegrator and an AngularIntegrat...
Definition: integrator.h:370
sc::DenIntegrator::done
virtual void done()
Must be called between calls to init.
sc::RadialAngularIntegrator::print
void print(std::ostream &=ExEnv::out0()) const
Print the object.
sc::BeckeIntegrationWeight
Implements Becke's integration weight scheme.
Definition: integrator.h:168
sc::DenIntegrator::DenIntegrator
DenIntegrator()
Construct a new DenIntegrator.
sc::DenIntegrator::set_compute_potential_integrals
void set_compute_potential_integrals(int)
Call with non zero if the potential integrals are to be computed.
sc::BeckeIntegrationWeight::init
void init(const Ref< Molecule > &, double tolerance)
Initialize the integration weight object.
sc::GaussLegendreAngularIntegrator
An implementation of an angular integrator using the Gauss-Legendre weights and grid points.
Definition: integrator.h:323
sc::DenIntegrator::basis
const Ref< GaussianBasisSet > & basis() const
Returns the basis set used for the density.
Definition: integrator.h:92
sc::RadialIntegrator::nr
virtual int nr() const =0
The number of quadrature points (redundant since radial_value takes this as a parameter)
sc::StateOut
Definition: stateout.h:71
sc::RadialAngularIntegrator::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::AngularIntegrator
An abstract base class for angular integrators.
Definition: integrator.h:218
sc::GaussLegendreAngularIntegrator::print
void print(std::ostream &=ExEnv::out0()) const
Print the object.
sc::LebedevLaikovIntegrator::print
void print(std::ostream &=ExEnv::out0()) const
Print the object.
sc::SCVector3
a 3-element version of SCVector
Definition: vector3.h:43
sc::DenIntegrator::value
double value() const
Returns the result of the integration.
Definition: integrator.h:97
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::IntegrationWeight::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::DenIntegrator::beta_vmat
const double * beta_vmat() const
Returns the beta potential integrals.
Definition: integrator.h:110
sc::SavableState
Base class for objects that can save/restore state.
Definition: state.h:45
sc::EulerMaclaurinRadialIntegrator::nr
int nr() const
The number of quadrature points (redundant since radial_value takes this as a parameter)
sc::DenIntegrator::spin_polarized
bool spin_polarized() const
Return true if the densities are spin polarized.
Definition: integrator.h:131
sc::RadialIntegrator
An abstract base class for radial integrators.
Definition: integrator.h:197
sc::RadialIntegrator::radial_value
virtual double radial_value(int ir, int nr, double radii, double &multiplier)=0
returns the radius for the quadrature point ir.
sc::RadialAngularIntegrator::integrate
void integrate(const Ref< DenFunctional > &, const RefSymmSCMatrix &densa=0, const RefSymmSCMatrix &densb=0, double *nuclear_gradient=0)
Performs the integration of the given functional using the given alpha and beta density matrices.
sc::EulerMaclaurinRadialIntegrator::print
void print(std::ostream &=ExEnv::out0()) const
Print the object.
sc::BeckeIntegrationWeight::done
void done()
Called when finished with the integration weight object.
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::EulerMaclaurinRadialIntegrator
An implementation of a radial integrator using the Euler-Maclaurin weights and grid points.
Definition: integrator.h:236
sc::IntegrationWeight::init
virtual void init(const Ref< Molecule > &, double tolerance)
Initialize the integration weight object.
sc::IntegrationWeight::done
virtual void done()
Called when finished with the integration weight object.

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