Minor modifications, new script to extract beam waist

This commit is contained in:
Karthik 2025-03-01 04:32:14 +01:00
parent 21716395c5
commit fbf985fa63
6 changed files with 96 additions and 5 deletions

View File

@ -36,6 +36,7 @@ LatticeSpacing = Wavelength ./ (2.*sin((theta*pi/180)/2));
figure(1); figure(1);
set(gcf,'Position',[100 100 950 750]) set(gcf,'Position',[100 100 950 750])
set(gca,'FontSize',16,'Box','On','Linewidth',2);
plot(theta, LatticeSpacing * 1E6, LineWidth=2.0) plot(theta, LatticeSpacing * 1E6, LineWidth=2.0)
xlim([0 19]); xlim([0 19]);
ylim([0.5 21]); ylim([0.5 21]);
@ -67,6 +68,7 @@ nu_z = Omega_z ./ (2*pi);
figure(2); figure(2);
set(gcf,'Position',[100 100 950 750]) 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) plot(LatticeSpacings * 1E6, nu_z * 1E-3, LineWidth=2.0)
xlim([0.5 21]); xlim([0.5 21]);
xlabel('Lattice spacing (µm)', FontSize=16) xlabel('Lattice spacing (µm)', FontSize=16)
@ -97,6 +99,7 @@ units = ' E_r';
figure(3); figure(3);
set(gcf,'Position',[100 100 950 750]) set(gcf,'Position',[100 100 950 750])
set(gca,'FontSize',16,'Box','On','Linewidth',2);
plot(Powers, TrapDepthsToPlot, LineWidth=2.0) plot(Powers, TrapDepthsToPlot, LineWidth=2.0)
xlim([0.0 5.25]); xlim([0.0 5.25]);
xlabel('Powers (W)', FontSize=16) xlabel('Powers (W)', FontSize=16)
@ -111,6 +114,7 @@ RecoilEnergy = PlanckConstant^2 ./ (8 .* Dy164Mass .* LatticeSpacing.^2);
figure(4); figure(4);
set(gcf,'Position',[100 100 950 750]) set(gcf,'Position',[100 100 950 750])
set(gca,'FontSize',16,'Box','On','Linewidth',2);
semilogy(LatticeSpacing * 1E6, RecoilEnergy/PlanckConstant, LineWidth=2.0) semilogy(LatticeSpacing * 1E6, RecoilEnergy/PlanckConstant, LineWidth=2.0)
xlim([0.5 21]); xlim([0.5 21]);
xlabel('Lattice spacing (µm)', FontSize=16) xlabel('Lattice spacing (µm)', FontSize=16)
@ -124,6 +128,7 @@ ExpansionTime = linspace(1E-3, 20.0E-3, 100);
figure(5); figure(5);
set(gcf,'Position',[100 100 950 750]) set(gcf,'Position',[100 100 950 750])
set(gca,'FontSize',16,'Box','On','Linewidth',2);
labels = []; labels = [];
for ls = [2E-6:2E-6:5E-6 6E-6:6E-6:20E-6] for ls = [2E-6:2E-6:5E-6 6E-6:6E-6:20E-6]
@ -155,6 +160,7 @@ TrapDepthsInUnitsOfRecoilEnergy = TrapDepthsInHz ./ TwoPhotonRecoilEnergyInHz;
figure(6); figure(6);
set(gcf,'Position',[100 100 950 750]) set(gcf,'Position',[100 100 950 750])
set(gca,'FontSize',16,'Box','On','Linewidth',2);
plot(TrapDepthsInUnitsOfRecoilEnergy, RabiOscillationFrequency .* 1E-3, LineWidth=2.0) plot(TrapDepthsInUnitsOfRecoilEnergy, RabiOscillationFrequency .* 1E-3, LineWidth=2.0)
xlim([0 4]); xlim([0 4]);
xlabel('Trap depths (E_r)', FontSize=16) xlabel('Trap depths (E_r)', FontSize=16)
@ -182,6 +188,7 @@ PopulationInFirstOrders = C .* (sin(0.5 .* PulseDurations .* (RabiOscill
figure(7); figure(7);
set(gcf,'Position',[100 100 950 750]) 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']) 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) xlabel('Pulse duration (µs)', FontSize=16)
ylabel('Fraction of atoms in first order', FontSize=16) ylabel('Fraction of atoms in first order', FontSize=16)

View File

@ -66,6 +66,7 @@ end
figure(1) figure(1)
clf clf
set(gcf,'Position',[50 50 950 750]) 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 imagesc(Power_values, waist_values * 1e6, R_z_matrix); % Specify x and y data for axes
hold on hold on
[contour_matrix, contour_handle] = contour(Power_values, waist_values * 1e6, R_z_matrix, 'LineColor', 'white', 'LineWidth', 1.5); [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) figure(2)
clf clf
set(gcf,'Position',[50 50 950 750]) 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 imagesc(Power_values, waist_values * 1e6, omega_eff_matrix); % Specify x and y data for axes
hold on hold on
[contour_matrix, contour_handle] = contour(Power_values, waist_values * 1e6, omega_eff_matrix, 'LineColor', 'white', 'LineWidth', 1.5); [contour_matrix, contour_handle] = contour(Power_values, waist_values * 1e6, omega_eff_matrix, 'LineColor', 'white', 'LineWidth', 1.5);

View File

@ -15,15 +15,16 @@ CavitySignal = CavitySignal - yoffset;
Time = Time - xoffset; Time = Time - xoffset;
% Plot the data % 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); scatter(Time, CavitySignal, 10, 'b', 'filled', 'MarkerFaceAlpha', 0.5);
grid on;
% Format the plot
xlabel('\bf Time (s)', 'FontSize', 16); xlabel('\bf Time (s)', 'FontSize', 16);
ylabel('\bf Voltage (V)', 'FontSize', 16); ylabel('\bf Voltage (V)', 'FontSize', 16);
title('\bf Cavity Signal', 'FontSize', 16); title('\bf Cavity Signal', 'FontSize', 16);
set(gca, 'FontSize', 12); set(gca, 'FontSize', 12);
grid on;
%% Fit cavity signal %% Fit cavity signal

View File

@ -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

View File

@ -285,7 +285,7 @@ function plotResult(func, var, rang)
% Create a figure % Create a figure
figure; figure;
set(gcf, 'Position', [100 100 950 750]); set(gcf, 'Position', [100 100 950 750]);
set(gca,'FontSize',16,'Box','On','Linewidth',2);
% Plot the function and its negative % Plot the function and its negative
plot(rang, y_vals, 'b'); hold on; plot(rang, y_vals, 'b'); hold on;
plot(rang, y_neg_vals, 'b'); plot(rang, y_neg_vals, 'b');

View File

@ -86,6 +86,7 @@ function plotZernike(n, m, NumberOfGridPoints)
figure(1) figure(1)
clf clf
set(gcf,'Position',[50 50 950 750]) set(gcf,'Position',[50 50 950 750])
set(gca,'FontSize',16,'Box','On','Linewidth',2);
surf(X, Y, Z, 'EdgeColor', 'none'); surf(X, Y, Z, 'EdgeColor', 'none');
colormap jet; colormap jet;
colorbar; colorbar;
@ -131,6 +132,7 @@ function plotImage(xvals, yvals, image, titlestring)
figure figure
clf clf
set(gcf,'Position',[50 50 950 750]) set(gcf,'Position',[50 50 950 750])
set(gca,'FontSize',16,'Box','On','Linewidth',2);
imagesc(xvals, yvals, image); imagesc(xvals, yvals, image);
colorbar; colorbar;
colormap jet; colormap jet;