penny lane hamiltonian attempt - RPIQuantumComputing/QuantumCircuits GitHub Wiki

import pennylane as qml from pennylane import numpy as np

Create wires for the system

system = range(4)

The generator of the group

c = qml.Permute([3, 0, 1, 2], wires=system) c_mat = qml.matrix(c)

Create Hamiltonians

obs = [qml.PauliX(system[0]), qml.PauliX(system[1]), qml.PauliX(system[2]), qml.PauliX(system[3])] coeffs1, coeffs2, coeffs3 = [1, 1, 1, 1], [1, 1.1, 0.9, 1], [1, 2, 3, 0] Hsymm, Hnsym, Hasym = ( qml.Hamiltonian(coeffs1, obs), qml.Hamiltonian(coeffs2, obs), qml.Hamiltonian(coeffs3, obs), )

Create copy of the system

copy = range(4, 8)

Prepare entangled state on system and copy

def prep_entangle(): for wire in system: qml.Hadamard(wire) qml.CNOT(wires=[wire, wire + 4])

Use Choi-Jamiołkowski isomorphism

def choi_state(hamiltonian, time): prep_entangle() qml.CommutingEvolution(hamiltonian, time)

Create group register and device

aux = range(8, 10) dev = qml.device("lightning.qubit", wires=10)

Create plus state

def prep_plus(): qml.Hadamard(wires=aux[0]) qml.Hadamard(wires=aux[1])

Implement controlled symmetry operations on system

def CU_sys(): qml.ControlledQubitUnitary(c_mat @ c_mat, control_wires=[aux[0]], wires=system) qml.ControlledQubitUnitary(c_mat, control_wires=[aux[1]], wires=system)

Implement controlled symmetry operations on copy

def CU_cpy(): qml.ControlledQubitUnitary(c_mat @ c_mat, control_wires=[aux[0]], wires=copy) qml.ControlledQubitUnitary(c_mat, control_wires=[aux[1]], wires=copy)

Circuit for average symmetry

@qml.qnode(dev, interface="autograd") def avg_symm(hamiltonian, time):

# Use Choi-Jamiołkowski isomorphism
choi_state(hamiltonian, time)

# Apply controlled symmetry operations
prep_plus()
CU_sys()
CU_cpy()

# Ready register for measurement
prep_plus()

return qml.probs(wires=aux)

print("For Hamiltonian Hsymm, the |+> state is observed with probability", avg_symm(Hsymm, 1)[0], ".") print("For Hamiltonian Hnsym, the |+> state is observed with probability", avg_symm(Hnsym, 1)[0], ".") print("For Hamiltonian Hasym, the |+> state is observed with probability", avg_symm(Hasym, 1)[0], ".")

Define asymmetry circuit

def asymm(hamiltonian, time): d, G = 16, 4 P_plus = avg_symm(hamiltonian, time)[0] xi = 2 * d * (1 - P_plus) / (time ** 2) return xi

print("The asymmetry for Hsymm is", asymm(Hsymm, 1e-4), ".") print("The asymmetry for Hnsym is", asymm(Hnsym, 1e-4), ".") print("The asymmetry for Hasym is", asymm(Hasym, 1e-4), ".") and