---
name: "sc_BatchElectronDensity"
section: "3"
platform: "linux"
package: "libsc-doc"
version: "2.3.1-22"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/sc_BatchElectronDensity"
---

# sc\_BatchElectronDensity(3)

This a more highly optimized than ElectronDensity since everything is precomputed.

## NAME

sc::BatchElectronDensity - This a more highly optimized than **ElectronDensity** since everything is precomputed.

## SYNOPSIS

`#include <density.h>`

Inherits **sc::Volume**.

### Public Types

enum { **X** =0, **Y** =1, **Z** =2 }\
 This gives the elements of gradient arrays.  enum { **XX** =0, **YX** =1, **YY** =2, **ZX** =3, **ZY** =4, **ZZ** =5 }\
 This gives the elements of hessian arrays.

### Public Member Functions

**BatchElectronDensity** (const **Ref**\< **KeyVal** \> &)\
 **BatchElectronDensity** (const **Ref**\< **Wavefunction** \> &, double accuracy=DBL\_EPSILON)\
 **BatchElectronDensity** (const **Ref**\< **BatchElectronDensity** \> &d, bool reference\_parent\_data=false)\
 This will construct copies of this.  virtual void **boundingbox** (double valuemin, double valuemax, **SCVector3** &p1, **SCVector3** &p2)\
 Returns the bounding box.  void **clear** ()\
 This will cause all stratch storage to be released.  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 **init** (bool initialize\_density\_matrices=true)\
 This is called to finish initialization of the object.  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 **set\_linear\_scaling** (bool b)\
 Turn linear scaling algorithm on/off.  void **set\_accuracy** (double a)\
 Sets the accuracy.  void **set\_use\_dmat\_bound** (bool b)\
 Turn use of density matrix bounds on/off.

**DFT Support Members.**\
 These return some of the internal data, some of which is only value after a density has been computed.

This data is needed by the density functional theory code.

double \* **alpha\_density\_matrix** ()\
 Return the alpha density matrix.  double \* **beta\_density\_matrix** ()\
 Return the beta density matrix.  int **ncontrib** ()\
 int \* **contrib** ()\
 int **ncontrib\_bf** ()\
 int \* **contrib\_bf** ()\
 double \* **bs\_values** ()\
 double \* **bsg\_values** ()\
 double \* **bsh\_values** ()\
 void **set\_need\_basis\_gradient** (bool b)\
 To ensure that that the basis functions gradients are computed, use this.  void **set\_need\_basis\_hessian** (bool b)\

### Protected Member Functions

virtual void **init\_common\_data** (bool initialize\_density\_matrices)\
 virtual void **init\_scratch\_data** ()\
 void **compute\_basis\_values** (const **SCVector3** &r)\
 void **compute\_spin\_density** (const double \*dmat, double \*rho, double \*grad, double \*hess)\
 virtual void **compute** ()\
 Recompute at least the results that have compute true and are not already computed.

### Protected Attributes

**Ref**\< **Wavefunction** \> **wfn\_**\
 **Ref**\< **GaussianBasisSet** \> **basis\_**\
 double \* **alpha\_dmat\_**\
 double \* **beta\_dmat\_**\
 double \* **dmat\_bound\_**\
 **ShellExtent** \* **extent\_**\
 **GaussianBasisSet::ValueData** \* **valdat\_**\
 int **ncontrib\_**\
 int \* **contrib\_**\
 int **ncontrib\_bf\_**\
 int \* **contrib\_bf\_**\
 double \* **bs\_values\_**\
 double \* **bsg\_values\_**\
 double \* **bsh\_values\_**\
 int **nshell\_**\
 int **nbasis\_**\
 int **spin\_polarized\_**\
 int **linear\_scaling\_**\
 int **use\_dmat\_bound\_**\
 bool **need\_hessian\_**\
 bool **need\_gradient\_**\
 bool **need\_basis\_hessian\_**\
 bool **need\_basis\_gradient\_**\
 bool **using\_shared\_data\_**\
 double **accuracy\_**\

### Additional Inherited Members

## Detailed Description

This a more highly optimized than **ElectronDensity** since everything is precomputed.

However, it cannot be used if the density and/or geometry might change between computations of the density or bounding box, unless the obsolete member is called.

## Constructor & Destructor Documentation

### sc::BatchElectronDensity::BatchElectronDensity (const Ref\< BatchElectronDensity \> & d, bool reference\_parent\_data = `false`)

This will construct copies of this. If reference\_parent\_data is true, then data that do not change, such as the density matrices and shell extent, are referenced rather than copied. In this case, the original object that allocated this items must be valid while copied objects are used to compute densities. Also d must have already been intialized and the resulting copy is already initialized (and cannot be reinitialized).

If reference\_parent\_data is false, then init must be called on this object before it is used. \

## Member Function Documentation

### virtual void sc::BatchElectronDensity::boundingbox (double valuemin, double valuemax, SCVector3 & p1, SCVector3 & p2)` [virtual]`

Returns the bounding box.

Implements **sc::Volume**.

### virtual void sc::BatchElectronDensity::compute ()` [protected]`, ` [virtual]`

Recompute at least the results that have compute true and are not already computed. This should only be called by **Result**'s members.

Implements **sc::Volume**.

### virtual void sc::BatchElectronDensity::init (bool initialize\_density\_matrices = `true`)` [virtual]`

This is called to finish initialization of the object. It must not be called with objects that created in a way that they share parent data, those objects are initialized when they are constructed. This member is usually called automatically, however, if it will be used to initial other objects that share parent data, then it must be initialized first and this return is the way to do that. If initialize\_density\_matrices is false, then the density matrices will be allocated, but not filled in. They must be later filled in with set\_densities.

### void sc::BatchElectronDensity::set\_accuracy (double a)` [inline]`

Sets the accuracy. \

### virtual void sc::BatchElectronDensity::set\_densities (const RefSymmSCMatrix & aden, const RefSymmSCMatrix & bden)` [virtual]`

This will fill in the internel copies of the density matrices with new values. aden is the alpha density matrix and bden is the beta density matrix. bden is ignored if the wavefunction is not spin polarized.

### void sc::BatchElectronDensity::set\_linear\_scaling (bool b)` [inline]`

Turn linear scaling algorithm on/off. The effect of this will be delayed until the next time **init()** is called.

## Author

Generated automatically by Doxygen for MPQC from the source code.
