{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# PyOR Quantum\n", "## Author: Vineeth Thalakottoor\n", "## Introduction to Partial Trace" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Define the source path\n", "SourcePath = '/media/HD2/Vineeth/PostDoc_Simulations/Github/PyOR_V1/PyOR_Combined/Source_Doc'\n", "\n", "# Add source path\n", "import sys\n", "sys.path.append(SourcePath)\n", "import time\n", "%matplotlib ipympl\n", "\n", "# Import PyOR package\n", "from PyOR_QuantumSystem import QuantumSystem as QunS\n", "from PyOR_Hamiltonian import Hamiltonian\n", "from PyOR_DensityMatrix import DensityMatrix\n", "from PyOR_QuantumObject import QunObj\n", "from PyOR_HardPulse import HardPulse\n", "from PyOR_Basis import Basis\n", "from PyOR_Evolution import Evolutions\n", "from PyOR_Plotting import Plotting\n", "import PyOR_SignalProcessing as Spro\n", "from PyOR_QuantumLibrary import QuantumLibrary" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Define the spin system\n", "Spin_list = {\"A\" : \"H1\", \"B\" : \"H1\"}\n", "QS = QunS(Spin_list,PrintDefault=False)\n", "\n", "# initialize the system\n", "QS.Initialize()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Set parameters" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Rotating frame frequencies: {'A': -2514706800.0, 'B': -2514706800.0}\n", "Offset frequencies: {'A': 10.0, 'B': 50.0}\n", "Initial spin temperatures: {'A': 300.0, 'B': 300.0}\n", "Final spin temperatures: {'A': 300.0, 'B': 300.0}\n", "Radiation damping gain: {'A': 0, 'B': 0}\n", "Radiation damping phase: {'A': 0, 'B': 0}\n", "\n", "Rprocess = No Relaxation\n", "RelaxParDipole_tau = 0.0\n", "DipolePairs = []\n", "RelaxParDipole_bIS = []\n" ] } ], "source": [ "# Master Equation\n", "QS.PropagationSpace = \"Hilbert\"\n", "QS.MasterEquation = \"Redfield\"\n", "\n", "# B0 Field in Tesla, Static Magnetic field (B0) along Z\n", "QS.B0 = 9.4\n", "\n", "# Offset Frequency in rotating frame (Hz)\n", "QS.OFFSET[\"A\"] = 10.0\n", "QS.OFFSET[\"B\"] = 50.0\n", "\n", "# Define initial and final Spin Temperature\n", "QS.I_spintemp[\"A\"] = 300.0\n", "QS.I_spintemp[\"B\"] = 300.0\n", "QS.F_spintemp[\"A\"] = 300.0\n", "QS.F_spintemp[\"B\"] = 300.0\n", "\n", "QS.Update()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Genrate individual Density Matrix" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.500016005441018 & 0\\\\0 & 0.499983994558982\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.500016005441018, 0],\n", "[ 0, 0.499983994558982]])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "QS.Arho.matrix" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.500016005442617 & 0\\\\0 & 0.499983994557383\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.500016005442617, 0],\n", "[ 0, 0.499983994557383]])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "QS.Brho.matrix" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "rho = QS.Arho.TensorProduct(QS.Brho)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.250016005697992 & 0 & 0 & 0\\\\0 & 0.249999999743026 & 0 & 0\\\\0 & 0 & 0.249999999744626 & 0\\\\0 & 0 & 0 & 0.249983994814357\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.250016005697992, 0, 0, 0],\n", "[ 0, 0.249999999743026, 0, 0],\n", "[ 0, 0, 0.249999999744626, 0],\n", "[ 0, 0, 0, 0.249983994814357]])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rho.matrix" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Partial Trace" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "QLib = QuantumLibrary(QS)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "rho_A = QLib.PartialTrace(rho, [0])\n", "rho_B = QLib.PartialTrace(rho, [1], [2,2])" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.500016005441018 & 0\\\\0 & 0.499983994558982\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.500016005441018, 0],\n", "[ 0, 0.499983994558982]])" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rho_A.matrix" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.500016005442617 & 0\\\\0 & 0.499983994557383\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.500016005442617, 0],\n", "[ 0, 0.499983994557383]])" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rho_B.matrix" ] } ], "metadata": { "kernelspec": { "display_name": "base", "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.7" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }