mindquantum.simulator.mqchem.SequentialUCCAnsatz

View Source On AtomGit
class mindquantum.simulator.mqchem.SequentialUCCAnsatz(n_qubits=None, n_electrons=None)[source]

Sequential Unitary Coupled-Cluster (UCC) Ansatz.

This class allows constructing a UCC ansatz by adding excitation operators sequentially. Unlike FermionOperator which merges terms with the same index, this class preserves the order and distinctness of each added term, enabling the construction of multi-layer or Trotterized ansatzes where the same excitation operator may appear multiple times with different parameters.

Note

The generated circuit uses UCCExcitationGate, which is intended for MQChemSimulator.

Parameters
  • n_qubits (int) – The number of qubits (spin-orbitals) in the simulation. Default: None.

  • n_electrons (int) – The number of electrons of the given molecule. Default: None.

Examples

>>> from mindquantum.simulator import mqchem
>>> from mindquantum.core.operators import FermionOperator
>>> ansatz = mqchem.SequentialUCCAnsatz()
>>> ansatz.append(FermionOperator("3^ 1", "a"))
>>> ansatz.append(FermionOperator("4^ 2", "b"))
>>> ansatz.append(FermionOperator("3^ 1", "c"))
>>> print(len(ansatz.circuit))
3
>>> print(ansatz.circuit.params_name)
['a', 'b', 'c']
append(operator)[source]

Append a FermionOperator to the ansatz.

Parameters

operator (FermionOperator) – The excitation operator to add. Must have exactly one term.

property circuit: mindquantum.core.circuit.circuit.Circuit

Get the generated ansatz circuit.

property operators

Return the list of operators in the ansatz.

remove(index)[source]

Remove and return the operator at the specified index.

Parameters

index (int) – The index of the operator to remove.

Returns

FermionOperator, the removed operator.