MPQC
2.3.1
|
00001 // 00002 // density.h 00003 // 00004 // Copyright (C) 1996 Limit Point Systems, Inc. 00005 // 00006 // Author: Curtis Janssen <cljanss@limitpt.com> 00007 // Maintainer: LPS 00008 // 00009 // This file is part of the SC Toolkit. 00010 // 00011 // The SC Toolkit is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published by 00013 // the Free Software Foundation; either version 2, or (at your option) 00014 // any later version. 00015 // 00016 // The SC Toolkit is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to 00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00024 // 00025 // The U.S. Government is granted a limited license as per AL 91-7. 00026 // 00027 00028 #ifndef _chemistry_qc_wfn_density_h 00029 #define _chemistry_qc_wfn_density_h 00030 00031 #ifdef __GNUC__ 00032 #pragma interface 00033 #endif 00034 00035 #include <math/isosurf/volume.h> 00036 #include <chemistry/qc/wfn/wfn.h> 00037 #include <chemistry/qc/basis/extent.h> 00038 #include <chemistry/molecule/molrender.h> 00039 00040 namespace sc { 00041 00044 class ElectronDensity: public Volume { 00045 protected: 00046 Ref<Wavefunction> wfn_; 00047 virtual void compute(); 00048 public: 00049 ElectronDensity(const Ref<KeyVal>&); 00050 ElectronDensity(const Ref<Wavefunction>&); 00051 ~ElectronDensity(); 00052 virtual void boundingbox(double valuemin, 00053 double valuemax, 00054 SCVector3& p1, SCVector3& p2); 00055 }; 00056 00062 class BatchElectronDensity: public Volume { 00063 void zero_pointers(); 00064 protected: 00065 Ref<Wavefunction> wfn_; 00066 00067 Ref<GaussianBasisSet> basis_; 00068 00069 // shared between threads 00070 double *alpha_dmat_; 00071 double *beta_dmat_; 00072 double *dmat_bound_; 00073 ShellExtent *extent_; 00074 00075 // private data 00076 GaussianBasisSet::ValueData *valdat_; 00077 int ncontrib_; 00078 int *contrib_; 00079 int ncontrib_bf_; 00080 int *contrib_bf_; 00081 double *bs_values_; 00082 double *bsg_values_; 00083 double *bsh_values_; 00084 00085 int nshell_; 00086 int nbasis_; 00087 int spin_polarized_; 00088 int linear_scaling_; 00089 int use_dmat_bound_; 00090 00091 bool need_hessian_, need_gradient_; 00092 bool need_basis_hessian_, need_basis_gradient_; 00093 00094 bool using_shared_data_; 00095 00096 double accuracy_; 00097 virtual void init_common_data(bool initialize_density_matrices); 00098 // this must be called after common data is initialized, 00099 // either with init_common_data or by copying 00100 virtual void init_scratch_data(); 00101 void compute_basis_values(const SCVector3&r); 00102 void compute_spin_density(const double *dmat, 00103 double *rho, double *grad, double *hess); 00104 00105 virtual void compute(); 00106 public: 00107 00109 enum {X=0, Y=1, Z=2}; 00111 enum {XX=0, YX=1, YY=2, ZX=3, ZY=4, ZZ=5}; 00112 00113 BatchElectronDensity(const Ref<KeyVal>&); 00114 BatchElectronDensity(const Ref<Wavefunction>&, double accuracy=DBL_EPSILON); 00125 BatchElectronDensity(const Ref<BatchElectronDensity>& d, 00126 bool reference_parent_data=false); 00127 ~BatchElectronDensity(); 00129 virtual void boundingbox(double valuemin, 00130 double valuemax, 00131 SCVector3& p1, SCVector3& p2); 00132 00134 void clear(); 00135 00138 void compute_density(const SCVector3 &r, 00139 double *alpha_density, 00140 double *alpha_density_grad, 00141 double *alpha_density_hessian, 00142 double *beta_density, 00143 double *beta_density_grad, 00144 double *beta_density_hessian); 00145 00155 virtual void init(bool initialize_density_matrices = true); 00156 00161 virtual void set_densities(const RefSymmSCMatrix &aden, 00162 const RefSymmSCMatrix &bden); 00163 00166 void set_linear_scaling(bool b) { linear_scaling_ = b; } 00167 00169 void set_accuracy(double a) { accuracy_ = a; } 00170 00172 void set_use_dmat_bound(bool b) { use_dmat_bound_ = b; } 00173 00180 double *alpha_density_matrix() { return alpha_dmat_; } 00182 double *beta_density_matrix() 00183 { return (spin_polarized_?beta_dmat_:alpha_dmat_); } 00184 int ncontrib() { return ncontrib_; } 00185 int *contrib() { return contrib_; } 00186 int ncontrib_bf() { return ncontrib_bf_; } 00187 int *contrib_bf() { return contrib_bf_; } 00188 double *bs_values() { return bs_values_; } 00189 double *bsg_values() { return bsg_values_; } 00190 double *bsh_values() { return bsh_values_; } 00193 void set_need_basis_gradient(bool b) { need_basis_gradient_ = b; } 00194 void set_need_basis_hessian(bool b) { need_basis_hessian_ = b; } 00196 }; 00197 00198 class DensityColorizer: public MoleculeColorizer { 00199 protected: 00200 Ref<Wavefunction> wfn_; 00201 double scale_; 00202 double reference_; 00203 int have_scale_; 00204 int have_reference_; 00205 public: 00206 DensityColorizer(const Ref<KeyVal>&); 00207 ~DensityColorizer(); 00208 00209 void colorize(const Ref<RenderedPolygons> &); 00210 }; 00211 00212 class GradDensityColorizer: public MoleculeColorizer { 00213 protected: 00214 Ref<Wavefunction> wfn_; 00215 double scale_; 00216 double reference_; 00217 int have_scale_; 00218 int have_reference_; 00219 public: 00220 GradDensityColorizer(const Ref<KeyVal>&); 00221 ~GradDensityColorizer(); 00222 00223 void colorize(const Ref<RenderedPolygons> &); 00224 }; 00225 00226 } 00227 00228 #endif 00229 00230 // Local Variables: 00231 // mode: c++ 00232 // c-file-style: "CLJ" 00233 // End: