Hamiltonians

Define a class for Markov chain infidelity Hamiltonians.

class vulqano.hamiltonians.MCHamiltonian(hamiltonian_operator, dim, is_continuous)[source]

Class for continuous and discrete MC Hamiltonians encoding infidelity.

The dictionary in input define the Hamiltonian. While in the input Hamiltonian the gates are encoded as strings, in Markov chain Hamiltonian the gates are labeled by integers. This different encoding allows to more quickly count a subciruit with a given cost appears in the circuit state.

Arguments

hamiltonian_operatorlist of (np.array of strings, float, mask)

Abstract description of the Hamiltonian. The energy is obtained by counting how many times each subcircuit hamiltonian_operator[i][0] appears on a region A of the circuit suck that that hamiltonian_operator[i][2] is True for all (t,q) in A. The counted number is multiplied by the weight hamiltonian_operator[i][1].

dimint

Number of dimension of the circuit state on which the Hamiltonian acts, i.e. 1 + number of dimensions of the qubits lattice.

is_continuousbool

If true the Hamiltonian acts on continuous states. If false it acts on discrete states.

Attributes

hamiltonian_operatorlist of (np.array of ints, np.array of floats)

Abstract description of the Hamiltonian. The energy is obtained as E = sum_i sum_{t,q} IS(hamiltonian_operator[i][0](t,q))*

hamiltonian_operator[i][1](t,q)

Where IS(hamiltonian_operator[i][0](t,q)) checks if the subcircuit hamiltonian_operator[i][0] is appears on the site (t,q) of the circuit state.

dimint

Number of dimension of the circuit state on which the Hamiltonian acts, i.e. 1 + number of dimensions of the qubits lattice.

interactions_range(int,int)

A tuple with two ints, respectively corresponding to the interaction range (the maximum distance between interacting gates of the time-qubits lattice) in the time and qubits directions.

is_continuousbool

If true the Hamiltonian acts on continuous states. If false it acts on discrete states.

get_energy(state_vector, position=None)[source]

Returns the energy associated by the Hamiltonian to a (sub)circuit state.

Arguments

state_vectornumpy.array of ints

A vector representing the circuit (or subcircuit) state.

positiontuple ints or None, optional

Position of the first gate of the subcircuit in the global circuit state. If None the position is (0,…,0). Default is None.

Returns

energyfloat

The expectation value of the Hamiltonian (infidelity cost).

get_energy_diff(state_vector, transition)[source]

Returns the energy difference generated in the circuit by appliyng a rule that repleces a subcircuit in a given region.

Arguments

state_vectornp.array of strings

A vector representing the circuit state.

transition(window, (rule, direction))

Description of the transition to be applied-> window : touple of ints

Region of the circuit where the transition rule applies: (t_min,q1_min,q2_min,…,t_max,q1_max,q2_max,… )

ruleDiscreteMCRule

Transformation rule to apply.

directionbool

Direction of the transformation rule: True for state_a->state_b, False for state_b->state_a.

Returns

energy_difffloat

Energy after the transition - energy before the transition.

transition_instructions(np array of ints, mask)

Matrix representing the new subcircuit. Where the mask is true, the gate is not raplaced.