ffsim.MolecularHamiltonianUnrestricted

class ffsim.MolecularHamiltonianUnrestricted(one_body_tensors, two_body_tensors, constant=0.0)[source]

Bases: SupportsApproximateEquality, SupportsDiagonal, SupportsFermionOperator, SupportsLinearOperator

A spin-unrestricted molecular Hamiltonian.

A Hamiltonian of the form

\[\begin{split}H = \sum_{\substack{pq \\ \sigma}} h^{\sigma}_{pq} a^\dagger_{p\sigma} a_{q\sigma} + \frac12 \sum_{pqrs} h^{\alpha\alpha}_{pqrs} a^\dagger_{p\alpha} a^\dagger_{r\alpha} a_{s\alpha} a_{q\alpha} + \sum_{pqrs} h^{\alpha\beta}_{pqrs} a^\dagger_{p\alpha} a^\dagger_{r\beta} a_{s\beta} a_{q\alpha} + \frac12 \sum_{pqrs} h^{\beta\beta}_{pqrs} a^\dagger_{p\beta} a^\dagger_{r\beta} a_{s\beta} a_{q\beta} + \text{constant}.\end{split}\]

Here \(h^{\alpha}\) and \(h^{\beta}\) are the one-body tensors and \(h^{\alpha\alpha}\), \(h^{\alpha\beta}\), and \(h^{\beta\beta}\) are the two-body tensors. The two-body tensors use chemist ordering, and their spin labels refer to the two pairs of indices: in \(h^{\alpha\beta}_{pqrs}\), the indices \(pq\) belong to spin alpha and the indices \(rs\) belong to spin beta.

Unlike MolecularHamiltonian, which uses a single one-body tensor and a single two-body tensor shared by both spin sectors, this class stores independent tensors for each spin sector. As a result, it can represent Hamiltonians that are not invariant under exchange of the spin alpha and spin beta orbitals, such as the result of applying a different orbital rotation to each spin sector. See rotated().

The beta-alpha two-body tensor is not stored because it is determined by the alpha-beta tensor:

\[h^{\beta\alpha}_{pqrs} = h^{\alpha\beta}_{rspq}.\]

Note that the alpha-beta term in the Hamiltonian above therefore appears with coefficient 1 rather than \(\frac12\), since the implicit beta-alpha term contributes the other half.

Attributes

constant

The constant.

norb

The number of spatial orbitals.

one_body_tensors

The one-body tensors \((h^{\alpha}, h^{\beta})\), as a single Numpy array of shape (2, norb, norb).

two_body_tensors

The two-body tensors \((h^{\alpha\alpha}, h^{\alpha\beta}, h^{\beta\beta})\), as a single Numpy array of shape (3, norb, norb, norb, norb).

constant: float = 0.0

The constant.

norb

The number of spatial orbitals.

one_body_tensors: ndarray

The one-body tensors \((h^{\alpha}, h^{\beta})\), as a single Numpy array of shape (2, norb, norb).

two_body_tensors: ndarray

The two-body tensors \((h^{\alpha\alpha}, h^{\alpha\beta}, h^{\beta\beta})\), as a single Numpy array of shape (3, norb, norb, norb, norb).

Methods

from_fermion_operator(op)

Initialize a MolecularHamiltonianUnrestricted from a FermionOperator.

rotated(orbital_rotation)

Return the Hamiltonian in a rotated orbital basis.

to_spinless()

Convert to a spinless molecular Hamiltonian.

static from_fermion_operator(op)[source]

Initialize a MolecularHamiltonianUnrestricted from a FermionOperator.

The input operator must contain only terms of the following form:

  • A real-valued constant

  • \(a^\dagger_{p\sigma} a_{q\sigma}\)

  • \(a^\dagger_{p\sigma}a^\dagger_{r\tau}a_{s\tau}a_{q\sigma}\)

Any other terms will cause an error to be raised. No attempt will be made to normal-order terms.

Unlike MolecularHamiltonian.from_fermion_operator(), the coefficients of the spin alpha and spin beta terms are stored independently rather than averaged, so spin-dependent operators are represented exactly.

Parameters:

op (FermionOperator) – The FermionOperator from which to initialize the Hamiltonian.

Return type:

MolecularHamiltonianUnrestricted

Returns:

The MolecularHamiltonianUnrestricted represented by the input FermionOperator.

rotated(orbital_rotation)[source]

Return the Hamiltonian in a rotated orbital basis.

Given an orbital rotation \(\mathcal{U}\), returns the operator

\[\mathcal{U} H \mathcal{U}^\dagger\]

where \(H\) is the original Hamiltonian.

Parameters:

orbital_rotation (ndarray | tuple[ndarray | None, ndarray | None]) – The orbital rotation. You can pass either a single Numpy array specifying the orbital rotation to apply to both spin sectors, or you can pass a pair of Numpy arrays specifying independent orbital rotations for spin alpha and spin beta. If passing a pair, you can use None for one of the values in the pair to indicate that no operation should be applied to that spin sector.

Return type:

MolecularHamiltonianUnrestricted

Returns:

The rotated Hamiltonian.

to_spinless()[source]

Convert to a spinless molecular Hamiltonian.

Returns a MolecularHamiltonianSpinless on 2 * norb orbitals representing the same Hamiltonian, with the spin alpha orbitals occupying the first norb orbitals and the spin beta orbitals the last norb orbitals.

Return type:

MolecularHamiltonianSpinless

Returns:

The spinless molecular Hamiltonian.