3.7.5. horton.meanfield.gridgroup – Container for observables involving numerical integration

class horton.meanfield.gridgroup.GridGroup(obasis, grid, grid_terms, label='grid_group', density_cutoff=1e-09)

Bases: horton.meanfield.observable.Observable

Initialize a GridGroup instance.

Parameters:
  • obasis (GOBasis) – The orbital basis.
  • grid (IntGrid) – A numerical integration grid. (must have points attribute and integrate method.)
  • grid_terms (list of GridObservable instances.) – The contributions to the effective Hamiltonian.
  • label (str) – A label for the group.
  • density_cutoff (float) – Whenever the density on a grid point falls below this threshold, all data for that grid point is set to zero. This is mainly relevant for functionals that use derivatives of the density or the orbitals, i.e. GGA and MGGA functionals.
__init__(obasis, grid, grid_terms, label='grid_group', density_cutoff=1e-09)

Initialize a GridGroup instance.

Parameters:
  • obasis (GOBasis) – The orbital basis.
  • grid (IntGrid) – A numerical integration grid. (must have points attribute and integrate method.)
  • grid_terms (list of GridObservable instances.) – The contributions to the effective Hamiltonian.
  • label (str) – A label for the group.
  • density_cutoff (float) – Whenever the density on a grid point falls below this threshold, all data for that grid point is set to zero. This is mainly relevant for functionals that use derivatives of the density or the orbitals, i.e. GGA and MGGA functionals.
add_dot_hessian(cache, *outputs)

Add contribution to the dot product of the Hessian with the trial delta DM.

The Hessian in this method is the second derivative of the observable towards the matrix elements of the density matrix or matrices. The dms and delta dms are stored in the cache.

Parameters:
  • cache – A cache object used to store intermediate results that can be reused or inspected later. All results specific for the detla_dm are stored with the tag ‘d’ in the cache object.
  • output2, .. (output1,) – Output objects, to which contributions from the dot product of the Hessian with the delta density matrices is added.
add_fock(cache, *focks)

Add contributions to the Fock matrix.

This method basically dispatches the work to all GridObservable instances in self.grid_terms.

Parameters:
  • cache (Cache) – Used to store intermediate results.
  • focks (list of TwoIndex) – A list of Fock matrices.
compute_energy(cache)

Compute the sum of the expectation values.

This method basically dispatches the work to all GridObservable instances in self.grid_terms.

Parameters:cache (Cache) – Used to store intermediate results.
df_level

The density-functional level of this grid group.

Returns:df_level – This can be any of the following:
  • DF_LEVEL_LDA: only LDA functionals are used.
  • DF_LEVEL_GGA: GGA (and LDA) functionals are used.
  • DF_LEVEL_MGGA: MGGA (and LDA and/or GGA) functionals are used.
Return type:int
class horton.meanfield.gridgroup.RGridGroup(obasis, grid, grid_terms, label='grid_group', density_cutoff=1e-09)

Bases: horton.meanfield.gridgroup.GridGroup

Initialize a GridGroup instance.

Parameters:
  • obasis (GOBasis) – The orbital basis.
  • grid (IntGrid) – A numerical integration grid. (must have points attribute and integrate method.)
  • grid_terms (list of GridObservable instances.) – The contributions to the effective Hamiltonian.
  • label (str) – A label for the group.
  • density_cutoff (float) – Whenever the density on a grid point falls below this threshold, all data for that grid point is set to zero. This is mainly relevant for functionals that use derivatives of the density or the orbitals, i.e. GGA and MGGA functionals.
__init__(obasis, grid, grid_terms, label='grid_group', density_cutoff=1e-09)

Initialize a GridGroup instance.

Parameters:
  • obasis (GOBasis) – The orbital basis.
  • grid (IntGrid) – A numerical integration grid. (must have points attribute and integrate method.)
  • grid_terms (list of GridObservable instances.) – The contributions to the effective Hamiltonian.
  • label (str) – A label for the group.
  • density_cutoff (float) – Whenever the density on a grid point falls below this threshold, all data for that grid point is set to zero. This is mainly relevant for functionals that use derivatives of the density or the orbitals, i.e. GGA and MGGA functionals.
add_dot_hessian(cache, output_alpha)

Add contribution to the dot product of the Hessian with the trial delta DM.

The Hessian in this method is the second derivative of the observable towards the matrix elements of the density matrix or matrices. The dms and delta dms are stored in the cache.

Parameters:
  • cache – A cache object used to store intermediate results that can be reused or inspected later. All results specific for the detla_dm are stored with the tag ‘d’ in the cache object.
  • output2, .. (output1,) – Output objects, to which contributions from the dot product of the Hessian with the delta density matrices is added.
add_fock(cache, *focks)

Add contributions to the Fock matrix.

This method basically dispatches the work to all GridObservable instances in self.grid_terms.

Parameters:
  • cache (Cache) – Used to store intermediate results.
  • focks (list of TwoIndex) – A list of Fock matrices.
compute_energy(cache)

Compute the sum of the expectation values.

This method basically dispatches the work to all GridObservable instances in self.grid_terms.

Parameters:cache (Cache) – Used to store intermediate results.
df_level

The density-functional level of this grid group.

Returns:df_level – This can be any of the following:
  • DF_LEVEL_LDA: only LDA functionals are used.
  • DF_LEVEL_GGA: GGA (and LDA) functionals are used.
  • DF_LEVEL_MGGA: MGGA (and LDA and/or GGA) functionals are used.
Return type:int
class horton.meanfield.gridgroup.UGridGroup(obasis, grid, grid_terms, label='grid_group', density_cutoff=1e-09)

Bases: horton.meanfield.gridgroup.GridGroup

Initialize a GridGroup instance.

Parameters:
  • obasis (GOBasis) – The orbital basis.
  • grid (IntGrid) – A numerical integration grid. (must have points attribute and integrate method.)
  • grid_terms (list of GridObservable instances.) – The contributions to the effective Hamiltonian.
  • label (str) – A label for the group.
  • density_cutoff (float) – Whenever the density on a grid point falls below this threshold, all data for that grid point is set to zero. This is mainly relevant for functionals that use derivatives of the density or the orbitals, i.e. GGA and MGGA functionals.
__init__(obasis, grid, grid_terms, label='grid_group', density_cutoff=1e-09)

Initialize a GridGroup instance.

Parameters:
  • obasis (GOBasis) – The orbital basis.
  • grid (IntGrid) – A numerical integration grid. (must have points attribute and integrate method.)
  • grid_terms (list of GridObservable instances.) – The contributions to the effective Hamiltonian.
  • label (str) – A label for the group.
  • density_cutoff (float) – Whenever the density on a grid point falls below this threshold, all data for that grid point is set to zero. This is mainly relevant for functionals that use derivatives of the density or the orbitals, i.e. GGA and MGGA functionals.
add_dot_hessian(cache, *outputs)

Add contribution to the dot product of the Hessian with the trial delta DM.

The Hessian in this method is the second derivative of the observable towards the matrix elements of the density matrix or matrices. The dms and delta dms are stored in the cache.

Parameters:
  • cache – A cache object used to store intermediate results that can be reused or inspected later. All results specific for the detla_dm are stored with the tag ‘d’ in the cache object.
  • output2, .. (output1,) – Output objects, to which contributions from the dot product of the Hessian with the delta density matrices is added.
add_fock(cache, *focks)

Add contributions to the Fock matrix.

This method basically dispatches the work to all GridObservable instances in self.grid_terms.

Parameters:
  • cache (Cache) – Used to store intermediate results.
  • focks (list of TwoIndex) – A list of Fock matrices.
compute_energy(cache)

Compute the sum of the expectation values.

This method basically dispatches the work to all GridObservable instances in self.grid_terms.

Parameters:cache (Cache) – Used to store intermediate results.
df_level

The density-functional level of this grid group.

Returns:df_level – This can be any of the following:
  • DF_LEVEL_LDA: only LDA functionals are used.
  • DF_LEVEL_GGA: GGA (and LDA) functionals are used.
  • DF_LEVEL_MGGA: MGGA (and LDA and/or GGA) functionals are used.
Return type:int
class horton.meanfield.gridgroup.GridObservable(label)

Bases: object

Initialize a GridObservable.

Parameters:label (str) – A unique label for this contribution.
__init__(label)

Initialize a GridObservable.

Parameters:label (str) – A unique label for this contribution.
add_dot(cache, grid, *args)

Add a dot product with the kernel to the output arguments.

Parameters:
  • cache (Cache) – Used to share intermediate results between the compute and add_pot methods. This cache will also contain pre-computed functions evaluate on the grid. See RGridGroup and UGridGroup for more details.
  • grid (IntGrid) – A numerical integration grid.
  • args (list of [np.ndarray, shape=(npoint, npot), dtype=float]) – The result of this method is added to these output arguments. They are a list of dot arrays. (Only one array for the alpha density in case of restricted. Two arrays, one for alpha and one for beta electrons, in case of unrestricted.) To each array dot data will be added, e.g. the dot product of the density kernel with a change in density, the dot product of the gradient kernel with a change in gradient, etc.
add_pot(cache, grid, *args)

Add the potential to the output arguments.

Parameters:
  • cache (Cache) – Used to share intermediate results between the compute and add_pot methods. This cache will also contain pre-computed functions evaluate on the grid. See RGridGroup and UGridGroup for more details.
  • grid (IntGrid) – A numerical integration grid.
  • args (list of [np.ndarray, shape=(npoint, npot), dtype=float]) –

    A list of potential arrays. (Only one array for the alpha density in case of restricted. Two arrays, one for alpha and one for beta electrons, in case of unrestricted.) Each array contains potential data, e.g. derivatives of a density functional toward:

    • column 0: the density
    • columns 1,2,3: gradient (x, y, z)
    • column 4: Laplacian
    • column 5: kinetic energy density

    Later columns may not be present if the functional does not need them. They could be present when other terms in the effective Hamiltonian need them.

compute_energy(cache, grid)

Compute the expectation value using numerical integration.

Parameters:
  • cache (Cache) – Used to share intermediate results between the compute and add_pot methods. This cache will also contain pre-computed functions evaluate on the grid. See RGridGroup and UGridGroup for more details.
  • grid (IntGrid) – A numerical integration grid.
df_level = None