From 116d622a403e31be113f5d9e05a0cc66456b0969 Mon Sep 17 00:00:00 2001 From: Caitao Zhan Date: Tue, 10 Dec 2024 23:38:00 -0600 Subject: [PATCH] [minor] update jupyter notebook demo --- example/qkd.ipynb | 37 +++++++++++++--------------- example/random_request_network.ipynb | 25 ++++++++++--------- example/three_node_eg_ep_es.ipynb | 9 ++++--- example/two_node_eg.ipynb | 18 +++++--------- sequence/gui/user_templates.json | 15 +++++------ 5 files changed, 47 insertions(+), 57 deletions(-) diff --git a/example/qkd.ipynb b/example/qkd.ipynb index bc4ec525..01e6ade0 100644 --- a/example/qkd.ipynb +++ b/example/qkd.ipynb @@ -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" @@ -65,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -104,7 +105,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -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", @@ -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 }, @@ -206,7 +205,7 @@ "" ] }, - "execution_count": 6, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -240,7 +239,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -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", @@ -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 }, @@ -366,7 +363,7 @@ "" ] }, - "execution_count": 7, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -389,7 +386,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "test", "language": "python", "name": "python3" }, @@ -403,7 +400,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/example/random_request_network.ipynb b/example/random_request_network.ipynb index 313a2381..a46da867 100644 --- a/example/random_request_network.ipynb +++ b/example/random_request_network.ipynb @@ -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" ] }, @@ -78,7 +79,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -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", @@ -170,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -238,7 +239,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 8, "metadata": { "scrolled": false }, @@ -246,12 +247,12 @@ { "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": {}, @@ -263,13 +264,13 @@ "" ] }, - "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])" ] }, { @@ -282,9 +283,9 @@ ], "metadata": { "kernelspec": { - "display_name": "venv", + "display_name": "test", "language": "python", - "name": "venv" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -296,7 +297,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.2" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/example/three_node_eg_ep_es.ipynb b/example/three_node_eg_ep_es.ipynb index a9ad7179..4c15c49c 100644 --- a/example/three_node_eg_ep_es.ipynb +++ b/example/three_node_eg_ep_es.ipynb @@ -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" @@ -288,7 +289,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "ae7c189c50ff4b7fab644d454646e5b6", + "model_id": "3ac58091b34a48859e6116198cda0bd3", "version_major": 2, "version_minor": 0 }, @@ -327,9 +328,9 @@ ], "metadata": { "kernelspec": { - "display_name": "venv", + "display_name": "test", "language": "python", - "name": "venv" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -341,7 +342,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.2" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/example/two_node_eg.ipynb b/example/two_node_eg.ipynb index 110569fa..79896d53 100644 --- a/example/two_node_eg.ipynb +++ b/example/two_node_eg.ipynb @@ -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" @@ -238,7 +239,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": { "tags": [] }, @@ -246,7 +247,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "ace2a2b9901c45e5adbf82cf44f4bd3a", + "model_id": "9ea2b2a6f968415396064e10de53449d", "version_major": 2, "version_minor": 0 }, @@ -263,7 +264,7 @@ "" ] }, - "execution_count": 6, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -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" }, @@ -310,7 +304,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/sequence/gui/user_templates.json b/sequence/gui/user_templates.json index 534bbdef..eaadf1d8 100644 --- a/sequence/gui/user_templates.json +++ b/sequence/gui/user_templates.json @@ -1,7 +1,8 @@ { - "BSM_node": { + "BSMNode": { "default_BSM": { - "detector_type": "default_detector" + "detector_1": "default_detector", + "detector_2": "default_detector" } }, "Detector": { @@ -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": {} + } } \ No newline at end of file