Introduction to 1D pulse acquisition (User defiend Hamiltonian)
Author: Vineeth Thalakottoor
Email: vineeth.thalakottoor@ens.psl.eu or vineethfrancis.physics@gmail.com# PyOR Quantum
[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
[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" # TTry "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 0x7f2f6159e5d0>
[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 0x7f2f61d3b200>
[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]$
Initialize density matrix
[11]:
# Initial Density Matrix
rho_in = QS.Az + QS.Bz
rho_in.matrix
[11]:
$\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]$
[12]:
# Final Density Matrix
rhoeq = QS.Az + QS.Bz
rhoeq.matrix
[12]:
$\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]$
Hard Pulse
[13]:
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
[13]:
$\displaystyle \left[\begin{matrix}0 & 0.5 & 0.5 & 0\\0.5 & 0 & 0 & 0.5\\0.5 & 0 & 0 & 0.5\\0 & 0.5 & 0.5 & 0\end{matrix}\right]$
Evolution
[14]:
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.014617443084717 seconds
Expectation
[15]:
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
[16]:
plot = Plotting(QS)
[23]:
plot.PlotFigureSize = (10,5)
plot.PlotFontSize = 20
plot.PlotXlimt= (0,5)
plot.PlotYlimt= (-2,2)
plot.Plotting_SpanSelector(t,Mt,"time (s)",r"$M_T$","red",saveplt=True,savename="Transverse Magnetization")
/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)
[23]:
(<Figure size 1000x500 with 1 Axes>,
<matplotlib.widgets.SpanSelector at 0x7f2f51ddac60>)
[21]:
plot.PlotFigureSize = (10,5)
plot.PlotFontSize = 20
plot.PlotXlimt= (0,5)
plot.PlotYlimt= (0,2)
plot.Plotting_SpanSelector(t,Mz,"time (s)",r"$M_Z$","red")
[21]:
(<Figure size 1000x500 with 1 Axes>,
<matplotlib.widgets.SpanSelector at 0x7f2f538657c0>)
Fourier Transform
[19]:
freq, spectrum = Spro.FourierTransform(Mt,QS.AcqFS,5)
[20]:
plot.PlotFigureSize = (10,5)
plot.PlotFontSize = 20
plot.PlotXlimt= (0,60)
plot.PlotYlimt= (0,6000)
plot.Plotting_SpanSelector(freq,spectrum,"Frequency (Hz)","Spectrum","red")
[20]:
(<Figure size 1000x500 with 1 Axes>,
<matplotlib.widgets.SpanSelector at 0x7f2f51e97020>)