{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "6718709f", "metadata": {}, "source": [ "# Basis Change of the System (Spin operators and States)\n", "- Author: Vineeth Francis Thalakottoor\n", "- Email: vineeth.thalakottoor@ens.psl.eu or vineethfrancis.physics@gmail.com" ] }, { "cell_type": "code", "execution_count": 1, "id": "27a57f94", "metadata": {}, "outputs": [], "source": [ "# Define the source path\n", "SourcePath = '/media/HD2/Vineeth/PostDoc_Simulations/Github/PyOR_V1/PyOR_Combined/PyOR/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_Commutators import Commutators\n", "from PyOR_QuantumLibrary import QuantumLibrary\n", "from PyOR_Relaxation import RelaxationProcess" ] }, { "cell_type": "code", "execution_count": 2, "id": "ab0e39a3", "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()" ] }, { "cell_type": "markdown", "id": "bbf2e20a", "metadata": {}, "source": [ "### Spin Operators\n", "- After (first) QS.Initialize(), spin operators are always in Zeeman basis" ] }, { "cell_type": "code", "execution_count": 3, "id": "8e9435da", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0.5 & 0\\\\0 & 0 & 0 & 0.5\\\\0.5 & 0 & 0 & 0\\\\0 & 0.5 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0, 0.5, 0],\n", "[ 0, 0, 0, 0.5],\n", "[0.5, 0, 0, 0],\n", "[ 0, 0.5, 0, 0]])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "QS.Ax.matrix" ] }, { "attachments": {}, "cell_type": "markdown", "id": "3a59211f", "metadata": {}, "source": [ "### Set parameters" ] }, { "cell_type": "code", "execution_count": 4, "id": "275d8217", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Larmor Frequency in MHz: [-400.22802765 -400.22806765]\n" ] } ], "source": [ "# Master Equation\n", "QS.PropagationSpace = \"Hilbert\"\n", "QS.MasterEquation = \"Redfield\"\n", "\n", "# Operator Basis\n", "#QS.Basis_SpinOperators_Hilbert = \"Singlet Triplet\" # or\n", "QS.Basis_SpinOperators_Hilbert = \"Zeeman\"\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", "# Define paris of spins coupled by dipolar interaction\n", "QS.Dipole_Pairs = [(\"A\",\"B\")]\n", "\n", "# Relaxation Process\n", "QS.Rprocess = \"Auto-correlated Dipolar Homonuclear\"\n", "QS.RelaxParDipole_tau = 10.0e-12\n", "QS.RelaxParDipole_bIS = [30.0e3]\n", "\n", "QS.Update()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "0f7c0f44", "metadata": {}, "source": [ "### Generate Hamiltonians" ] }, { "cell_type": "code", "execution_count": 5, "id": "b27e93bc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Larmor Frequency in MHz: [-400.22802765 -400.22806765]\n" ] } ], "source": [ "# generate Larmor Frequencies\n", "\n", "Ham = Hamiltonian(QS)\n", "COMM = Commutators(QS)\n", "\n", "# Zeeman Hamiltonian in rotating frame\n", "Hz = Ham.Zeeman_RotFrame()\n", "\n", "# J coupling Hamiltonian\n", "Hj = Ham.Jcoupling()\n", "\n", "# Generating the commutation superoperator\n", "QLib = QuantumLibrary(QS)" ] }, { "cell_type": "code", "execution_count": 6, "id": "fb63d498", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}-30.0000000759161 & 0 & 0 & 0\\\\0 & 20.0000008601147 & 0 & 0\\\\0 & 0 & -20.0000008601147 & 0\\\\0 & 0 & 0 & 30.0000000759161\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[-30.0000000759161, 0, 0, 0],\n", "[ 0, 20.0000008601147, 0, 0],\n", "[ 0, 0, -20.0000008601147, 0],\n", "[ 0, 0, 0, 30.0000000759161]])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Hz.Inverse2PI().matrix" ] }, { "cell_type": "code", "execution_count": 7, "id": "7792fc79", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.24999997786618 & 0 & 0 & 0\\\\0 & -1.24999997786618 & 2.49999995573235 & 0\\\\0 & 2.49999995573235 & -1.24999997786618 & 0\\\\0 & 0 & 0 & 1.24999997786618\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[1.24999997786618, 0, 0, 0],\n", "[ 0, -1.24999997786618, 2.49999995573235, 0],\n", "[ 0, 2.49999995573235, -1.24999997786618, 0],\n", "[ 0, 0, 0, 1.24999997786618]])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Hj.Inverse2PI().Tolarence(1.0e-5).matrix" ] }, { "cell_type": "markdown", "id": "db7744d2", "metadata": {}, "source": [ "### Calling Hamiltonian class from QunautmSystem class\n", "- Alternate way of calling Hamiltonian class from QuantuSystem class" ] }, { "cell_type": "code", "execution_count": 8, "id": "74f01d80", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.24999997786618 & 0 & 0 & 0\\\\0 & -1.24999997786618 & 2.49999995573235 & 0\\\\0 & 2.49999995573235 & -1.24999997786618 & 0\\\\0 & 0 & 0 & 1.24999997786618\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[1.24999997786618, 0, 0, 0],\n", "[ 0, -1.24999997786618, 2.49999995573235, 0],\n", "[ 0, 2.49999995573235, -1.24999997786618, 0],\n", "[ 0, 0, 0, 1.24999997786618]])" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Hj1 = QS.Class_hamiltonian.Jcoupling()\n", "Hj1.Inverse2PI().Tolarence(1.0e-5).matrix" ] }, { "cell_type": "markdown", "id": "6be770d3", "metadata": {}, "source": [ "### Spin operators\n", "- After QS.Update, all the spin operators will be in the new basis" ] }, { "cell_type": "code", "execution_count": 9, "id": "24deaadc", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0.5 & 0\\\\0 & 0 & 0 & 0.5\\\\0.5 & 0 & 0 & 0\\\\0 & 0.5 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0, 0.5, 0],\n", "[ 0, 0, 0, 0.5],\n", "[0.5, 0, 0, 0],\n", "[ 0, 0.5, 0, 0]])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "QS.Ax.matrix" ] }, { "cell_type": "markdown", "id": "5500951f", "metadata": {}, "source": [ "### Basis states\n", "- Singlet and triplet\n", "- Zeeman" ] }, { "cell_type": "code", "execution_count": 10, "id": "7c1c7bfb", "metadata": {}, "outputs": [], "source": [ "# Singlet Triplet states\n", "ST_B, dic_ST = QS.Class_basis.SingletTriplet_Basis()\n", "\n", "# Zeeman states\n", "Z_B, dic_Z = QS.Class_basis.Zeeman_Basis()" ] }, { "cell_type": "code", "execution_count": 11, "id": "80da9d16", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['S0 ', 'Tp ', 'T0 ', 'Tm ']" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Singlet triplet states dictionary\n", "dic_ST" ] }, { "cell_type": "code", "execution_count": 12, "id": "d1794d8c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['|1/2,1/2⟩|1/2,1/2⟩',\n", " '|1/2,1/2⟩|1/2,-1/2⟩',\n", " '|1/2,-1/2⟩|1/2,1/2⟩',\n", " '|1/2,-1/2⟩|1/2,-1/2⟩']" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Zeeman states dictionary\n", "dic_Z" ] }, { "cell_type": "code", "execution_count": 13, "id": "47a7c15e", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0\\\\0.707106781186547\\\\-0.707106781186547\\\\0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0],\n", "[ 0.707106781186547],\n", "[-0.707106781186547],\n", "[ 0]])" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ST_B[0].matrix" ] }, { "cell_type": "code", "execution_count": 14, "id": "8aa491c3", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0\\\\1.0\\\\0\\\\0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0],\n", "[1.0],\n", "[ 0],\n", "[ 0]])" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Z_B[1].matrix" ] }, { "cell_type": "code", "execution_count": 15, "id": "36bc4732", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Ket State = 1.0 Tm \n" ] } ], "source": [ "# Decompose the states in basis states\n", "QS.Class_basis.KetState_Components(Z_B[3],ST_B, dic_ST)" ] }, { "cell_type": "code", "execution_count": 32, "id": "1513fc02", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0\\\\0\\\\0\\\\1.0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0],\n", "[ 0],\n", "[ 0],\n", "[1.0]])" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create a stat with magnetic quantum number\n", "X1 = QS.State({\"A\": -1/2,\"B\": -1/2})\n", "X1.matrix" ] }, { "cell_type": "code", "execution_count": 33, "id": "bf9780a7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Ket State = 1.0 Tm \n" ] } ], "source": [ "QS.Class_basis.KetState_Components(X1, ST_B, dic_ST)" ] }, { "cell_type": "code", "execution_count": 34, "id": "b0103a5a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Ket State = 1.0 |1/2,-1/2⟩|1/2,-1/2⟩\n" ] } ], "source": [ "QS.Class_basis.KetState_Components(X1, Z_B, dic_Z)" ] }, { "cell_type": "code", "execution_count": 35, "id": "3d6a8bf2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Ket State = 0.70711 |1/2,1/2⟩|1/2,-1/2⟩ + -0.70711 |1/2,-1/2⟩|1/2,1/2⟩\n" ] } ], "source": [ "QS.Class_basis.KetState_Components(ST_B[0], Z_B, dic_Z)" ] }, { "cell_type": "code", "execution_count": null, "id": "b82657e9", "metadata": {}, "outputs": [], "source": [] } ], "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" } }, "nbformat": 4, "nbformat_minor": 5 }