{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# PyOR Quantum\n", "## Author: Vineeth Thalakottoor\n", "## Introduction to equlibrium density matrix" ] }, { "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", "\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" ] }, { "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 J coupling between Spins \n", "QS.JcoupleValue(\"A\",\"B\",5.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": [ "### Generate Hamiltonians" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Larmor Frequency in MHz: [-400.22802765 -400.22806765]\n" ] } ], "source": [ "# generate Larmor Frequencies\n", "QS.print_Larmor = True\n", "Ham = Hamiltonian(QS)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Trace of density matrix = 1.0\n", "Trace of density matrix = 1.0\n" ] } ], "source": [ "DM = DensityMatrix(QS,Ham)\n", "\n", "Thermal_DensMatrix = True\n", "\n", "if Thermal_DensMatrix: \n", " # High Temperature\n", " HT_approx = False\n", " \n", " # Initial Density Matrix\n", " rho_in = DM.EquilibriumDensityMatrix(QS.Ispintemp,HT_approx)\n", " \n", " # Equlibrium Density Matrix\n", " rhoeq = DM.EquilibriumDensityMatrix(QS.Fspintemp,HT_approx)\n", "else:\n", " rho_in = QunObj(QS.Az + QS.Bz)\n", " rhoeq = QunObj(QS.Az + QS.Bz) " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.250016003847122 & 0 & 0 & 0\\\\0 & 0.25 & 0 & 0\\\\0 & 0 & 0.25 & 0\\\\0 & 0 & 0 & 0.249983996152878\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.250016003847122, 0, 0, 0],\n", "[ 0, 0.25, 0, 0],\n", "[ 0, 0, 0.25, 0],\n", "[ 0, 0, 0, 0.249983996152878]])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Initial Density Matrix\n", "rho_in.matrix" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.250016003847122 & 0 & 0 & 0\\\\0 & 0.25 & 0 & 0\\\\0 & 0 & 0.25 & 0\\\\0 & 0 & 0 & 0.249983996152878\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.250016003847122, 0, 0, 0],\n", "[ 0, 0.25, 0, 0],\n", "[ 0, 0, 0.25, 0],\n", "[ 0, 0, 0, 0.249983996152878]])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Final Density Matrix\n", "rhoeq.matrix" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "DM = DensityMatrix(QS,Ham)\n", "\n", "Thermal_DensMatrix = False\n", "\n", "if Thermal_DensMatrix: \n", " # High Temperature\n", " HT_approx = False\n", " \n", " # Initial Density Matrix\n", " rho_in = DM.EqulibriumDensityMatrix(QS.Ispintemp,HT_approx)\n", " \n", " # Equlibrium Density Matrix\n", " rhoeq = DM.EqulibriumDensityMatrix(QS.Fspintemp,HT_approx)\n", "else:\n", " rho_in = QS.Az + QS.Bz\n", " rhoeq = QS.Az + QS.Bz" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & -1.0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[1.0, 0, 0, 0],\n", "[ 0, 0, 0, 0],\n", "[ 0, 0, 0, 0],\n", "[ 0, 0, 0, -1.0]])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Initial Density Matrix\n", "rho_in.matrix" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & -1.0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[1.0, 0, 0, 0],\n", "[ 0, 0, 0, 0],\n", "[ 0, 0, 0, 0],\n", "[ 0, 0, 0, -1.0]])" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Final Density Matrix\n", "rhoeq.matrix" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Individual density matrix" ] }, { "cell_type": "code", "execution_count": 11, "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": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "QS.Arho.matrix" ] }, { "cell_type": "code", "execution_count": 12, "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": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "QS.Brho.matrix" ] }, { "cell_type": "code", "execution_count": 13, "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": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rho = QS.Arho.TensorProduct(QS.Brho)\n", "rho.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 }