quantumlib / OpenFermion

The electronic structure package for quantum computers.
Apache License 2.0
1.51k stars 372 forks source link

Help with one-body and two-body coefficients for orbital removal #810

Open buttercutter opened 1 year ago

buttercutter commented 1 year ago

Cross-referenced from https://github.com/tencent-quantum-lab/tensorcircuit/issues/120 which uses openfermion.chem library

I am trying to migrate vqe_h2o.ipynb to use CO2 carbon dioxide molecule.

Note: Another relevant issues would be https://github.com/quantumlib/OpenFermion/issues/744 and https://github.com/pyscf/pyscf/issues/1202#issuecomment-1416736671 which use another method to retrieve one-body and two-body terms.

  1. For print(fh.terms[((0, 1), (0, 0))]) which is the two-body coefficients, it gives -36.01932840424451. When I try to access the one-body coefficients using the following code snippet, nothing is printed out. Could you advise how to decide which orbitals to be removed for CO2 ? The video comes with a notebook code which no longer runs since it is using deprecated qiskit-chemistry package.
one_body_terms = fh.terms
for term, coefficient in one_body_terms.items():
    if len(term) == 2:
        # Only consider terms with one creation and one annihilation operator
        i, j = term
        if i[0] == "c" and j[0] == "c":
            print("Term: c^\dagger_{} c_{} Coefficient: {}".format(i[1], j[1], coefficient))
  1. Besides, the kernel crashes when running ma = tc.quantum.PauliStringSum2COO_numpy(lsa, wa)

image

image