{ "cells": [ { "cell_type": "markdown", "id": "logical-diving", "metadata": {}, "source": [ "This notebook is used to define a noise model for benchmarking purposes." ] }, { "cell_type": "code", "execution_count": 1, "id": "understanding-business", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import qutip as qt" ] }, { "cell_type": "code", "execution_count": 2, "id": "fallen-office", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Preparing Q# environment...\n" ] } ], "source": [ "import qsharp\n", "from qsharp.experimental import enable_noisy_simulation, get_noise_model, set_noise_model\n", "enable_noisy_simulation()" ] }, { "cell_type": "code", "execution_count": 3, "id": "pursuant-plenty", "metadata": {}, "outputs": [], "source": [ "I, X, Y, Z = qt.qeye(2), qt.sigmax(), qt.sigmay(), qt.sigmaz()" ] }, { "cell_type": "code", "execution_count": 4, "id": "labeled-strike", "metadata": {}, "outputs": [], "source": [ "sI, sX, sY, sZ = map(qt.to_super, [I, X, Y, Z])" ] }, { "cell_type": "code", "execution_count": 5, "id": "answering-europe", "metadata": {}, "outputs": [], "source": [ "def total_dephasing_channel():\n", " return (1 / 2) * sI + (1 / 2) * sZ" ] }, { "cell_type": "code", "execution_count": 6, "id": "attached-juice", "metadata": {}, "outputs": [], "source": [ "def dephasing_channel(p):\n", " return (1 - p) * sI + p * total_dephasing_channel()" ] }, { "cell_type": "code", "execution_count": 7, "id": "serious-warner", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[[2], [2]], [[2], [2]]], shape = (4, 4), type = super, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}1.0 & 0.0 & 0.0 & 0.0\\\\0.0 & 0.900 & 0.0 & 0.0\\\\0.0 & 0.0 & 0.900 & 0.0\\\\0.0 & 0.0 & 0.0 & 1.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[[2], [2]], [[2], [2]]], shape = (4, 4), type = super, isherm = True\n", "Qobj data =\n", "[[1. 0. 0. 0. ]\n", " [0. 0.9 0. 0. ]\n", " [0. 0. 0.9 0. ]\n", " [0. 0. 0. 1. ]]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dephasing_channel(0.1)" ] }, { "cell_type": "code", "execution_count": 8, "id": "requested-instruction", "metadata": {}, "outputs": [], "source": [ "def total_depolarizing_channel():\n", " return (sI + sX + sY + sZ) / 4" ] }, { "cell_type": "code", "execution_count": 9, "id": "exact-argument", "metadata": {}, "outputs": [], "source": [ "def depolarizing_channel(p):\n", " return (1 - p) * sI + p * total_depolarizing_channel()" ] }, { "cell_type": "code", "execution_count": 10, "id": "academic-focus", "metadata": {}, "outputs": [], "source": [ "def finite_visibility_meas(visibility):\n", " return [\n", " qt.to_super(visibility * (I + sign * Z) / 2 + (1 - visibility) * I / 2)\n", " for sign in (+1, -1)\n", " ]" ] }, { "cell_type": "code", "execution_count": 11, "id": "inclusive-active", "metadata": {}, "outputs": [], "source": [ "noise_model = get_noise_model()" ] }, { "cell_type": "code", "execution_count": 12, "id": "instructional-mortality", "metadata": {}, "outputs": [], "source": [ "noise_model['x'] = depolarizing_channel(0.1) * sX\n", "noise_model['z'] = dephasing_channel(0.1) * sZ\n", "noise_model['z_meas']['effects'] = finite_visibility_meas(0.95)" ] }, { "cell_type": "code", "execution_count": 13, "id": "voluntary-parallel", "metadata": {}, "outputs": [], "source": [ "set_noise_model(noise_model)\n", "qsharp.client._execute('%experimental.noise_model --save benchmark-noise-model.json')" ] }, { "cell_type": "code", "execution_count": null, "id": "functional-concentrate", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.2" } }, "nbformat": 4, "nbformat_minor": 5 }