I am trying to compute the 2-electron reduced-density matrix (2-RDM) for a given quantum state with openfermion. The code is as follow
two_rdm = np.zeros((n_qubits,) * 4, dtype=complex)
psi = = openfermion.haar_random_vector(2 ** n_qubits, random_seed).astype(numpy.complex64)
for i, j, k, l in itertools.product(range(n_qubits), repeat=4):
transformed_operator = jordan_wigner(
FermionOperator(((i, 1), (j, 1), (k, 0), (l, 0))))
two_rdm[i, j, k, l] = openfermion.linalg.expectation(transformed_operator, psi)
The problem is with the last line, which gives the following exception
TypeError: can only concatenate str (not "ABCMeta") to str
After examning the source code, I figured out that the problem is with the [operator * state][1]
. Can anybody help to fix this?
converter
? You mention the packageopenfermion
, but it looks like you're actually using Qiskit Nature? $\endgroup$init_state
. But it's hard to diagnose without a minimal working example: stackoverflow.com/help/minimal-reproducible-example $\endgroup$