Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
%% Here's the real test -- move the resonator and see how it responds
apply_eta  = @(x, eta_offset, eta) (x + eta_offset)*eta;

% can place resonator +/- Fdsp/2
dfres = 1e3; % move the resonator from it's original frequency
fres  = 300e3 + dfres;
fnorm = fres/Fdsp;

z0 = 0.98*exp(1j*2*pi*fnorm);
p0 = 0.95*exp(1j*2*pi*(fnorm+0.002));
b = [1, -z0];
a = [1, -p0];

[s21, w] = freqz(b, a, w);                  % resonator S21
s21 = s21.*exp(-1j*theta);                  % apply arb phase offset
s21 = s21.*exp(-1j*2*pi*tau*f);             % apply time delay
s21_eta  = apply_eta(s21, eta_offset, eta); % apply eta

disp(['We moved the resonator ', num2str(dfres), 'Hz and measured ', num2str(round(imag(s21_eta(ftone)))), ' Hz error'])

>> We moved the resonator 1000Hz and measured -984 Hz error

How I got that:

Define a cost function eta_cost.m

Code Block
function cost = eta_cost(s21, idx, eta_offset, eta_phase)
    % we can initially calibrate eta_offset as pure imag number
    s21_eta      = (s21 + 1j*eta_offset)*exp(1j*eta_phase);
    s21_eta_diff = diff(s21_eta);
    s21_idx      = s21_eta(idx);
    s21_idx_diff = s21_eta_diff(idx);
    cost = imag(s21_idx).^2 + real(s21_idx_diff).^2;
end

Then run minimization:

Code Block
%% first calculate eta offset and eta phase
df = f(2) - f(1); % our scan frequency steps
apply_eta  = @(x, eta_offset, eta) (x + eta_offset)*eta;
v = [0, 0];
eta_min_f  = @(x) eta_cost(s21, idx, x(1), x(2));
a          = fminsearch(eta_min_f, v);
eta_offset = 1j*a(1);
eta        = exp(1j*a(2));
s21_eta    = apply_eta(s21, eta_offset, eta);
% calculate eta_mag
eta_mag    = 2*df/imag(s21_eta(idx + 1)  - s21_eta(idx - 1));
eta        = eta*eta_mag;
s21_corr   = apply_eta(s21, eta_offset, eta);

Using Pickles cryostat at SLAC

...