ffsim.MolecularHamiltonianUnrestricted¶
- class ffsim.MolecularHamiltonianUnrestricted(one_body_tensors, two_body_tensors, constant=0.0)[source]¶
Bases:
SupportsApproximateEquality,SupportsDiagonal,SupportsFermionOperator,SupportsLinearOperatorA 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. Seerotated().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
The constant.
The number of spatial orbitals.
The one-body tensors \((h^{\alpha}, h^{\beta})\), as a single Numpy array of shape
(2, norb, norb).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).- 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
Initialize a MolecularHamiltonianUnrestricted from a FermionOperator.
rotated(orbital_rotation)Return the Hamiltonian in a rotated orbital basis.
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:
- 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 useNonefor one of the values in the pair to indicate that no operation should be applied to that spin sector.- Return type:
- Returns:
The rotated Hamiltonian.
- to_spinless()[source]¶
Convert to a spinless molecular Hamiltonian.
Returns a
MolecularHamiltonianSpinlesson2 * norborbitals representing the same Hamiltonian, with the spin alpha orbitals occupying the firstnorborbitals and the spin beta orbitals the lastnorborbitals.- Return type:
- Returns:
The spinless molecular Hamiltonian.