electron_histogram = np.vstack( (electron_histogram, electron_hist)) k += 1 #print("Ja!") Vres = f["Vres"][()] print("Out of %d simulations, %d did not converge..." % (len(Vres), len(Vres) - np.sum(converged))) fig = plt.figure(figsize=(7., 4.)) common.configure_axes(12) plt.pcolormesh(Vres, bins[:-1] * 1E6, np.log10(electron_histogram.T), vmin=0, vmax=2.0, cmap=plt.cm.hot_r) plt.colorbar() plt.xlim(Vres[0], Vres[-1]) plt.ylim(np.min(bins) * 1E6, np.max(bins) * 1E6) plt.xlabel("Resonator voltage (V)") plt.ylabel("Position across the channel ($\mu$m)") plt.title(r"$^{10}\log (n_\ell)$ for bin size = %.1f nm" % (dbin * 1E9)) if save: common.save_figure(fig, os.path.join(save_path, sub_dir)) print("Done!") plt.show()
def coordinate_transformation(r): x, y = anneal.r2xy(r) y_new = EP.map_y_into_domain(y) r_new = anneal.xy2r(x, y_new) return r_new # This is where the actual solving starts... os.mkdir(os.path.join(save_path, sub_dir)) time.sleep(1) os.mkdir(os.path.join(save_path, sub_dir, "Figures")) if save: common.save_figure(fig0, save_path=os.path.join(save_path, sub_dir)) common.save_figure(fig1, save_path=os.path.join(save_path, sub_dir)) # Save the data to a single file f = h5py.File(os.path.join(os.path.join(save_path, sub_dir), "Results.h5"), "w") f.create_dataset("electrostatic_potential", data=-Uinterp_symmetric) f.create_dataset("xpoints", data=x_symmetric * 1E-6) f.create_dataset("ypoints", data=y_box) f.create_dataset("Vres", data=resVs) f.create_dataset("use_gradient", data=use_gradient) f.create_dataset("gradient_tolerance", data=gradient_tolerance) conv_mon_save_path = os.path.join(save_path, sub_dir, "Figures") for k, Vres in tqdm(enumerate(resVs)):
plt.ylim(0., cavity_contributions[ten_strongest_mode_numbers[-1, -2]]) plt.xlabel("Mode number") plt.ylabel("Cavity contributions") plt.title("$V_\mathrm{res}$ = %.2f V" % Vres[-1]) Voi = 0.25 Voi_idx = common.find_nearest(np.array(Vres), Voi) modes = ten_strongest_mode_numbers[Voi_idx, 1:10] fig3 = plt.figure(figsize=(6., 4.)) plt.plot(np.sqrt(Eigenvalues[Voi_idx, ranked_cavity_contributions]) / (2 * np.pi * 1E9), 'o', **common.plot_opt('red', msize=4)) plt.xlabel("Decreasing coupling to the cavity") plt.ylabel("$\omega_e/2\pi$ (GHz)") plt.title("Frequency of all modes at Vres = %.2f V" % Voi) if save: common.save_figure(fig3, save_path=os.path.join(save_path, sub_dir)) # Look at the electron position of the last voltage step and single out the electrons in the left and right row # Note: this only makes sense if you have two rows! xi, yi = anneal.r2xy(electron_positions[Voi_idx, :]) right_idxs = np.where(xi > 0)[0] sorted_right_idxs = np.argsort(right_idxs) left_idxs = np.where(xi < 0)[0] sorted_left_idxs = np.argsort(left_idxs) sorted_idxs = np.argsort(yi) if len(right_idxs) == 0 or len(left_idxs) == 0: print("2 row configuration not detected, assuming 1 row") two_rows = False else: two_rows = False
f.create_dataset("Vtg", data=Vtg) f.close() time.sleep(1) # Take a slice through the middle, at y = 0 to check if the insertion went well and doesn't produce weird gradients. if 0: U = output[0]['V'].T fig = plt.figure(figsize=(10.,3.)) common.configure_axes(13) plt.plot(x_eval[np.int(len(y_eval)/2), :] * 1E6, -U[np.int(len(y_eval)/2), :], '-k') plt.plot(x_trap_init * 1E6, np.zeros(len(x_trap_init)), 'o', color='mediumpurple', alpha=0.5) plt.xlabel("$x$ ($\mu$m)") plt.ylabel("Potential energy (eV)") if save: common.save_figure(fig, save_path=os.path.join(save_path, sub_dir)) plt.show() # This is where the actual solving starts... t = trap_analysis.TrapSolver() c = trap_analysis.get_constants() x_eval, y_eval, cropped_potentials = t.crop_potentials(output, ydomain=None, xdomain=None) for k, s in tqdm(enumerate(sweep_points)): coefficients = np.array([Vres, Vtrap, Vrg, Vcg, Vtg]) coefficients[SweepIdx] = s if Vcg is None: coefficients = np.delete(coefficients, 3)
plt.close('all') if twod_slice: electron_pos = electron_ri[::2] * 1E6 fig = plt.figure(figsize=(7., 3.)) common.configure_axes(13) plt.plot(x_plot * 1E6, CMS.V(x_plot, 0), '-', color='orange') plt.plot(electron_pos[electron_pos < 6], CMS.V(electron_pos[electron_pos < 6] * 1E-6, 0) + 0.005, 'o', color='cornflowerblue', lw=2.0, alpha=0.7, mec='k', mew=0.75) plt.xlabel("$x$ ($\mu$m)") plt.ylabel("Potential energy (eV)") plt.title("%s = %.2f V" % (electrode_names[swept_electrode_idx], coefficients[swept_electrode_idx])) #plt.ylim(np.min(CMS.V(x_plot, 0)), ) common.save_figure(fig, save_path=os.path.join( data_path, "2D slice")) plt.close(fig) k += 1
noof_electrons.append(N_electrons) # Here we plot the scaled cavity frequency shift vs. the resonator voltage. # fig6 = plt.figure(figsize=(6., 4.)) # plt.plot(Vres, scaled_cavity_frequency / 1E9, 'o', **common.plot_opt('red', msize=4)) # plt.ylabel("Scaled cavity frequency $\omega_0/2\pi$ (GHz)") # plt.xlabel("Resonator voltage (V)") # if save: # common.save_figure(fig6, save_path=os.path.join(save_path, sub_dir)) color.cycle_cmap(len(sub_dirs), cmap=plt.cm.Spectral) fig = plt.figure(figsize=(8., 4.)) common.configure_axes(12) for r in range(len(sub_dirs)): plt.plot(Vres, expt_frequency[r, :] / 1E9, '.-', label="N = %d" % noof_electrons[r]) plt.ylabel("Scaled cavity frequency $\omega_0/2\pi$ (GHz)") plt.xlabel("Resonator voltage (V)") plt.ylim(7.95, 8.0) plt.legend(loc=0, prop={'size': 10}) if save: common.save_figure(fig, save_path=os.path.join(save_path, sub_dirs[-1])) plt.show()