1. Calibration-Based Qubit Selection
Load IBM Cloud credentials and select the backend 'ibm_torino'.
For each qubit q_i read:
T_1^(i), T_2^(i), ϵ_√X^(i).
Minimize the weighted cost:
C(S) = ∑ [ αϵ_√X^(i) - βT_1^(i) - γT_2^(i)],
qi∈S
with positive constants α, β, γ.
The set:
S* = arg min C(S)
S⊂Q, ∣S∣=49
furnishes the initial layout mapping logical lattice sites to the 49 best physical qubits.
2. Registers
Quantum register: Q = {q_(r, c ∣ r, c ∈ {0, …, 6}} is addressed in row‑major order q_(r, c) =^ q_(7r + c).
Classical register: C = {c_0, …, c_48} receives one bit per qubit.
3. 3. Twistor phase imprint
Choose a Twistor phase:
ϕ = π/8.
Apply:
U_twist(q_r, c) = { R_Z(+2ϕ) (r = c)
R_Z(−2ϕ) (r + c = 6), R_Z(θ) = e^(−iθZ/2).
1 otherwise
4. Casimir mirror boundaries
To emulate perfectly conducting plates, add a second phase:
ψ = π/4,
and act on the extreme rows:
U_mirror(q_(0, c)) = R_Z(+ψ)
U_mirror(q_(6, c)) = R_Z(−ψ)
Combined single‑qubit unitary:
U(q) = U_mirrorU_twist
5. Vacuum‑mode entangling ladder
For each column c build a nearest‑neighbour CNOT chain:
CX(q_(0, c) -> q_(1, c)) CX(q_(1, c) -> q_(2,c)) … CX(q_(5, c) -> q_(6,c)), linking the top plate to the bottom plate through six sequential edges. Physically this allows vacuum‑fluctuation correlations to bounce’ between mirrors along null vertical geodesics imposed by the Twistor field.
6. Measurement
Perform a projective measurement in the computational basis on every qubit:
M: ∣0⟩⟨0∣, ∣1⟩⟨1∣ ∀q ∈ Q,
storing outcome strings b ∈ {0, 1}^49 into the classical register.
7. Boundary‑pair creation observable
Denote by t_c = q_(0, c) (top) and b_c = q_(6, c) (bottom) the two mirror qubits in column c.
For a bitstring b let:
χ_c(b) = { 1 if b_(t_c) = b_(b_c) = 1,
0 otherwise
From N = 32768 shots compute:
ρ_c = 1/N ∑ χ_c(b) f(b),
b
where f(b) is that bitstring’s frequency. ρ_c is the boundary‑pair creation rate, a digital analogue of the Casimir photon‑pair density in column c.
8. Json
Store the saved data {ϕ, ψ, raw_counts, ρ_0, …, ρ_6} to a Json.
Code:
# Main circuit
# Imports
import json, logging, pandas as pd
from math import pi
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, transpile
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2
logging.basicConfig(level=logging .INFO, format="%(levelname)s: %(message)s")
log = logging.getLogger("Twistor‑Casimir")
# IBMQ
TOKEN = "IBMQ_API_KEY_O-`"
INSTANCE = "IBMQ_CRN"
service = QiskitRuntimeService(
channel="ibm_cloud",
token=TOKEN,
instance=INSTANCE,
)
backend = service.backend("ibm_torino")
# Calibration-Based Qubit Selection (49)
def best_qubits(cal_csv: str, n: int = 49) -> list[int]:
"""Order by √X error ↑ then T1 ↓ then T2 ↓ and return the first *n* qubits."""
df = pd .read_csv(cal_csv)
df.columns = df.columns.str.strip()
ordered = df.sort_values(
["√x (sx) error", "T1 (us)", "T2 (us)"],
ascending=[True, False, False],
)
winners = ordered["Qubit"].head(n).astype(int).tolist()
log .info("Initial‑layout physical qubits: %s", winners)
return winners
CAL_CSV = "/Users/steventippeconnic/Downloads/ibm_torino_calibrations_2025-05-12T17_23_16Z.csv"
physical_layout = best_qubits(CAL_CSV, 49)
# Registers
d_q = QuantumRegister(49, "q") # Lattice qubits (7 x 7 null grid)
c_q = ClassicalRegister(49, "c") # One classical bit per qubit
qc = QuantumCircuit(d_q, c_q, name="Twistor‑Casimir‑Null‑Lattice")
# Twistor phase imprint (dual null diagonals)
phi = pi / 8 # Twistor phase rotation
psi = pi / 4 # Extra mirror‑boundary phase
def idx(r: int, c: int) -> int:
"""Map (row, col) -> flat qubit index in row‑major order."""
return 7 * r + c
for r in range(7):
for c in range(7):
q = d_q[idx(r, c)]
# null diagonals
if r == c:
qc.rz(+2 * phi, q)
elif r + c == 6:
qc.rz(-2 * phi, q)
# Casimir mirror boundaries - top & bottom rows
if r == 0:
qc.rz(+psi, q)
elif r == 6:
qc.rz(-psi, q)
qc.barrier(label="Twistor + Casimir phases")
# Vacuum‑mode CX ladder (column‑wise)
# Each column chain CX from top mirror -> … -> bottom mirror to correlate modes
for c in range(7):
for r in range(6): # 0 - 5 links neighbor rows
qc .cx(d_q[idx(r, c)], d_q[idx(r + 1, c)])
qc.barrier(label="Vacuum entangling ladder")
# Measurements
for q in range(49):
qc.measure(d_q[q], c_q[q])
# Transpile
qc_t = transpile(
qc,
backend=backend,
initial_layout=physical_layout,
optimization_level=3,
)
log .info("Transpiled circuit depth: %d", qc_t.depth())
# Execute
sampler = SamplerV2(mode=backend)
job = sampler .run([qc_t], shots=32768)
result = job.result()
# Counts
creg_name = qc_t.cregs[0].name # "c"
counts = result[0].data.__getattribute__(creg_name).get_counts()
shots = sum(counts.values())
# Boundary‑pair creation rate calculation
def both_one(bitstring: str, i: int, j: int) -> bool:
return bitstring[i] == "1" and bitstring[j] == "1"
pair_counts = {c: 0 for c in range(7)} # column‑indexed
for bits, freq in counts.items():
# Bit ordering
bits = bits[::-1]
for col in range(7):
top = idx(0, col)
bottom = idx(6, col)
if both_one(bits, top, bottom):
pair_counts[col] += freq
pair_rates = {k: v / shots for k, v in pair_counts.items()}
# Json
out = {
"experiment_name": "Twistor‑Casimir Coupling (49‑qubit null lattice)",
"twistor_phase_phi": float(phi),
"mirror_phase_psi": float(psi),
"raw_counts": counts,
"boundary_pair_rates": pair_rates,
}
JSON_PATH = "/Users/steventippeconnic/Documents/Twistor_Casimir_Coupling_0.json"
with open(JSON_PATH, "w") as fp:
json.dump(out, fp, indent=4)
log .info("Results JSON saved → %s", JSON_PATH)
# Console summary
log .info("Average boundary pair‑creation rate: %.5f", sum(pair_rates.values()) / 7)
for col, rate in pair_rates.items():
log .info(" column %d : %.5f", col, rate)
# End
/////////////////////////////////////////////////////////////////
# Code for all visuals from experiment JSON
# Twistor‑Casimir visual suite
import json, numpy as np, matplotlib.pyplot as plt
from pathlib import Path
from itertools import combinations
from scipy.stats import linregress
# Load counts
FILE = Path('/Users/steventippeconnic/Documents/QC/Twistor_Casimir_Coupling_0.json')
raw = json.loads(FILE.read_text())
counts = raw['raw_counts']
shots = sum(counts.values())
# Map (row, col) -> flat index, row‑major
idx = lambda r, c: 7 * r + c
# Helper reduce a bit‑string to useful observables
def parse_bits(bits):
bits = bits[::-1] # little‑endian -> row‑major
# single‑qubit mirror excitations
top = [int(bits[idx(0, c)]) for c in range(7)]
bot = [int(bits[idx(6, c)]) for c in range(7)]
# pair map π_c = 1 iff both mirrors in col c are |1⟩
pair = [t & b for t, b in zip(top, bot)]
return np.array(top), np.array(bot), np.array(pair)
tops, bots, pairs = [], [], []
for b, f in counts.items():
t, b_, p = parse_bits(b)
tops.append(np.repeat(t[None, :], f, axis=0))
bots.append(np.repeat(b_[None, :], f, axis=0))
pairs.append(np.repeat(p[None, :], f, axis=0))
tops = np.vstack(tops)
bots = np.vstack(bots)
pairs = np.vstack(pairs)
ρ = pairs.mean(axis=0) # pair‑creation rate (7,)
p_top = tops.mean(axis=0) # single‑plate rates (7,)
p_bot = bots.mean(axis=0)
product = p_top * p_bot # uncorrelated baseline
pair_rates = pairs.mean(axis=0) # ρ_c
top_rates = tops.mean(axis=0)
bot_rates = bots.mean(axis=0)
pair_matrix = np.corrcoef(pairs.T) # 7×7 cross correlations
multiplicity = pairs.sum(axis=1) # number of columns with a pair per shot
# Boundary pair‑creation rate per column
plt.figure(figsize=(6,3))
plt.title('Boundary pair‑creation rate per column')
plt.bar(range(7), pair_rates)
plt.ylabel('ρ_c')
plt.xlabel('column')
plt.ylim(0, max(pair_rates)*1.15)
plt.tight_layout()
plt.show()
# Mirror‑qubit 1 occupancy
plt.figure(figsize=(6,3))
plt.title('Mirror‑qubit 1 occupancy')
w = 0.35
plt.bar(np.arange(7)-w/2, top_rates, width=w, label='top')
plt.bar(np.arange(7)+w/2, bot_rates, width=w, label='bottom')
plt.ylabel('P(1)')
plt.xlabel('column')
plt.legend()
plt.ylim(0, 1)
plt.tight_layout()
plt.show()
# Column‑to‑column pair‑event correlation
plt.figure(figsize=(4,4))
plt.title('Column‑to‑column pair‑event correlation')
plt.imshow(pair_matrix, cmap='coolwarm', vmin=-1, vmax=1)
plt.colorbar(label='Correlation')
plt.xticks(range(7)), plt.yticks(range(7))
plt.xlabel('Columns')
plt.ylabel('Columns')
plt.tight_layout()
plt.show()
# Multiplicity of simultaneous mirror pairs
plt.figure(figsize=(6,3))
plt.title('Multiplicity of simultaneous mirror pairs')
plt.hist(multiplicity, bins=np.arange(0,8)-0.5, rwidth=0.9)
plt.xlabel('Columns with pair in a shot')
plt.ylabel('frequency')
plt.tight_layout()
plt.show()
# Two‑plate coherence enhancement κ_c
κ = np.divide(ρ, product, out=np.zeros_like(ρ), where=product>0)
plt.figure(figsize=(6,3))
plt.title('Two‑plate coherence enhancement κ_c')
plt.bar(range(7), κ)
plt.axhline(1, color='k', linestyle='--', linewidth=0.7)
plt.ylabel('κ_c = ρ_c / (P_top P_bottom)')
plt.xlabel('column')
plt.ylim(0, κ.max()*1.15)
plt.tight_layout()
plt.show()
# Joint mirror‑state distribution per column
states = np.zeros((7,4)) # order: 00,01,10,11
for b, f in counts.items():
t, bo, _ = parse_bits(b)
for c,(u,v) in enumerate(zip(t,bo)):
s = (u<<1) | v # encodes 00→0, 01→1, 10→2, 11→3
states[c,s] += f
states /= shots
labels = ['00','01','10','11']
bottom = np.zeros(7)
plt.figure(figsize=(6,3))
plt.title('Joint mirror‑state distribution per column')
for i,lab in enumerate(labels):
plt.bar(range(7), states[:,i], bottom=bottom, label=lab)
bottom += states[:,i]
plt.xlabel('column')
plt.ylabel('probability')
plt.legend(ncol=4, fontsize='small')
plt.tight_layout()
plt.show()
# Polar view of ρ_c (twistor null corridors)
θ = np.linspace(0, 2*np.pi, 7, endpoint=False)
plt.figure(figsize=(5,5))
ax = plt.subplot(111, projection='polar')
ax.set_title('Polar view of ρ_c (twistor null corridors)')
ax.bar(θ, ρ, width=2*np.pi/7, alpha=0.8)
ax.set_yticklabels([])
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)
plt.tight_layout()
plt.show()
# Survival‑CDF of simultaneous pair multiplicit
multiplicity = pairs.sum(axis=1)
vals, counts_hist = np.unique(multiplicity, return_counts=True)
cdf = 1 - np.cumsum(counts_hist)/shots # survival function
plt.figure(figsize=(5,3))
plt.title('Survival‑CDF of simultaneous pair multiplicity')
plt.loglog(vals, cdf, marker='o')
plt.xlabel('≥ m columns with a pair')
plt.ylabel('P(M ≥ m)')
plt.grid(True, which='both', ls=':', lw=0.6)
plt.tight_layout()
plt.show()
# Raw counts for final visuals
tops, bots, whole = [], [], []
for b, f in counts.items():
bits = b[::-1] # row‑major
t = np.array([int(bits[idx(0,c)]) for c in range(7)])
bo = np.array([int(bits[idx(6,c)]) for c in range(7)])
w = np.array([int(bit) for bit in bits]) # 49‑vector
tops .append(np.repeat(t[None,:], f, 0))
bots .append(np.repeat(bo[None,:],f, 0))
whole.append(np.repeat(w[None,:], f, 0))
tops = np.vstack(tops)
bots = np.vstack(bots)
whole = np.vstack(whole)
P_top = tops.mean(axis=0)
P_bot = bots.mean(axis=0)
ρ = (tops & bots).mean(axis=0) # pair‑creation
# Per‑qubit 1 probability across lattic
P_qubit = whole.mean(axis=0).reshape(7,7)
plt.figure(figsize=(4,4))
plt.title('Per‑qubit 1 probability across lattice')
plt.imshow(P_qubit, cmap='viridis', vmin=0, vmax=P_qubit.max())
plt.colorbar(label='P(1)')
plt.xticks(range(7)), plt.yticks(range(7))
plt.xlabel('Columns')
plt.ylabel('Columns')
plt.tight_layout()
plt.show()
# Conditional P(top=1 | bottom=1) per column
ζ = np.divide(ρ, P_bot, out=np.zeros_like(ρ), where=P_bot>0)
plt.figure(figsize=(6,3))
plt.title('Conditional P(top=1 | bottom=1) per column')
plt.bar(range(7), ζ)
plt.ylabel('ζ_c')
plt.xlabel('column')
plt.ylim(0, ζ.max()*1.15)
plt.tight_layout()
plt.show()
# Vertical excitation gradient across lattice rows
P_row = P_qubit.mean(axis=1)
plt.figure(figsize=(6,3))
plt.title('Vertical excitation gradient across lattice rows')
plt.plot(range(7), P_row, marker='o')
plt.xlabel('row (0 = top mirror)')
plt.ylabel('average P(1)')
plt.grid(alpha=0.5, ls=':')
plt.tight_layout()
plt.show()
# ρ_c vs P_top
slope, intercept, r, *_ = linregress(P_top, ρ)
plt.figure(figsize=(4.5,4))
plt.title(f'ρ_c vs P_top (r = {r:+.2f})')
plt.scatter(P_top, ρ, s=60)
xfit = np.linspace(P_top.min(), P_top.max(), 100)
plt.plot(xfit, intercept + slope*xfit, color='k', lw=1)
plt.xlabel('P_top (single‑mirror 1 rate)')
plt.ylabel('ρ_c (pair‑creation)')
plt.tight_layout()
plt.show()
# End