Stimulated Oscillation

Define functions and classes


In [1]:
%matplotlib inline
import sys
sys.path.insert(0, '../../module')
import neuosc as ns
import numpy as np
import scipy as sp
from scipy.linalg import expm
import matplotlib.pyplot as plt

In [3]:
reload(ns)


Out[3]:
<module 'neuosc' from '../../module/neuosc.pyc'>

In [244]:
thetav = 0.537#*sp.pi/180
fraction = 2
lambda0 = np.cos(2*thetav)/fraction
alpha = 0.1
omegam = np.sqrt(lambda0**2+1-2*lambda0*np.cos(2*thetav))
beta_r = 1-1/fraction

In [245]:
def lambda1(beta,x):
    """perturbation of matter"""

    return alpha*lambda0*np.sin(beta*x);

In [246]:
def hamil(beta,x):
    """"Hamiltonian of the system with perturbation"""
    
    return (-omegam/2 + (lambda1(beta,x)/2 )*((np.cos(2*thetav)-lambda0)/(omegam)) )*ns.pauli_matrices(3) +  (lambda1(beta,x)/2) * (np.sin(2*thetav) /omegam)*ns.pauli_matrices(1)

In [247]:
def sliced_evo(beta,x,deltax):
    
    return expm(-1j*hamil(beta,x)*deltax)

Calculate the evolution matrix at anytime


In [248]:
def evo(beta,x,deltax):
    
    evo_mat =  np.array([[1,0],[0,1]])
    
    for xi in np.linspace(0, x, np.floor(x/deltax)):
        evo_mat = np.dot(sliced_evo(beta,xi,deltax), evo_mat)
        
    return evo_mat

In [249]:
def evo_00(beta,x,deltax):
    
    evo_mat = np.array([[1,0],[0,1]])
    evo_00_list = np.array([])
    
    for xi in np.linspace(0, x, np.floor(x/deltax)):
        evo_mat = np.dot(sliced_evo(beta,xi,deltax), evo_mat)
        evo_00_list = np.append(evo_00_list, np.absolute(evo_mat[0,0])**2)
        #print xi
        #print np.absolute(evo_mat[0,0])**2
        #print ""
        
    return evo_00_list

In [279]:
np.absolute(sliced_evo(beta_r*(1-0.09),1,1)[0,0])**2


Out[279]:
0.99992305093046641


In [278]:
print np.absolute(1+0.5j), norm(1+0.5j)


 1.11803398875
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-278-5c0bbf795ab6> in <module>()
----> 1 print np.absolute(1+0.5j), norm(1+0.5j)

NameError: name 'norm' is not defined

In [292]:
endtemp = 10000
step = 1

sliced_evo_lt = np.ones(endtemp)


for temp in range(0,endtemp):
    sliced_evo_lt[temp] = np.absolute(sliced_evo(beta_r*(1-0.09),temp,step)[0,0])**2
#    print np.absolute(sliced_evo(beta_r*(1-0.09),temp,step)[0,0])**2
    
plt.figure(figsize=(10,10))
plt.plot(sliced_evo_lt)


Out[292]:
[<matplotlib.lines.Line2D at 0x11357e6d0>]

In [298]:
endtemp = 100
step = 1

sliced_evo_lt = np.ones(endtemp)


for temp in range(0,endtemp):
    sliced_evo_lt[temp] = np.real(hamil(beta_r*(1-0.09),temp)[0,1])

    
plt.figure(figsize=(10,10))
plt.plot(sliced_evo_lt)


Out[298]:
[<matplotlib.lines.Line2D at 0x1181eb710>]

In [ ]:


In [261]:
plt.figure(figsize=(10,10))
plt.plot(evo_00(beta_r*(1-0.1),10000,1))
plt.ylabel("1,1 element")


Out[261]:
<matplotlib.text.Text at 0x135fbcd90>

In [264]:
plt.figure(figsize=(10,10))
plt.plot(evo_00(beta_r*(1-0.09),1000,0.1))
plt.ylabel("1,1 element")


Out[264]:
<matplotlib.text.Text at 0x1133ca890>

In [252]:
ns.pauli_matrices(1.0)


Out[252]:
array([[ 0.+0.j,  1.+0.j],
       [ 1.+0.j,  0.+0.j]])

In [253]:
np.append(np.array(ns.pauli_matrices(1)),np.array(ns.pauli_matrices(2)),axis=0)


Out[253]:
array([[ 0.+0.j,  1.+0.j],
       [ 1.+0.j,  0.+0.j],
       [ 0.+0.j,  0.-1.j],
       [ 0.+1.j,  0.+0.j]])

In [254]:
def evo_01(beta,x,deltax):
    
    evo_mat = np.array([[1,0],[0,1]])
    evo_01_list = np.array([])
    
    for xi in np.linspace(0, x, np.floor(x/deltax)):
        evo_mat = np.dot(sliced_evo(beta,xi,deltax), evo_mat)
        evo_01_list = np.append(evo_01_list, np.absolute(evo_mat[0,1])**2)
        #print xi
        #print np.absolute(evo_mat[0,0])**2
        #print ""
        
    return evo_01_list

In [255]:
plt.figure(figsize=(10,10))
plt.plot(evo_01(beta_r,10000,1))
plt.ylabel("1,2 element")


Out[255]:
<matplotlib.text.Text at 0x13539ea90>

In [256]:
np.dot(evo(beta_r,5000,1),np.array([1,0]))


Out[256]:
array([ 0.56206046+0.81906661j, -0.09061432-0.07075996j])

In [257]:
evo(beta_r,5000,1)


Out[257]:
array([[ 0.56206046+0.81906661j,  0.09061432-0.07075996j],
       [-0.09061432-0.07075996j,  0.56206046-0.81906661j]])

In [258]:
hamil(beta_r,1)


Out[258]:
array([[-0.45279719+0.j,  0.00967713+0.j],
       [ 0.00967713+0.j,  0.45279719+0.j]])

In [ ]: