mindquantum.core.operators.TimeEvolution

View Source On Gitee
class mindquantum.core.operators.TimeEvolution(ops: QubitOperator, time=None)[source]

The time evolution operator that can generate a corresponded circuit.

The time evolution operator will do the following evolution:

\[\left|\varphi(t)\right>=e^{-iHt}\left|\varphi(0)\right>\]

Note

The hamiltonian should be a parameterized or non parameterized QubitOperator. If the QubitOperator has multiple terms, the first order trotter decomposition will be used.

Parameters
  • ops (QubitOperator) – The qubit operator hamiltonian, could be parameterized or non parameterized.

  • time (Union[numbers.Number, dict, ParameterResolver]) – The evolution time, could be a number or a parameter resolver. If None, the time will be set to 1. Default: None.

Examples

>>> from mindquantum.core.operators import TimeEvolution, QubitOperator
>>> q1 = QubitOperator('Z0 Y1', 'a')
>>> q2 = QubitOperator('X0 Z1', 'b')
>>> ops1 = q1 + q2
>>> ops2 = q2 + q1
>>> TimeEvolution(ops1).circuit
                                          ┏━━━┓                                ┏━━━┓
q0: ────────────────■─────────────────■───┨ H ┠──────────■─────────────────■───┨ H ┠───
                    ┃                 ┃   ┗━━━┛          ┃                 ┃   ┗━━━┛
      ┏━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━┓ ┏━┻━┓
q1: ──┨ RX(π/2) ┠─┨╺╋╸┠─┨ RZ(2*a) ┠─┨╺╋╸┠─┨ RX(7π/2) ┠─┨╺╋╸┠─┨ RZ(2*b) ┠─┨╺╋╸┠─────────
      ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━┛ ┗━━━┛
>>> TimeEvolution(ops2).circuit
      ┏━━━┓                         ┏━━━┓
q0: ──┨ H ┠───■─────────────────■───┨ H ┠─────────■─────────────────■──────────────────
      ┗━━━┛   ┃                 ┃   ┗━━━┛         ┃                 ┃
            ┏━┻━┓ ┏━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━━┓
q1: ────────┨╺╋╸┠─┨ RZ(2*b) ┠─┨╺╋╸┠─┨ RX(π/2) ┠─┨╺╋╸┠─┨ RZ(2*a) ┠─┨╺╋╸┠─┨ RX(7π/2) ┠───
            ┗━━━┛ ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━━┛
property circuit

Get the first order trotter decomposition circuit of this time evolution operator.