MPQC  3.0.0-alpha
density.h
1 //
2 // density.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_wfn_density_h
29 #define _chemistry_qc_wfn_density_h
30 
31 #include <math/isosurf/volume.h>
32 #include <chemistry/qc/wfn/wfn.h>
33 #include <chemistry/qc/basis/extent.h>
34 #include <chemistry/molecule/molrender.h>
35 #include <chemistry/molecule/molecule.h>
36 #include <math/mmisc/grid.h>
37 
38 namespace sc {
39 
42 class ElectronDensity: public Volume {
43  protected:
44  Ref<Wavefunction> wfn_;
45  virtual void compute();
46  public:
49  ~ElectronDensity();
50  virtual void boundingbox(double valuemin,
51  double valuemax,
52  SCVector3& p1, SCVector3& p2);
53 };
54 
61  void zero_pointers();
62  protected:
63  // wfn_ might be null in which case basis_ and integral_
64  // must be initialized and set_densities must be used.
65  Ref<Wavefunction> wfn_;
66 
67  Ref<GaussianBasisSet> basis_;
68  Ref<Integral> integral_;
69 
70  bool initialized_;
71 
72  // shared between threads
73  double *alpha_dmat_;
74  double *beta_dmat_;
75  double *dmat_bound_;
76  ShellExtent *extent_;
77 
78  // private data
80  int ncontrib_;
81  int *contrib_;
82  int ncontrib_bf_;
83  int *contrib_bf_;
84  double *bs_values_;
85  double *bsg_values_;
86  double *bsh_values_;
87 
88  int nshell_;
89  int nbasis_;
90  bool spin_polarized_;
91  int linear_scaling_;
92  int use_dmat_bound_;
93 
94  bool need_hessian_, need_gradient_;
95  bool need_basis_hessian_, need_basis_gradient_;
96 
97  bool using_shared_data_;
98 
99  double accuracy_;
100  virtual void init_common_data();
101  // this must be called after common data is initialized,
102  // either with init_common_data or by copying
103  virtual void init_scratch_data();
104  void compute_basis_values(const SCVector3&r);
105  void compute_spin_density(const double *RESTRICT dmat,
106  double *RESTRICT rho,
107  double *RESTRICT grad,
108  double *RESTRICT hess);
109 
110  virtual void compute();
111  public:
112 
114  enum {X=0, Y=1, Z=2};
116  enum {XX=0, YX=1, YY=2, ZX=3, ZY=4, ZZ=5};
117 
120  const Ref<Integral> &integral,
121  double accuracy=DBL_EPSILON);
123  double accuracy=DBL_EPSILON);
135  bool reference_parent_data=false);
138  virtual void boundingbox(double valuemin,
139  double valuemax,
140  SCVector3& p1, SCVector3& p2);
141 
143  void clear();
144 
147  void compute_density(const SCVector3 &r,
148  double *alpha_density,
149  double *alpha_density_grad,
150  double *alpha_density_hessian,
151  double *beta_density,
152  double *beta_density_grad,
153  double *beta_density_hessian);
154 
165  virtual void init();
166 
172  virtual void set_densities(const RefSymmSCMatrix &aden,
173  const RefSymmSCMatrix &bden = 0);
174 
177  virtual void set_densities(const Ref<Wavefunction> &wfn);
178 
181  void set_linear_scaling(bool b) { linear_scaling_ = b; }
182 
184  void set_accuracy(double a) { accuracy_ = a; }
185 
187  void set_use_dmat_bound(bool b) { use_dmat_bound_ = b; }
188 
191  bool spin_polarized() const { return spin_polarized_; }
192 
199  double *alpha_density_matrix() { return alpha_dmat_; }
202  { return (spin_polarized_?beta_dmat_:alpha_dmat_); }
203  int ncontrib() { return ncontrib_; }
204  int *contrib() { return contrib_; }
205  int ncontrib_bf() { return ncontrib_bf_; }
206  int *contrib_bf() { return contrib_bf_; }
207  double *bs_values() { return bs_values_; }
208  double *bsg_values() { return bsg_values_; }
209  double *bsh_values() { return bsh_values_; }
212  void set_need_basis_gradient(bool b) { need_basis_gradient_ = b; }
213  void set_need_basis_hessian(bool b) { need_basis_hessian_ = b; }
215 };
216 
220  private:
221  double df_alpha(double alpha, double beta);
222  double df_beta(double alpha, double beta);
223  double df_sum(double alpha, double beta);
224  double df_spin(double alpha, double beta);
225  protected:
226  Ref<Wavefunction> wfn_;
228  double accuracy_;
229  std::string type_;
230  double (WriteElectronDensity::*density_function_)(double, double);
231 
232  void initialize();
233  void label(char* buffer);
235  double calculate_value(SCVector3 point);
236  public:
252 };
253 
255  protected:
256  Ref<Wavefunction> wfn_;
257  double scale_;
258  double reference_;
259  int have_scale_;
260  int have_reference_;
261  public:
263  ~DensityColorizer();
264 
265  void colorize(const Ref<RenderedPolygons> &);
266 };
267 
269  protected:
270  Ref<Wavefunction> wfn_;
271  double scale_;
272  double reference_;
273  int have_scale_;
274  int have_reference_;
275  public:
278 
279  void colorize(const Ref<RenderedPolygons> &);
280 };
281 
282 }
283 
284 #endif
285 
286 // Local Variables:
287 // mode: c++
288 // c-file-style: "CLJ"
289 // End:
sc::GradDensityColorizer
Definition: density.h:268
sc::BatchElectronDensity::compute_density
void compute_density(const SCVector3 &r, double *alpha_density, double *alpha_density_grad, double *alpha_density_hessian, double *beta_density, double *beta_density_grad, double *beta_density_hessian)
This is a alternate to the Volume interface that avoids some of the overhead of that interface.
sc::WriteElectronDensity
The WriteElectronDensity class writes the electron density at user defined grid points to the standar...
Definition: density.h:219
sc::WriteElectronDensity::initialize
void initialize()
Prepares some pre-caculated values before the repetitive grid calculations are perfomed.
sc::BatchElectronDensity::set_densities
virtual void set_densities(const RefSymmSCMatrix &aden, const RefSymmSCMatrix &bden=0)
This will fill in the internal copies of the density matrices with new values.
sc::BatchElectronDensity::beta_density_matrix
double * beta_density_matrix()
Return the beta density matrix.
Definition: density.h:201
sc::RefSymmSCMatrix
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition: matrix.h:265
sc::BatchElectronDensity::compute
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::X
Definition: reftestx.h:32
sc::WriteElectronDensity::WriteElectronDensity
WriteElectronDensity(const Ref< KeyVal > &)
The KeyVal constructor.
sc::WriteElectronDensity::label
void label(char *buffer)
A label that identifies the scalar function evaluated at the grid points, is written to the buffer ar...
sc::WriteElectronDensity::get_molecule
Ref< Molecule > get_molecule()
Returns the molecule around which the grid values are calculated.
sc::WriteElectronDensity::calculate_value
double calculate_value(SCVector3 point)
Returns the value of the scalar function at the given coordinate.
sc::BatchElectronDensity::alpha_density_matrix
double * alpha_density_matrix()
Return the alpha density matrix.
Definition: density.h:199
sc::BatchElectronDensity
This a more highly optimized than ElectronDensity since everything is precomputed.
Definition: density.h:60
sc::ElectronDensity
This is a Volume that computes the electron density.
Definition: density.h:42
sc::BatchElectronDensity::set_need_basis_gradient
void set_need_basis_gradient(bool b)
To ensure that that the basis functions gradients are computed, use this.
Definition: density.h:212
sc::BatchElectronDensity::init
virtual void init()
This is called to finish initialization of the object.
sc::DensityColorizer
Definition: density.h:254
sc::BatchElectronDensity::spin_polarized
bool spin_polarized() const
Return true if the densities are spin polarized.
Definition: density.h:191
sc::BatchElectronDensity::clear
void clear()
This will cause all stratch storage to be released.
sc::ShellExtent
Definition: extent.h:22
sc::WriteGrid
The abstract WriteGrid class provides an interface for writing the value of a scalar function evaluat...
Definition: grid.h:85
sc::Volume
A Volume is a Function of three variables.
Definition: volume.h:38
sc::BatchElectronDensity::set_accuracy
void set_accuracy(double a)
Sets the accuracy.
Definition: density.h:184
sc::BatchElectronDensity::set_use_dmat_bound
void set_use_dmat_bound(bool b)
Turn use of density matrix bounds on/off.
Definition: density.h:187
sc::SCVector3
a 3-element version of SCVector
Definition: vector3.h:43
sc::GaussianBasisSet::ValueData
This holds scratch data needed to compute basis function values.
Definition: gaussbas.h:261
sc::ElectronDensity::compute
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
sc::BatchElectronDensity::boundingbox
virtual void boundingbox(double valuemin, double valuemax, SCVector3 &p1, SCVector3 &p2)
Returns the bounding box.
sc::Y
Definition: reftestx.h:41
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::BatchElectronDensity::set_linear_scaling
void set_linear_scaling(bool b)
Turn linear scaling algorithm on/off.
Definition: density.h:181
sc::MoleculeColorizer
Definition: molrender.h:77

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