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



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.


function omega = spotsize(z_0, w_0, z)



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

fityvals=spotsize(z_0, w_0, xvals);

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



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);
fitvert=spotsize(vertparams(1), vertparams(2), dists);
spoterror=[.1, .1, .1, .1, .1]; %uncertainties, all in mm

fminopts=optimset('TolFun',1e-6,'MaxIter', 100000);
fithoriz=spotsize(horizparams(1), horizparams(2), dists);

hold off
hold on
errorbar(dists, vert, spoterror, 'x')
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

hold on
xlabel('Distance (z)')
ylabel('Fractional Difference')
legend('Vertical Fit Residuals','Horizontal Fit Residuals',...

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-