:::danger Challenge question 3a 完成可以產生該量子態的不平衡值的函數 ::: ```python=1 def get_imbalance(state): ###EDIT CODE BELOW ### HINT: MAKE SURE TO SKIP CALCULATING IMBALANCE OF THE |00...0> STATE imbalance_val=0 ###DO NOT EDIT BELOW states_number = len(state.probabilities_dict()) keys = [] values = [] states_imbalance_val = [] for key, value in state.probabilities_dict().items(): keys.append(key) values.append(value) for i in range(len(keys)): even = 0 odd = 0 for j in range(len(keys[i])): if j%2: #odd odd = odd + int(keys[i][j]) else: even = even + int(keys[i][j]) if (odd+even)== 0: state_imbalance = (odd-even) states_imbalance_val.append(state_imbalance) else: state_imbalance = (odd-even)/(odd+even) states_imbalance_val.append(state_imbalance) for k in range(len(states_imbalance_val)): imbalance_val = imbalance_val + states_imbalance_val[k] * values[k] return -imbalance_val ``` 接著,我們要探討量子資訊和糾纏 entropy 如何在系統中增長。在糾纏系統中,忽略會使子系統進入不同數量態之混合態的其他系統,我們可以用 von Neuman entropy 來深入了解子系統 A 和其他系統之間的糾纏程度: $$S_vn (ρ_A )=-tr(ρ_A \lnρ_A )$$ 在這裡,$ρ_A$ 是子系統 A 的 reduced density matrix。如果子系統 A 跟其他系統是 fully entangled,則 $S_vn (ρ_A )=\ln2$,如果子系統跟其他系統是完全隔開(即純態),則 $S_vn (ρ_A )=0$。讓我們看一個範例: ```python=+ bell_state = qi.Statevector(np.array([0,1,1,0])/np.sqrt(2)) rho_0 = qi.partial_trace(bell_state,[1]) # We trace out qubit 1 rho_1 = qi.partial_trace(bell_state,[0]) # We trace out qubit 0 print('QB0 vn entropy: ', qi.entropy(rho_0, base=np.exp(1))) print('QB1 vn entropy: ', qi.entropy(rho_1, base=np.exp(1))) ``` > QB0 vn entropy: 0.6931471805599454 > QB1 vn entropy: 0.6931471805599454 探討 12 個 qubits 之直鏈的多體量子動力學 ```python=+ t = Parameter(‘t’) ``` ```python=+ num_qubits=12 deltas=[Parameter('delta_{:d}'.format(idx)) for idx in range(num_qubits)] disorder_trot_step=generate_disordered_tb_instruction(t, deltas, num_qubits) ``` ```python=+ # Here we define the disorder pattern beta=(np.sqrt(5)-1)/2 # DO NOT EDIT AA_pattern=np.cos(2*np.pi*beta*np.arange(num_qubits)) # DO NOT EDIT ```
:::danger Challenge question 3b 將 qubits 0, 4, 和 8 設定為 |1⟩ 設定系統初始狀態 ::: ```python=+ delta_t=0.1 time_steps=np.arange(0,21,2) circuits={} Ws=[1,4,10] for W in Ws: disorders=W*AA_pattern circuits[W]=[] for n_steps in time_steps: qr = QuantumRegister(num_qubits) qc = QuantumCircuit(qr) ###EDIT CODE BELOW qc.x(0) qc.x(4) qc.x(8) ###DO NOT EDIT BELOW for _ in range(n_steps): qc.append(disorder_trot_step, [i for i in range(num_qubits)]) if n_steps!=0: qc = qc.bind_parameters({t: delta_t}) qc = qc.bind_parameters({deltas[idx]: disorders[idx] for idx in range(num_qubits)}) circuits[W].append(qc) ```
:::danger Challenge question 3c 計算 qubit 0 於不同 disorder strengths與不同演化時間點的 von Neumann entropy :::
:::danger Challenge question 3d 計算不同 disorder strengths 與不同演化時間點,晶格的不平衡值 ::: ```python=+ state_vector_imbalances={} vn_entropies={} for W in tqdm(Ws): probability_densities[W]=[] state_vector_imbalances[W]=[] vn_entropies[W]=[] for circ in circuits[W]: transpiled_circ=transpile(circ, backend_sim, optimization_level=3) job_sim = backend_sim.run(transpiled_circ) # Grab the results from the job. result_sim = job_sim.result() outputstate = result_sim.get_statevector(transpiled_circ, decimals=6) ps=[] for idx in range(num_qubits): ps.append(np.abs(qi.partial_trace(outputstate,[i for i in range(num_qubits) if i!=idx]))[1,1]**2) entropy=0 ### EDIT CODE BELOW (extract the density matrix of qubit 0 by tracing out all other qubits) rho_3 = qi.partial_trace(outputstate,[i for i in range(1,num_qubits)]) entropy = qi.entropy(rho_3, base=np.exp(1)) ###DO NOT EDIT BELOW imbalance=0 ### EDIT CODE BELOW keys = [] values = [] states_imbalance_val = [] for key, value in outputstate.probabilities_dict().items(): keys.append(key) values.append(value) for i in range(len(keys)): even = 0 odd = 0 for j in range(len(keys[i])): if j%2: #odd odd = odd + int(keys[i][j]) else: even = even + int(keys[i][j]) if (odd+even)== 0: state_imbalance = (odd-even) states_imbalance_val.append(state_imbalance) else: state_imbalance = (odd-even)/(odd+even) states_imbalance_val.append(state_imbalance) for k in range(len(states_imbalance_val)): imbalance = imbalance + states_imbalance_val[k] * values[k] imbalance = -imbalance ###DO NOT EDIT BELOW vn_entropies[W].append(entropy) probability_densities[W].append(ps) state_vector_imbalances[W].append(imbalance) ``` ```python=+ fig, axs = plt.subplots(1,3,figsize=(15,5), facecolor='white', sharey=True) for i,W in enumerate(Ws): ax=axs[i] ax.pcolormesh(np.arange(0,num_qubits,1), time_steps*delta_t ,probability_densities[W]) ax.set_xlabel('Qubit index') ax.set_xticks(np.arange(1,num_qubits+1,1)) axs[0].set_ylabel('Time (1/J)') plt.show() ``` - **隨著時間,每一個 qubit 的機率密度** ![](https://i.imgur.com/HXDldEb.png) - **隨著時間,不同 W 值的 entropy 值** ![](https://i.imgur.com/kX1H3bC.png) - **不同 disorder strength 之系統的不平衡值隨著時間的進展** ![](https://i.imgur.com/zM1Wyjo.png)