def tune_to_voltage_ibex_optics(tune_goal, f_rf_MHz): """This function assumes a sinusoid waveform and equal tunes in both planes. It searches for the voltage amplitude that produces tune_goal""" op = ibex_optics.optics(f_rf=f_rf_MHz, npts=1000) def volt_root(v): tune = op.voltage_to_tune(v)[0] - tune_goal return tune vg = 60 #initial guess vsol = newton(volt_root, vg) return vsol
max_bits = 2**15 # 1E8 samples per second is the limit of the system #################################################### # option to use Mathematica or approximate equation to convert tune to voltage use_mathematica = False if use_mathematica: # Use the mathematica to convert the tune to a voltage. Read output file tune_x, tune_y, rf_voltage, offset_voltage = readfiledata('V-DC.txt') else: # Use ibex_optics script to do conversion # assumes equal tunes in both transverse plane import ibex_optics op = ibex_optics.optics(f_rf=1.0, npts=1000) accumulation_voltage = tune_to_voltage_ibex_optics(accumulation_tune) tune_x = np.linspace(initial_tune, final_tune, tune_points) voltage_array = [] for tune in tune_x: v = tune_to_voltage_ibex_optics(tune) voltage_array.append(v) if rods_powered == 2: voltage_array = voltage_array * 2 accumulation_voltage = accumulation_voltage * 2 print "v, 2v ", v, 2 * v amp_connect = {
qfn = lambda qm, r0, omega0, Vrf: 4 * qm * Vrf / (r0 * omega0)**2 afn = lambda qm, r0, omega0, U: 8 * qm * U / (r0 * omega0)**2 plt.rcParams.update({'axes.labelsize': 20}) plt.rcParams.update({'xtick.labelsize': 14}) plt.rcParams.update({'ytick.labelsize': 14}) charge = 1.602176565e-19 mass_proton = 1.672621777e-27 qm_proton = charge / mass_proton A_Ar = 39.948 f_rf_MHz = 1 omega_rf = 2 * math.pi * f_rf_MHz * 1e6 r0 = 5e-3 op = ibex_optics.optics(f_rf=f_rf_MHz, npts=1000) nv = 40 nu = nv v_a = np.linspace(0, 95, nv) u_a = np.linspace(0, 50, nu) #convert to a-q parameters q_a = qfn(qm_proton / A_Ar, r0, omega_rf, v_a) a_a = afn(qm_proton / A_Ar, r0, omega_rf, u_a) show_aq = True stability_a = [] index_row = 0
max_bits = 2**15 # 1E8 samples per second is the limit of the system #################################################### # option to use Mathematica or approximate equation to convert tune to voltage use_mathematica = False if use_mathematica: # Use the mathematica to convert the tune to a voltage. Read output file tune_x, tune_y, rf_voltage, offset_voltage = readfiledata('V-DC.txt') else: # Use ibex_optics script to do conversion # assumes equal tunes in both transverse plane import ibex_optics op = ibex_optics.optics(f_rf=1.0, npts=1000, lat_type="step") accumulation_voltage = tune_to_voltage_ibex_optics(accumulation_tune) tune_x = np.linspace(initial_tune, final_tune, tune_points) voltage_array = [] for tune in tune_x: v = tune_to_voltage_ibex_optics(tune) voltage_array.append(v) if rods_powered == 2: voltage_array = voltage_array * 2 accumulation_voltage = accumulation_voltage * 2 print "v, 2v ", v, 2 * v amp_connect = {