Skip to content

Commit

Permalink
[minor] update jupyter notebook demo
Browse files Browse the repository at this point in the history
  • Loading branch information
caitaozhan committed Dec 11, 2024
1 parent 5826c44 commit 116d622
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 57 deletions.
37 changes: 17 additions & 20 deletions example/qkd.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# !pip install ipywidgets # in case ipywidgets is not installed\n",
"from ipywidgets import interact\n",
"from matplotlib import pyplot as plt\n",
"import time"
Expand Down Expand Up @@ -65,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -104,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -134,10 +135,8 @@
" cc1.set_ends(n2, n1.name)\n",
" # construct a quantum communication channel\n",
" # (with arguments for the channel name, timeline, attenuation (in db/m), and distance (in m))\n",
" qc0 = QuantumChannel(\"qc_n1_n2\", tl, attenuation=1e-5, distance=1e3,\n",
" polarization_fidelity=0.97)\n",
" qc1 = QuantumChannel(\"qc_n2_n1\", tl, attenuation=1e-5, distance=1e3,\n",
" polarization_fidelity=0.97)\n",
" qc0 = QuantumChannel(\"qc_n1_n2\", tl, attenuation=1e-5, distance=1e3, polarization_fidelity=0.97)\n",
" qc1 = QuantumChannel(\"qc_n2_n1\", tl, attenuation=1e-5, distance=1e3, polarization_fidelity=0.97)\n",
" qc0.set_ends(n1, n2.name)\n",
" qc1.set_ends(n2, n1.name)\n",
" \n",
Expand Down Expand Up @@ -183,13 +182,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "28d22d2059344083b9c46aef7f89a6fc",
"model_id": "e8aae143b19945ec903d712d36db68b0",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -206,7 +205,7 @@
"<function __main__.test(sim_time, keysize)>"
]
},
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -240,7 +239,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -284,10 +283,8 @@
" cc1 = ClassicalChannel(\"cc_n2_n1\", tl, distance=1e3)\n",
" cc0.set_ends(n1, n2.name)\n",
" cc1.set_ends(n2, n1.name)\n",
" qc0 = QuantumChannel(\"qc_n1_n2\", tl, attenuation=1e-5, distance=1e3,\n",
" polarization_fidelity=0.97)\n",
" qc1 = QuantumChannel(\"qc_n2_n1\", tl, attenuation=1e-5, distance=1e3,\n",
" polarization_fidelity=0.97)\n",
" qc0 = QuantumChannel(\"qc_n1_n2\", tl, attenuation=1e-5, distance=1e3, polarization_fidelity=0.97)\n",
" qc1 = QuantumChannel(\"qc_n2_n1\", tl, attenuation=1e-5, distance=1e3, polarization_fidelity=0.97)\n",
" qc0.set_ends(n1, n2.name)\n",
" qc1.set_ends(n2, n1.name)\n",
" \n",
Expand Down Expand Up @@ -343,13 +340,13 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d0703f7c810843e7b4e4c3d286b20381",
"model_id": "d50c93005ce44aed8e11db898491341c",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -366,7 +363,7 @@
"<function __main__.test(sim_time, keysize)>"
]
},
"execution_count": 7,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -389,7 +386,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "test",
"language": "python",
"name": "python3"
},
Expand All @@ -403,7 +400,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
25 changes: 13 additions & 12 deletions example/random_request_network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"# !pip install ipywidgets # in case ipywidgets is not installed\n",
"from ipywidgets import interact\n",
"import pandas as pd\n",
"import time"
]
},
Expand Down Expand Up @@ -78,7 +79,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -138,7 +139,7 @@
" memory_sizes = []\n",
" for node in network_topo.get_nodes_by_type(RouterNetTopo.QUANTUM_ROUTER):\n",
" node_name = node.name\n",
" for reservation in node.network_manager.protocol_stack[1].accepted_reservation:\n",
" for reservation in node.network_manager.protocol_stack[1].accepted_reservations:\n",
" s_t, e_t, size = reservation.start_time, reservation.end_time, reservation.memory_size\n",
" if reservation.initiator != node.name and reservation.responder != node.name:\n",
" size *= 2\n",
Expand Down Expand Up @@ -170,7 +171,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -238,20 +239,20 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e5b30c59d8854386a190d0ee3d9e6169",
"model_id": "3696019279184c42bc92a3ba929865fa",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=50000.0, description='sim_time', max=150000.0, min=-50000.0), Dropdown…"
"interactive(children=(IntSlider(value=3000, description='sim_time', max=4000, min=2000, step=500), Dropdown(de"
]
},
"metadata": {},
Expand All @@ -263,13 +264,13 @@
"<function __main__.test(sim_time, qc_atten)>"
]
},
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"interact(test, sim_time=50e3, qc_atten=[0, 1e-5, 2e-5])"
"interact(test, sim_time=(2000, 4000, 500), qc_atten=[0, 1e-5, 2e-5])"
]
},
{
Expand All @@ -282,9 +283,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"display_name": "test",
"language": "python",
"name": "venv"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -296,7 +297,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.2"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
9 changes: 5 additions & 4 deletions example/three_node_eg_ep_es.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"metadata": {},
"outputs": [],
"source": [
"# !pip install ipywidgets # in case ipywidgets is not installed\n",
"from ipywidgets import interact\n",
"from matplotlib import pyplot as plt\n",
"import time"
Expand Down Expand Up @@ -288,7 +289,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ae7c189c50ff4b7fab644d454646e5b6",
"model_id": "3ac58091b34a48859e6116198cda0bd3",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -327,9 +328,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"display_name": "test",
"language": "python",
"name": "venv"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -341,7 +342,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.2"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
18 changes: 6 additions & 12 deletions example/two_node_eg.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"outputs": [],
"source": [
"# !pip install ipywidgets # in case ipywidgets is not installed\n",
"from ipywidgets import interact\n",
"from matplotlib import pyplot as plt\n",
"import time"
Expand Down Expand Up @@ -238,15 +239,15 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ace2a2b9901c45e5adbf82cf44f4bd3a",
"model_id": "9ea2b2a6f968415396064e10de53449d",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -263,7 +264,7 @@
"<function __main__.test(sim_time, cc_delay, qc_atten, qc_dist)>"
]
},
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -285,18 +286,11 @@
"\n",
"In this example, we note that the number of entangled memories increases at a roughly linear rate with a slope inversely proportional to the quantum channel length and attenuation. We also see clusters of memories entangled at roughly the same time, based on entanglement processes that are started at the same time and encounter similar errors. The time intervals between these events roughly corresponds to the classical channel delay."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "test",
"language": "python",
"name": "python3"
},
Expand All @@ -310,7 +304,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
15 changes: 6 additions & 9 deletions sequence/gui/user_templates.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"BSM_node": {
"BSMNode": {
"default_BSM": {
"detector_type": "default_detector"
"detector_1": "default_detector",
"detector_2": "default_detector"
}
},
"Detector": {
Expand All @@ -26,21 +27,17 @@
"raw_fidelity": 0.85
}
},
"Photon_Source": {},
"Protocol": {},
"QKD": {
"PhotonSource": {},
"QKDNode": {
"default_QKD": {
"encoding": "polarization",
"stack_size": 5
}
},
"QuantumErrorCorrection": {},
"QuantumRepeater": {},
"QuantumRouter": {
"default_router": {
"mem_type": "default_memory",
"memo_size": 50
}
},
"Temp": {}
}
}

0 comments on commit 116d622

Please # to comment.