Hamiltonian

Submodules

paulis module

Convenience initialization of Pauli Operators. Resulting structures can be added and multiplied together. Currently uses OpenFermion as backend (QubitOperators)

tequila_code.hamiltonian.paulis.I(*args, **kwargs) QubitHamiltonian[source]

Initialize unit Operator

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.KetBra(ket: QubitWaveFunction, bra: QubitWaveFunction, hermitian: bool = False, threshold: float = 1e-06, n_qubits=None)[source]

Notes

Initialize the general KetBra operator .. math:

H = \lvert ket \rangle \langle bra \rvert

e.g. wfn1 = tq.QubitWaveFunction.from_string(“1.0*|00> + 1.0*|11>”).normalize() wfn2 = tq.QubitWaveFunction.from_string(“1.0*|00>”) operator = tq.paulis.KetBra(ket=wfn1, bra=wfn1) initializes the transfer operator from the all-zero state to a Bell state

Parameters:
  • ket (QubitWaveFunction:) – QubitWaveFunction which defines the ket element can also be given as string or array or integer

  • bra (QubitWaveFunction:) – QubitWaveFunction which defines the bra element can also be given as string or array or integer

  • hermitian (bool: (Default False)) – if True the hermitian version H + H^dagger is returned

  • threshold (float: (Default 1.e-6)) – elements smaller than the threshold will be ignored

  • n_qubits (only needed if ket and/or bra are passed down as integers)

Returns:

a tequila QubitHamiltonian (not necessarily hermitian) representing the KetBra operator desired.

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.Projector(wfn, threshold=0.0, n_qubits=None) QubitHamiltonian[source]

Notes

Initialize a projector given by

\[H = \lvert \Psi \rangle \langle \Psi \rvert\]
Parameters:

wfn (QubitWaveFunction or int, or string, or array :) – The wavefunction onto which the projector projects Needs to be passed down as tequilas QubitWaveFunction type See the documentation on how to initialize a QubitWaveFunction from integer, string or array (can also be passed down diretly as one of those types)

threshold: float: (Default value = 0.0)

neglect small parts of the operator

n_qubits: only needed when an integer is given as wavefunction

tequila_code.hamiltonian.paulis.Qm(qubit) QubitHamiltonian[source]

Notes

Initialize

\[\frac{1}{2} \left( 1 + \sigma_z \right)\]
Parameters:

qubit (int or list of ints) – qubit(s) on which the operator should act

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.Qp(qubit) QubitHamiltonian[source]

Notes

Initialize

\[\frac{1}{2} \left( 1 - \sigma_z \right)\]
Parameters:

qubit (int or list of ints) – qubit(s) on which the operator should act

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.Sm(qubit) QubitHamiltonian[source]

Notes

Initialize

\[\frac{1}{2} \left( \sigma_x - i \sigma_y \right)\]
Parameters:

qubit (int or list of ints) – qubit(s) on which the operator should act

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.Sp(qubit) QubitHamiltonian[source]

Notes

Initialize

\[\frac{1}{2} \left( \sigma_x + i\sigma_y \right)\]
Parameters:

qubit (int or list of ints) – qubit(s) on which the operator should act

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.X(qubit) QubitHamiltonian[source]

Initialize a single Pauli X Operator

Parameters:

qubit (int or list of ints) – qubit(s) on which the operator should act

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.Y(qubit) QubitHamiltonian[source]

Initialize a single Pauli Y Operator

Parameters:

qubit (int or list of ints) – qubit(s) on which the operator should act

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.Z(qubit) QubitHamiltonian[source]

Initialize a single Pauli Z Operator

Parameters:

qubit (int or list of ints) – qubit(s) on which the operator should act

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.Zero(*args, **kwargs) QubitHamiltonian[source]

Initialize 0 Operator

Return type:

QubitHamiltonian

tequila_code.hamiltonian.paulis.decompose_transfer_operator(ket: BitString, bra: BitString, qubits: List[int] = None) QubitHamiltonian[source]

Notes

Create the operator

Note that this is operator is not necessarily hermitian So be careful when using it as a generator for gates

e.g. decompose_transfer_operator(ket=”01”, bra=”10”, qubits=[2,3]) gives the operator

\[\lvert 01 \rangle \langle 10 \rvert_{2,3}\]

acting on qubits 2 and 3

Parameters:
  • ket (pass an integer, string, or tequila BitString)

  • bra (pass an integer, string, or tequila BitString)

  • qubits (pass the qubits onto which the operator acts)

tequila_code.hamiltonian.paulis.from_string(string, openfermion_format=False)[source]
tequila_code.hamiltonian.paulis.pauli(qubit, type) QubitHamiltonian[source]
Parameters:
  • qubit (int or list of ints)

  • type (str or int or list of strquaing or int:) – define if X, Y or Z (0,1,2)

Return type:

QubitHamiltonian

paulistring module

qubit-hamiltonian module

Module contents