CNOT[4, 3] = 1 CNOT[5, 5] = 1 CNOT = DenseOperator(CNOT) CNOT_4 = CNOT.truncate_to_subspace(comp_sub_sub_space_ind) def exchange_interaction(amplitude): return np.exp(amplitude) def deriv_exchange_interaction(amplitude): return np.exp(amplitude) sig_1_z = SIGMA_Z.kron(SIGMA_0).kron(SIGMA_0).kron(SIGMA_0) sig_2_z = SIGMA_0.kron(SIGMA_Z).kron(SIGMA_0).kron(SIGMA_0) sig_3_z = SIGMA_0.kron(SIGMA_0).kron(SIGMA_Z).kron(SIGMA_0) sig_4_z = SIGMA_0.kron(SIGMA_0).kron(SIGMA_0).kron(SIGMA_Z) h_drift = B12 / 8 * ((-3 * sig_1_z) + sig_2_z + sig_3_z + sig_4_z) \ + B23 / 4 * ((-1 * sig_1_z) - sig_2_z + sig_3_z + sig_4_z) \ + B34 / 8 * ((-1 * sig_1_z) - sig_2_z - sig_3_z + (3 * sig_4_z)) # h_drift += B_G / 2 * (sig_1_z + sig_2_z + sig_3_z + sig_4_z) # this contribution is 0 on the subspace. h_drift = DenseOperator(h_drift.data[sub_space_ind]) h_ctrl = [DenseOperator(np.zeros((2**4, 2**4))) for _ in range(3)]
import numpy as np from qopt.matrix import DenseOperator from qopt.energy_spectrum import plot_energy_spectrum pauli_z = DenseOperator(np.asarray([[1, 0], [0, -1]])) pauli_x = DenseOperator(np.asarray([[0, 1], [1, 0]])) tau_z = pauli_z.kron(pauli_z.identity_like()) tau_x = pauli_x.kron(pauli_x.identity_like()) sigma_z = (pauli_z.identity_like()).kron(pauli_z) sigma_x = (pauli_x.identity_like()).kron(pauli_x) sigma_x_tau_x = pauli_x.kron(pauli_x) def example_hamiltonian_flopping(detuning): hamiltonian = [] t_c = 20 e_z = 24 g_mu_b_b_x = 15 g_mu_b_b_z = 4 for eps in detuning: omega = np.sqrt(eps**2 + (2 * t_c)**2) theta = np.arctan(eps / (2 * t_c)) hamiltonian.append(.5 * omega * tau_z + (e_z / 2) * sigma_z - (g_mu_b_b_x / 2) * sigma_x * (np.cos(theta) * tau_x - np.sin(theta) * tau_z) - (g_mu_b_b_z / 2) * sigma_z * (np.cos(theta) * tau_x - np.sin(theta) * tau_z)) return hamiltonian