def setup(self): """Sets up matrices for Hamiltonian construction.""" with timer("Generating states"): if self.hamiltonian.endswith("relevant"): self.states = States(self.n, basis=Basis.N_L_ML_MS_RELEVANT) print("Loaded relevant N L ML MS states.") else: self.states = States(self.n, basis=Basis.N_L_ML_MS) print("Loaded N L ML MS states.") with timer("Loading Hamiltonian"): mat_1, mat_1_zeeman, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian( self.hamiltonian) mat_2_combination = mat_2_plus + mat_2_minus with timer("Loading transformations"): transform_1 = load_transformation(self.n, Basis.N_L_J_MJ_RELEVANT, Basis.N_L_ML_MS_RELEVANT) with timer("Applying transformation to nlmlms"): mat_1 = transform_basis(mat_1, transform_1) mat_1_zeeman = transform_basis(mat_1_zeeman, transform_1) mat_2 = transform_basis(mat_2, transform_1) # mat_2_plus = transform_basis(mat_2_plus, transform_1) # mat_2_minus = transform_basis(mat_2_minus, transform_1) mat_2_combination = transform_basis(mat_2_combination, transform_1) self.mat_1 = mat_1 self.mat_1_zeeman = mat_1_zeeman self.mat_2 = mat_2 # self.mat_2_plus = mat_2_plus # self.mat_2_minus = mat_2_minus self.mat_2_combination = mat_2_combination
with timer("Generating states"): states = States(n, basis=Basis.N_L_ML_MS_RELEVANT) # states = States(n, basis=Basis.N_L_ML_MS) with timer("Loading Hamiltonian"): mat_1, mat_1_zeeman, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian( f"{n}_rubidium87_relevant") # mat_1, mat_1_zeeman, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian(f"{n}_rubidium87") with timer("Loading transformations"): transform_1 = load_transformation(n, Basis.N_L_J_MJ_RELEVANT, Basis.N_L_ML_MS_RELEVANT) # transform_1 = load_transformation(n, Basis.N_L_J_MJ, Basis.N_L_ML_MS) with timer("Applying transformation to nlmlms"): mat_1 = transform_basis(mat_1, transform_1) mat_2 = transform_basis(mat_2, transform_1) mat_2_plus = transform_basis(mat_2_plus, transform_1) mat_2_minus = transform_basis(mat_2_minus, transform_1) steps = 50 steps = 100 # dc_fields = np.linspace(140, 185, steps) # V / m # dc_fields = np.linspace(185, 140, steps) # V / m # dc_fields = np.linspace(100, 350, steps) # V / m dc_fields = np.linspace(350, 100, steps) # V / m # dc_fields = np.linspace(250, 200, steps) # V / m rf_freq = 230e6 / 1e9 # GHz rf_field = 4.6 # V / m
mat_1, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian(f"{n}_rubidium87") # mat_1, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian(f"{n}_hydrogen") mat_2_combination = mat_2_plus + mat_2_minus # Units of a0 e # mat_2_combination = mat_2_plus # Units of a0 e mat_2_combination *= C_e * physical_constants["Bohr radius"][0] / C_hbar # Conversion from atomic units for dipole matrix elements to a Rabi freq in Hz mat_2_combination *= 1e-9 # Convert Hz to GHz # plot_matrices([mat_1, mat_2]) with timer("Loading transformations"): transform_1 = load_transformation(n, Basis.N_L_J_MJ, Basis.N_L_ML_MS) transform_2 = load_transformation(n, Basis.N_L_ML_MS, Basis.N1_N2_ML_MS) with timer("Applying transformation to nlmlms"): mat_1 = transform_basis(mat_1, transform_1) mat_2 = transform_basis(mat_2, transform_1) mat_2_combination = transform_basis(mat_2_combination, transform_1) with timer("Applying transformation to n1n2mlms"): mat_1 = transform_basis(mat_1, transform_2) mat_2 = transform_basis(mat_2, transform_2) mat_2_combination = transform_basis(mat_2_combination, transform_2) with timer("Applying state filters"): indices_to_keep = [] for i, (n1, n2, _ml, _ms) in enumerate(states): if _ms > 0 and n1 == 0 and _ml >= 0: # if _ms > 0 and n2 == 0 and _ml >= 0: indices_to_keep.append(i)
with timer("Loading Hamiltonian"): # mat_1, mat_1_zeeman, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian("51_rubidium87") # test = load_hamiltonian("51_rubidium87_relevant") mat_1, mat_1_zeeman, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian( "51_rubidium87_relevant") mat_1_h, mat_1_zeeman_h, mat_2_h, mat_2_minus_h, mat_2_plus_h = load_hamiltonian( "51_hydrogen") with timer("Loading transformations"): # transform = load_transformation(n, Basis.N_L_J_MJ, Basis.N_L_ML_MS) transform = load_transformation(n, Basis.N_L_J_MJ_RELEVANT, Basis.N_L_ML_MS_RELEVANT) with timer("Applying transformations"): mat_1 = transform_basis(mat_1, transform) mat_2 = transform_basis(mat_2, transform) mat_1_h = transform_basis(mat_1_h, transform) mat_2_h = transform_basis(mat_2_h, transform) dc_field = 100 hamiltonian_with_field = dc_field * mat_2 hamiltonian_with_field_h = dc_field * mat_2_h # hamiltonian_with_field = mat_1 + dc_field * mat_2 # hamiltonian_with_field_h = mat_1_h + dc_field * mat_2_h x = [] y = [] y_h = [] # Get eigenvalues for Hamiltonians
with timer("Generating states"): states_n_l_ml_ms = States(n, basis=Basis.N_L_ML_MS).states states = States(n, basis=Basis.N1_N2_ML_MS).states with timer("Loading Hamiltonian"): # mat_1, mat_1_zeeman, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian("51_rubidium87") mat_1, mat_1_zeeman, mat_2, mat_2_minus, mat_2_plus = load_hamiltonian( "_51_rubidium87") with timer("Loading transformations"): transform_1 = load_transformation(n, Basis.N_L_J_MJ, Basis.N_L_ML_MS) transform_2 = load_transformation(n, Basis.N_L_ML_MS, Basis.N1_N2_ML_MS) with timer("Applying transformations"): mat_2 = transform_basis(mat_2, transform_1) mat_2 = transform_basis(mat_2, transform_2) with timer("Applying state filters"): indices_to_keep = [] for i, (n1, n2, _ml, _ms) in enumerate(states): if _ms > 0 and _ml >= 0: indices_to_keep.append(i) mat_2 = mat_2[indices_to_keep, :][:, indices_to_keep] states = np.array(states)[indices_to_keep] dc_field = 230 x = [] y = []