00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _chemistry_qc_dft_integrator_h
00029 #define _chemistry_qc_dft_integrator_h
00030
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034
00035 #include <util/state/state.h>
00036 #include <util/group/thread.h>
00037 #include <chemistry/qc/dft/functional.h>
00038 #include <chemistry/qc/basis/extent.h>
00039
00041 class DenIntegrator: virtual public SavableState {
00042 protected:
00043 Ref<Wavefunction> wfn_;
00044 Ref<ShellExtent> extent_;
00045
00046 Ref<ThreadGrp> threadgrp_;
00047 Ref<MessageGrp> messagegrp_;
00048
00049 double value_;
00050 double accuracy_;
00051
00052 double *alpha_vmat_;
00053 double *beta_vmat_;
00054
00055 double *alpha_dmat_;
00056 double *beta_dmat_;
00057 double *dmat_bound_;
00058
00059 int spin_polarized_;
00060
00061 int need_density_;
00062 double density_;
00063 int nbasis_;
00064 int nshell_;
00065 int natom_;
00066 int compute_potential_integrals_;
00067
00068 int linear_scaling_;
00069 int use_dmat_bound_;
00070
00071 void init_integration(const Ref<DenFunctional> &func,
00072 const RefSymmSCMatrix& densa,
00073 const RefSymmSCMatrix& densb,
00074 double *nuclear_gradient);
00075 void done_integration();
00076
00077 void init_object();
00078 public:
00080 DenIntegrator();
00082 DenIntegrator(const Ref<KeyVal> &);
00084 DenIntegrator(StateIn &);
00085 ~DenIntegrator();
00086 void save_data_state(StateOut &);
00087
00089 Ref<Wavefunction> wavefunction() const { return wfn_; }
00091 double value() const { return value_; }
00092
00094 void set_accuracy(double a) { accuracy_ = a; }
00095 double get_accuracy(void) {return accuracy_; }
00098 void set_compute_potential_integrals(int);
00101 const double *alpha_vmat() const { return alpha_vmat_; }
00104 const double *beta_vmat() const { return beta_vmat_; }
00105
00108 virtual void init(const Ref<Wavefunction> &);
00110 virtual void done();
00114 virtual void integrate(const Ref<DenFunctional> &,
00115 const RefSymmSCMatrix& densa =0,
00116 const RefSymmSCMatrix& densb =0,
00117 double *nuclear_grad = 0) = 0;
00118 };
00119
00120
00122 class IntegrationWeight: virtual public SavableState {
00123
00124 protected:
00125
00126 Ref<Molecule> mol_;
00127 double tol_;
00128
00129 void fd_w(int icenter, SCVector3 &point, double *fd_grad_w);
00130
00131 public:
00132 IntegrationWeight();
00133 IntegrationWeight(const Ref<KeyVal> &);
00134 IntegrationWeight(StateIn &);
00135 ~IntegrationWeight();
00136 void save_data_state(StateOut &);
00137
00138 void test(int icenter, SCVector3 &point);
00139 void test();
00140
00142 virtual void init(const Ref<Molecule> &, double tolerance);
00144 virtual void done();
00149 virtual double w(int center, SCVector3 &point, double *grad_w = 0) = 0;
00150 };
00151
00152
00154 class BeckeIntegrationWeight: public IntegrationWeight {
00155
00156 int ncenters;
00157 SCVector3 *centers;
00158 double *atomic_radius;
00159
00160 double **a_mat;
00161 double **oorab;
00162
00163 void compute_grad_p(int gc, int ic, int wc, SCVector3&r, double p,
00164 SCVector3&g);
00165 void compute_grad_nu(int gc, int bc, SCVector3 &point, SCVector3 &grad);
00166
00167 double compute_t(int ic, int jc, SCVector3 &point);
00168 double compute_p(int icenter, SCVector3&point);
00169
00170 public:
00171 BeckeIntegrationWeight();
00172 BeckeIntegrationWeight(const Ref<KeyVal> &);
00173 BeckeIntegrationWeight(StateIn &);
00174 ~BeckeIntegrationWeight();
00175 void save_data_state(StateOut &);
00176
00177 void init(const Ref<Molecule> &, double tolerance);
00178 void done();
00179 double w(int center, SCVector3 &point, double *grad_w = 0);
00180 };
00181
00183 class RadialIntegrator: virtual public SavableState {
00184 protected:
00185 int nr_;
00186 public:
00187 RadialIntegrator();
00188 RadialIntegrator(const Ref<KeyVal> &);
00189 RadialIntegrator(StateIn &);
00190 ~RadialIntegrator();
00191 void save_data_state(StateOut &);
00192
00193 virtual int nr() const = 0;
00194 virtual double radial_value(int ir, int nr, double radii,
00195 double &multiplier) = 0;
00196 };
00197
00198
00200 class AngularIntegrator: virtual public SavableState{
00201 protected:
00202 public:
00203 AngularIntegrator();
00204 AngularIntegrator(const Ref<KeyVal> &);
00205 AngularIntegrator(StateIn &);
00206 ~AngularIntegrator();
00207 void save_data_state(StateOut &);
00208
00209 virtual int nw(void) const = 0;
00210 virtual int num_angular_points(double r_value, int ir) = 0;
00211 virtual double angular_point_cartesian(int iangular, double r,
00212 SCVector3 &integration_point) const = 0;
00213 };
00214
00215
00218 class EulerMaclaurinRadialIntegrator: public RadialIntegrator {
00219 public:
00220 EulerMaclaurinRadialIntegrator();
00221 EulerMaclaurinRadialIntegrator(int i);
00222 EulerMaclaurinRadialIntegrator(const Ref<KeyVal> &);
00223 EulerMaclaurinRadialIntegrator(StateIn &);
00224 ~EulerMaclaurinRadialIntegrator();
00225 void save_data_state(StateOut &);
00226
00227 int nr() const;
00228 double radial_value(int ir, int nr, double radii, double &multiplier);
00229
00230 void print(std::ostream & =ExEnv::out()) const;
00231 };
00232
00274 class LebedevLaikovIntegrator: public AngularIntegrator {
00275 protected:
00276 int npoint_;
00277 double *x_, *y_, *z_, *w_;
00278
00279 void init(int n);
00280 public:
00281 LebedevLaikovIntegrator();
00282 LebedevLaikovIntegrator(const Ref<KeyVal> &);
00283 LebedevLaikovIntegrator(StateIn &);
00284 LebedevLaikovIntegrator(int);
00285 ~LebedevLaikovIntegrator();
00286 void save_data_state(StateOut &);
00287
00288 int nw(void) const;
00289 int num_angular_points(double r_value, int ir);
00290 double angular_point_cartesian(int iangular, double r,
00291 SCVector3 &integration_point) const;
00292 void print(std::ostream & =ExEnv::out()) const;
00293 };
00294
00297 class GaussLegendreAngularIntegrator: public AngularIntegrator {
00298 protected:
00299 int ntheta_;
00300 int nphi_;
00301 int Ktheta_;
00302 int ntheta_r_;
00303 int nphi_r_;
00304 int Ktheta_r_;
00305 double *theta_quad_weights_;
00306 double *theta_quad_points_;
00307
00308 int get_ntheta(void) const;
00309 void set_ntheta(int i);
00310 int get_nphi(void) const;
00311 void set_nphi(int i);
00312 int get_Ktheta(void) const;
00313 void set_Ktheta(int i);
00314 int get_ntheta_r(void) const;
00315 void set_ntheta_r(int i);
00316 int get_nphi_r(void) const;
00317 void set_nphi_r(int i);
00318 int get_Ktheta_r(void) const;
00319 void set_Ktheta_r(int i);
00320 int nw(void) const;
00321 double sin_theta(SCVector3 &point) const;
00322 void gauleg(double x1, double x2, int n);
00323 public:
00324 GaussLegendreAngularIntegrator();
00325 GaussLegendreAngularIntegrator(const Ref<KeyVal> &);
00326 GaussLegendreAngularIntegrator(StateIn &);
00327 ~GaussLegendreAngularIntegrator();
00328 void save_data_state(StateOut &);
00329
00330 int num_angular_points(double r_value, int ir);
00331 double angular_point_cartesian(int iangular, double r,
00332 SCVector3 &integration_point) const;
00333 void print(std::ostream & =ExEnv::out()) const;
00334 };
00335
00338 class RadialAngularIntegrator: public DenIntegrator {
00339 private:
00340 int prune_grid_;
00341 double **Alpha_coeffs_;
00342 int gridtype_;
00343 int **nr_points_, *xcoarse_l_;
00344 int npruned_partitions_;
00345 double *grid_accuracy_;
00346 int dynamic_grids_;
00347 int natomic_rows_;
00348 int max_gridtype_;
00349 protected:
00350 Ref<IntegrationWeight> weight_;
00351 Ref<RadialIntegrator> radial_user_;
00352 Ref<AngularIntegrator> angular_user_;
00353 Ref<AngularIntegrator> ***angular_grid_;
00354 Ref<RadialIntegrator> **radial_grid_;
00355 public:
00356 RadialAngularIntegrator();
00357 RadialAngularIntegrator(const Ref<KeyVal> &);
00358 RadialAngularIntegrator(StateIn &);
00359 ~RadialAngularIntegrator();
00360 void save_data_state(StateOut &);
00361
00362 void integrate(const Ref<DenFunctional> &,
00363 const RefSymmSCMatrix& densa =0,
00364 const RefSymmSCMatrix& densb =0,
00365 double *nuclear_gradient = 0);
00366 void print(std::ostream & =ExEnv::out()) const;
00367 AngularIntegrator *get_angular_grid(double radius, double atomic_radius,
00368 int charge);
00369 RadialIntegrator *get_radial_grid(int charge);
00370 void init_default_grids(void);
00371 int angular_grid_offset(int i);
00372 void set_grids(void);
00373 int get_atomic_row(int i);
00374 void init_parameters(void);
00375 void init_parameters(const Ref<KeyVal>& keyval);
00376 void init_pruning_coefficients(const Ref<KeyVal>& keyval);
00377 void init_pruning_coefficients(void);
00378 void init_alpha_coefficients(void);
00379 int select_dynamic_grid(void);
00380 Ref<IntegrationWeight> weight() { return weight_; }
00381 };
00382
00383 #endif
00384
00385
00386
00387
00388