def squid_model_func( bfield: np.ndarray, transparency1: float, transparency2: float, switching_current1: float, switching_current2: float, bfield_offset: float, radians_per_tesla: float, anom_phase1: float, anom_phase2: float, temperature: float, gap: float, inductance: float, both_branches: bool = False, ): """The model function to fit against the data.""" bfield = bfield - bfield_offset i_squid = [ compute_squid_current( bfield * radians_per_tesla, cpr, (anom_phase1, switching_current1, transparency1), cpr, (anom_phase2, switching_current2, transparency2), positive=positive, inductance=inductance, ) for positive in ((True, False) if both_branches else (True, )) ] return np.array(i_squid).flatten()
def eval_squid_current(pfield, i, j, params, branch='positive'): """Compute the squid flowing as a function of the perpendicular field. """ t_id = (params['t_idler'] if 't_idler' in params else params[f't_idler_{i}']) i_id = (params[f'I_idler_{i}'] if f'I_idler_{i}' in params else params[f'I_idler_{i}_{j}']) idler_params = (params[f'phi_idler_{i}'], i_id, t_id) phi_id = (params[f'phi_active_{i}_{j}'] if f'phi_active_{i}_{j}' in params else params[f'phi_active_{i}']) active_params = (phi_id, params[f'I_active_{i}_{j}'], params[f't_active_{i}']) f = (pfield - params[f'Boffset_{i}']) fscale = (params[f'fraun_scale'] if 'fraun_scale' in params else params[f'fraun_scale_{i}']) fraun_phase = f * fscale + params[f'fraun_offset_{i}'] fe = fraunhofer_envelope(fraun_phase) conversion = (params[f'phase_conversion'] if 'phase_conversion' in params else params[f'phase_conversion_{i}']) sq = compute_squid_current(HANDEDNESS * f * conversion, finite_transparency_jj_current, idler_params, finite_transparency_jj_current, active_params, positive=bool(branch == 'positive')) return fe * sq
def eval_squid_current(pfield, i, j, params): """Compute the squid flowing as a function of the perpendicular field. """ t_id = (params['t_idler'] if 't_idler' in params else params[f't_idler_{i}']) idler_params = (params[f'phi_idler_{i}'], params[f'I_idler_{i}'], t_id) active_params = (params[f'phi_active_{i}_{j}'], params[f'I_active_{i}_{j}'], params[f't_active_{i}_{j}']) fe = fraunhofer_envelope(pfield*params[f'fraun_scale'] + params[f'fraun_offset_{i}']) sq = compute_squid_current(pfield*params['phase_conversion'] * PHASE_SIGN, finite_transparency_jj_current, idler_params, finite_transparency_jj_current, active_params) return fe*sq
def update(_=None): for ax, branch in zip(axs, [True, False]): (line, ) = ax.get_lines() line.set_ydata( compute_squid_current( phase, cpr, (phi1.slider.val * np.pi, 1, tau1.slider.val), cpr, ( phi2.slider.val * np.pi, 10**logratio.slider.val, tau2.slider.val, ), inductance=L.slider.val * FLUX_QUANTUM, positive=branch, ), ) # remove pop and color=... for a cool trip ax.collections.pop() poly = ax.fill_between(*line.get_data(), color="tab:blue") ax.relim() ax.autoscale_view() fig.canvas.draw_idle()
def eval_squid_current(pfield, i, j, k, params): """Compute the squid flowing as a function of the perpendicular field. Parameters ---------- pfield : np.ndarray Perpendicular field applied on the SQUID i : int Index of the field dataset. j : int j+1 is the index of the active junction k : int Index of the gate dataset considered params : dict Key value pairs of the fitting parameters. """ phi_id = (params[f'phi_j{j+1}_active_{i}_{k}'] if f'phi_j{j+1}_active_{i}_{k}' in params else params[f'phi_j{j+1}_active_{i}']) if j == 0: j1_params = (phi_id, params[f'I_j1_active_{i}_{k}'], params[f't_j1_{i}']) j2_params = (0, params[f'I_j2_idler_{i}'], params[f't_j2_{i}']) else: j1_params = (phi_id, params[f'I_j1_idler_{i}'], params[f't_j1_{i}']) j2_params = (0, params[f'I_j2_active_{i}_{k}'], params[f't_j2_{i}']) f = (pfield - params[f'Boffset_j{j+1}_{i}']) fraun_phase = f * params[f'fraun_scale'] + params[f'fraun_offset_{i}'] fe = fraunhofer_envelope(fraun_phase) sq = compute_squid_current( HANDEDNESS * f * params[f'phase_conversion_j{j+1}'], finite_transparency_jj_current, j1_params, finite_transparency_jj_current, j2_params) return fe * sq
# ============================================================================= # --- Execution --------------------------------------------------------------- # ============================================================================= import numpy as np import matplotlib.pyplot as plt from shabanipy.squid.squid_model import compute_squid_current from shabanipy.squid.cpr import finite_transparency_jj_current as cpr phase_diff = np.linspace(-2 * np.pi, 2 * np.pi, 1001) offset = 1.2 for t in SECOND_JUNCTION_TRANSPARENCIES: # plt.figure() for i, a in enumerate(SECOND_JUNCTION_AMPLITUDES): squid = compute_squid_current(phase_diff, cpr, (0, *FIRST_JUNCTION), cpr, (offset, a, t)) neg_squid = compute_squid_current(phase_diff, cpr, (0, *FIRST_JUNCTION), cpr, (offset, a, t), False) amplitude = (np.amax(squid) - np.min(squid)) baseline = (np.amax(squid) + np.min(squid)) / 2 plt.plot(phase_diff, 2 * (squid - baseline) / amplitude + 1, label=f't={t}, a={a}') #, color=f'C{i}') amplitude = (np.amax(neg_squid) - np.min(neg_squid)) baseline = (np.amax(neg_squid) + np.min(neg_squid)) / 2 plt.plot(phase_diff, 2 * (neg_squid - baseline) / amplitude - 1, color=f'C{i}') plt.legend() # plt.figure()
from shabanipy.squid.squid_model import compute_squid_current from shabanipy.squid.cpr import finite_transparency_jj_current as cpr plt.rcParams['axes.linewidth'] = 1.5 plt.rcParams['font.size'] = 13 plt.rcParams['pdf.fonttype'] = 42 phase_diff = np.linspace(-2*np.pi, 2*np.pi, 1001) fig, axes = plt.subplots(4, 3, figsize=(12,6), constrained_layout=True, sharex=True, sharey='row') for i, a in enumerate((0.1, 0.5, 0.95, 1.5)): for j, t in enumerate((0.1, 0.5, 0.9)): squid = compute_squid_current(phase_diff, cpr, (0, 1, 0.9), cpr, (0, a, t)) amplitude = (np.amax(squid) - np.min(squid)) baseline = (np.amax(squid) + np.min(squid))/2 axes[i, j].plot(phase_diff/np.pi, squid, label=f'a={a}') line = axes[i, j].axvline(phase_diff[100 + np.argmax(squid[100:])]/np.pi) line.set_linestyle('--') axes[i, j].tick_params(direction='in', width=1.5) if i == 0: axes[i, j].set_title(f'Transparency {t}') if i == 2: ticks = [-2, -1, 0, 1, 2] labels = [f'{v} π' if v not in (0.0, 1.0) else ('0.0' if v == 0 else 'π') for v in ticks]