quantumlib / OpenFermion

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

Query about function uccsd_singlet_paramsize #742

Closed ChrisW918 closed 3 years ago

ChrisW918 commented 3 years ago

Hi,

I was testing the ansatz generated by unitary_cc, and want to know the parameter size for a built ccsd circuit.

I saw a function _uccsd_singlet_paramsize( n_qubits, ne), is this my expectated function, namely, return the size of a parameter vector which later is used in optimization?

Following is the code I used

geometry=[('H', (.0, .0, .0)),
         ('H', (.0, .0, .74))]
basis='sto-3g'
multiplicity=1
charge=0
molecule=openfermion.MolecularData(geometry,
                                  basis,
                                  multiplicity,
                                  )
molecule.load()
print(molecule.n_electrons)
print(molecule.n_qubits)
print(uccsd_singlet_paramsize(4, 2))

2 4 2

ncrubin commented 3 years ago

yup! that's the number of parameters for restricted UCCSD. The function definition is pretty clear (https://github.com/quantumlib/OpenFermion/blob/8ef0c8bcadf6c284e854449f30878d776d53e016/src/openfermion/circuits/unitary_cc.py#L106). You can see we are adding together the number of single UCC amplitudes and doubles UCC amplitudes. Since we are working with a restricted ansatz we consider spin-free excitation operators (thus the computations with spatial orbitals).