Introduction to 1D pulse acquisition (Hamiltonian Eigen State)
Author: Vineeth Thalakottoor
Email: vineeth.thalakottoor@ens.psl.eu or vineethfrancis.physics@gmail.com
[1]:
# Define the source path
SourcePath = '/media/HD2/Vineeth/PostDoc_Simulations/Github/PyOR_V1/PyOR_Combined/PyOR/Source_Doc'
# Add source path
import sys
sys.path.append(SourcePath)
import time
import numpy as np
%matplotlib ipympl
# Import PyOR package
from PyOR_QuantumSystem import QuantumSystem as QunS
from PyOR_HardPulse import HardPulse
from PyOR_Evolution import Evolutions
from PyOR_Plotting import Plotting
import PyOR_SignalProcessing as Spro
from PyOR_Basis import Basis
from PyOR_DensityMatrix import DensityMatrix
[2]:
# Define the spin system
Spin_list = {"A" : "H1", "B" : "H1"}
QS = QunS(Spin_list,PrintDefault=False)
# initialize the system
QS.Initialize()
Set parameters
[3]:
# Master Equation
QS.PropagationSpace = "Hilbert"
QS.MasterEquation = "Redfield"
# Operator Basis
QS.Basis_SpinOperators_Hilbert = "Zeeman" # Try "Singlet Triplet" and see what happen to the all spin operators and Hamiltoninas
# Relaxation Process
QS.Rprocess = "Phenomenological"
QS.R1 = 1
QS.R2 = 1
QS.Update()
Larmor Frequency in MHz: [-400.22801765 -400.22801765]
Spin operators
[4]:
QS.Az
[4]:
<PyOR_QuantumObject.QunObj at 0x7f6c48481be0>
[5]:
QS.Az.matrix
[5]:
$\displaystyle \left[\begin{matrix}0.5 & 0 & 0 & 0\\0 & 0.5 & 0 & 0\\0 & 0 & -0.5 & 0\\0 & 0 & 0 & -0.5\end{matrix}\right]$
[6]:
QS.Az.data
[6]:
array([[ 0.5+0.j, 0. +0.j, 0. +0.j, 0. +0.j],
[ 0. +0.j, 0.5+0.j, 0. +0.j, 0. +0.j],
[ 0. +0.j, 0. +0.j, -0.5+0.j, -0. +0.j],
[ 0. +0.j, 0. +0.j, -0. +0.j, -0.5+0.j]])
[7]:
QS.Az_sub
[7]:
<PyOR_QuantumObject.QunObj at 0x7f6c0b1c16a0>
[8]:
QS.Az_sub.matrix
[8]:
$\displaystyle \left[\begin{matrix}0.5 & 0\\0 & -0.5\end{matrix}\right]$
Generate Hamiltonians
[9]:
# 1. Zeeman Hamiltonian
Hz = 2.0 * np.pi * 10 * QS.Az + 2.0 * np.pi * 50 * QS.Bz
Hz.Inverse2PI().matrix
[9]:
$\displaystyle \left[\begin{matrix}30.0 & 0 & 0 & 0\\0 & -20.0 & 0 & 0\\0 & 0 & 20.0 & 0\\0 & 0 & 0 & -30.0\end{matrix}\right]$
[10]:
# 2. J coupling Hamiltonian
Hj = 2.0 * np.pi * 5 * (QS.Ax * QS.Bx + QS.Ay * QS.By + QS.Az * QS.Bz)
Hj.Inverse2PI().matrix
[10]:
$\displaystyle \left[\begin{matrix}1.25 & 0 & 0 & 0\\0 & -1.25 & 2.5 & 0\\0 & 2.5 & -1.25 & 0\\0 & 0 & 0 & 1.25\end{matrix}\right]$
Change basis to Hamiltonian eigen states
[11]:
eigenvectors, Dic = QS.Class_basis.BasisChange_HamiltonianEigenStates(Hj)
Ket State = 0.70711 |1/2,1/2⟩|1/2,-1/2⟩ + 0.70711 |1/2,-1/2⟩|1/2,1/2⟩
Ket State = 0.70711 |1/2,1/2⟩|1/2,-1/2⟩ + -0.70711 |1/2,-1/2⟩|1/2,1/2⟩
Ket State = 1.0 |1/2,1/2⟩|1/2,1/2⟩
Ket State = 1.0 |1/2,-1/2⟩|1/2,-1/2⟩
Larmor Frequency in MHz: [-400.22801765 -400.22801765]
[12]:
Dic
[12]:
['0.70711 |1/2,1/2⟩|1/2,-1/2⟩ + 0.70711 |1/2,-1/2⟩|1/2,1/2⟩',
'0.70711 |1/2,1/2⟩|1/2,-1/2⟩ + -0.70711 |1/2,-1/2⟩|1/2,1/2⟩',
'1.0 |1/2,1/2⟩|1/2,1/2⟩',
'1.0 |1/2,-1/2⟩|1/2,-1/2⟩']
[13]:
eigenvectors[0].matrix
[13]:
$\displaystyle \left[\begin{matrix}1.0\\0\\0\\0\end{matrix}\right]$
[14]:
QS.Basis_SpinOperators_Hilbert
[14]:
'Zeeman to Hamiltonian eigen states'
[15]:
QS.Basis_SpinOperators_TransformationMatrix.matrix
[15]:
$\displaystyle \left[\begin{matrix}0 & 0 & 1.0 & 0\\0.707106781186547 & 0.707106781186547 & 0 & 0\\0.707106781186547 & -0.707106781186547 & 0 & 0\\0 & 0 & 0 & 1.0\end{matrix}\right]$
[16]:
QS.Az.matrix
[16]:
$\displaystyle \left[\begin{matrix}-1.11855713399442 \cdot 10^{-17} & 0.5 & 0 & 0\\0.5 & -1.11855713399442 \cdot 10^{-17} & 0 & 0\\0 & 0 & 0.5 & 0\\0 & 0 & 0 & -0.5\end{matrix}\right]$
Generate Hamiltonians in new basis state
[17]:
Hz = 2.0 * np.pi * 10 * QS.Az + 2.0 * np.pi * 50 * QS.Bz
Hz.Inverse2PI().Tolarence(1.0e-5).matrix
[17]:
$\displaystyle \left[\begin{matrix}0 & -20.0 & 0 & 0\\-20.0 & 0 & 0 & 0\\0 & 0 & 30.0 & 0\\0 & 0 & 0 & -30.0\end{matrix}\right]$
[18]:
Hj = 2.0 * np.pi * 5 * (QS.Ax * QS.Bx + QS.Ay * QS.By + QS.Az * QS.Bz)
Hj.Inverse2PI().Tolarence(1.0e-5).matrix
[18]:
$\displaystyle \left[\begin{matrix}1.24999991442865 & 0 & 0 & 0\\0 & -3.74999991442865 & 0 & 0\\0 & 0 & 1.25 & 0\\0 & 0 & 0 & 1.25\end{matrix}\right]$
[19]:
(Hz + Hj).Tolarence(1.0e-5).matrix
[19]:
$\displaystyle \left[\begin{matrix}7.85398109631381 & -125.663706143592 & 0 & 0\\-125.663706143592 & -23.5619443642628 & 0 & 0\\0 & 0 & 196.349540849362 & 0\\0 & 0 & 0 & -180.641577581413\end{matrix}\right]$
Product Operator Basis (PMZ / Shift Z basis)
[20]:
BS = Basis(QS)
sort = 'negative to positive'
Index = False
Normal = True
Basis_PMZ, coh_PMZ, dic_PMZ = BS.ProductOperators_SpinHalf_PMZ(sort,Index,Normal)
Product Operator Basis Zeeman
[21]:
Basis_Zeeman, dic_Zeeman, coh_Zeeman, coh_Zeeman_array = BS.ProductOperators_Zeeman()
Initialize density matrix
[22]:
DM = DensityMatrix(QS)
# Initial Density Matrix
rho_in = QS.Az + QS.Bz
rho_in.matrix
[22]:
$\displaystyle \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 1.0 & 0\\0 & 0 & 0 & -1.0\end{matrix}\right]$
[23]:
DM.DensityMatrix_Components(rho_in,Basis_PMZ,dic_PMZ)
Density Matrix = 1.0 Iz1 Id2 + 1.0 Id1 Iz2
[24]:
DM.DensityMatrix_Components(rho_in,Basis_Zeeman, dic_Zeeman)
Density Matrix = 1.0 |1/2,1/2⟩|1/2,1/2⟩⟨1/2,1/2|⟨1/2,1/2| + -1.0 |1/2,-1/2⟩|1/2,-1/2⟩⟨1/2,-1/2|⟨1/2,-1/2|
[25]:
# Final Density Matrix
rhoeq = QS.Az + QS.Bz
rhoeq.matrix
[25]:
$\displaystyle \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 1.0 & 0\\0 & 0 & 0 & -1.0\end{matrix}\right]$
Hard Pulse
[26]:
HardP = HardPulse(QS)
flip_angle = 90.0 # Flip angle
rho = HardP.Rotate_Pulse(rho_in,flip_angle,QS.Ay + QS.By).Tolarence(1.0e-5)
rho.matrix
[26]:
$\displaystyle \left[\begin{matrix}0 & 0 & 0.707106781186547 & 0.707106781186547\\0 & 0 & 0 & 0\\0.707106781186547 & 0 & 0 & 0\\0.707106781186547 & 0 & 0 & 0\end{matrix}\right]$
[27]:
DM.DensityMatrix_Components(rho,Basis_PMZ,dic_PMZ)
Density Matrix = 0.70711 Im1 Id2 + 0.70711 Id1 Im2 + -0.70711 Id1 Ip2 + -0.70711 Ip1 Id2
[28]:
DM.DensityMatrix_Components(rho,Basis_Zeeman, dic_Zeeman)
Density Matrix = 0.5 |1/2,1/2⟩|1/2,1/2⟩⟨1/2,1/2|⟨1/2,-1/2| + 0.5 |1/2,1/2⟩|1/2,1/2⟩⟨1/2,-1/2|⟨1/2,1/2| + 0.5 |1/2,1/2⟩|1/2,-1/2⟩⟨1/2,1/2|⟨1/2,1/2| + 0.5 |1/2,1/2⟩|1/2,-1/2⟩⟨1/2,-1/2|⟨1/2,-1/2| + 0.5 |1/2,-1/2⟩|1/2,1/2⟩⟨1/2,1/2|⟨1/2,1/2| + 0.5 |1/2,-1/2⟩|1/2,1/2⟩⟨1/2,-1/2|⟨1/2,-1/2| + 0.5 |1/2,-1/2⟩|1/2,-1/2⟩⟨1/2,1/2|⟨1/2,-1/2| + 0.5 |1/2,-1/2⟩|1/2,-1/2⟩⟨1/2,-1/2|⟨1/2,1/2|
Evolution
[29]:
QS.AcqDT = 0.0001
QS.AcqAQ = 5.0
QS.OdeMethod = 'DOP853'
QS.PropagationMethod = "ODE Solver"
EVol = Evolutions(QS)
start_time = time.time()
t, rho_t = EVol.Evolution(rho,rhoeq,Hz+Hj)
end_time = time.time()
timetaken = end_time - start_time
print("Total time = %s seconds " % (timetaken))
Larmor Frequency in MHz: [-400.22801765 -400.22801765]
Total time = 3.0579121112823486 seconds
Expectation
[30]:
det_Mt = QS.Ap + QS.Bp
det_Z = QS.Az + QS.Bz
t, Mt = EVol.Expectation(rho_t,det_Mt)
t, Mz = EVol.Expectation(rho_t,det_Z)
Plotting
[31]:
plot = Plotting(QS)
[32]:
plot.PlotFigureSize = (10,5)
plot.PlotFontSize = 20
plot.Plotting_SpanSelector(t,Mt,"time (s)","Mt","red")
/opt/anaconda3/lib/python3.12/site-packages/matplotlib/cbook.py:1762: ComplexWarning: Casting complex values to real discards the imaginary part
return math.isfinite(val)
/opt/anaconda3/lib/python3.12/site-packages/matplotlib/cbook.py:1398: ComplexWarning: Casting complex values to real discards the imaginary part
return np.asarray(x, float)
[32]:
(<Figure size 1000x500 with 1 Axes>,
<matplotlib.widgets.SpanSelector at 0x7f6c0ae589b0>)
[33]:
plot.PlotFigureSize = (10,5)
plot.PlotFontSize = 20
plot.Plotting_SpanSelector(t,Mz,"time (s)","Mz","red")
[33]:
(<Figure size 1000x500 with 1 Axes>,
<matplotlib.widgets.SpanSelector at 0x7f6c08d122d0>)
Fourier Transform
[34]:
freq, spectrum = Spro.FourierTransform(Mt,QS.AcqFS,5)
[35]:
plot.PlotFigureSize = (10,5)
plot.PlotFontSize = 20
plot.PlotXlimt= (0,60)
plot.PlotYlimt= (0,6000)
plot.Plotting_SpanSelector(freq,spectrum,"Frequency (Hz)","Spectrum","red")
[35]:
(<Figure size 1000x500 with 1 Axes>,
<matplotlib.widgets.SpanSelector at 0x7f6c08de22d0>)