View source on GitHub |
Class for storing Hamiltonians that are quadratic in the fermionic ladder operators.
Inherits From: PolynomialTensor
openfermion.ops.QuadraticHamiltonian(
hermitian_part,
antisymmetric_part=None,
constant=0.0,
chemical_potential=0.0
)
Used in the notebooks
Used in the tutorials |
---|
The operators stored in this class take the form
$$ \sum{p, q} (M{pq} - \mu \delta_{pq}) a^\dagger_p a_q
+ \frac12 \sum_{p, q}
(\Delta_{pq} a^\dagger_p a^\dagger_q + \text{h.c.})
+ \text{constant}
$$
where
- \\(M\\) is a Hermitian `n_qubits` x `n_qubits` matrix.
- \\(\Delta\\) is an antisymmetric `n_qubits` x `n_qubits` matrix.
- \\(\mu\\) is a real number representing the chemical potential.
- \\(\delta_{pq}\\) is the Kronecker delta symbol.
We separate the chemical potential \(\mu\) from \(M\) so that we can use it to adjust the expectation value of the total number of particles.
Methods
add_chemical_potential
add_chemical_potential(
chemical_potential
)
Increase (or decrease) the chemical potential by some value.
diagonalizing_bogoliubov_transform
diagonalizing_bogoliubov_transform(
spin_sector=None
)
Compute the unitary that diagonalizes a quadratic Hamiltonian.
Any quadratic Hamiltonian can be rewritten in the form
\[ \sum_{j} \varepsilon_j b^\dagger_j b_j + \text{constant}, \]
where the \(b^\dagger_j\) are a new set fermionic creation operators that satisfy the canonical anticommutation relations. The new creation operators are linear combinations of the original ladder operators. In the most general case, creation and annihilation operators are mixed together:
\[ \begin{pmatrix} b^\dagger_1 \\ \vdots \\ b^\dagger_N \\ \end{pmatrix} = W \begin{pmatrix} a^\dagger_1 \\ \vdots \\ a^\dagger_N \\ a_1 \\ \vdots \\ a_N \end{pmatrix}, \]
where \(W\) is an \(N \times (2N)\) matrix. However, if the Hamiltonian conserves particle number then creation operators don't need to be mixed with annihilation operators and \(W\) only needs to be an \(N \times N\) matrix:
\[ \begin{pmatrix} b^\dagger_1 \\ \vdots \\ b^\dagger_N \\ \end{pmatrix} = W \begin{pmatrix} a^\dagger_1 \\ \vdots \\ a^\dagger_N \\ \end{pmatrix}, \]
This method returns the matrix \(W\).
Args | |
---|---|
spin_sector
|
optional str
An optional integer specifying a spin sector to restrict to: 0 for spin-up and 1 for spin-down. Should only be specified if the Hamiltonian includes a spin degree of freedom and spin-up modes do not interact with spin-down modes. If specified, the modes are assumed to be ordered so that spin-up orbitals come before spin-down orbitals. |
Returns | |
---|---|
orbital_energies(ndarray) A one-dimensional array containing the \(\varepsilon_j\) | |
diagonalizing_unitary
|
ndarray
constant(float) The constant |
diagonalizing_circuit
diagonalizing_circuit()
Get a circuit for a unitary that diagonalizes this Hamiltonian
This circuit performs the transformation to a basis in which the Hamiltonian takes the diagonal form
\[ \sum_{j} \varepsilon_j b^\dagger_j b_j + \text{constant}. \]
Returns
circuit_description (list[tuple]):
A list of operations describing the circuit. Each operation
is a tuple of objects describing elementary operations that
can be performed in parallel. Each elementary operation
is either the string 'pht' indicating a particle-hole
transformation on the last fermionic mode, or a tuple of
the form \\((i, j, \theta, \varphi)\\),
indicating a Givens rotation
of modes \\(i\\) and \\(j\\) by angles \\(\theta\\)
and \\(\varphi\\).
ground_energy
ground_energy()
Return the ground energy.
majorana_form
majorana_form()
Return the Majorana represention of the Hamiltonian.
Any quadratic Hamiltonian can be written in the form
\[ \frac{i}{2} \sum_{j, k} A_{jk} f_j f_k + \text{constant} \]
where the \(f_i\) are normalized Majorana fermion operators:
\(\) f_j = \frac{1}{\sqrt{2} } (a^\dagger_j + a_j)
f_{j + N} = \frac{i}{\sqrt{2} } (a^\dagger_j - a_j)
\(\)
and \(A\) is a (2 * n_qubits
) x (2 * n_qubits
) real
antisymmetric matrix. This function returns the matrix
\(A\) and the constant.
orbital_energies
orbital_energies(
non_negative=False
)
Return the orbital energies.
Any quadratic Hamiltonian is unitarily equivalent to a Hamiltonian of the form
\[ \sum_{j} \varepsilon_j b^\dagger_j b_j + \text{constant}. \]
We call the \(\varepsilon_j\) the orbital energies. The eigenvalues of the Hamiltonian are sums of subsets of the orbital energies (up to the additive constant).
Args | |
---|---|
non_negative
|
bool
If True, always return a list of orbital energies that are non-negative. This option is ignored if the Hamiltonian does not conserve particle number, in which case the returned orbital energies are always non-negative. |
Returns
orbital_energies(ndarray) A one-dimensional array containing the \(\varepsilon_j\) constant(float) The constant
projected_n_body_tensors
projected_n_body_tensors(
selection, exact=False
)
Keep only selected elements.
Args | |
---|---|
selection
|
Union[int, Iterable[int]
If int, keeps terms with at most (exactly, if exact is True) that many unique indices. If iterable, keeps only terms containing (all of, if exact is True) the specified indices. |
exact
|
bool
Whether or not the selection is strict. |
rotate_basis
rotate_basis(
rotation_matrix
)
Rotate the orbital basis of the PolynomialTensor.
Args | |
---|---|
rotation_matrix
|
A square numpy array or matrix having dimensions of n_qubits by n_qubits. Assumed to be real and invertible. |
with_function_applied_elementwise
with_function_applied_elementwise(
func
)
__add__
__add__(
addend
)
__eq__
__eq__(
other
)
Return self==value.
__getitem__
__getitem__(
args
)
Look up matrix element.
Args | |
---|---|
args
|
Tuples indicating which coefficient to get. For instance,
my_tensor[(6, 1), (8, 1), (2, 0)]
returns
my_tensor.n_body_tensors[1, 1, 0][6, 8, 2]
|
__iter__
__iter__()
Iterate over non-zero elements of PolynomialTensor.
__mod__
__mod__(
other
)
__mul__
__mul__(
multiplier
)
__ne__
__ne__(
other
)
Return self!=value.
__neg__
__neg__()
__radd__
__radd__(
addend
)
__rmul__
__rmul__(
multiplier
)
__rsub__
__rsub__(
subtrahend
)
__sub__
__sub__(
subtrahend
)
__truediv__
__truediv__(
dividend
)