\chapter{A robust, automated strategy to collect high quality OPA tuning curves} \label{cha:opa}

\begin{dquote}
  Principle design features of the new EVV 2DIR optical delivery system include the following:
  \begin{ditemize}
    \item Pairs of motorized gimbal mount mirrors on each OPA to compensate beam pointing changes.
    \item Automated calibration of OPAs, delay stages and motorized mounts.
  \end{ditemize}
      
  \dsignature{Paul Donaldson, ``Improving ... EVV 2DIR Spectroscopy'' (2007)
    \cite{DonaldsonPaulMurray2007a}}  % appears on page 313
\end{dquote}

\clearpage

\section{Introduction}  % =========================================================================

In frequency-domain Multi-Resonant Coherent Multidimensional Spectroscopy (MR-CMDS), automated
Optical Parametric Amplifiers (OPAs) are used to actively scan excitation color axes.
\cite{CerulloGiulio2003a}  %
To accomplish these experiments, exquisite OPA performance is required.  %
During the experiment, motors inside the OPA move to pre-recorded positions to optimize output at
the desired color.  %
Parametric conversion (``mixing'') strategies are now readily avalible, extending the 800 nm pumped
OPA tuning range into the visible, near-infrared, and mid-infrared.  %

OPAs are very sensitive to changes in upstream lasers and lab conditions, so OPA tuning is
regularly required.  %
Manual OPA tuning can easily take a full day. %
Furthermore, manual tuning typically results in inferior tuning curves, since it is difficult for
humans to consider all available information simultaneously.  %
Automated OPA tuning makes OPA upkeep easier, faster and more reproducible, facilitating higher
throughput, higher quality frequency domain experiments. %
The major challenges in automated OPA tuning are:
\begin{enumerate}
  \item Expensive to take high resoltion data.
  \item Need smooth curves for interpolation, especially at edges where output is low.
  \item Optimization metrics are not necessarily separable along motor dimensions.
\end{enumerate}

In this chapter I describe my strategy for automatically collecting high resolution OPA tuning
curves.  %
While I have strategies for all four kinds of OPAs used in the Wright Group, I focus on the
femtosecond TOPAS-C models because they are by far the most challenging model to calibrate.  %

\section{Curves} \label{opa:sec:curves}  % ========================================================

OPA tuning curves are the functional correspondence between desired output color and motor
positions.  %
In theory, these could be recorded as analytical functions derived in an \textit{ab initio} way
from known phase matching and dispersion relations.  %
In practice, ideal tuning curves are determined empirically by simply monitoring OPA output at a
series of given motor combinations.  %
This practice of seeing how OPA output depends on motor positions is called ``tuning'' the OPA.  %

I have defined a Python class \python{Curve} which acts as a interface to OPA tuning curves.  %
Within the class, a series of discrete OPA output colors (``setpoints'') are defined, and the motor
positions are defined for each setpoint.  %
Since it is important that OPAs be settable to \emph{any} position within their output range, a
one-dimensional interpolator is used to determine the correct motor positions for \emph{any} valid
color.  %
There are three kinds of interpolators, linear, spline and polynomial.  %
The particular interpolator used depends on the model of OPA and the complexity of its tuning
curve.  %
The method \python{Curve.get_motor_positions} abstracts away this complexity, simply returning a
list of motor positions for the desired color(s).  %

OPAs often use multiple ``stages'' of interaction to create the desired output.  %
For example, an OPA might generate signal and idler in a first stage, then send that signal on to
be doubled in a second ``second harmonic signal'' (SHS) stage.  %
Depending on the experiment being performed, different stages of the OPA will be used.  %
One could approach this complexity by simply creating an entirely separate curve for each
combination of stages, but this would result in the same information being duplicated in many
different curves.  %
Instead, I have chosen to use a nested approach that directly reflects the approach that the
hardware uses.  %
Curve objects can have ``subcurves'' which define the behavior of the proceeding stage.  %
In the example above, the parent curve would control the second harmonic signal stage.  %
For each SHS position, the parent would define a desired signal color for the first stage to
create.  %
This is passed to the subcurve, which defines the motor positions needed in the first stage to
achieve optimal conversion at the desired \emph{signal} color.  %
In this way, each stage can be tuned separately and the tuning of an upstream stage is immediately
propagated to all downstream stages.  %

% BJT: consider putting an example curve figure

% TODO: table of curve methods and attributes

\section{TOPAS-C}  % ==============================================================================

The TOPAS-C is a popular commercially available motorized OPA.  %
It consists of a large initial stage where signal and idler are generated, and a series of optional
mixing stages where further up- or down-conversion can occur to widen the total range of output
frequencies.  %
\autoref{opa:fig:ranges} shows all of the possible output ranges of the TOPAS.  %
It ranges from the mid infrared (accessible through difference frequency generation) to the
ultraviolet (accessible through multiple second harmonic upconversion).  %

\autoref{opa:fig:TOPAS-C} diagrams the internals of the TOPAS-C initial stage, where signal and
idler are generated.  %
Upon entering the OPA, roughly 98\% of pump light is split off immediately (BS1).  %
The remaining 2\% goes on to be split again (BS2).  %
After being attenuated further and passed through an aperture, part of this 800 nm light is sent
into a sapphire plate to generate white light.  %
This white light is then intentionally chirped, and mixed with the other small portion of the pump
\python{non-collinearly} in NC1.  %
The angle of the crystal is tuned, as is the relative arrival time of chirped white light and the
small pump portion.  %
These two degrees of freedom control the efficiency of conversion at a given color in C1, and
together they make up the ``preamp''.
I describe my strategy for preamp tuning in \autoref{opa:sec:preamp}.  %

The signal portion from the preamp is picked off and meets the gigantic 98\% portion of pump split
off at the very beginning in NC2.  %
Again, the relative arrival time and crystal angle are motorized internally.  %
Together these degrees of freedom make up the ``poweramp''.
I describe my strategy for poweramp tuning in \autoref{opa:sec:poweramp}.  %

After the poweramp, the output signal and idler can be sent through appropriate filters and,
optionally, mixed further in three subsequent mixing stages to create all of the ranges seen in
\autoref{opa:fig:ranges}.  %
Each of these mixing stages has only crystal angle tunability.  %
I describe my strategy for mixer tuning in \autoref{opa:sec:mixer}.  %

It is important to realize that the total conversion efficiency for each output color varies wildly
over all of the different mixing strategies.  %
\autoref{opa:fig:powers} shows the empirical-best output energy achievable for each setpoint.  %

\begin{figure}
  \includegraphics[width=\textwidth]{opa/OPA_ranges}
  \caption{
    TOPAS-C interaction ranges.
  }
  \label{opa:fig:ranges}
\end{figure}

\begin{figure}
  \includegraphics[width=\textwidth]{opa/TOPAS-C}
  \caption[TOPAS-C internal optics and beam path.]{
    TOPAS-C internal optics and beam path.  %
    Image taken from manual, originally generated by Light Conversion.  %
  }
  \label{opa:fig:TOPAS-C}
\end{figure}

\begin{figure}
  \includegraphics[width=\textwidth]{opa/OPA_powers}
  \caption[TOPAS-C interaction range output powers.]{
    TOPAS-C interaction range output powers.
  }
  \label{opa:fig:powers}
\end{figure}

\section{Preamp} \label{opa:sec:preamp}  % ========================================================

In TOPAS-C OPAs, a small portion of input light is used to generate a signal seed in a BBO crystal
``C1''.  %
A motorized delay stage ``D1'' is used to temporally overlap a particular color in chirped white
light with 800 nm pump.  %
C1 angle is tuned to optimize phase matching.  %

Measured seed intensity and color for all combinations of C1 and D1 position are shown in
\autoref{opa:fig:preamp}.  %
Crucially, output color and intensity are not separable along the preamp motor axes.  %
We are obligated to use a multidimensional fitting strategy to find the best preamp motor positions
at each setpoint.  %

Luckily we have an InGaAs near-infrared array detector, so it is very quick to capture the entire
output spectrum at each motor position.  %
PyCMDS visits an entire series of (C1, D1) positions, scanning D1 about the prior best position for
each C1 in the curve.  %

\autoref{opa:fig:preamp_flowchart} diagrams the preamp processing procedure in its entirety.  %
The original datset is three-dimensional in C1, D1, color.  %
In the first step, the dimensionality is reduced by fitting each array slice to extract a center,
amplitude and width.  %
These fits are interpolated to find contours of constant output color.  %
I then search along that contour in \emph{intensity} space to find the motor positions that give
maximum intensity for that color.  %
Finally I fit a smooth spline through those chosen values to generate the output curve.  %

A representative preamp tune procedure output image is shown in \autoref{fig:autotune_preamp}.  %
This is an automatically generated image from PyCMDS.  %
The thick black line is the final output curve.  %
The dark grey lines are the contours of constant color.  %
Each contour of constant color is marked with the output color in nanometers.  %
The colorbar shows the Delaunay-interpolated intensity values for each motor position.  %

Preamp tuning takes less than 20 minutes, in large part due to a NIR array detector which collects
the full spectrum at each motor position.  %

\begin{figure}
  \includegraphics[width=\textwidth]{opa/preamp}
  \caption{
    TOPAS-C preamp motortune.
  }
  \label{opa:fig:preamp}
\end{figure}

\begin{figure}
  \includegraphics[width=\linewidth]{opa/preamp_flowchart}
  \caption{
    Preamp tune procedure flowchart.
  }
  \label{opa:fig:preamp_flowchart}
\end{figure}

\begin{figure}
  \includegraphics[width=\linewidth]{opa/autotune_preamp}
  \caption{
    Preamp tuning output.
  }
  \label{opa:fig:autotune_preamp}
\end{figure}

\section{Poweramp} \label{opa:sec:poweramp}  % ====================================================

Once generated, the seed goes on to be amplified in a second BBO crystal ``C2'' with the rest of
the 800 nm pump.  %
Optimizing this amplification step is primarily a matter of setting C2 angle.  %
A small delay correction ``D2'' is necessary to account for dispersion in the seed optics.  %
To fully explore poweramp behavior, we need to tak a C2-D23 scan for each seed color.  %
Measured output intensity and color in this 3D space is represented in \autoref{opa:fig:poweramp}.  %
Note that the motor axes are scans about the previously recorded tuning curve value.  %

The best position (zero displacement along both axes) is chosen to maximize output intensity while
keeping the output color identical to the seed color.  %
Optimizing for zero detuining rather than simply for output intensity has led to better OPA
performance and stability.  %
Like in the preamp case, color and intensity are not fully separable along the poweramp motor
dimensions (this is especially true at the edge output colors).  %
In the poweramp, the increased dimensionaity makes it too expensive to do a full multidimensional
tuning procedure.  %
Instead we emply an iterative procedure as diagrammed below.  %
\autoref{fig:opa:poweramp_flowchart} diagrams this iterative procedure.  %

We always end the iteration(s) with C2 so that the OPA's color calibration is as good as
possible.  %
Typically only one iteration is required but multiple iterations may be necessary if dramatic OPA
realignment has occurred.  %
In total, poweramp tuning typically takes less than 1 hour. %
Representative procedure output images for D2 (\autoref{op:fig:d2}) and C2 (\autoref{opa:fig:c2})
are shown.  %

For the D2 figure, the lower panel shows the intensity of the data taken.  %
Note the thick grey line, which represents the chosen points before the final spline step.  %
The top panel compares the old tuning curve (thin) with the output tuning curve (thick).  %
For the C2 image, the bottom panel represents the color of each fit mapped onto detuning.  %
Each separate marker color represents a different setpoint.  %
As with D2, the C2 upper panel compares the old tuning curve (thin black) with the output tuning
curve (colored X's).  %

\begin{figure}
  \includegraphics[width=\linewidth]{opa/poweramp}
  \caption{
    TOPAS-C poweramp motortune.
  }
  \label{opa:fig:poweramp}
\end{figure}

\begin{figure}
  \includegraphics[width=\linewidth]{opa/poweramp_flowchart}
  \caption{
    Poweramp tune procedure flowchart.
  }
  \label{opa:fig:poweramp_flowchart}
\end{figure}

\begin{figure}
  \includegraphics[width=\textwidth]{opa/d2}
  \caption{
    Poweramp D2 tuning output.
  }
  \label{opa:fig:d2}
\end{figure}

\begin{figure}
  \includegraphics[width=\textwidth]{opa/c2}
  \caption{
    Poweramp C2 tuning output.
  }
  \label{opa:fig:c2}
\end{figure}

\section{Mixers} \label{opa:sec:mixers}  % ========================================================

Because mixers only have one degree of freedom each (crystal angle), there is really not that much
ambiguity about what the ideal motor positions are.  %
In fact, the best motor positions can be chosen simply by taking excursions relative to the old
points (as in \autoref{opa:fig:d2}) and picking the points with the highest intensity.  %
After choosing motor positions, a simple correction for actual output frequencies can be applied
using the monochromator.  %

I have prepared two functions: \python{process_intensity} and \python{process_tune} which
accomplish each of these goals.  %
They are general, capable of being used for \emph{any} mixer or tune test.  %

PyCMDS can also explicitly take a spectrum at each motor position.  %
This information takes longer to collect, but less human intervention---so it is a valid strategy
that is sometimes employed.  %

\section{Generalizability}  % =====================================================================

This chapter has considered the automated procedures used in tuning the TOPAS-C, just one of the
four models of OPA owned by the Wright Group.  %
Simply put, this is because the other three OPA models (all picosecond OPAs) are easy to tune.  %

\autoref{opa:fig:ps_opa} displays the entire tuning space for generation of signal and idler in one
of the picosecond OPAs.  %
In contrast to the TOPAS behavior, where neither motor axis constrains the output very well,
\emph{both} motors have very narrow features in this picosecond OPA.  %
This means that it is at all times \emph{unambiguous} whether a given motor position is ideal.  %

Much like the mixers, these OPAs can be readily tuned using a combination of the general functions
\python{process_intensity} and \python{process_tune}.  %

\begin{figure}
  \includegraphics[width=\textwidth]{"opa/signal_and_idler_motortune"}
  \caption[Picosecond OPA motortune.]{
    Motortune for picosecond OPA, monitored using a single pyroelectric detector.
  }
  \label{opa:fig:ps_opa}
\end{figure}