Composed Ansatz

In this section we show to merge two InQuanto ansatzes into a single ansatz object. This can be done using the ComposedAnsatz class: one just needs to pass the two ansatz objects to its constructor, with the order of parameters being the inverse of how their circuits are to be ordered with respect to each other.

For example, if one would like to perform a multi-reference generalized UCC calculation for a system of two electrons in four spin-orbitals, one could consider employing MultiConfigurationAnsatz to define a singly-excited multi-configuration reference state with variable parameters (CI coefficients), and combining it with an empty-reference FermionSpaceAnsatzUCCGD:

from inquanto.spaces import FermionSpace
from inquanto.states import FermionStateString, FermionState
from inquanto.mappings import QubitMappingJordanWigner
from inquanto.ansatzes import (
    MultiConfigurationAnsatz,
    FermionSpaceAnsatzUCCGD,
    ComposedAnsatz
)
from numpy import sqrt

space = FermionSpace(4)
fss_ref = FermionStateString([1, 1, 0, 0])
fss_1001 = FermionStateString([1, 0, 0, 1])
fss_0110 = FermionStateString([0, 1, 1, 0])
# Note: coefficients don't actually matter as we are building a symbolic ansatz.
fstate_multiconf = FermionState({fss_ref: sqrt(0.8), fss_1001: sqrt(0.1), fss_0110: sqrt(0.1)})

qubit_mapping = QubitMappingJordanWigner()
fstate_multiconf = qubit_mapping.state_map(fstate_multiconf)

ansatz_givens = MultiConfigurationAnsatz(fstate_multiconf.terms)
ansatz_uccgd = FermionSpaceAnsatzUCCGD(space, FermionState([0, 0, 0, 0]))
ansatz_multiref = ComposedAnsatz(ansatz_uccgd, ansatz_givens)

The Givens rotations of MultiConfigurationAnsatz will be applied to the circuit first, then the unitaries of the FermionSpaceAnsatzUCCGD part will be appended at the end. In this particular case the resulting multireference ansatz will be identical to a UCCGSD ansatz constructed from the HF reference state \(|1100\rangle\) and in the same Fock space as above. For more complicated Fock spaces one could cherry-pick some important reference states and use them in conjunction with a shallower UCC ansatz. Other use cases of combining various ansatzes can be easily envisaged.