From fbf985fa63584f3a39e7b8a3c2f3bbca719191ad Mon Sep 17 00:00:00 2001 From: Karthik Date: Sat, 1 Mar 2025 04:32:14 +0100 Subject: [PATCH] Minor modifications, new script to extract beam waist --- Estimations/EstimatesForAccordionLattice.m | 7 ++ Estimations/EstimatesForStaticLattice.m | 2 + .../ExtractParametersFromCavityModeProfile.m | 9 ++- Estimations/ExtractWaist.m | 79 +++++++++++++++++++ Estimations/GaussianABCDCalculator.m | 2 +- Estimations/ModellingImagingAberrations.m | 2 + 6 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 Estimations/ExtractWaist.m diff --git a/Estimations/EstimatesForAccordionLattice.m b/Estimations/EstimatesForAccordionLattice.m index df9df88..cfc109e 100644 --- a/Estimations/EstimatesForAccordionLattice.m +++ b/Estimations/EstimatesForAccordionLattice.m @@ -36,6 +36,7 @@ LatticeSpacing = Wavelength ./ (2.*sin((theta*pi/180)/2)); figure(1); set(gcf,'Position',[100 100 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); plot(theta, LatticeSpacing * 1E6, LineWidth=2.0) xlim([0 19]); ylim([0.5 21]); @@ -67,6 +68,7 @@ nu_z = Omega_z ./ (2*pi); figure(2); set(gcf,'Position',[100 100 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); plot(LatticeSpacings * 1E6, nu_z * 1E-3, LineWidth=2.0) xlim([0.5 21]); xlabel('Lattice spacing (µm)', FontSize=16) @@ -97,6 +99,7 @@ units = ' E_r'; figure(3); set(gcf,'Position',[100 100 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); plot(Powers, TrapDepthsToPlot, LineWidth=2.0) xlim([0.0 5.25]); xlabel('Powers (W)', FontSize=16) @@ -111,6 +114,7 @@ RecoilEnergy = PlanckConstant^2 ./ (8 .* Dy164Mass .* LatticeSpacing.^2); figure(4); set(gcf,'Position',[100 100 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); semilogy(LatticeSpacing * 1E6, RecoilEnergy/PlanckConstant, LineWidth=2.0) xlim([0.5 21]); xlabel('Lattice spacing (µm)', FontSize=16) @@ -124,6 +128,7 @@ ExpansionTime = linspace(1E-3, 20.0E-3, 100); figure(5); set(gcf,'Position',[100 100 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); labels = []; for ls = [2E-6:2E-6:5E-6 6E-6:6E-6:20E-6] @@ -155,6 +160,7 @@ TrapDepthsInUnitsOfRecoilEnergy = TrapDepthsInHz ./ TwoPhotonRecoilEnergyInHz; figure(6); set(gcf,'Position',[100 100 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); plot(TrapDepthsInUnitsOfRecoilEnergy, RabiOscillationFrequency .* 1E-3, LineWidth=2.0) xlim([0 4]); xlabel('Trap depths (E_r)', FontSize=16) @@ -182,6 +188,7 @@ PopulationInFirstOrders = C .* (sin(0.5 .* PulseDurations .* (RabiOscill figure(7); set(gcf,'Position',[100 100 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); plot(PulseDurations .* 1E6, PopulationInFirstOrders, LineWidth=2.0, DisplayName=['\bf Power = ' num2str(Power) ' W / Trap depth = ' num2str(round(TrapDepthsInUnitsOfRecoilEnergy, 1)) ' E_r']) xlabel('Pulse duration (µs)', FontSize=16) ylabel('Fraction of atoms in first order', FontSize=16) diff --git a/Estimations/EstimatesForStaticLattice.m b/Estimations/EstimatesForStaticLattice.m index da9c868..4c7eff6 100644 --- a/Estimations/EstimatesForStaticLattice.m +++ b/Estimations/EstimatesForStaticLattice.m @@ -66,6 +66,7 @@ end figure(1) clf set(gcf,'Position',[50 50 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); imagesc(Power_values, waist_values * 1e6, R_z_matrix); % Specify x and y data for axes hold on [contour_matrix, contour_handle] = contour(Power_values, waist_values * 1e6, R_z_matrix, 'LineColor', 'white', 'LineWidth', 1.5); @@ -81,6 +82,7 @@ title(['\bf Thomas-Fermi Radius @ Lattice Spacing = ' num2str(LatticeConstant * figure(2) clf set(gcf,'Position',[50 50 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); imagesc(Power_values, waist_values * 1e6, omega_eff_matrix); % Specify x and y data for axes hold on [contour_matrix, contour_handle] = contour(Power_values, waist_values * 1e6, omega_eff_matrix, 'LineColor', 'white', 'LineWidth', 1.5); diff --git a/Estimations/ExtractParametersFromCavityModeProfile.m b/Estimations/ExtractParametersFromCavityModeProfile.m index 5428522..e575cc0 100644 --- a/Estimations/ExtractParametersFromCavityModeProfile.m +++ b/Estimations/ExtractParametersFromCavityModeProfile.m @@ -15,15 +15,16 @@ CavitySignal = CavitySignal - yoffset; Time = Time - xoffset; % Plot the data -figure; +figure(1); +clf; +set(gcf,'Position',[50 50 950 750]) +set(gca,'FontSize',16,'Box','On','Linewidth',2); scatter(Time, CavitySignal, 10, 'b', 'filled', 'MarkerFaceAlpha', 0.5); -grid on; - -% Format the plot xlabel('\bf Time (s)', 'FontSize', 16); ylabel('\bf Voltage (V)', 'FontSize', 16); title('\bf Cavity Signal', 'FontSize', 16); set(gca, 'FontSize', 12); +grid on; %% Fit cavity signal diff --git a/Estimations/ExtractWaist.m b/Estimations/ExtractWaist.m new file mode 100644 index 0000000..a5dad34 --- /dev/null +++ b/Estimations/ExtractWaist.m @@ -0,0 +1,79 @@ +z = sort((26:-1:1))*1e-3; +d = sort([246, 240, 235, 230, 226, 222, 218, 215, 213, 210, 206, 204, 201, 199, 197, 195, 194, 193, 192, 191, 190, 191, 190, 189, 189, 189])*1e-6; +Wavelength = 532e-9; +TrimIndex = 7; +Seed = [100e-6 -5e-2]; + +[w0, dw0, z0, dz0] = extractWaist(z, d, Wavelength, Seed, TrimIndex); + +%% + +z = z0; +f = 500e-3; +Mr = abs(f/(z-f)); +r = zr/(z-f); +M = Mr/sqrt(1+r^2); +zp_to_f = M^2*(z-f)*10^6; % distance of waist to focal point in um +w0p = M*w0*1e3; % waist after objective in um + +%% + +z = z0+dz0; +f = 50e-3; +Mr = abs(f/(z-f)); +r = zr/(z-f); +M = Mr/sqrt(1+r^2); +zp_to_fmax = M^2*(z-f)*10^6; % distance of waist ot focal point in um +w0pmax = M*w0*1e3; % waist after objective in um + +z = z0-dz0; +f = 50e-3; +Mr = abs(f/(z-f)); +r = zr/(z-f); +M = Mr/sqrt(1+r^2); +zp_to_fmin = M^2*(z-f)*10^6; % distance of waist ot focal point in um +w0pmin = M*w0*1e3; % waist after objective in um + +function [w0, dw0, z0, dz0] = extractWaist(z, d, lb, seed, trim_idx) + + w = d/2; + + fitmodel_waist = @(w0,z0,x)w0*sqrt(1+(x-z0).^2/(pi.*w0.^2/lb).^2); + fitmodel_waist_far= @(w0,z0,x)(x-z0)*lb/pi./w0; + + lower_bounds = [0, -inf]; % Setting lower bound for w0 as 0 to prevent negative waist sizes + upper_bounds = [inf, inf]; + z_trimmed = z(end-trim_idx:end); + w_trimmed = w(end-trim_idx:end); + fitwaistfar = fit(z_trimmed', w_trimmed', fitmodel_waist_far, 'StartPoint', seed, 'Lower', lower_bounds, 'Upper', upper_bounds); % fit first as if waist far away + + seed = [fitwaistfar.w0 fitwaistfar.z0]; + fitwaist = fit(z', w', fitmodel_waist, 'StartPoint', seed, 'Lower', lower_bounds, 'Upper', upper_bounds); + + ci = confint(fitwaist,1-exp(-1)); %63% uncertainty confidence interval + ws = ci(:,1)*1e3; % in mm + w0 = mean(ws); + dw0 = diff(ws)/2; + z0s = ci(:,2)*1e3; % in mm + z0 = mean(z0s); + dz0 = diff(z0s)/2; + + % Plot + zplot = linspace(-0.03, 0.03, 1001); + waistplot = feval(fitwaist,zplot); + waistplotfar = feval(fitwaistfar, zplot); + + figure(1); + clf; + set(gcf,'Position',[100 100 950 750]) + set(gca,'FontSize',16,'Box','On','Linewidth',2); + hold all + plot(z*1e3, w*1e6, 'ok', 'Linewidth',2, 'DisplayName', 'Measured Data') + plot(zplot*1e3, waistplot*1e6,'r-','Linewidth',2, 'DisplayName', 'Fit at near distances') + plot(zplot*1e3, waistplotfar*1e6,'b--','Linewidth',2, 'DisplayName', 'Fit at far distances') + ylim([min(w)*1e6, max(w)*1e6]) + grid on + xlabel('Distance (mm)'); + ylabel('Beam Radius (mum)') + legend('Location', 'NorthWest') +end \ No newline at end of file diff --git a/Estimations/GaussianABCDCalculator.m b/Estimations/GaussianABCDCalculator.m index 084104d..3984077 100644 --- a/Estimations/GaussianABCDCalculator.m +++ b/Estimations/GaussianABCDCalculator.m @@ -285,7 +285,7 @@ function plotResult(func, var, rang) % Create a figure figure; set(gcf, 'Position', [100 100 950 750]); - + set(gca,'FontSize',16,'Box','On','Linewidth',2); % Plot the function and its negative plot(rang, y_vals, 'b'); hold on; plot(rang, y_neg_vals, 'b'); diff --git a/Estimations/ModellingImagingAberrations.m b/Estimations/ModellingImagingAberrations.m index aac55e1..49a8a72 100644 --- a/Estimations/ModellingImagingAberrations.m +++ b/Estimations/ModellingImagingAberrations.m @@ -86,6 +86,7 @@ function plotZernike(n, m, NumberOfGridPoints) figure(1) clf set(gcf,'Position',[50 50 950 750]) + set(gca,'FontSize',16,'Box','On','Linewidth',2); surf(X, Y, Z, 'EdgeColor', 'none'); colormap jet; colorbar; @@ -131,6 +132,7 @@ function plotImage(xvals, yvals, image, titlestring) figure clf set(gcf,'Position',[50 50 950 750]) + set(gca,'FontSize',16,'Box','On','Linewidth',2); imagesc(xvals, yvals, image); colorbar; colormap jet;