{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# PyOR Quantum\n", "## Author: Vineeth Thalakottoor\n", "## Introduction to Spin Operators (Two Spins)" ] }, { "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/PyOR/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" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Define the spin system\n", "Spin_list = {\"A\" : \"H1\", \"B\" : \"H2\"}\n", "QS = QunS(Spin_list,PrintDefault=False)\n", "\n", "# initialize the system\n", "QS.Initialize()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0.5 & 0 & 0\\\\0 & 0 & 0 & 0 & 0.5 & 0\\\\0 & 0 & 0 & 0 & 0 & 0.5\\\\0.5 & 0 & 0 & 0 & 0 & 0\\\\0 & 0.5 & 0 & 0 & 0 & 0\\\\0 & 0 & 0.5 & 0 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0, 0, 0.5, 0, 0],\n", "[ 0, 0, 0, 0, 0.5, 0],\n", "[ 0, 0, 0, 0, 0, 0.5],\n", "[0.5, 0, 0, 0, 0, 0],\n", "[ 0, 0.5, 0, 0, 0, 0],\n", "[ 0, 0, 0.5, 0, 0, 0]])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"X\" spin operator, Particle A\n", "QS.Ax.matrix" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0.70710676908493 & 0 & 0 & 0 & 0\\\\0.70710676908493 & 0 & 0.70710676908493 & 0 & 0 & 0\\\\0 & 0.70710676908493 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0.70710676908493 & 0\\\\0 & 0 & 0 & 0.70710676908493 & 0 & 0.70710676908493\\\\0 & 0 & 0 & 0 & 0.70710676908493 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0.70710676908493, 0, 0, 0, 0],\n", "[0.70710676908493, 0, 0.70710676908493, 0, 0, 0],\n", "[ 0, 0.70710676908493, 0, 0, 0, 0],\n", "[ 0, 0, 0, 0, 0.70710676908493, 0],\n", "[ 0, 0, 0, 0.70710676908493, 0, 0.70710676908493],\n", "[ 0, 0, 0, 0, 0.70710676908493, 0]])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"X\" spin operator, Particle B\n", "QS.Bx.matrix" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & - 0.5 i & 0 & 0\\\\0 & 0 & 0 & 0 & - 0.5 i & 0\\\\0 & 0 & 0 & 0 & 0 & - 0.5 i\\\\0.5 i & 0 & 0 & 0 & 0 & 0\\\\0 & 0.5 i & 0 & 0 & 0 & 0\\\\0 & 0 & 0.5 i & 0 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0, 0, -0.5*I, 0, 0],\n", "[ 0, 0, 0, 0, -0.5*I, 0],\n", "[ 0, 0, 0, 0, 0, -0.5*I],\n", "[0.5*I, 0, 0, 0, 0, 0],\n", "[ 0, 0.5*I, 0, 0, 0, 0],\n", "[ 0, 0, 0.5*I, 0, 0, 0]])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"Y\" spin operator, Particle A\n", "QS.Ay.matrix" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & - 0.70710676908493 i & 0 & 0 & 0 & 0\\\\0.70710676908493 i & 0 & - 0.70710676908493 i & 0 & 0 & 0\\\\0 & 0.70710676908493 i & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & - 0.70710676908493 i & 0\\\\0 & 0 & 0 & 0.70710676908493 i & 0 & - 0.70710676908493 i\\\\0 & 0 & 0 & 0 & 0.70710676908493 i & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, -0.70710676908493*I, 0, 0, 0, 0],\n", "[0.70710676908493*I, 0, -0.70710676908493*I, 0, 0, 0],\n", "[ 0, 0.70710676908493*I, 0, 0, 0, 0],\n", "[ 0, 0, 0, 0, -0.70710676908493*I, 0],\n", "[ 0, 0, 0, 0.70710676908493*I, 0, -0.70710676908493*I],\n", "[ 0, 0, 0, 0, 0.70710676908493*I, 0]])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"Y\" spin operator, Particle B\n", "QS.By.matrix" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.5 & 0 & 0 & 0 & 0 & 0\\\\0 & 0.5 & 0 & 0 & 0 & 0\\\\0 & 0 & 0.5 & 0 & 0 & 0\\\\0 & 0 & 0 & -0.5 & 0 & 0\\\\0 & 0 & 0 & 0 & -0.5 & 0\\\\0 & 0 & 0 & 0 & 0 & -0.5\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.5, 0, 0, 0, 0, 0],\n", "[ 0, 0.5, 0, 0, 0, 0],\n", "[ 0, 0, 0.5, 0, 0, 0],\n", "[ 0, 0, 0, -0.5, 0, 0],\n", "[ 0, 0, 0, 0, -0.5, 0],\n", "[ 0, 0, 0, 0, 0, -0.5]])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"Z\" spin operator, Particle A\n", "QS.Az.matrix" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & -1.0 & 0 & 0 & 0\\\\0 & 0 & 0 & 1.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, 0, 0],\n", "[ 0, 0, 0, 0, 0, 0],\n", "[ 0, 0, -1.0, 0, 0, 0],\n", "[ 0, 0, 0, 1.0, 0, 0],\n", "[ 0, 0, 0, 0, 0, 0],\n", "[ 0, 0, 0, 0, 0, -1.0]])" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"Z\" spin operator, Particle B\n", "QS.Bz.matrix" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 1.0 & 0 & 0\\\\0 & 0 & 0 & 0 & 1.0 & 0\\\\0 & 0 & 0 & 0 & 0 & 1.0\\\\0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0, 0, 0, 1.0, 0, 0],\n", "[0, 0, 0, 0, 1.0, 0],\n", "[0, 0, 0, 0, 0, 1.0],\n", "[0, 0, 0, 0, 0, 0],\n", "[0, 0, 0, 0, 0, 0],\n", "[0, 0, 0, 0, 0, 0]])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"+\"\" spin operator, Particle A\n", "QS.Ap.matrix" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 1.41421353816986 & 0 & 0 & 0 & 0\\\\0 & 0 & 1.41421353816986 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 1.41421353816986 & 0\\\\0 & 0 & 0 & 0 & 0 & 1.41421353816986\\\\0 & 0 & 0 & 0 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0, 1.41421353816986, 0, 0, 0, 0],\n", "[0, 0, 1.41421353816986, 0, 0, 0],\n", "[0, 0, 0, 0, 0, 0],\n", "[0, 0, 0, 0, 1.41421353816986, 0],\n", "[0, 0, 0, 0, 0, 1.41421353816986],\n", "[0, 0, 0, 0, 0, 0]])" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"+\"\" spin operator, Particle B\n", "QS.Bp.matrix" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0\\\\1.0 & 0 & 0 & 0 & 0 & 0\\\\0 & 1.0 & 0 & 0 & 0 & 0\\\\0 & 0 & 1.0 & 0 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0, 0, 0, 0, 0],\n", "[ 0, 0, 0, 0, 0, 0],\n", "[ 0, 0, 0, 0, 0, 0],\n", "[1.0, 0, 0, 0, 0, 0],\n", "[ 0, 1.0, 0, 0, 0, 0],\n", "[ 0, 0, 1.0, 0, 0, 0]])" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"-\"\" spin operator, Particle A\n", "QS.Am.matrix" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0 & 0 & 0\\\\1.41421353816986 & 0 & 0 & 0 & 0 & 0\\\\0 & 1.41421353816986 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 1.41421353816986 & 0 & 0\\\\0 & 0 & 0 & 0 & 1.41421353816986 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0, 0, 0, 0, 0],\n", "[1.41421353816986, 0, 0, 0, 0, 0],\n", "[ 0, 1.41421353816986, 0, 0, 0, 0],\n", "[ 0, 0, 0, 0, 0, 0],\n", "[ 0, 0, 0, 1.41421353816986, 0, 0],\n", "[ 0, 0, 0, 0, 1.41421353816986, 0]])" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"-\"\" spin operator, Particle B\n", "QS.Bm.matrix" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0.5\\\\0.5 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0.5],\n", "[0.5, 0]])" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"X\" spin operator sub-system, Particle A\n", "QS.Ax_sub.matrix" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0.70710676908493 & 0\\\\0.70710676908493 & 0 & 0.70710676908493\\\\0 & 0.70710676908493 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0.70710676908493, 0],\n", "[0.70710676908493, 0, 0.70710676908493],\n", "[ 0, 0.70710676908493, 0]])" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"X\" spin operator sub-system, Particle B\n", "QS.Bx_sub.matrix" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & - 0.5 i\\\\0.5 i & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, -0.5*I],\n", "[0.5*I, 0]])" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"Y\" spin operator sub-system, Particle A\n", "QS.Ay_sub.matrix" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & - 0.70710676908493 i & 0\\\\0.70710676908493 i & 0 & - 0.70710676908493 i\\\\0 & 0.70710676908493 i & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, -0.70710676908493*I, 0],\n", "[0.70710676908493*I, 0, -0.70710676908493*I],\n", "[ 0, 0.70710676908493*I, 0]])" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"Y\" spin operator sub-system, Particle B\n", "QS.By_sub.matrix" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0.5 & 0\\\\0 & -0.5\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0.5, 0],\n", "[ 0, -0.5]])" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"Z\" spin operator sub-system, Particle A\n", "QS.Az_sub.matrix" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.0 & 0 & 0\\\\0 & 0 & 0\\\\0 & 0 & -1.0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[1.0, 0, 0],\n", "[ 0, 0, 0],\n", "[ 0, 0, -1.0]])" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"Z\" spin operator sub-system, Particle B\n", "QS.Bz_sub.matrix" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 1.0\\\\0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0, 1.0],\n", "[0, 0]])" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"+\" spin operator sub-system, Particle A\n", "QS.Ap_sub.matrix" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 1.41421353816986 & 0\\\\0 & 0 & 1.41421353816986\\\\0 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0, 1.41421353816986, 0],\n", "[0, 0, 1.41421353816986],\n", "[0, 0, 0]])" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"+\" spin operator sub-system, Particle B\n", "QS.Bp_sub.matrix" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0\\\\1.0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0],\n", "[1.0, 0]])" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"-\" spin operator sub-system, Particle A\n", "QS.Am_sub.matrix" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0\\\\1.41421353816986 & 0 & 0\\\\0 & 1.41421353816986 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0, 0, 0],\n", "[1.41421353816986, 0, 0],\n", "[ 0, 1.41421353816986, 0]])" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# \"-\" spin operator sub-system, Particle B\n", "QS.Bm_sub.matrix" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'H1'" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Particle Parameter: Nuclies name, Particle A\n", "QS.A.name" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.5" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Particle Parameter: Spin quantum number, Particle A\n", "QS.A.spin" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "267522000.0" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Particle Parameter: gyromagnetic ratio, Particle A\n", "QS.A.gamma" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Particle Parameter: Quadrupole vale, Particle A\n", "QS.A.quadrupole" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'H2'" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Particle Parameter: Nuclies name, Particle B\n", "QS.B.name" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Particle Parameter: Spin quantum number, Particle B\n", "QS.B.spin" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "41065000.0" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Particle Parameter: gyromagnetic ratio, Particle B\n", "QS.B.gamma" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.285783" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Particle Parameter: Quadrupole vale, Particle B\n", "QS.B.quadrupole" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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": 4 }