\chapter{Reflection Fitting}
\section{First pass at a reflection fit}\label{sec:reflection_fit_procedure}
The measured reflected power  is modeled as
\begin{equation}
  %\abs{\Gamma}^2 = C-\left(\frac{f_0}{2Q}\right)^2\frac{\Delta y}{(f-f_0)^2+\left(\frac{f_0}{2Q}\right)^2}
  \abs{\Gamma}^2 = C-\frac{\delta y}{1+4\Delta^2}; \hspace{1cm} \Delta \equiv Q\frac{f-f_0}{f_0}
		\label{eqn:reflection_model}
\end{equation}
where $\Gamma$ reflection coefficient, $f_0$ ($Q$) is the resonant frequency (quality factor) of the cavity, C is some constant offset, and $\delta y$ is the depth of the Lorentzian. One can check that $\Gamma(f_0) = C-\delta y$ and $\Gamma(f_0 - \delta f/2)=C-\delta y/2$, where the bandwidth $\delta f = f_0/Q$. 
To obtain the resonant frequency and Q of the cavity, we fit Equation~\ref{eqn:reflection_model} to the measured reflected power, as shown in Figure~\ref{fig:reflection_fitting}.
\begin{figure}[!htbp]
    \centering
    \includegraphics[width=0.8\textwidth]{main_reflection_fit_20191108.pdf}
		\caption{The process of fitting a Lorentzian to the reflection coefficient to extract the resonant frequency and quality factor. The blue curve is the square of the measured reflected coefficient. The orange line is the initial guess of the Lorentzian. The green line is the curve fit, which tries to minimize the $\chi^2$.}
    \label{fig:reflection_fitting}
\end{figure}
%
Non-linear fits are often sensitive to the initial guess of fit parameters, so the initial guesses should be close to the correct answer (aim for an order of magnitude). One can come up with reasonable guesses from abstracting features of the reflected power. Below is a list of methods to obtain the initial guesses.

\newcommand{\gu}{\text{guess}}

\begin{enumerate}
	\item $f_{0,\gu}$: Find the frequency that corresponds to $\Gamma^2_{min}$

	\item $C_{\gu}$: Take the median of the upper 2/3 of the $\abs{\Gamma}^2$ values. The lower 1/3 probably corresponds to the reflection on resonance. 

	\item $\delta y_{\gu} = C_{\gu} - \abs{\Gamma}^2_{\text{min}}$ 

	\item $Q_{\gu}$: Find bandwidth $\delta f$ by determining frequencies where $\Gamma = C_{\gu} - \delta y_{\gu}/2$, i.e., find the full-width-half-max. $Q_{\gu} = f_{0,\gu}/\delta f$.\\
    Of course, if you already roughly know the Q of the system, then you can manually put in that guess.
\end{enumerate}

\FloatBarrier
Now let us extract the antenna coupling coefficient $\beta$. In later sections, I derive that the reflection coefficient of the cavity is $\Gamma_{c} = \frac{\frac{1-\beta}{1+\beta} +2i\Delta}{1+2i\Delta} $. Figure~\ref{fig:gamma_angle} shows the phase response for an undercoupled cavity ($\beta<1$), overcoupled cavity ($\beta>1$), and critically-coupled cavity ($\beta=1$). We can check the phase of the measured IQ data around resonance to determine if we are undercoupled or overcoupled. As one option, one can check if $\angle \Gamma(f_0^+) > \angle \Gamma(f_0^-)$ to check if the cavity is undercoupled.
\begin{figure}[!htbp]
    \centering
    \includegraphics[width=0.8\textwidth]{reflection_phase_functional_form.png}
  \caption{The phase change of the reflection coefficient for the undercoupled case (blue), critically-coupled case (green), and overcoupled case (orange). The derivative on resonance is positive for the undercoupled case and negative for the overcoupled case.}
    \label{fig:gamma_angle}
\end{figure}

We can calculate the coupling coefficient from the reflected power. It's best to use the value from the fitted function since the measured values at low power tend to be noisy.

\begin{align}
 \beta = 
  \begin{cases} 
   \frac{1-{\abs{\Gamma_c(f_0)}}}{1+\abs{\Gamma_c(f_0)}} & \text{if } \beta \leq 1 \\
   \frac{1+\abs{\Gamma_c(f_0)}}{1-\abs{\Gamma_c(f_0)}} & \text{if } \beta \geq 1
  \end{cases}
\end{align}

But we do not measure the cavity reflection coefficient directly. The signal is amplified and then attenuated by cables. To estimate $\abs{\Gamma_c(f_0)}$, we note that the cavity acts like a reflector off resonance, so $\abs{\Gamma_c(\Delta)} \rightarrow 1$ for large $\Delta$. After normalizing the reflected power to estimate $\abs{\Gamma_c(\Delta)}^2$, we can calculate $\abs{\Gamma_c(f_0)}$ using the fitted parameters $\abs{\Gamma_c(f_0)} = \sqrt{1-\frac{\delta y}{C}}$.I


\FloatBarrier
A proper chi-square minimization requires inputting accurate relative uncertainties of each datapoint in the reflected power. The uncertainty of each data point can be derived as $\sigma_P^2 = 4 \sigma_V^2 P$, where $\sigma_V $ is the uncertainty of the IQ voltages. $\sigma_V$ depends on the VNA settings such as the number of averages and the IF bandwidth. $\sigma_V $ can be estimated by measuring the standard deviation of the recorded IQ voltages from the VNA noise floor. 

The derivation for the uncertainty in reflected power follows:
\begin{proof}
	\begin{align*}
		P &\propto V_{I}^2 + V_{R}^2
	\end{align*}
	Let $Re \equiv V_{R}^2$ and $Im \equiv V_{I}^2$.

	\begin{align*}
		P &\propto R + I \\
		\sigma_P^2 &= \sigma_{R}^2 + \sigma_{I}^2\\
		\left(\frac{\sigma_{R}^2}{R}\right)^2 &= \left(\frac{2\sigma_{V_{R}}}{V_{R}}\right)^2\\
		\sigma_{R}^2 &= (2V_{R}\sigma_{V_{R}})^2
	\end{align*}
	Similarly
	\begin{align*}
		\sigma_{I}^2 &= (2V_{I}\sigma_{V_{I}})^2\\
		\sigma_{P}^2 &= (2V_{R}\sigma_{V_{R}})^2 + (2V_{I}\sigma_{V_{I}})^2\\
		\sigma_{V_R} &= \sigma_{V_I} \equiv \sigma_V\\
		\sigma_{P}^2 &= (2\sigma_V)^2 (V_R^2 + V_I^2)\\
		\sigma_{P}^2 &= 4\sigma_V^2 P 
	\end{align*}
	
\end{proof}


\section{Deriving the reflection off of the cavity}\label{sec:reflection_derivation}
In this section, we derive why the reflected power off a cavity follows a Lorentzian profile.

A cavity can be modeled as a series RLC circuit (Pozar 4th ed. Ch. 6), and the cavity impedance $Z_c$ is
\begin{align*}
  Z_c &= R + \frac{1}{i\omega C} + i\omega L \\
      &= R + \frac{1-\omega^2 L C }{i \omega C}
\end{align*}

For an RLC circuit, $\omega_o = \frac{1}{LC}$. Define $\omega \equiv \omega_o - \delta \omega$. Then $\omega_o^2 \approx \omega_o^2-2\omega_o\delta\omega$.

\begin{align*}
  Z_c-R &\approx  \frac{1-\frac{1}{\omega_o^2}(\omega_o^2 -2\omega_o\delta\omega)}{i \omega_o C} \\
          &= \frac{-2\frac{\delta\omega}{\omega_o}}{i\omega_o^2 C}
\end{align*}

Define $Q_o \equiv \frac{1}{\omega_o R C} = \frac{1}{R}{\sqrt{\frac{L}{C}}} = \frac{\omega_o L}{R}$.

\begin{align*}
  Z_c = R\left(1+2i\frac{\delta\omega Q_o}{\omega_o}\right)
\end{align*}

Let's connect the cavity to a load with impedance $Z_o=R_o$. Assume that the transmission line connecting the cavity to the load is impedance-matched to the load. Then the reflection coefficient, from Pozar 4th ed. Equation~2.35, is
\begin{align*}
  \Gamma_{c}=\frac{Z_c-Z_o}{Z_c+Z_o}
\end{align*}

Define an antenna coupling coefficient $\beta=\frac{Q_o}{Q_e} = \frac{Z_o}{R}$. 
\begin{align*}
  \frac{1}{Q_L} &= \frac{1}{Q_o}+\frac{1}{Q_e}\\
  \frac{1}{Q_L} &= \frac{1}{Q_o}\left(1+\frac{Q_o}{Q_e}\right)\\
  Q_L &= \frac{Q_o}{1+\beta}
\end{align*}

On resonance, $Z_c = R$ and the magnitude of the reflection coefficient depends on the coupling coefficient.
\begin{align}
  \Gamma_{c}(f_o) &= \frac{1-\frac{Z_o}{R}}{1+\frac{Z_o}{R}} \nonumber\\
  \Gamma_{c}(f_o) &= \frac{1-\beta}{1+\beta} 
\end{align}

Let's now solve for the reflection coeffient around the resonance.
\begin{align*}
  \Gamma_{c} &= \frac{Z_c-Z_o}{Z_c+Z_o}\\
   &= \frac{1+2i\frac{\delta\omega Q_o}{\omega_o}-\frac{Z_o}{R}}{1+2i\frac{\delta\omega Q_o}{\omega_o}+\frac{Z_o}{R}}\\
   &= \frac{1+2i\frac{\delta\omega Q_o}{\omega_o}-\beta}{1+2i\frac{\delta\omega Q_o}{\omega_o}+\beta}\\
   &= \frac{1+2i\frac{\delta\omega Q_o}{\omega_o}-\beta}{1+2i\frac{\delta\omega Q_o}{\omega_o}+\beta}\times\left(\frac{1+\beta}{1+\beta}\right)\\
  \Gamma_{c} &= \frac{\frac{1-\beta}{1+\beta} +2i\frac{\delta\omega Q_L}{\omega_o}}{1+2i\frac{\delta\omega Q_L}{\omega_o}}\\
\end{align*}
Define $\Delta \equiv Q_L \frac{\delta \omega}{\omega_o}$
\begin{align}
  \Gamma_{c} &= \frac{\frac{1-\beta}{1+\beta} +2i\Delta}{1+2i\Delta}
  \label{eqn:reflection_coefficient}
\end{align}

The reflected power is the magnitude-squared of the reflection coefficient.
\begin{align*}
  |\Gamma_{c}|^2 = \frac{\frac{1-\beta}{1+\beta}^2 + 4\Delta^2}{1+4\Delta^2}\\
  \frac{4\Delta^2}{1+4\Delta^2} = 1-\frac{1}{1+4\Delta^2}\\
  |\Gamma_{c}|^2 = 1-\frac{\frac{4\beta}{(1+\beta)^2}}{1+4\Delta^2}\\
\end{align*}
Let $L(f) \equiv \frac{1}{1+4\Delta^2}$. This is the functional form of the Lorentzian. Then 
\begin{align}
  |\Gamma_{c}|^2 = 1 - \frac{4\beta}{(\beta+1)^2}L(f)
\end{align}


\FloatBarrier
\section{Model of a resonator connected to directional coupler and amplifier}\label{sec:reflection_coupler}
In the previous section, we modeled a cavity connected to a load, and the transmission line was impedance-matched to the load. More realistically, the transmission line is composed of many components with various sources of impedance mismatches.

Figure~\ref{fig:orpheus_reflection_measurement} demonstrates the reflection measurement off of the Orpheus cavity. The VNA sends a signal to port 3 of the directional coupler. The signal travels to port 1 and reflects off the cavity. Then the signal travels from port 1 to port 2, and then through the amplifier and back to the VNA. However, the amplifier could be mismatched, allowing for standing waves to form in the transmission path. Furthermore, there might be additional crosstalk-like effects when one considers the directivity and isolation of the coupler. 

\begin{figure}[!htbp]
    \centering
  \includegraphics[height=0.3\textheight]{directional_coupler.png}
  \caption{The reflection measurement off of the Orpheus cavity. The VNA sends a signal to port 3 of the directional coupler. The signal travels to port 1 and reflects off the cavity. Then the signal travels from port 1 to port 2, and then through the amplifier and back to the VNA.}
  \label{fig:orpheus_reflection_measurement}
\end{figure}

To simplify the analysis, I've simplified the reflection model in Figure~\ref{fig:orpheus_reflection_measurement} to Figure~\ref{fig:coupling_math_model}. Our VNA measures $\frac{V_{out}}{V_{in}}$. Let $V_1$ be the voltage reflected off of the cavity heading towards the amplifier, and let $\Gamma_a$ be the reflection coefficient of the amplifier. Furthermore, let $V_x$ represent the crosstalk-like effects of the directional coupler that are abstracted away. $V_{out} \propto V_{in}$, so let's solve for $V_{in}$

\begin{figure}[!htbp]
    \centering
  \includegraphics[height=0.3\textheight]{simplified_reflection_model.png}
  \caption{A simplified mathematical model for a reflection measurement. A signal is injected into the cavity. $V_1$ is the signal reflected off the cavity heading towards the direction of the amplifier. $V_1$ reaches the amplifier and is partially reflected back to the cavity. That signal is then reflected again off the cavity and is added to $V_1$. There is an additional $V_x$ term that represents the complications from the injected signal interacting with the four different ports in the directional coupler.}
  \label{fig:coupling_math_model}
\end{figure}

\begin{align*}
  V_1 = V_{in}\Gamma_c + V_1 e^{i\theta}\Gamma_c \Gamma_a + V_x\\
  \frac{V_1}{V_{in}} = \frac{\Gamma_c + \frac{V_x}{V_{in}}}{1-e^{i\theta}\Gamma_c \Gamma_a}\\
  \end{align*}

  The denominator is reminiscent of the mismatched generator problem in Pozar 4th ed. 2.6. Let's say $\frac{V_x}{V_{in}}=e^{i\phi}\chi$ and assume that $\chi$ is constant across the resonance of the cavity.

  Now, let's assume that the amplifier is matched well enough that reflections are minimal and set $\Gamma_c=0$

\begin{align*}
  \frac{V_1}{V_{in}} \approx \Gamma_c + e^{i\phi}\chi\\
\end{align*}

We want to see how this additional term perturbs the reflected power away from the Lorentzian.

\begin{align*}
  \abs{\frac{V_1}{V_{in}}}^2 = \abs{\Gamma_c}^2 + \abs{\chi}^2 + \chi (\Gamma_c e^{-i\phi} + \Gamma_c^* e^{i\phi})\\
\end{align*}

By using Equation~\ref{eqn:reflection_coefficient} and expanding, one can show
\begin{align}
  \Gamma_c e^{-i\phi} + \Gamma_c^* e^{i\phi} = 2\cos\phi - \frac{4\beta}{1+\beta}\cos\phi L(f) + \frac{8\beta}{1+\beta}\sin\phi\Delta L(f)
  \label{eqn:complex_expansion}
\end{align}

Using Equation~\ref{eqn:complex_expansion}, we get

\begin{align}
  \abs{\frac{V_1}{V_{in}}}^2 &= 1 - \frac{4\beta}{(\beta + 1)^2}L(f) + \abs{\chi}^2 + 2\chi\cos\phi - \frac{4\chi\beta}{1+\beta}\cos\phi L(f) + 8\chi\sin\phi\frac{\beta}{1+\beta}\Delta L(f)\nonumber\\
                             &= 1 + \abs{\chi}^2 + 2\chi\cos\phi - 4\left(\frac{\beta}{(\beta + 1)^2} + \frac{\chi\beta}{1+\beta}\cos\phi \right)L(f) + 8\chi\sin\phi\frac{\beta}{1+\beta}\Delta L(f)
\end{align}

Let $C\equiv 1-2\chi^2\cos\phi+\chi^2$, $D\equiv \chi \cos\phi$, $F\equiv 8\chi\sin\phi$.
\begin{align*}
  \abs{\frac{V_1}{V_{in}}}^2 = C - 4\left(\frac{\beta}{(\beta + 1)^2} + D\frac{\beta}{1+\beta}\right)L(f) + F\frac{\beta}{1+\beta}\Delta L(f)
\end{align*}
Finally,
\begin{align}
  \abs{\frac{V_{out}}{V_{in}}}^2 = A\left(C - 4\left(\frac{\beta}{(\beta + 1)^2} + D\frac{\beta}{1+\beta}\right)L(f) + F\frac{\beta}{1+\beta}\Delta L(f)\right)
  \label{eqn:complicated_fit}
\end{align}
where $A$ represents the amplification of the amplifier and the attenuation from the amplifier to the VNA.

If we had not set $\Gamma_a=0$, then Equation~\ref{eqn:complicated_fit} becomes
\begin{align*}
  \abs{\frac{V_{out}}{V_{in}}}^2 = A\left(\frac{C - 4\left(\frac{\beta}{(\beta + 1)^2} + D\frac{\beta}{1+\beta}\right)L(f) + F\frac{\beta}{1+\beta}\Delta L(f)}{1+\Gamma_a(2\cos\theta-4\frac{\beta}{\beta+1}(\cos\theta+\Delta\sin\theta)) + \Gamma_a^2 \left(1-\frac{4\beta}{(\beta+1)^2}L(f)\right)}\right)
\end{align*}

Equation~\ref{eqn:complicated_fit} is a promising candidate to fit reflected powers that deviate from the standard Lorentzian shape. This model fits Orpheus data better than a Lorentzian (Figure~\ref{fig:complicated_fit}) and more accurately extracts the Q parameter, as evident by the fact that the reflection $Q_L$ matches the transmission $Q_L$ (Figure~\ref{fig:fitted_qs}). Unfortunately, there is a large degeneracy between $\beta$, $\chi$, and $\phi$. The resulting elements in the covariance matrix are huge. So Equation~\ref{eqn:complicated_fit} hasn't proved useful for extracting $\beta$. One may be able to make progress by constraining $\chi$ to be appropriately small. 

\begin{figure}[ht]
    \centering
  \includegraphics[height=0.4\textheight]{measurement_9.png}
  \caption{The fitted transmitted (standard Lorentzian fit) and reflected power (perturbed Lorentzian fit, Equation~\ref{eqn:complicated_fit}).}
  \label{fig:complicated_fit}
\end{figure}


\begin{figure}[ht]
    \centering
  \includegraphics[height=0.4\textheight]{20210404180209_loaded_q_slanted_reflection.png}
  \caption{The fitted loaded quality factors for transmission (standard Lorentzian fit) and reflection (perturbed Lorentzian fit, Equation~\ref{eqn:complicated_fit}).}
  \label{fig:fitted_qs}
\end{figure}

\FloatBarrier
\section{Axion coupling sensitivity to uncertainty in antenna coupling coefficient}
A resonators sensitivity to the axion is related to the antenna coupling coefficient

\begin{align*}
  g_{a\gamma \gamma} \propto \left(\frac{\beta+1}{\beta}\right)^{1/2}
\end{align*}

The uncertainty in $g_{a\gamma \gamma}$ is related to the uncertainty in $\beta$ by
\begin{align*}
  \Delta g_{a\gamma\gamma} &= \abs{\pdv{g_{a\gamma\gamma}}{\beta}} \Delta\beta\\
  \pdv{g_{a\gamma\gamma}}{\beta} &= -\frac{1}{2\beta^2\sqrt{\frac{\beta+1}{\beta}}}
\end{align*}

$\pdv{g_{a\gamma\gamma}}{\beta}$ is plotted in Figure~\ref{fig:dgamma_dbeta}. This suggests that near critical-coupling, the uncertainty in axion sensitivity is insensitive to the uncertainty in antenna coupling. Then it becomes very sensitive when we are weakly coupled.

\begin{figure}[!htbp]
    \centering
  \includegraphics[height=0.3\textheight]{dgamma_dbeta.png}
  \caption{The derivative of the axion-photon coupling constant vs antenna coupling coefficient. This relationship determines how the uncertainty in $\beta$ affects the uncertainty in $g_{a\gamma\gamma}$.}
  \label{fig:dgamma_dbeta}
\end{figure}

\section{Magnet Design}\label{appendix:magnet}
Seth Kimes and Richard Ottens designed the magnet. The planned dipole magnet has dimensions $44\times18.5\times18$ \SI{}{cm^3}. The NbTi superconducting is from Supercon, Inc. The model is 56S53, the diameter is \SI{0.30}{mm} bare and \SI{0.33}{mm} with the insulation. The critical current is \SI{125}{A} at \SI{3}{T}. Each dipole side will have 57 layers of winding, and each layer will have 57 turns. The dipole magnet will run \SI{103}{A} to produce a \SI{1.5}{T} field inside the detector volume. The magnetic field profile is shown in Figure~\ref{fig:magnet_field}. The force between the wires of the dipole magnet, depending on the direction, is $\mathcal{O}(\SI{2000}{lbs.})$ of force. Seth Kimes designed the vacuum vessel to withstand that force with a certain safety factor.
\begin{figure}
  \centering
  \subfloat[Along the axis of the cavity]{\includegraphics[height=0.25\textheight]{Orpheus_B_Field_Optical_Axis.pdf}}\hfil
  \subfloat[XY Plane]{\includegraphics[height=0.25\textheight]{Orpheus_B_Field_XY_plane.pdf}}\\
  \subfloat[XZ Plane]{\includegraphics[height=0.25\textheight]{Orpheus_B_Field_XZ_plane.pdf}}\hfil
  \subfloat[YZ Plane]{\includegraphics[height=0.25\textheight]{Orpheus_B_Field.pdf}}
  \caption{Calculated magnetic field of the planned Orpheus magnet. For this calculation, Z is the axis of the magnet, X is along the long side of the dipole magnet, and Y is along the short side of the dipole magnet.}
  \label{fig:magnet_field}
\end{figure}

We are currently in the process of winding the superconducting dipole magnet. James Sinnis spent the Summer of 2021 practicing the winding and potting technique, and the results in Figure~\ref{fig:magnet_winding} look satisfactory. We are now waiting for cryogenic epoxy to arrive, but the supply chains are currently in chaos.
\begin{figure}
  \centering
  \subfloat[]{\includegraphics[height=0.2\textheight]{copper_magnet_core.jpg}}\hfil
  \subfloat[]{\includegraphics[height=0.2\textheight]{wire_cross_section_corner_of_magnet.jpg}}
  \caption{Practicing Orpheus magnet widning with copper wire.}
  \label{fig:magnet_winding}
\end{figure}
