3.7.9. horton.meanfield.observable – Base classes for energy terms and other observables of the wavefunction

class horton.meanfield.observable.Observable(label)

Bases: object

Initialize an Observable instance.

Parameters:label (str) – A short string to identify the observable.
__init__(label)

Initialize an Observable instance.

Parameters:label (str) – A short string to identify the observable.
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 matrices.

Parameters:
  • cache (Cache) – Used to store intermediate results that can be reused or inspected later.
  • fock2, .. (fock1,) – A list of output Fock operators. The caller is responsible for setting these operators initially to zero (if desired).
compute_energy(cache)

Compute the expectation value of the observable.

Parameters:cache (Cache) – Used to store intermediate results that can be reused or inspected later.
class horton.meanfield.observable.RTwoIndexTerm(op_alpha, label)

Bases: horton.meanfield.observable.Observable

Initialize a RTwoIndexTerm instance.

Parameters:
  • op_alpha (TwoIndex) – Expansion of one-body operator in basis of alpha orbitals. Same is used for beta.
  • label (str) – A short string to identify the observable.
__init__(op_alpha, label)

Initialize a RTwoIndexTerm instance.

Parameters:
  • op_alpha (TwoIndex) – Expansion of one-body operator in basis of alpha orbitals. Same is used for beta.
  • label (str) – A short string to identify the observable.
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, fock_alpha)

Add contributions to the Fock matrices.

Parameters:
  • cache (Cache) – Used to store intermediate results that can be reused or inspected later.
  • fock2, .. (fock1,) – A list of output Fock operators. The caller is responsible for setting these operators initially to zero (if desired).
compute_energy(cache)

Compute the expectation value of the observable.

Parameters:cache (Cache) – Used to store intermediate results that can be reused or inspected later.
class horton.meanfield.observable.UTwoIndexTerm(op_alpha, label, op_beta=None)

Bases: horton.meanfield.observable.Observable

Initialize a RTwoIndexTerm instance.

Parameters:
  • op_alpha (TwoIndex) – Expansion of one-body operator in basis of alpha orbitals.
  • label (str) – A short string to identify the observable.
  • op_beta (TwoIndex) – Expansion of one-body operator in basis of beta orbitals. When not given, op_alpha is used.
__init__(op_alpha, label, op_beta=None)

Initialize a RTwoIndexTerm instance.

Parameters:
  • op_alpha (TwoIndex) – Expansion of one-body operator in basis of alpha orbitals.
  • label (str) – A short string to identify the observable.
  • op_beta (TwoIndex) – Expansion of one-body operator in basis of beta orbitals. When not given, op_alpha is used.
add_dot_hessian(cache, output_alpha, output_beta)

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, fock_alpha, fock_beta)

Add contributions to the Fock matrices.

Parameters:
  • cache (Cache) – Used to store intermediate results that can be reused or inspected later.
  • fock2, .. (fock1,) – A list of output Fock operators. The caller is responsible for setting these operators initially to zero (if desired).
compute_energy(cache)

Compute the expectation value of the observable.

Parameters:cache (Cache) – Used to store intermediate results that can be reused or inspected later.
class horton.meanfield.observable.RDirectTerm(op_alpha, label)

Bases: horton.meanfield.observable.Observable

Initialize a RDirectTerm instance.

Parameters:
  • op_alpha (FourIndex) – Expansion of two-body operator in basis of alpha orbitals. Same is used for beta orbitals.
  • label (str) – A short string to identify the observable.
__init__(op_alpha, label)

Initialize a RDirectTerm instance.

Parameters:
  • op_alpha (FourIndex) – Expansion of two-body operator in basis of alpha orbitals. Same is used for beta orbitals.
  • label (str) – A short string to identify the observable.
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, fock_alpha)

Add contributions to the Fock matrices.

Parameters:
  • cache (Cache) – Used to store intermediate results that can be reused or inspected later.
  • fock2, .. (fock1,) – A list of output Fock operators. The caller is responsible for setting these operators initially to zero (if desired).
compute_energy(cache)

Compute the expectation value of the observable.

Parameters:cache (Cache) – Used to store intermediate results that can be reused or inspected later.
class horton.meanfield.observable.UDirectTerm(op_alpha, label, op_beta=None)

Bases: horton.meanfield.observable.Observable

Initialize a UDirectTerm instance.

Parameters:
  • op_alpha (FourIndex) – Expansion of two-body operator in basis of alpha orbitals.
  • label (str) – A short string to identify the observable.
  • op_beta (FourIndex) – Expansion of two-body operator in basis of beta orbitals. When not given, op_alpha is used.
__init__(op_alpha, label, op_beta=None)

Initialize a UDirectTerm instance.

Parameters:
  • op_alpha (FourIndex) – Expansion of two-body operator in basis of alpha orbitals.
  • label (str) – A short string to identify the observable.
  • op_beta (FourIndex) – Expansion of two-body operator in basis of beta orbitals. When not given, op_alpha is used.
add_dot_hessian(cache, output_alpha, output_beta)

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, fock_alpha, fock_beta)

Add contributions to the Fock matrices.

Parameters:
  • cache (Cache) – Used to store intermediate results that can be reused or inspected later.
  • fock2, .. (fock1,) – A list of output Fock operators. The caller is responsible for setting these operators initially to zero (if desired).
compute_energy(cache)

Compute the expectation value of the observable.

Parameters:cache (Cache) – Used to store intermediate results that can be reused or inspected later.
class horton.meanfield.observable.RExchangeTerm(op_alpha, label, fraction=1.0)

Bases: horton.meanfield.observable.Observable

Initialize a RExchangeTerm instance.

Parameters:
  • op_alpha (FourIndex) – Expansion of two-body operator in basis of alpha orbitals. Same is used for beta orbitals.
  • fraction (float) – Amount of exchange to be included (1.0 corresponds to 100%).
  • label (str) – A short string to identify the observable.
__init__(op_alpha, label, fraction=1.0)

Initialize a RExchangeTerm instance.

Parameters:
  • op_alpha (FourIndex) – Expansion of two-body operator in basis of alpha orbitals. Same is used for beta orbitals.
  • fraction (float) – Amount of exchange to be included (1.0 corresponds to 100%).
  • label (str) – A short string to identify the observable.
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, fock_alpha)

Add contributions to the Fock matrices.

Parameters:
  • cache (Cache) – Used to store intermediate results that can be reused or inspected later.
  • fock2, .. (fock1,) – A list of output Fock operators. The caller is responsible for setting these operators initially to zero (if desired).
compute_energy(cache)

Compute the expectation value of the observable.

Parameters:cache (Cache) – Used to store intermediate results that can be reused or inspected later.
class horton.meanfield.observable.UExchangeTerm(op_alpha, label, fraction=1.0, op_beta=None)

Bases: horton.meanfield.observable.Observable

Initialize a UExchangeTerm instance.

Parameters:
  • op_alpha (FourIndex) – Expansion of two-body operator in basis of alpha orbitals.
  • label (str) – A short string to identify the observable.
  • fraction (float) – Amount of exchange to be included (1.0 corresponds to 100%).
  • op_beta (FourIndex) – Expansion of two-body operator in basis of beta orbitals. When not given, op_alpha is used.
__init__(op_alpha, label, fraction=1.0, op_beta=None)

Initialize a UExchangeTerm instance.

Parameters:
  • op_alpha (FourIndex) – Expansion of two-body operator in basis of alpha orbitals.
  • label (str) – A short string to identify the observable.
  • fraction (float) – Amount of exchange to be included (1.0 corresponds to 100%).
  • op_beta (FourIndex) – Expansion of two-body operator in basis of beta orbitals. When not given, op_alpha is used.
add_dot_hessian(cache, output_alpha, output_beta)

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, fock_alpha, fock_beta)

Add contributions to the Fock matrices.

Parameters:
  • cache (Cache) – Used to store intermediate results that can be reused or inspected later.
  • fock2, .. (fock1,) – A list of output Fock operators. The caller is responsible for setting these operators initially to zero (if desired).
compute_energy(cache)

Compute the expectation value of the observable.

Parameters:cache (Cache) – Used to store intermediate results that can be reused or inspected later.
horton.meanfield.observable.compute_dm_full(cache, prefix=”, tags=None)

Add the spin-summed density matrix to the cache unless it is already present.

Parameters:
  • cache (Cache) – Used to store intermediate results that can be reused or inspected later.
  • prefix (str) – A prefix, in case one wants to load a special density matrix and store the results in a special place. The typical use case is the delta_ prefix which is used to process a change in density.
  • tags (str) – The tags to use for the cache when allocating the arrays. In case of changes in density matrices, this argument is typically equal to ‘d’.