Ejemplo n.º 1
0
def generate_plots_1():
    """
    Generates energy level diagrams for V > 0, V < 0, and 1D, 2D, 3D,
    """
    N = 12

    for C6_coeff in [-1]:
        _C6 = C6 * C6_coeff
        for _geometry in [
                RegularLattice1D(spacing=LATTICE_SPACING),
                RegularLattice2D((3, 4), spacing=LATTICE_SPACING),
                RegularLattice3D((2, 2, 3), spacing=LATTICE_SPACING)
        ]:
            s_qs = StaticQubitSystem(N=N,
                                     V=_C6,
                                     geometry=_geometry,
                                     Omega=0,
                                     Delta=np.linspace(-2e9, 4e9, 2) *
                                     C6_coeff)

            V_sign = "V-" if _C6 < 0 else "V+"
            _geometry_str = str(_geometry.shape) if not isinstance(
                _geometry, RegularLattice1D) else "1D"
            s_qs.plot_detuning_energy_levels(
                False,
                savefig_name=
                f"paper_plots_1_{V_sign}_shape_{_geometry_str}.png",
                fig_kwargs={'figsize': (5, 4)},
                plot_title=False,
                ylim=(-20e9, 60e9))
            plt.clf()
def rescale_evolving_qubit_system():
    t = 1.1e-6
    N = 4
    e_qs = EvolvingQubitSystem(
        N=N,
        V=paper_data.V,
        geometry=RegularLattice1D(),
        Omega=paper_data.get_hamiltonian_coeff_fn(paper_data.Omega, N),
        Delta=paper_data.get_hamiltonian_coeff_fn(paper_data.Delta, N),
        t_list=np.linspace(0, t, 100),
        ghz_state=AlternatingGHZState(N))
    e_qs.solve()
    # e_qs.plot()

    print(e_qs.get_fidelity_with("ghz"))

    max_Omega = 50e6

    e_qs = EvolvingQubitSystem(
        N=N,
        V=paper_data.V / max_Omega,
        geometry=RegularLattice1D(),
        Omega=paper_data.get_hamiltonian_coeff_fn(
            {
                k: {_k * max_Omega: _v / max_Omega
                    for _k, _v in v.items()}
                for k, v in paper_data.Omega.items()
            }, N),
        Delta=paper_data.get_hamiltonian_coeff_fn(
            {
                k: {_k * max_Omega: _v / max_Omega
                    for _k, _v in v.items()}
                for k, v in paper_data.Delta.items()
            }, N),
        t_list=np.linspace(0, t * max_Omega, 100),
        ghz_state=AlternatingGHZState(N))

    e_qs.solve()
    e_qs.plot()

    print(e_qs.get_fidelity_with("ghz"))
Ejemplo n.º 3
0
def get_normalised_hamiltonian(N: int, norm_V: float):
    norm_e_qs = EvolvingQubitSystem(
        N=N, V=norm_V, geometry=RegularLattice1D(),
        Omega=None, Delta=None,
        t_list=None,
        ghz_state=None
    )
    norm_hamiltonian = norm_e_qs.get_hamiltonian()

    norm_H_d = norm_hamiltonian[0]  # "drift": time-independent part
    norm_H_c = [norm_hamiltonian[1][0], norm_hamiltonian[2][0]]  # "control": time-dependent parts
    return norm_H_d, norm_H_c, norm_e_qs.psi_0
def rescale_static_qubit_system():
    N = 4
    Delta = np.linspace(-15e6, 20e7, 16)
    Omega = 3e7
    s_qs_1 = StaticQubitSystem(
        N=N,
        V=paper_data.V,
        geometry=RegularLattice1D(),
        Omega=Omega,
        Delta=Delta,
    )
    s_qs_1.plot_detuning_energy_levels(plot_state_names=True, show=True)

    # Rescaled
    max_Omega = Omega

    s_qs_2 = StaticQubitSystem(
        N=N,
        V=paper_data.V / max_Omega,
        geometry=RegularLattice1D(),
        Omega=Omega / max_Omega,
        Delta=Delta / max_Omega,
    )
    s_qs_2.plot_detuning_energy_levels(plot_state_names=True)

    ax = plt.gca()

    ax.set_xticks(np.arange(0, 2.1e8, 0.5e8) / max_Omega)
    ax.set_yticks(np.arange(-4e8, 5e8, 2e8) / max_Omega)

    scaled_xaxis_ticker = ticker.FuncFormatter(
        lambda x, pos: '{0:.1e}'.format(x * max_Omega))
    scaled_yaxis_ticker = ticker.FuncFormatter(
        lambda x, pos: '{0:g}'.format(x * max_Omega))
    ax.xaxis.set_major_formatter(scaled_xaxis_ticker)
    ax.yaxis.set_major_formatter(scaled_yaxis_ticker)
    plt.tight_layout()

    plt.show()
Ejemplo n.º 5
0
def plot_n_8():
    N = 8
    a = 532e-9

    # C6 = 2 * constants.pi * 0.4125e6 * (8 * a) ** 6  # [MHz m^6]
    C6 = 1.625e-60  # [J m^6]

    L = (N - 1) * a
    V_L = C6 / (L**6) / constants.hbar  # Joules / hbar
    V = C6 / constants.hbar
    # "/ constants.hbar" due to hamiltonian definition (H / hbar as input)

    s_qs = StaticQubitSystem(N=N,
                             V=V,
                             geometry=RegularLattice1D(spacing=a),
                             Omega=0,
                             Delta=np.linspace(-3e4 * V_L, 23e4 * V_L, 3))

    s_qs.plot_detuning_energy_levels(plot_state_names=False)

    ax = plt.gca()
    ax.xaxis.set_ticks(np.arange(0, 21e4, 5e4) * V_L)
    ax.yaxis.set_ticks(np.arange(-10e4, 11e4, 5e4) * V_L)
    ax.set_xlim(-3e4 * V_L, 23e4 * V_L)
    ax.set_ylim(-10 * V_L * 7**6, 10 * V_L * 7**6)  # WHY IS THERE A 7^6 TERM?!
    # ax.set_ylim(-10 * V_L, 10 * V_L)

    scaled_xaxis_ticker = ticker.FuncFormatter(
        lambda x, pos: '{0:.1e}'.format(x / V_L))
    scaled_yaxis_ticker = ticker.FuncFormatter(
        lambda x, pos: '{0:g}'.format(x / V_L))
    ax.xaxis.set_major_formatter(scaled_xaxis_ticker)
    ax.yaxis.set_major_formatter(scaled_yaxis_ticker)
    plt.show()

    -.3, 1.4
Ejemplo n.º 6
0
from qubit_system.geometry.regular_lattice_1d import RegularLattice1D
from qubit_system.utils.ghz_states import AlternatingGHZState

N_RYD = 50
C6 = interaction_constants.get_C6(N_RYD)

LATTICE_SPACING = 1.5e-6

print(f"C6: {C6:.3e}")
characteristic_V = C6 / (LATTICE_SPACING**6)
print(f"Characteristic V: {characteristic_V:.3e} Hz")

N = 8
timesteps = 50
t = 2e-6
geometry = RegularLattice1D(LATTICE_SPACING)
t_list = np.linspace(0, t, timesteps + 1)
ghz_state = AlternatingGHZState(N)

norm_t = t * characteristic_V
optim_result = get_optimised_controls(
    N,
    n_ts=timesteps,
    norm_t=norm_t,
    norm_V=1,
    target_state_symmetric=True,
    ghz_state=ghz_state,
    optim_kwargs={
        'init_pulse_type': "RND",
        'max_wall_time': 300,
        'max_iter': 1000,
Ejemplo n.º 7
0
    iter_stop=40,
    continue_from=Result.load(OPT_RESULT_DUMP, objectives=objectives) if CONTINUE_FROM else None
)

dump_file_name = OPT_RESULT_DUMP if not CONTINUE_FROM else OPT_RESULT_DUMP + "_1"
opt_result.dump(dump_file_name)

print(opt_result)

if SHOW_PLOTS:
    plot_pulse(opt_result.optimized_controls[0], norm_t_list, "Optimised $\Omega$")
    plot_pulse(opt_result.optimized_controls[1], norm_t_list, "Optimised $\Delta$")

opt_dynamics = opt_result.optimized_objectives[0].mesolve(
    norm_t_list, e_ops=[proj_G, proj_GHZ])
plot_population(opt_dynamics)

final_Omega = opt_result.optimized_controls[0] * characteristic_V
final_Delta = opt_result.optimized_controls[1] * characteristic_V
t_list = norm_t_list / characteristic_V
e_qs = EvolvingQubitSystem(
    N=N, V=C6, geometry=RegularLattice1D(LATTICE_SPACING),
    Omega=get_hamiltonian_coeff_interpolation(t_list, final_Omega, "cubic"),
    Delta=get_hamiltonian_coeff_interpolation(t_list, final_Delta, "cubic"),
    t_list=np.linspace(0, t, 300),
    ghz_state=StandardGHZState(N)
)
solve_and_print_stats(e_qs)

plt.show()

N = int(os.getenv("N"))
job_id = os.getenv("PBS_JOBID")
alg = os.getenv("ALG")
geometry_envvar = eval(os.getenv("QUBIT_GEOMETRY"))

print("Parameters:\n"
      f"\tjob_id: {job_id}\n"
      f"\tN: {N}\n"
      f"\tQUBIT_GEOMETRY: {geometry_envvar}\n"
      f"\tALG: {alg}\n"
      f"\tAMP_BOUNDS: {AMP_BOUNDS}\n"
      f"\tMAX_WALL_TIME: {MAX_WALL_TIME}\n")
if geometry_envvar == 1:
    geometry = RegularLattice1D(LATTICE_SPACING)
    norm_geometry = RegularLattice1D()
elif len(geometry_envvar) == 2:
    geometry = RegularLattice2D(geometry_envvar, spacing=LATTICE_SPACING)
    norm_geometry = RegularLattice2D(geometry_envvar)
elif len(geometry_envvar) == 3:
    geometry = RegularLattice3D(geometry_envvar, spacing=LATTICE_SPACING)
    norm_geometry = RegularLattice3D(geometry_envvar)
else:
    raise ValueError(
        'QUBIT_GEOMETRY has to be either "1", "(X, Y)", or "(X, Y, Z)"')

OPTIM_RESULT_FOLDER = Path(__file__).parent / 'optim_results'
OPTIM_RESULT_FOLDER.mkdir(exist_ok=True)

trigger_event("job_progress", value1="Job started", value2=job_id)
Ejemplo n.º 9
0
# plt.grid()
# plt.tight_layout()
# plt.show()
from qubit_system.utils.states_quimb import get_states, get_label_from_state, get_product_basis_states_index

t = 1.1e-6
N = 20
ghz_state = AlternatingGHZState(N)
num_ts = 150
Omega_func = get_hamiltonian_coeff_fn(paper_data.Omega, N)
Delta_func = get_hamiltonian_coeff_fn(paper_data.Delta, N)
Omega = np.array([Omega_func(_t) for _t in np.linspace(0, t, num_ts)])[:-1]
Delta = np.array([Delta_func(_t) for _t in np.linspace(0, t, num_ts)])[:-1]
e_qs = EvolvingQubitSystem(N=N,
                           V=paper_data.V,
                           geometry=RegularLattice1D(),
                           Omega=Omega,
                           Delta=Delta,
                           t_list=np.linspace(0, t, num_ts),
                           ghz_state=ghz_state)


def get_hamiltonian_variables_with_edge_fields(
        e_qs: EvolvingQubitSystem) -> Tuple[q.qarray, q.qarray, q.qarray]:
    sx = q.pauli("X", sparse=True)
    sz = q.pauli("Z", sparse=True)
    qnum = (sz + q.identity(2, sparse=True)) / 2
    dims = [2] * e_qs.N

    # noinspection PyTypeChecker
    time_independent_terms: q.qarray = 0
Ejemplo n.º 10
0
        # (Star(8, spacing=LATTICE_SPACING),
        #  CustomGHZState(N, [True, False, True, False, False, True, False, True]),
        #  "2D_star_alt"),

        # (RegularLattice2D((4, 3), spacing=LATTICE_SPACING),
        #  CustomGHZState(N, [True, False, True, False, True, False, True, False, True, False, True, False]),
        #  "2d_alt_n12"),

        # (RegularLattice2D((4, 4), spacing=LATTICE_SPACING),
        #  CustomGHZState(N, [True, False, True, False, False, True, False, True, True, False, True, False, False, True, False, True]),
        #  "2d_alt_n16"),

        # (RegularLattice2D((4, 5), spacing=LATTICE_SPACING),
        #  CustomGHZState(N, [True, False, True, False, True, False, True, False, True, False, True, False, True, False, True, False, True, False, True, False]),
        #  "2d_alt_n20"),
        (RegularLattice1D(LATTICE_SPACING),
         CustomGHZState(N, [True, True, True, True]), "1d_std_n4"),

        # (RegularLattice1D(LATTICE_SPACING),
        #  CustomGHZState(N, [True, True]),
        #  "1d_std_n2"),
    ]

    REPEATS = 2
    for i, (geometry, ghz_state, name) in enumerate(tqdm.tqdm(configurations)):
        crossing = get_crossing(ghz_state, geometry, N, C6)
        Omega_limits = (0, crossing)
        Delta_limits = (0.5 * crossing, 1.5 * crossing)
        domain = get_domain(Omega_limits, Delta_limits, timesteps)

        fidelities = []
Ejemplo n.º 11
0
        # pulse_scaling=1, pulse_offset=1,
        gen_stats=True,
        alg="GRAPE",
        init_pulse_type="RND",
        max_wall_time=30,
        max_iter=5000,
        fid_err_targ=1e-3,
        log_level=qutip.logging_utils.WARN,
    )
    result.stats.report()

    final_fidelity = qutip.fidelity(target_state_, result.evo_full_final)**2
    print(f"Final fidelity: {final_fidelity:.5f}")

    print(f"Final gradient normal: {result.grad_norm_final:.3e}")
    print(f"Terminated due to: {result.termination_reason}")

    return final_fidelity


for target_state in [
        StandardGHZState(N).get_state_tensor(True),
        AlternatingGHZState(N).get_state_tensor(True),
]:
    for geometry in [
            RegularLattice1D(),
            RegularLattice2D((2, 4)),
            RegularLattice3D((2, 2, 2)),
    ]:
        optimise_and_evaluate_fidelity(target_state, geometry)
Ejemplo n.º 12
0
plt.rc('font', family="serif", serif="CMU Serif")

N_RYD = 50
C6 = interaction_constants.get_C6(N_RYD)

LATTICE_SPACING = 1.5e-6

print(f"C6: {C6:.3e}")
print(f"Characteristic V: {C6 / (LATTICE_SPACING ** 6):.3e} Hz")

t = 2e-6

N = 4
s_qs = StaticQubitSystem(N=N,
                         V=C6,
                         geometry=RegularLattice1D(spacing=LATTICE_SPACING),
                         Omega=0,
                         Delta=np.linspace(-2e9, 2e9, 2**N))
s_qs.plot_detuning_energy_levels(True,
                                 savefig_name="energy_levels.png",
                                 show=True)


def solve_and_print_stats(e_qs: EvolvingQubitSystem):
    e_qs.solve()
    fidelity_with_ghz = e_qs.get_fidelity_with("ghz")
    fidelity_with_ghz_asymmetric = e_qs.get_fidelity_with("ghz_antisymmetric")
    print(
        f"fidelity with GHZ: {fidelity_with_ghz:.4f} (with antisymmetric: {fidelity_with_ghz_asymmetric:.4f})"
    )
    fidelity_with_ground = e_qs.get_fidelity_with("ground")
Ejemplo n.º 13
0

if __name__ == '__main__':
    N_RYD = 50
    C6 = interaction_constants.get_C6(N_RYD)

    LATTICE_SPACING = 1.5e-6

    print(f"C6: {C6:.3e}")
    characteristic_V = C6 / (LATTICE_SPACING**6)
    print(f"Characteristic V: {characteristic_V:.3e} Hz")

    N = 8

    geometry_and_labels = [
        (RegularLattice1D(), ['egegegeg']),
        (RegularLattice2D((4, 2)), ['eggeegge']),
        (RegularLattice3D((2, 2, 2)), ['eggegeeg']),
    ]
    i = 2
    geometry = geometry_and_labels[i][0]
    s_qs = StaticQubitSystem(
        N=N,
        V=characteristic_V,
        geometry=geometry,
        Omega=0,
        Delta=np.linspace(-characteristic_V * 5, characteristic_V * 5, 50),
    )

    geometry.plot()
    calculate_ghz_crossings(s_qs,