{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# If necessary, install the qsharp package and the qsharp-widgets\n",
    "# by running the following command in a terminal:\n",
    "# pip install qsharp qsharp-widgets -U\n",
    "\n",
    "import qsharp\n",
    "from qsharp_widgets import SpaceChart, EstimateDetails, EstimatesOverview, EstimatesPanel\n",
    "\n",
    "with open(\"Dynamics.qs\", \"r\") as f:\n",
    "    contents = f.read()\n",
    "qsharp.eval(contents)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "result = qsharp.estimate(\n",
    "    \"QuantumDynamics.Main()\",\n",
    "    [\n",
    "        {\n",
    "        \"qubitParams\": { \"name\": \"qubit_gate_ns_e3\" },\n",
    "        \"estimateType\": \"frontier\",\n",
    "        },\n",
    "        {\n",
    "        \"qubitParams\": { \"name\": \"qubit_gate_ns_e4\" },\n",
    "        \"estimateType\": \"frontier\",\n",
    "        },\n",
    "        {\n",
    "        \"qubitParams\": { \"name\": \"qubit_gate_us_e3\" },\n",
    "        \"estimateType\": \"frontier\",\n",
    "        },\n",
    "        {\n",
    "        \"qubitParams\": { \"name\": \"qubit_gate_us_e4\" },\n",
    "        \"estimateType\": \"frontier\",\n",
    "        },\n",
    "        {\n",
    "        \"qubitParams\": { \"name\": \"qubit_maj_ns_e4\" },\n",
    "        \"qecScheme\": { \"name\": \"floquet_code\" },\n",
    "        \"estimateType\": \"frontier\",\n",
    "        },\n",
    "        {\n",
    "        \"qubitParams\": { \"name\": \"qubit_maj_ns_e6\" },\n",
    "        \"qecScheme\": { \"name\": \"floquet_code\" },\n",
    "        \"estimateType\": \"frontier\",\n",
    "        },\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# The full experience with the summary table, the space-time diagrams, the space diagrams, and the estimate details\n",
    "EstimatesPanel(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Qubit usage diagram for the first (estimate index=0) run and the third (point index=2) shortest runtime\n",
    "SpaceChart(result[0],8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Estimate details usage for the second (estimate index=0) run and the fourth (point index=3) shortest runtime\n",
    "EstimateDetails(result[1], 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Estimate overview with the summary table and the space-time diagram\n",
    "EstimatesOverview(result, colors=[\"#1f77b4\", \"#ff7f0e\", \"blue\", \"red\", \"green\", \"yellow\"], runNames=[\"Gate ns e3, surface\", \"Gate ns e4, surface\", \"Gate us e3, surface\", \"Gate us e4, surface\", \"Majorana ns e4, floquet\", \"Majorana ns e6, floquet\"])"
   ]
  }
 ],
 "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.12.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
