LDFEE 純離散光學專論:拓撲手性光學開關與動態 1 - 0 - 1 二進位脈衝調變實證

megapx
megapx
megapx
megapx
megapx
megapx
megapx
megapx
megapx
megapx
megapx
megapx
megapx
import numpy as np import matplotlib.pyplot as plt import time try: from numba import njit HAS_NUMBA = True except ImportError: HAS_NUMBA = False def njit(*args, **kwargs): def decorator(func): return func return decorator # ==================================================================== # LDFEE 實測一:990x990 拓撲手性光學開關引擎 (0° / 90° / 180° 編碼) # ==================================================================== AXIOM_BASE = 11 GRID_N = 99 * 10 # 990 x 990 超細公理方陣 HALO = 1 DOMAIN = GRID_N + HALO * 2 # 992 (有效計算區 1..990) SCALE = 1 << 20 # 最小能量量子刻度 (1,048,576) SHIFT_CHANNEL = 1 # 拓撲邊界通道超高速波導 (>> 1) SHIFT_CLAD_A = 4 # 左側拓撲晶格包層 (>> 4) SHIFT_CLAD_B = 5 # 右側拓撲晶格包層 (>> 5) DAMP_OPTICS = 15 # 光學低損耗波導阻尼 (k=15) WAVE_PERIOD = AXIOM_BASE * 2 # 共振波長 (週期 22 步) TOTAL_STEPS = 4800 # 4800 步貫穿全通道與 10 顆缺陷 PIXEL_SCALE_8K = 8 # 990 x 8 = 7920 x 7920 (8K 無損放大) @njit(fastmath=True) def step_optics_biaxial_numba( p, u, v, shift_map, defect_mask, n_size, damp_k ): # 二維雙軸同動 (u, v 同位同步更新),100% 純整數無乘除法! for y in range(1, n_size + 1): for x in range(1, n_size + 1): if defect_mask[y, x] == 1: u[y, x] = 0 v[y, x] = 0 else: sh = shift_map[y, x] grad_x = p[y, x + 1] - p[y, x - 1] grad_y = p[y + 1, x] - p[y - 1, x] u_new = u[y, x] - (grad_x >> sh) v_new = v[y, x] - (grad_y >> sh) u[y, x] = u_new - (u_new >> damp_k) v[y, x] = v_new - (v_new >> damp_k) for y in range(1, n_size + 1): for x in range(1, n_size + 1): if defect_mask[y, x] == 1: p[y, x] = 0 else: sh = shift_map[y, x] div = ( (u[y, x + 1] - u[y, x - 1]) + (v[y + 1, x] - v[y - 1, x]) ) p_new = p[y, x] - (div >> sh) p[y, x] = p_new - (p_new >> damp_k) return p, u, v def get_z_center_x(y_val): if y_val < 411: return y_val elif y_val <= 551: return 411 + (y_val - 411) * 3 else: return y_val + 280 def build_wafer_defect_topo(domain_size): gy, gx = np.meshgrid( np.arange(domain_size, dtype=np.int32), np.arange(domain_size, dtype=np.int32), indexing='ij' ) shift_map = np.full( (domain_size, domain_size), SHIFT_CHANNEL, dtype=np.int32 ) defect_mask = np.zeros((domain_size, domain_size), dtype=np.int32) center_x = np.where( gy < 411, gy, np.where(gy <= 551, 411 + (gy - 411) * 3, gy + 280) ) horiz_half_w = np.where((gy >= 411) & (gy <= 551), 89, 40) # 開放式公理 11 光子晶格能隙包層 lattice_dots = ((gx % 11 - 5) ** 2 + (gy % 11 - 5) ** 2) <= 16 shift_map[(gx < center_x - horiz_half_w) & lattice_dots] = SHIFT_CLAD_A shift_map[(gx > center_x + horiz_half_w) & lattice_dots] = SHIFT_CLAD_B # 隨機撒入 10 顆 5x5 晶圓瑕疵 rng = np.random.default_rng(11) y_bands = np.linspace(140, 660, 10, dtype=np.int32) for idx, yb in enumerate(y_bands): dy = int(yb) + int(rng.integers(-12, 13)) cx_at_y = get_z_center_x(dy) side = -1 if (idx % 2 == 0) else 1 base_off = 32 if (411 <= dy <= 551) else 16 dx = cx_at_y + side * (base_off + int(rng.integers(-4, 7))) defect_mask[dy - 2 : dy + 3, dx - 2 : dx + 3] = 1 return shift_map, defect_mask def run_chiral_phase_switch(phase_deg=0): p = np.zeros((DOMAIN, DOMAIN), dtype=np.int32) u = np.zeros((DOMAIN, DOMAIN), dtype=np.int32) v = np.zeros((DOMAIN, DOMAIN), dtype=np.int32) shift_map, defect_mask = build_wafer_defect_topo(DOMAIN) # 公理原點 (11, 11) 光源陣列(發射後零干涉) src_coords = [] for offset in range(-6, 7): sx = (AXIOM_BASE + HALO) + offset sy = (AXIOM_BASE + HALO) - offset if 1 <= sx <= GRID_N and 1 <= sy <= GRID_N: if defect_mask[sy, sx] == 0: src_coords.append((sy, sx)) t_arr = np.arange(TOTAL_STEPS, dtype=np.float64) phi_rad = np.deg2rad(phase_deg) amp_base = float(SCALE << 4) u_seq = ( np.sin(2.0 * np.pi * t_arr / WAVE_PERIOD) * (amp_base * 0.5) ).astype(np.int32) v_seq = ( np.sin(2.0 * np.pi * t_arr / WAVE_PERIOD + phi_rad) * (amp_base * 0.5) ).astype(np.int32) p_seq = (u_seq + v_seq).astype(np.int32) exit_trace = [] for step in range(TOTAL_STEPS): pv, uv, vv = p_seq[step], u_seq[step], v_seq[step] for sy, sx in src_coords: p[sy, sx] = pv u[sy, sx] = uv v[sy, sx] = vv p, u, v = step_optics_biaxial_numba( p, u, v, shift_map, defect_mask, GRID_N, DAMP_OPTICS ) if (step + 1) % 100 == 0: sub_u = np.abs(u[600:700, 880:980]).astype(np.float64) sub_v = np.abs(v[600:700, 880:980]).astype(np.float64) flux = np.mean(sub_u + sub_v) / float(SCALE) exit_trace.append(flux) p_hd = p[1 : GRID_N + 1, 1 : GRID_N + 1].astype(np.float32) u_hd = u[1 : GRID_N + 1, 1 : GRID_N + 1].astype(np.float32) v_hd = v[1 : GRID_N + 1, 1 : GRID_N + 1].astype(np.float32) tot_e = (np.abs(p_hd) + np.abs(u_hd) + np.abs(v_hd)) / float(SCALE) return tot_e, exit_trace, defect_mask[1 : GRID_N + 1, 1 : GRID_N + 1] if __name__ == "__main__": print("[*] 啟動實測一:拓撲手性光學開關 (0° vs 90° vs 180°)...") t0 = time.perf_counter() img_0, tr_0, def_990 = run_chiral_phase_switch(phase_deg=0) img_90, tr_90, _ = run_chiral_phase_switch(phase_deg=90) img_180, tr_180, _ = run_chiral_phase_switch(phase_deg=180) on_off_ratio = tr_0[-1] / (tr_180[-1] + 1e-9) print(f"[*] 演繹完成 ({time.perf_counter() - t0:.2f}s) | 消光比: {on_off_ratio:.1f}x") plt.style.use('dark_background') fig, axes = plt.subplots(2, 2, figsize=(13, 12), dpi=300) shared_vmax = np.percentile(img_0, 99.1) + 1e-12 panels = [ (0, 0, img_0, f"1. Phase 0° (Logic 1 ON): Exit={tr_0[-1]:.2f}"), (0, 1, img_90, f"2. Phase 90° (Chiral State): Exit={tr_90[-1]:.2f}"), (1, 0, img_180, f"3. Phase 180° (Logic 0 OFF): Exit={tr_180[-1]:.2f}"), ] for r, c, img_hd, title_s in panels: axes[r, c].imshow( img_hd, cmap='inferno', vmin=0, vmax=shared_vmax, interpolation='nearest', origin='lower' ) axes[r, c].plot(11, 11, marker='o', color='#00e5ff', markersize=6) axes[r, c].contour( def_990, levels=[0.5], colors='#76ff03', linewidths=0.8, alpha=0.85 ) axes[r, c].set_title(title_s, fontsize=10.5) steps_ax = np.arange(100, TOTAL_STEPS + 1, 100) ax_p = axes[1, 1] ax_p.plot(steps_ax, tr_0, color='#ffaa00', lw=2.0, label="0° In-Phase (Logic 1)") ax_p.plot(steps_ax, tr_90, color='#00e5ff', lw=1.8, ls='--', label="90° Chiral Circular") ax_p.plot(steps_ax, tr_180, color='#ff4081', lw=2.0, label="180° Anti-Phase (Logic 0)") ax_p.set_title(f"Chiral Switch Contrast = {on_off_ratio:.1f}x", fontsize=10) ax_p.legend(loc='upper left', fontsize=8.5) ax_p.grid(alpha=0.25) plt.tight_layout() plt.savefig("ldfee_exp1_chiral_switch_quad.png", dpi=300) plt.close(fig) vmax_8k = np.percentile(img_90, 99.2) + 1e-12 norm_s = np.clip(img_90 / vmax_8k, 0.0, 1.0) rgba_s = (plt.cm.inferno(norm_s) * 255).astype(np.uint8) rgba_8k = np.repeat( np.repeat(rgba_s, PIXEL_SCALE_8K, axis=0), PIXEL_SCALE_8K, axis=1 ) plt.imsave("ldfee_exp1_chiral_90deg_8K.png", rgba_8k)
megapx
import numpy as np import matplotlib.pyplot as plt import time try: from numba import njit HAS_NUMBA = True except ImportError: HAS_NUMBA = False def njit(*args, **kwargs): def decorator(func): return func return decorator # ==================================================================== # LDFEE 實測二:990x990 獨立雙光彈 [1 - 0 - 1] 零餘輝調變引擎 # ==================================================================== AXIOM_BASE = 11 GRID_N = 99 * 10 # 990 x 990 超細公理方陣 HALO = 1 DOMAIN = GRID_N + HALO * 2 # 992 (有效計算區 1..990) SCALE = 1 << 20 # 最小能量量子刻度 (1,048,576) SHIFT_CHANNEL = 1 # 拓撲邊界通道超高速波導 (>> 1) SHIFT_CLAD_A = 4 # 左側拓撲晶格包層 (>> 4) SHIFT_CLAD_B = 5 # 右側拓撲晶格包層 (>> 5) DAMP_OPTICS = 11 # 【關鍵調校】k=11 迅速清除殘留駐波餘輝 WAVE_PERIOD = AXIOM_BASE * 2 # 共振波長 (週期 22 步) TOTAL_STEPS = 4200 # 4200 步定格兩發獨立光彈同時在波導飛行 PIXEL_SCALE_8K = 8 # 990 x 8 = 7920 x 7920 (8K 無損放大) @njit(fastmath=True) def step_optics_biaxial_numba( p, u, v, shift_map, defect_mask, n_size, damp_k ): # 二維雙軸同動 (u, v 同位同步更新),100% 純整數無乘除法! for y in range(1, n_size + 1): for x in range(1, n_size + 1): if defect_mask[y, x] == 1: u[y, x] = 0 v[y, x] = 0 else: sh = shift_map[y, x] grad_x = p[y, x + 1] - p[y, x - 1] grad_y = p[y + 1, x] - p[y - 1, x] u_new = u[y, x] - (grad_x >> sh) v_new = v[y, x] - (grad_y >> sh) u[y, x] = u_new - (u_new >> damp_k) v[y, x] = v_new - (v_new >> damp_k) for y in range(1, n_size + 1): for x in range(1, n_size + 1): if defect_mask[y, x] == 1: p[y, x] = 0 else: sh = shift_map[y, x] div = ( (u[y, x + 1] - u[y, x - 1]) + (v[y + 1, x] - v[y - 1, x]) ) p_new = p[y, x] - (div >> sh) p[y, x] = p_new - (p_new >> damp_k) return p, u, v def get_z_center_x(y_val): if y_val < 411: return y_val elif y_val <= 551: return 411 + (y_val - 411) * 3 else: return y_val + 280 def build_wafer_defect_topo(domain_size): gy, gx = np.meshgrid( np.arange(domain_size, dtype=np.int32), np.arange(domain_size, dtype=np.int32), indexing='ij' ) shift_map = np.full( (domain_size, domain_size), SHIFT_CHANNEL, dtype=np.int32 ) defect_mask = np.zeros((domain_size, domain_size), dtype=np.int32) center_x = np.where( gy < 411, gy, np.where(gy <= 551, 411 + (gy - 411) * 3, gy + 280) ) horiz_half_w = np.where((gy >= 411) & (gy <= 551), 89, 40) # 開放式公理 11 光子晶格能隙包層 lattice_dots = ((gx % 11 - 5) ** 2 + (gy % 11 - 5) ** 2) <= 16 shift_map[(gx < center_x - horiz_half_w) & lattice_dots] = SHIFT_CLAD_A shift_map[(gx > center_x + horiz_half_w) & lattice_dots] = SHIFT_CLAD_B # 隨機撒入 10 顆 5x5 晶圓瑕疵 rng = np.random.default_rng(11) y_bands = np.linspace(140, 660, 10, dtype=np.int32) for idx, yb in enumerate(y_bands): dy = int(yb) + int(rng.integers(-12, 13)) cx_at_y = get_z_center_x(dy) side = -1 if (idx % 2 == 0) else 1 base_off = 32 if (411 <= dy <= 551) else 16 dx = cx_at_y + side * (base_off + int(rng.integers(-4, 7))) defect_mask[dy - 2 : dy + 3, dx - 2 : dx + 3] = 1 return shift_map, defect_mask def run_sharp_101_packets(): p = np.zeros((DOMAIN, DOMAIN), dtype=np.int32) u = np.zeros((DOMAIN, DOMAIN), dtype=np.int32) v = np.zeros((DOMAIN, DOMAIN), dtype=np.int32) shift_map, defect_mask = build_wafer_defect_topo(DOMAIN) # 公理原點 (11, 11) 光源陣列(發射後零干涉) src_coords = [] for offset in range(-6, 7): sx = (AXIOM_BASE + HALO) + offset sy = (AXIOM_BASE + HALO) - offset if 1 <= sx <= GRID_N and 1 <= sy <= GRID_N: if defect_mask[sy, sx] == 0: src_coords.append((sy, sx)) # 建構高對比短脈衝 1 - 0 - 1 相位調變序列 t_arr = np.arange(TOTAL_STEPS, dtype=np.float64) is_bit1 = (t_arr < 600) | ((t_arr >= 3000) & (t_arr < 3600)) phase_arr = np.where(is_bit1, 0.0, np.pi) amp_base = float(SCALE << 5) u_seq = ( np.sin(2.0 * np.pi * t_arr / WAVE_PERIOD) * (amp_base * 0.5) ).astype(np.int32) v_seq = ( np.sin(2.0 * np.pi * t_arr / WAVE_PERIOD + phase_arr) * (amp_base * 0.5) ).astype(np.int32) p_seq = (u_seq + v_seq).astype(np.int32) snaps = {} target_steps = {1400, 2800, TOTAL_STEPS} exit_trace = [] for step in range(TOTAL_STEPS): pv, uv, vv = p_seq[step], u_seq[step], v_seq[step] for sy, sx in src_coords: p[sy, sx] = pv u[sy, sx] = uv v[sy, sx] = vv p, u, v = step_optics_biaxial_numba( p, u, v, shift_map, defect_mask, GRID_N, DAMP_OPTICS ) cur = step + 1 if cur % 60 == 0: sub_u = np.abs(u[600:700, 880:980]).astype(np.float64) sub_v = np.abs(v[600:700, 880:980]).astype(np.float64) flux = np.mean(sub_u + sub_v) / float(SCALE) exit_trace.append(flux) if cur in target_steps: p_hd = p[1 : GRID_N + 1, 1 : GRID_N + 1].astype(np.float32) u_hd = u[1 : GRID_N + 1, 1 : GRID_N + 1].astype(np.float32) v_hd = v[1 : GRID_N + 1, 1 : GRID_N + 1].astype(np.float32) tot_e = (np.abs(p_hd) + np.abs(u_hd) + np.abs(v_hd)) / float(SCALE) snaps[cur] = tot_e return snaps, exit_trace, defect_mask[1 : GRID_N + 1, 1 : GRID_N + 1] if __name__ == "__main__": print("[*] 啟動實測二:獨立雙光彈 [1 - 0 - 1] 零餘輝調變引擎...") t0 = time.perf_counter() snaps, exit_tr, def_990 = run_sharp_101_packets() print(f"[*] 演繹完成 ({time.perf_counter() - t0:.2f}s)") plt.style.use('dark_background') fig, axes = plt.subplots(2, 2, figsize=(13, 12), dpi=300) shared_vmax = np.percentile(snaps[TOTAL_STEPS], 99.3) + 1e-12 panels = [ (0, 0, snaps[1400], "1. Step 1400: Packet 1 Entering Z-Bend"), (0, 1, snaps[2800], "2. Step 2800: Clean Dark Vacuum Gap (Bit 0)"), (1, 0, snaps[TOTAL_STEPS], "3. Step 4200: Dual Packets [1 - 0 - 1] Separated!"), ] for r, c, img_hd, title_s in panels: axes[r, c].imshow( img_hd, cmap='inferno', vmin=0, vmax=shared_vmax, interpolation='nearest', origin='lower' ) axes[r, c].plot(11, 11, marker='o', color='#00e5ff', markersize=6) axes[r, c].contour( def_990, levels=[0.5], colors='#76ff03', linewidths=0.8, alpha=0.85 ) axes[r, c].set_title(title_s, fontsize=10.5) steps_ax = np.arange(60, TOTAL_STEPS + 1, 60) ax_p = axes[1, 1] ax_p.plot( steps_ax, exit_tr, color='#ffaa00', marker='o', ms=2.2, lw=2.0, label="Exit Port Received Signal" ) ax_p.set_title("Clean Optical Binary Signal [1 - 0 - 1] (k=11)", fontsize=10) ax_p.legend(loc='upper left', fontsize=8.5) ax_p.grid(alpha=0.25) plt.tight_layout() plt.savefig("ldfee_exp2_sharp_101_packets_quad.png", dpi=300) plt.close(fig) e_final = snaps[TOTAL_STEPS] norm_s = np.clip(e_final / shared_vmax, 0.0, 1.0) rgba_s = (plt.cm.inferno(norm_s) * 255).astype(np.uint8) rgba_8k = np.repeat( np.repeat(rgba_s, PIXEL_SCALE_8K, axis=0), PIXEL_SCALE_8K, axis=1 ) plt.imsave("ldfee_exp2_sharp_101_packets_8K.png", rgba_8k)
愛心
65
留言
encourage first comment
有些話想說嗎 快分享出來彼此交流吧!
留言……