Skip to content

Commit

Permalink
updated RAR system
Browse files Browse the repository at this point in the history
  • Loading branch information
Phionx committed Aug 24, 2024
1 parent 98af97e commit 6d7a1ca
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 80 deletions.
113 changes: 94 additions & 19 deletions tutorials/3-fluxonium.ipynb

Large diffs are not rendered by default.

104 changes: 66 additions & 38 deletions tutorials/ats-coupler/0-resonator-ats-resonator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"import jaxquantum as jqt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Linear System"
]
},
{
"cell_type": "code",
"execution_count": 4,
Expand Down Expand Up @@ -67,8 +74,8 @@
{
"data": {
"text/plain": [
"Array([ 0.00000000e+00, -3.55271368e-06, 7.10542736e-06, 0.00000000e+00,\n",
" -1.77635684e-05, 2.84217094e-05], dtype=float64)"
"Array([-1.77635684e-06, 0.00000000e+00, 3.55271368e-06, -3.55271368e-06,\n",
" -3.55271368e-06, 1.42108547e-05], dtype=float64)"
]
},
"execution_count": 5,
Expand All @@ -90,8 +97,8 @@
{
"data": {
"text/plain": [
"Array([ 0.00000000e+00, -3.55271368e-06, 7.10542736e-06, 0.00000000e+00,\n",
" -1.77635684e-05, 2.84217094e-05], dtype=float64)"
"Array([-1.77635684e-06, 0.00000000e+00, 3.55271368e-06, -3.55271368e-06,\n",
" -3.55271368e-06, 1.42108547e-05], dtype=float64)"
]
},
"execution_count": 6,
Expand Down Expand Up @@ -164,66 +171,87 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"metrics, system, ϕ0, metrics0, system0 = get_metrics_normal_rar({})"
"metrics, system, ϕ0, metrics0, system0 = get_metrics_normal_rar({\n",
" \"ATS__phi_sum_ext\": 0.25,\n",
" \"ATS__phi_delta_ext\": 0.25,\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"H_static = system.get_H()\n",
"H_full = system.get_H()\n",
"\n",
"phi = system.params[\"phi\"]\n",
"Ejb = system.devices[1].params[\"Ej\"]\n",
"H_drive = -2*Ejb*jqt.sinm(phi)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# The full system Hamiltonian H = H_static + sin(eps(t)) * H_drive\n",
"H_static_qt = jqt.jqt2qt(H_static)\n",
"H_drive_qt = jqt.jqt2qt(H_drive) "
"phi_op = system.params[\"phi\"] \n",
"a_op = system.params[\"a\"]\n",
"b_op = system.params[\"b\"]\n",
"c_op = system.params[\"c\"]\n",
"\n",
"phi_sum = system.devices[1].params[\"phi_sum_ext\"]\n",
"phi_delta = system.devices[1].params[\"phi_delta_ext\"]\n",
"ATS_Ej = system.devices[1].params[\"Ej\"]\n",
"ATS_dEj = system.devices[1].params[\"dEj\"]\n",
"ATS_Ej2 = system.devices[1].params[\"Ej2\"]\n",
"\n",
"omega_a = metrics0[\"ω_ResonatorA\"]\n",
"omega_b = metrics0[\"ω_ResonatorB\"]\n",
"omega_c = metrics0[\"ω_ATS\"]\n",
"\n",
"H_rot = omega_a * a_op.dag() * a_op + omega_b * b_op.dag() * b_op \n",
"H_static = H_full - qs.ATS.get_H_nonlinear_static(phi_op, ATS_Ej, ATS_dEj, ATS_Ej2, phi_sum, phi_delta)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"Quantum object: dims = [[8, 10, 8], [8, 10, 8]], shape = (640, 640), type = oper, isherm = True $ \\\\ \\left(\\begin{matrix}0.0 & 0.697 & 0.0 & -2.651\\times10^{-05} & 0.0 & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\0.697 & 0.0 & 0.986 & 0.0 & -5.302\\times10^{-05} & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\0.0 & 0.986 & 0.0 & 1.207 & 0.0 & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\-2.651\\times10^{-05} & 0.0 & 1.207 & 0.0 & 1.394 & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\0.0 & -5.302\\times10^{-05} & 0.0 & 1.394 & 0.0 & \\cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\\\vdots & \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots & \\vdots & \\vdots & \\vdots\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & 0.0 & 1.139 & 0.0 & -9.688\\times10^{-05} & 0.0\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & 1.139 & 0.0 & 1.274 & 0.0 & -1.282\\times10^{-04}\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & 0.0 & 1.274 & 0.0 & 1.395 & 0.0\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & -9.688\\times10^{-05} & 0.0 & 1.395 & 0.0 & 1.507\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \\cdots & 0.0 & -1.282\\times10^{-04} & 0.0 & 1.507 & 0.0\\\\\\end{matrix}\\right)$"
],
"text/plain": [
"Quantum object: dims = [[8, 10, 8], [8, 10, 8]], shape = (640, 640), type = oper, isherm = True\n",
"Qobj data =\n",
"[[0. 0.69714856 0. ... 0. 0. 0. ]\n",
" [0.69714856 0. 0.98587103 ... 0. 0. 0. ]\n",
" [0. 0.98587103 0. ... 0. 0. 0. ]\n",
" ...\n",
" [0. 0. 0. ... 0. 1.39529043 0. ]\n",
" [0. 0. 0. ... 1.39529043 0. 1.50720291]\n",
" [0. 0. 0. ... 0. 1.50720291 0. ]]"
"Array(2.30926389e-14, dtype=float64)"
]
},
"execution_count": 12,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"H_drive_qt # qutip job"
"# Sanity Check (at the right bias point)\n",
"H_static_expected = omega_a * a_op.dag() * a_op + omega_b * b_op.dag() * b_op + omega_c * c_op.dag() * c_op\n",
"constant_offset = (9.009586565491253) * jqt.identity_like(H_rot)\n",
"jnp.max(jnp.abs((H_static - H_static_expected - constant_offset).data))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"phi = system.params[\"phi\"]\n",
"Ejb = system.devices[1].params[\"Ej\"]\n",
"H_drive_factor = -2*Ejb*jqt.sinm(phi) # only valid at the (phi_sum,phi_delta) = (0.25,0.25) bias point"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# The full system Hamiltonian H = H_static + sin(eps(t)) * H_drive_factor\n",
"H_rot_qt = jqt.jqt2qt(H_rot)\n",
"H_static_qt = jqt.jqt2qt(H_static)\n",
"H_drive_factor_qt = jqt.jqt2qt(H_drive_factor) "
]
},
{
Expand Down Expand Up @@ -610,7 +638,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
"version": "3.9.18"
}
},
"nbformat": 4,
Expand Down
49 changes: 26 additions & 23 deletions tutorials/ats-coupler/rar_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ def create_system_linear_rar(params):
devices = [resonator_a, ats, resonator_b]
Ns = [device.N for device in devices]

a0 = qs.promote(resonator_a.ops["a"], 0, Ns)
a0_dag = qs.promote(resonator_a.ops["a_dag"], 0, Ns)
a = qs.promote(resonator_a.ops["a"], 0, Ns)
a_dag = qs.promote(resonator_a.ops["a_dag"], 0, Ns)

c0 = qs.promote(ats.ops["a"], 1, Ns)
c0_dag = qs.promote(ats.ops["a_dag"], 1, Ns)
c = qs.promote(ats.ops["a"], 1, Ns)
c_dag = qs.promote(ats.ops["a_dag"], 1, Ns)

b0 = qs.promote(resonator_b.ops["a"], 2, Ns)
b0_dag = qs.promote(resonator_b.ops["a_dag"], 2, Ns)
b = qs.promote(resonator_b.ops["a"], 2, Ns)
b_dag = qs.promote(resonator_b.ops["a_dag"], 2, Ns)

couplings = []
couplings.append(-g_ac * (a0 - a0_dag) @ (c0 - c0_dag))
couplings.append(-g_cb * (c0 - c0_dag) @ (b0 - b0_dag))
couplings.append(-g_ac * (a - a_dag) @ (c - c_dag))
couplings.append(-g_cb * (c - c_dag) @ (b - b_dag))

system = qs.System.create(devices, couplings=couplings)
system.params["g_ac"] = g_ac
Expand Down Expand Up @@ -153,9 +153,9 @@ def get_devices_normal_rar(params):
ϕ0, metrics0, system0 = get_metrics_linear_rar(params)

# units are GHz and ns
ω_a0 = metrics0["ω_ResonatorA"]
ω_c0 = metrics0["ω_ATS"]
ω_b0 = metrics0["ω_ResonatorB"]
ω_a = metrics0["ω_ResonatorA"]
ω_c = metrics0["ω_ATS"]
ω_b = metrics0["ω_ResonatorB"]

ϕa_zpf = ϕ0["ResonatorA"]["ResonatorA"]
ϕc_zpf = ϕ0["ATS"]["ATS"]
Expand All @@ -166,9 +166,9 @@ def get_devices_normal_rar(params):
Ec_over_El_c = ϕc_zpf**4 / 2
Ec_over_El_b = ϕb_zpf**4 / 2

Ec_a = jnp.sqrt(ω_a0**2 / 8 * Ec_over_El_a)
Ec_c = jnp.sqrt(ω_c0**2 / 8 * Ec_over_El_c)
Ec_b = jnp.sqrt(ω_b0**2 / 8 * Ec_over_El_b)
Ec_a = jnp.sqrt(ω_a**2 / 8 * Ec_over_El_a)
Ec_c = jnp.sqrt(ω_c**2 / 8 * Ec_over_El_c)
Ec_b = jnp.sqrt(ω_b**2 / 8 * Ec_over_El_b)

resonator_a = qs.Resonator.create(
N_CONS["resonator_a"]["truncated"],
Expand Down Expand Up @@ -227,20 +227,20 @@ def get_system_normal_rar(params):
Ns = [device.N for device in devices]


a0 = qs.promote(resonator_a.ops["a"], a_indx, Ns)
a0_dag = qs.promote(resonator_a.ops["a_dag"], a_indx, Ns)
phi_a = ϕ0["ATS"]["ResonatorA"] * (a0 + a0_dag)
a = qs.promote(resonator_a.ops["a"], a_indx, Ns)
a_dag = qs.promote(resonator_a.ops["a_dag"], a_indx, Ns)
phi_a = ϕ0["ATS"]["ResonatorA"] * (a + a_dag)

b0 = qs.promote(resonator_b.ops["a"], b_indx, Ns)
b0_dag = qs.promote(resonator_b.ops["a_dag"], b_indx, Ns)
phi_b = ϕ0["ATS"]["ResonatorB"] * (b0 + b0_dag)
b = qs.promote(resonator_b.ops["a"], b_indx, Ns)
b_dag = qs.promote(resonator_b.ops["a_dag"], b_indx, Ns)
phi_b = ϕ0["ATS"]["ResonatorB"] * (b + b_dag)

c0 = qs.promote(ats.ops["a"], c_indx, Ns)
c0_dag = qs.promote(ats.ops["a_dag"], c_indx, Ns)
c = qs.promote(ats.ops["a"], c_indx, Ns)
c_dag = qs.promote(ats.ops["a_dag"], c_indx, Ns)
phi_c = qs.promote(ats.ops["phi"], c_indx, Ns)

# sanity check
phi_c_alternative = ϕ0["ATS"]["ATS"] * (c0 + c0_dag)
phi_c_alternative = ϕ0["ATS"]["ATS"] * (c + c_dag)
# assert jnp.abs(phi_c- phi_c_alternative).max() < 1e-10

phi = phi_a + phi_c + phi_b
Expand All @@ -256,6 +256,9 @@ def get_system_normal_rar(params):
system.params["phi_c"] = phi_c
system.params["phi_c_alternative"] = phi_c_alternative
system.params["phi"] = phi
system.params["a"] = a
system.params["b"] = b
system.params["c"] = c
return system, ϕ0, metrics0, system0


Expand Down

0 comments on commit 6d7a1ca

Please sign in to comment.