40m QIL Cryo_Lab CTN SUS_Lab TCS_Lab OMC_Lab CRIME_Lab FEA ENG_Labs OptContFac Mariner WBEEShop
  40m Log  Not logged in ELOG logo
Message ID: 5015     Entry time: Thu Jul 21 23:36:51 2011
Author: Jenny 
Type: Update 
Category:  
Subject: Fitting beam waist with MATLAB 

I am starting work on the PSL table at the 40m. My goal is to lock the laser coming from the nearby table to the FP cavity and get a measurement of the response to a temperature step on the surrounding can.

I have to mode match the beam to the cavity. Specifically, I have to mode match to the beam coming from the PMC through the EOM to the polarizing beam splitter. Yesterday David and I measured the beam width at various distances (from a particular lens through which the beam traveled), and I fit that data using MATLAB to find the beam's waist size and location. However, I'm not convinced that the fit is any good, since we only took measurements at five spots and they had large error bars.

 

z (mm) 2w_vert (mm) 2w_horiz (mm)
180 4.68 3.38
230 4.64 3.49
305 4.68 3.47
370 5.1 3.81
510 5.5 4.17

Here is the fit I obtained using fminsearch. The horizontal beam width measurements were smaller than the vertical width measurements, suggesting that the incoming beam was elliptical. I fit the data for each set of measurements separately and got two waist locations. The red trace is the fit for the horizontal width and the blue represents the vertical width of the beam. Averaging the two fitted waist locations and sizes gives

vert z_0= -1760 mm (waist location)

horiz z_0= -1540 mm (waist location)

vert w_0 = 0.286 mm (waist size)

horiz  w_0 = 0.275 mm (waist size)

avg z_0= -1650 mm

avg w_0 = 0.281 mm

 

twobeamfit2.jpg

Here is the code I used:

I defined the function spotsize.m and then made a function gaussbeam.m that called it with input parameters and returned the least squares error. I then wrote another function twobeamfits.m that ran fminsearch to minimize the least squares error and made the above plot. I've pasted the code below.

spotsize

function omega = spotsize(z_0, w_0, z)
lambda=0.001064;
omega=w_0*(1+(lambda*(z-z_0)/(pi*w_0^2)).^2).^(1/2);

 

gaussbeam

function sse = gaussbeam(params,xvals,yvals)

%This f'n takes as its inputs
%three parameters (w_0, z_0, and lambda),
%a vector of x-values (distances),
%and an associated vector of y-values (spotsizes),


%It then generates a vector of fitted y-values by applying
%an exponential approach function (single pole), with the given parameters,
%to the x-values.

%It then returns the sum of the squares of the entries of the difference
%between the fitted y-vector and the actual y-vector

z_0=params(1);
w_0=params(2);
fityvals=spotsize(z_0, w_0, xvals);

error=(fityvals - yvals);% .*xvals;
% sse stands for sum of squares error
sse=sum(error.^2);

 

twobeamfits

function [outputs] = twobeamfits(guesses, dists, vert, horiz)


%This f'n takes as its inputs
%two starting guess parameters (w_0 and z_0),
%a vector of distances (x-values),
%and two associated vectors of measured beam radii,

%the radius measured along the vertical axis

%and the radius measured along a horizontal axis (y-values).

%It then calls the gaussbeam f'n for each set of y-values and minimizes its output (sum of squares error)
%using the fminsearch f'n. It outputs the fit parameters it settles on.

%It then plots the input data, the fitted curves, and the residuals


fminopts=optimset('TolFun',1e-6,'MaxIter', 100000);
vertparams=fminsearch(@gaussbeam,guesses,fminopts,dists,vert);
fitvert=spotsize(vertparams(1), vertparams(2), dists);
resid1=(vert-fitvert)./vert;
spoterror=[.1, .1, .1, .1, .1]; %uncertainties, all in mm

fminopts=optimset('TolFun',1e-6,'MaxIter', 100000);
horizparams=fminsearch(@gaussbeam,guesses,fminopts,dists,horiz);
fithoriz=spotsize(horizparams(1), horizparams(2), dists);
resid2=(horiz-fithoriz)./horiz;


points=linspace(-2000,1000,1000);
figure(1)
hold off
clf
subplot(2,1,1)
hold on
errorbar(dists, vert, spoterror, 'x')
grid
errorbar(dists, horiz, spoterror, 'r*');
plot(points,spotsize(vertparams(1), vertparams(2), points));
plot(points,spotsize(horizparams(1), horizparams(2), points),'r');
xlabel('Distance z (mm)')
title('Gaussian Beam Fits')
ylabel('Spotsize w (mm)')
legend('Vertical Spotsize','Horizontal Spotsize','Vertical Fit',...
    'Horizontal Fit','Location','SouthEast')
hold off

subplot(2,1,2)
plot(dists,resid1,'x')
hold on
plot(dists,resid2,'r*');
xlabel('Distance (z)')
title('Residuals')
ylabel('Fractional Difference')
legend('Vertical Fit Residuals','Horizontal Fit Residuals',...
    'Location','SouthEast')
grid

outputs=[vertparams horizparams];

 

 

 

Later on I may repeat some measurements and try to gain more certainty in my fit. In the mean time I will use this beam profile for mode matching. 

 

ELOG V3.1.3-