#+TITLE: Attocube - Test Bench
:DRAWER:
#+LANGUAGE: en
#+EMAIL: dehaeze.thomas@gmail.com
#+AUTHOR: Dehaeze Thomas

#+HTML_LINK_HOME: ../index.html
#+HTML_LINK_UP:   ../index.html

#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/readtheorg.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/zenburn.css"/>
#+HTML_HEAD: <script type="text/javascript" src="./js/jquery.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/jquery.stickytableheaders.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/readtheorg.js"></script>

#+PROPERTY: header-args:latex  :headers '("\\usepackage{tikz}" "\\usepackage{import}" "\\import{$HOME/Cloud/tikz/org/}{config.tex}")
#+PROPERTY: header-args:latex+ :imagemagick t :fit yes
#+PROPERTY: header-args:latex+ :iminoptions -scale 100% -density 150
#+PROPERTY: header-args:latex+ :imoutoptions -quality 100
#+PROPERTY: header-args:latex+ :results raw replace :buffer no
#+PROPERTY: header-args:latex+ :eval no-export
#+PROPERTY: header-args:latex+ :exports both
#+PROPERTY: header-args:latex+ :mkdirp yes
#+PROPERTY: header-args:latex+ :output-dir figs
#+PROPERTY: header-args:latex+ :post pdf2svg(file=*this*, ext="png")

#+PROPERTY: header-args:matlab  :session *MATLAB*
#+PROPERTY: header-args:matlab+ :tangle script.m
#+PROPERTY: header-args:matlab+ :comments org
#+PROPERTY: header-args:matlab+ :exports both
#+PROPERTY: header-args:matlab+ :results none
#+PROPERTY: header-args:matlab+ :eval no-export
#+PROPERTY: header-args:matlab+ :noweb yes
#+PROPERTY: header-args:matlab+ :mkdirp yes
#+PROPERTY: header-args:matlab+ :output-dir figs
:END:

* Estimation of the Spectral Density of the Attocube Noise
** Introduction                                                      :ignore:

#+name: fig:test-bench-shematic
#+caption: Test Bench Schematic
[[file:figs/test-bench-shematic.png]]

#+name: fig:test-bench-picture
#+caption: Picture of the test bench. The Attocube and mirror are covered by a "bubble sheet"
[[file:figs/IMG-7865.JPG]]

** Matlab Init                                             :noexport:ignore:
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
  <<matlab-dir>>
#+end_src

#+begin_src matlab :exports none :results silent :noweb yes
  <<matlab-init>>
#+end_src

** Long and Slow measurement
The first measurement was made during ~17 hours with a sampling time of $T_s = 0.1\,s$.

#+begin_src matlab
  load('./mat/long_test2.mat', 'x', 't')
  Ts = 0.1; % [s]
#+end_src

#+begin_src matlab :exports none
  figure;
  plot(t/60/60, 1e9*x)
  xlabel('Time [h]'); ylabel('Displacement [nm]');
#+end_src

#+begin_src matlab :tangle no :exports results :results file replace
  exportFig('figs/long_meas_time_domain_full.pdf', 'width', 'wide', 'height', 'normal');
#+end_src

#+name: fig:long_meas_time_domain_full
#+caption: Long measurement time domain data
#+RESULTS:
[[file:figs/long_meas_time_domain_full.png]]

Let's fit the data with a step response to a first order low pass filter (Figure [[fig:long_meas_time_domain_fit]]).

#+begin_src matlab
  f = @(b,x) b(1)*(1 - exp(-x/b(2)));

  y_cur = x(t < 17*60*60);
  t_cur = t(t < 17*60*60);

  nrmrsd = @(b) norm(y_cur - f(b,t_cur)); % Residual Norm Cost Function
  B0 = [400e-9, 2*60*60];                        % Choose Appropriate Initial Estimates
  [B,rnrm] = fminsearch(nrmrsd, B0);     % Estimate Parameters ‘B’
#+end_src

The corresponding time constant is (in [h]):
#+begin_src matlab :results value replace :exports results
  B(2)/60/60
#+end_src

#+RESULTS:
: 2.0576

#+begin_src matlab :exports none
  figure;
  hold on;
  plot(t_cur/60/60, 1e9*y_cur);
  plot(t_cur/60/60, 1e9*f(B, t_cur));
  hold off;
  xlabel('Time [h]'); ylabel('Displacement [nm]');
#+end_src

#+begin_src matlab :tangle no :exports results :results file replace
  exportFig('figs/long_meas_time_domain_fit.pdf', 'width', 'wide', 'height', 'normal');
#+end_src

#+name: fig:long_meas_time_domain_fit
#+caption: Fit of the measurement data with a step response of a first order low pass filter
#+RESULTS:
[[file:figs/long_meas_time_domain_fit.png]]

We can see in Figure [[fig:long_meas_time_domain_full]] that there is a transient period where the measured displacement experiences some drifts.
This is probably due to thermal effects.
We only select the data between =t1= and =t2=.
The obtained displacement is shown in Figure [[fig:long_meas_time_domain_zoom]].

#+begin_src matlab
  t1 = 11; t2 = 17; % [h]

  x = x(t > t1*60*60 & t < t2*60*60);
  x = x - mean(x);
  t = t(t > t1*60*60 & t < t2*60*60);
  t = t - t(1);
#+end_src

#+begin_src matlab :exports none
  figure;
  plot(t/60/60, 1e9*x);
  xlabel('Time [h]'); ylabel('Measured Displacement [nm]')
#+end_src

#+begin_src matlab :tangle no :exports results :results file replace
  exportFig('figs/long_meas_time_domain_zoom.pdf', 'width', 'wide', 'height', 'normal');
#+end_src

#+name: fig:long_meas_time_domain_zoom
#+caption: Kept data (removed slow drifts during the first hours)
#+RESULTS:
[[file:figs/long_meas_time_domain_zoom.png]]

The Power Spectral Density of the measured displacement is computed
#+begin_src matlab
  win = hann(ceil(length(x)/20));
  [p_1, f_1] = pwelch(x, win, [], [], 1/Ts);
#+end_src

As a low pass filter was used in the measurement process, we multiply the PSD by the square of the inverse of the filter's norm.
#+begin_src matlab
  G_lpf = 1/(1 + s/2/pi);
  p_1 = p_1./abs(squeeze(freqresp(G_lpf, f_1, 'Hz'))).^2;
#+end_src

Only frequencies below 2Hz are taken into account (high frequency noise will be measured afterwards).
#+begin_src matlab
  p_1 = p_1(f_1 < 2);
  f_1 = f_1(f_1 < 2);
#+end_src

** Short and Fast measurement
An second measurement is done in order to estimate the high frequency noise of the interferometer.
The measurement is done with a sampling time of $T_s = 0.1\,ms$ and a duration of ~100s.

#+begin_src matlab
  load('./mat/short_test_plastic.mat')
  Ts = 1e-4; % [s]
#+end_src

#+begin_src matlab
  x = detrend(x, 0);
#+end_src

The time domain measurement is shown in Figure [[fig:short_meas_time_domain]].

#+begin_src matlab :exports none
  figure;
  plot(t, 1e9*x)
  xlabel('Time [s]'); ylabel('Displacement [nm]');
#+end_src

#+begin_src matlab :tangle no :exports results :results file replace
  exportFig('figs/short_meas_time_domain.pdf', 'width', 'wide', 'height', 'normal');
#+end_src

#+name: fig:short_meas_time_domain
#+caption: Time domain measurement with the high sampling rate
#+RESULTS:
[[file:figs/short_meas_time_domain.png]]

The Power Spectral Density of the measured displacement is computed
#+begin_src matlab
  win = hann(ceil(length(x)/10));
  [p_2, f_2] = pwelch(x, win, [], [], 1/Ts);
#+end_src

** Obtained Amplitude Spectral Density of the measured displacement

The computed ASD of the two measurements are combined in Figure [[fig:psd_combined]].

#+begin_src matlab :exports none
  figure;
  hold on;
  plot(f_1(8:end), sqrt(p_1(8:end)), 'k-');
  plot(f_2(8:end), sqrt(p_2(8:end)), 'k-');
  hold off;
  set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
  ylabel('ASD [$m/\sqrt{Hz}$]'); xlabel('Frequency [Hz]');
#+end_src

#+begin_src matlab :tangle no :exports results :results file replace
  exportFig('figs/psd_combined.pdf', 'width', 'wide', 'height', 'tall');
#+end_src

#+name: fig:psd_combined
#+caption: Obtained Amplitude Spectral Density of the measured displacement
#+RESULTS:
[[file:figs/psd_combined.png]]

* Effect of the "bubble sheet" and *Aluminium tube*
** Introduction                                                      :ignore:

 #+name: fig:picture-test-bench-aluminium-tube
 #+caption: Aluminium tube used to protect the beam path from disturbances
 [[file:figs/IMG-7864.JPG]]

** Matlab Init                                             :noexport:ignore:
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
  <<matlab-dir>>
#+end_src

#+begin_src matlab :exports none :results silent :noweb yes
  <<matlab-init>>
#+end_src

** Aluminium Tube and Bubble Sheet
#+begin_src matlab
  load('./mat/long_test_plastic.mat');
  Ts = 1e-4; % [s]
#+end_src

#+begin_src matlab
  x = detrend(x, 0);
#+end_src

#+begin_src matlab :exports none
  figure;
  plot(t, 1e9*x)
  xlabel('Time [s]'); ylabel('Displacement [nm]');
#+end_src

#+begin_src matlab
  win = hann(ceil(length(x)/10));
  [p_1, f_1] = pwelch(x, win, [], [], 1/Ts);
#+end_src

** Only Aluminium Tube
#+begin_src matlab
  load('./mat/long_test_alu_tube.mat');
  Ts = 1e-4; % [s]
#+end_src

#+begin_src matlab
  x = detrend(x, 0);
#+end_src

The time domain measurement is shown in Figure [[fig:short_meas_time_domain]].
#+begin_src matlab :exports none
  figure;
  plot(t, 1e9*x)
  xlabel('Time [s]'); ylabel('Displacement [nm]');
#+end_src

#+begin_src matlab
  win = hann(ceil(length(x)/10));
  [p_2, f_2] = pwelch(x, win, [], [], 1/Ts);
#+end_src

** Nothing
#+begin_src matlab
  load('./mat/long_test_without_material.mat');
  Ts = 1e-4; % [s]
#+end_src

#+begin_src matlab
  x = detrend(x, 0);
#+end_src

The time domain measurement is shown in Figure [[fig:short_meas_time_domain]].
#+begin_src matlab :exports none
  figure;
  plot(t, 1e9*x)
  xlabel('Time [s]'); ylabel('Displacement [nm]');
#+end_src

#+begin_src matlab
  win = hann(ceil(length(x)/10));
  [p_3, f_3] = pwelch(x, win, [], [], 1/Ts);
#+end_src

** Comparison
#+begin_src matlab :exports none
  figure;
  hold on;
  plot(f_1(8:end), sqrt(p_1(8:end)), '-', ...
       'DisplayName', 'Alunimium + Bubble');
  plot(f_2(8:end), sqrt(p_2(8:end)), '-', ...
       'DisplayName', 'Aluminium');
  plot(f_3(8:end), sqrt(p_3(8:end)), '-', ...
       'DisplayName', 'nothing');
  hold off;
  set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
  ylabel('ASD [$m/\sqrt{Hz}$]'); xlabel('Frequency [Hz]');
  legend('location', 'northeast');
#+end_src

#+begin_src matlab :tangle no :exports results :results file replace
  exportFig('figs/asd_noise_comp_bubble_aluminium.pdf', 'width', 'wide', 'height', 'normal');
#+end_src

#+name: fig:asd_noise_comp_bubble_aluminium
#+caption: Comparison of the noise ASD with and without bubble sheet
#+RESULTS:
[[file:figs/asd_noise_comp_bubble_aluminium.png]]
