We're celebrating World Quantum Day 2022! Join us

openfermion.linalg.get_number_preserving_sparse_operator

Initialize a Scipy sparse matrix in a specific symmetry sector.

This method initializes a Scipy sparse matrix from a FermionOperator, explicitly working in a particular particle number sector. Optionally, it can also restrict the space to contain only states with a particular Sz.

Finally, the Hilbert space can also be restricted to only those states which are reachable by excitations up to a fixed rank from an initial reference determinant.

fermion_op(FermionOperator): An instance of the FermionOperator class. It should not contain terms which do not preserve particle number. If spin_preserving is set to True it should also not contain terms which do not preserve the Sz (it is assumed that the ordering of the indices goes alpha, beta, alpha, beta, ...). num_qubits(int): The total number of qubits / spin-orbitals in the system. num_electrons(int): The number of particles in the desired Hilbert space. spin_preserving(bool): Whether or not the constructed operator should be defined in a space which has support only on states with the same Sz value as the reference_determinant. reference_determinant(list(bool)): A list, whose length is equal to num_qubits, which specifies which orbitals should be occupied in the reference state. If spin_preserving is set to True then the Sz value of this reference state determines the Sz value of the symmetry sector in which the generated operator acts. If a value for excitation_level is provided then the excitations are generated with respect to the reference state. In any case, the ordering of the states in the matrix representation of the operator depends on reference_determinant and the state corresponding to reference_determinant is the vector [1.0, 0.0, 0.0 ... 0.0]. Can be set to None in order to take the first num_electrons orbitals to be the occupied orbitals. excitation_level(int): The number of excitations from the reference state which should be included in the generated operator's matrix representation. Can be set to None to include all levels of excitation.

sparse_op(scipy.sparse.csc_matrix): A sparse matrix representation of fermion_op in the basis set by the arguments.