import numpy as np
import matplotlib.pyplot as plt
# --- Logical error rate model (surface code threshold approximation) ---
def logical_error_rate(physical_error, threshold=0.01, code_distance=5):
if physical_error >= threshold:
return 0.5 # logical qubit fails
return (physical_error / threshold) ** ((code_distance + 1) / 2)
# --- Channel model ---
def channel_error(distance_km, loss_db_per_km=0.2):
loss_db = distance_km * loss_db_per_km
transmission = 10 ** (-loss_db / 10)
return 1 - transmission
# --- Repeater chain with QEC ---
def repeater_chain_fidelity(num_repeaters, segment_length_km, code_distance):
physical_error = channel_error(segment_length_km)
logical_error = logical_error_rate(physical_error, code_distance=code_distance)
return (1 - logical_error) ** num_repeaters
# --- Grover success probability ---
def grover_success(fidelity):
return fidelity ** 2
# --- Simulation ---
segment_length = 100 # km
repeaters = np.arange(1, 51)
code_distance = 7 # moderate surface code
fidelities = [repeater_chain_fidelity(n, segment_length, code_distance) for n in repeaters]
success = [grover_success(f) for f in fidelities]
plt.plot(repeaters, success)
plt.xlabel("Number of Repeaters (100 km spacing)")
plt.ylabel("Grover Success Probability")
plt.title("Grover Algorithm With Quantum Error Correction (Surface Code)")
plt.grid(True)
plt.show()












No comments:
Post a Comment