From 60b9def24ec6cec874cf5982840ece489ec8227b Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Thu, 12 Jan 2023 19:16:52 +0100 Subject: [PATCH] Added functionality to compute potential due to a Gaussian beam with astigmatism, plotting of ideal potential along with affected potential to show deviation. --- calculateDipoleTrapPotential.py | 62 ++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/calculateDipoleTrapPotential.py b/calculateDipoleTrapPotential.py index f6beff7..f35bfe9 100644 --- a/calculateDipoleTrapPotential.py +++ b/calculateDipoleTrapPotential.py @@ -33,7 +33,7 @@ def z_R(w_0:np.ndarray, lamb:float)->np.ndarray: # Beam Radius def w(pos, w_0, lamb): - return w_0*np.sqrt(1+(pos*lamb/(np.pi*w_0**2))**2) + return w_0*np.sqrt(1+(pos / z_R(w_0, lamb))**2) def trap_depth(w_1:"float|u.quantity.Quantity", w_2:"float|u.quantity.Quantity", P:"float|u.quantity.Quantity", alpha:float)->"float|u.quantity.Quantity": return 2*P/(np.pi*w_1*w_2) * (1 / (2 * ac.eps0 * ac.c)) * alpha * (4 * np.pi * ac.eps0 * ac.a0**3) @@ -47,6 +47,12 @@ def single_gaussian_beam_potential(positions: "np.ndarray|u.quantity.Quantity", U = - U_tilde * A * np.exp(-2 * ((positions[0,:]/w(positions[1,:], waists[0], wavelength))**2 + (positions[2,:]/w(positions[1,:], waists[1], wavelength))**2)) return U +def astigmatic_single_gaussian_beam_potential(positions: "np.ndarray|u.quantity.Quantity", waists: "np.ndarray|u.quantity.Quantity", del_y:"float|u.quantity.Quantity", alpha:"float|u.quantity.Quantity", P:"float|u.quantity.Quantity"=1, wavelength:"float|u.quantity.Quantity"=1.064*u.um)->np.ndarray: + A = 2*P/(np.pi*w(positions[1,:] - (del_y/2), waists[0], wavelength)*w(positions[1,:] + (del_y/2), waists[1], wavelength)) + U_tilde = (1 / (2 * ac.eps0 * ac.c)) * alpha * (4 * np.pi * ac.eps0 * ac.a0**3) + U = - U_tilde * A * np.exp(-2 * ((positions[0,:]/w(positions[1,:] - (del_y/2), waists[0], wavelength))**2 + (positions[2,:]/w(positions[1,:] + (del_y/2), waists[1], wavelength))**2)) + return U + def single_gaussian_beam_potential_harmonic_approximation(positions: "np.ndarray|u.quantity.Quantity", waists: "np.ndarray|u.quantity.Quantity", depth:"float|u.quantity.Quantity"=1, wavelength:"float|u.quantity.Quantity"=1.064*u.um)->np.ndarray: U = - depth * (1 - (2 * (positions[0,:]/waists[0])**2) - (2 * (positions[2,:]/waists[1])**2) - (0.5 * positions[1,:]**2 * np.sum(np.reciprocal(z_R(waists, wavelength)))**2)) return U @@ -88,19 +94,24 @@ def plotPotential(Positions, Powers, ComputedPotentials, axis, TrapDepthLabels): ## plot of the measured parameter vs. scan parameter plt.figure(figsize=(9, 7)) + j = 0 for i in range(np.size(ComputedPotentials, 0)): v, dv, popt, pcov = extractTrapFrequency(Positions, ComputedPotentials[i], TrapDepthInKelvin, axis) unit = 'Hz' - if v <= 0: + if v <= 0.0: v = np.nan dv = np.nan unit = 'Hz' - elif v > 0 and orderOfMagnitude(v) > 2: + elif v > 0.0 and orderOfMagnitude(v) > 2: v = v / 1e3 # in kHz dv = dv / 1e3 # in kHz unit = 'kHz' tf_label = '\u03BD = %.1f \u00B1 %.2f %s'% tuple([v,dv,unit]) - plt.plot(Positions[axis], ComputedPotentials[i][axis], label = 'P = ' + str(Powers[i]) + ' W; ' + TrapDepthLabels[i] + '; ' + tf_label) + if i % 2 == 0 and j < len(Powers): + plt.plot(Positions[axis], ComputedPotentials[i][axis], '--',label = 'P = ' + str(Powers[j]) + ' W; ' + TrapDepthLabels[j] + '; ' + tf_label) + elif i % 2 != 0 and j < len(Powers): + plt.plot(Positions[axis], ComputedPotentials[i][axis], label = 'P = ' + str(Powers[j]) + ' W; ' + tf_label) + j = j + 1 if axis == 0: dir = 'X' elif axis == 1: @@ -111,7 +122,7 @@ def plotPotential(Positions, Powers, ComputedPotentials, axis, TrapDepthLabels): plt.ylabel('Trap Potential (uK)', fontsize= 12, fontweight='bold') plt.tight_layout() plt.grid(visible=1) - plt.legend(prop={'size': 12, 'weight': 'bold'}) + plt.legend(loc=3, prop={'size': 12, 'weight': 'bold'}) plt.show() # plt.savefig('pot_' + dir + '.png') @@ -122,7 +133,7 @@ if __name__ == '__main__': Powers = [40] Polarizability = 184.4 # in a.u, most precise measured value of Dy polarizability w_x, w_z = 34*u.um, 27.5*u.um # Beam Waists in the x and y directions - # w_x, w_z = 70*u.um, 70*u.um # Beam Waists in the x and y directions + # w_x, w_z = 30*u.um, 30*u.um # Beam Waists in the x and y directions # w_x, w_z = 20.5*u.um, 20.5*u.um axis = 1 # axis referenced to the beam along which you want the dipole trap potential @@ -132,13 +143,15 @@ if __name__ == '__main__': ComputedPotentials = [] TrapDepthLabels = [] - gravity = True - astigmatism = False + gravity = False + astigmatism = True tilt_gravity = True theta = 1 # in degrees tilt_axis = [1, 0, 0] # lab space coordinates are rotated about x-axis in reference frame of beam + disp_foci = 1.5 * z_R(w_0 = np.asarray([30]), lamb = 1.064)[0]*u.um # difference in position of the foci along the propagation direction (Astigmatism) + for p in Powers: Power = p*u.W # Single Beam Power @@ -163,12 +176,12 @@ if __name__ == '__main__': z_Positions = np.arange(-extent, extent, 1)*u.um Positions = np.vstack((x_Positions, y_Positions, z_Positions)) * projection_axis[:, np.newaxis] - if not gravity and not astigmatism: - TrappingPotential = single_gaussian_beam_potential(Positions, np.asarray([w_x.value, w_z.value])*u.um, P = Power, alpha = Polarizability) - TrappingPotential = TrappingPotential + np.zeros((3, len(TrappingPotential))) * TrappingPotential.unit - TrappingPotential = (TrappingPotential/ac.k_B).to(u.uK) + IdealTrappingPotential = single_gaussian_beam_potential(Positions, np.asarray([w_x.value, w_z.value])*u.um, P = Power, alpha = Polarizability) + IdealTrappingPotential = IdealTrappingPotential + np.zeros((3, len(IdealTrappingPotential))) * IdealTrappingPotential.unit + IdealTrappingPotential = (IdealTrappingPotential/ac.k_B).to(u.uK) - elif gravity and not astigmatism: + if gravity and not astigmatism: + ComputedPotentials.append(IdealTrappingPotential) # Influence of Gravity m = 164*u.u gravity_axis = np.array([0, 0, 1]) @@ -180,17 +193,32 @@ if __name__ == '__main__': TrappingPotential = (TrappingPotential/ac.k_B).to(u.uK) elif not gravity and astigmatism: + ComputedPotentials.append(IdealTrappingPotential) # Influence of Astigmatism - pass + TrappingPotential = astigmatic_single_gaussian_beam_potential(Positions, np.asarray([w_x.value, w_z.value])*u.um, P = Power, del_y = disp_foci, alpha = Polarizability) + TrappingPotential = TrappingPotential + np.zeros((3, len(TrappingPotential))) * TrappingPotential.unit + TrappingPotential = (TrappingPotential/ac.k_B).to(u.uK) + + elif gravity and astigmatism: + ComputedPotentials.append(IdealTrappingPotential) + # Influence of Gravity and Astigmatism + m = 164*u.u + gravity_axis = np.array([0, 0, 1]) + if tilt_gravity: + R = rotation_matrix(tilt_axis, np.radians(theta)) + gravity_axis = np.dot(R, gravity_axis) + gravity_axis_positions = np.vstack((x_Positions, y_Positions, z_Positions)) * gravity_axis[:, np.newaxis] + TrappingPotential = astigmatic_single_gaussian_beam_potential(Positions, np.asarray([w_x.value, w_z.value])*u.um, P = Power, del_y = disp_foci, alpha = Polarizability) + gravitational_potential(gravity_axis_positions, m) + TrappingPotential = (TrappingPotential/ac.k_B).to(u.uK) else: - # Influence of Gravity and Astigmatism - pass - + TrappingPotential = IdealTrappingPotential + # v, dv, popt, pcov = extractTrapFrequency(Positions, TrappingPotential, TrapDepthInKelvin, axis) # plotHarmonicFit(Positions, TrappingPotential, TrapDepthInKelvin, axis, popt, pcov) ComputedPotentials.append(TrappingPotential) + # print(np.shape(ComputedPotentials)) ComputedPotentials = np.asarray(ComputedPotentials) plotPotential(Positions, Powers, ComputedPotentials, axis, TrapDepthLabels) \ No newline at end of file