MPQC 2.3.1
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#ifdef __GNUC__
32#pragma interface
33#endif
34
35#include <math/isosurf/volume.h>
36#include <chemistry/qc/wfn/wfn.h>
37#include <chemistry/qc/basis/extent.h>
38#include <chemistry/molecule/molrender.h>
39
40namespace sc {
41
44class ElectronDensity: public Volume {
45 protected:
47 virtual void compute();
48 public:
49 ElectronDensity(const Ref<KeyVal>&);
50 ElectronDensity(const Ref<Wavefunction>&);
51 ~ElectronDensity();
52 virtual void boundingbox(double valuemin,
53 double valuemax,
54 SCVector3& p1, SCVector3& p2);
55};
56
62class BatchElectronDensity: public Volume {
63 void zero_pointers();
64 protected:
66
68
69 // shared between threads
70 double *alpha_dmat_;
71 double *beta_dmat_;
72 double *dmat_bound_;
73 ShellExtent *extent_;
74
75 // private data
77 int ncontrib_;
78 int *contrib_;
79 int ncontrib_bf_;
80 int *contrib_bf_;
81 double *bs_values_;
82 double *bsg_values_;
83 double *bsh_values_;
84
85 int nshell_;
86 int nbasis_;
87 int spin_polarized_;
88 int linear_scaling_;
89 int use_dmat_bound_;
90
91 bool need_hessian_, need_gradient_;
92 bool need_basis_hessian_, need_basis_gradient_;
93
94 bool using_shared_data_;
95
96 double accuracy_;
97 virtual void init_common_data(bool initialize_density_matrices);
98 // this must be called after common data is initialized,
99 // either with init_common_data or by copying
100 virtual void init_scratch_data();
101 void compute_basis_values(const SCVector3&r);
102 void compute_spin_density(const double *dmat,
103 double *rho, double *grad, double *hess);
104
105 virtual void compute();
106 public:
107
109 enum {X=0, Y=1, Z=2};
111 enum {XX=0, YX=1, YY=2, ZX=3, ZY=4, ZZ=5};
112
113 BatchElectronDensity(const Ref<KeyVal>&);
114 BatchElectronDensity(const Ref<Wavefunction>&, double accuracy=DBL_EPSILON);
126 bool reference_parent_data=false);
127 ~BatchElectronDensity();
129 virtual void boundingbox(double valuemin,
130 double valuemax,
131 SCVector3& p1, SCVector3& p2);
132
134 void clear();
135
139 double *alpha_density,
140 double *alpha_density_grad,
141 double *alpha_density_hessian,
142 double *beta_density,
143 double *beta_density_grad,
144 double *beta_density_hessian);
145
155 virtual void init(bool initialize_density_matrices = true);
156
161 virtual void set_densities(const RefSymmSCMatrix &aden,
162 const RefSymmSCMatrix &bden);
163
166 void set_linear_scaling(bool b) { linear_scaling_ = b; }
167
169 void set_accuracy(double a) { accuracy_ = a; }
170
172 void set_use_dmat_bound(bool b) { use_dmat_bound_ = b; }
173
179
180 double *alpha_density_matrix() { return alpha_dmat_; }
183 { return (spin_polarized_?beta_dmat_:alpha_dmat_); }
184 int ncontrib() { return ncontrib_; }
185 int *contrib() { return contrib_; }
186 int ncontrib_bf() { return ncontrib_bf_; }
187 int *contrib_bf() { return contrib_bf_; }
188 double *bs_values() { return bs_values_; }
189 double *bsg_values() { return bsg_values_; }
190 double *bsh_values() { return bsh_values_; }
193 void set_need_basis_gradient(bool b) { need_basis_gradient_ = b; }
194 void set_need_basis_hessian(bool b) { need_basis_hessian_ = b; }
196};
197
198class DensityColorizer: public MoleculeColorizer {
199 protected:
201 double scale_;
202 double reference_;
203 int have_scale_;
204 int have_reference_;
205 public:
206 DensityColorizer(const Ref<KeyVal>&);
207 ~DensityColorizer();
208
209 void colorize(const Ref<RenderedPolygons> &);
210};
211
212class GradDensityColorizer: public MoleculeColorizer {
213 protected:
215 double scale_;
216 double reference_;
217 int have_scale_;
218 int have_reference_;
219 public:
220 GradDensityColorizer(const Ref<KeyVal>&);
221 ~GradDensityColorizer();
222
223 void colorize(const Ref<RenderedPolygons> &);
224};
225
226}
227
228#endif
229
230// Local Variables:
231// mode: c++
232// c-file-style: "CLJ"
233// End:
void set_linear_scaling(bool b)
Turn linear scaling algorithm on/off.
Definition density.h:166
BatchElectronDensity(const Ref< BatchElectronDensity > &d, bool reference_parent_data=false)
This will construct copies of this.
double * alpha_density_matrix()
Return the alpha density matrix.
Definition density.h:180
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
void set_accuracy(double a)
Sets the accuracy.
Definition density.h:169
double * beta_density_matrix()
Return the beta density matrix.
Definition density.h:182
void set_need_basis_gradient(bool b)
To ensure that that the basis functions gradients are computed, use this.
Definition density.h:193
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.
virtual void set_densities(const RefSymmSCMatrix &aden, const RefSymmSCMatrix &bden)
This will fill in the internel copies of the density matrices with new values.
void clear()
This will cause all stratch storage to be released.
virtual void init(bool initialize_density_matrices=true)
This is called to finish initialization of the object.
virtual void boundingbox(double valuemin, double valuemax, SCVector3 &p1, SCVector3 &p2)
Returns the bounding box.
void set_use_dmat_bound(bool b)
Turn use of density matrix bounds on/off.
Definition density.h:172
virtual void compute()
Recompute at least the results that have compute true and are not already computed.
This holds scratch data needed to compute basis function values.
Definition gaussbas.h:211
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition matrix.h:261
A template class that maintains references counts.
Definition ref.h:332
Definition vector3.h:46
Definition extent.h:26

Generated at Mon Jan 20 2025 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.13.2.