Vacuum Neutrino Oscillations

Here is a notebook for homogeneous gas model.

Here we are talking about a homogeneous gas bulk of neutrinos with single energy. The EoM is $$ i \partial_t \rho_E = \left[ \frac{\delta m^2}{2E}B ,\rho_E \right] $$

while the EoM for antineutrinos is $$ i \partial_t \bar\rho_E = \left[- \frac{\delta m^2}{2E}B ,\bar\rho_E \right] $$

Initial: Homogeneous, Isotropic, Monoenergetic $\nu_e$ and $\bar\nu_e$

The equations becomes $$ i \partial_t \rho_E = \left[ \frac{\delta m^2}{2E} B ,\rho_E \right] $$ $$ i \partial_t \bar\rho_E = \left[- \frac{\delta m^2}{2E}B,\bar\rho_E \right] $$

Define $\omega=\frac{\delta m^2}{2E}$, $\omega = \frac{\delta m^2}{-2E}$, $\mu=\sqrt{2}G_F n_\nu$ $$ i \partial_t \rho_E = \left[ \omega B ,\rho_E \right] $$ $$ i \partial_t \bar\rho_E = \left[\bar\omega B,\bar\rho_E \right] $$

where

$$ B = \frac{1}{2} \begin{pmatrix} -\cos 2\theta_v & \sin 2\theta_v \\ \sin 2\theta_v & \cos 2\theta_v \end{pmatrix} $$

or just use theta =0.2rad

$$ L = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} $$

Initial condition $$ \rho(t=0) = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} $$

$$ \bar\rho(t=0) =\begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} $$

define the following quantities

  1. hbar$=\hbar$ %2. delm2E$= \delta m^2/2E$ %3. lamb $= \lambda$, lambb $= \bar\lambda$ %4. gF $= G_F$ %5. mu $=\mu$
  2. omega $=\omega$, omegab $=-\bar\omega$

Numerical


In [1]:
# This line configures matplotlib to show figures embedded in the notebook, 
# instead of opening a new window for each figure. More about that later. 
# If you are using an old version of IPython, try using '%pylab inline' instead.
%matplotlib inline
%load_ext snakeviz

import numpy as np
from scipy.optimize import minimize
from scipy.special import expit
import matplotlib.pyplot as plt

from matplotlib.lines import Line2D

import timeit

import pandas as pd

import plotly.plotly as py
from plotly.graph_objs import *
import plotly.tools as tls

In [101]:
# hbar=1.054571726*10**(-34)
hbar=1.0
delm2E=1.0
# lamb=1.0  ## lambda for neutrinos
# lambb=1.0 ## lambda for anti neutrinos
# gF=1.0
# nd=1.0  ## number density
# ndb=1.0   ## number density
omega=1.0
omegab=-1.0

## Here are some matrices to be used

elM = np.array([[1.0,0.0],[0.0,0.0]])
bM = 1.0/2*np.array( [ [ -np.cos(0.4),np.sin(0.4)] , [np.sin(0.4),np.cos(0.4)] ] )
#bM = 1.0/2*np.array( [ [ 1,0] , [0,1] ] )
print bM
## sqareroot of 2
sqrt2=np.sqrt(2.0)


[[-0.4605305   0.19470917]
 [ 0.19470917  0.4605305 ]]

I am going to substitute all density matrix elements using their corrosponding network expressions.

So first of all, I need the network expression for the unknown functions.

A function is written as

$$ y_i= 1+t_i v_k f(t_i w_k+u_k) ,$$

while it's derivative is

$$v_k f(t w_k+u_k) + t v_k f(tw_k+u_k) (1-f(tw_k+u_k)) w_k .$$

Now I can write down the equations using these two forms.


In [102]:
def trigf(x):
    #return 1/(1+np.exp(-x)) # It's not bad to define this function here for people could use other functions other than expit(x).
    return expit(x)

In [103]:
## The time derivative part

### Here are the initial conditions

init = np.array( [[1,0],[0,0]] )
#init = np.array( [[1,2],[3,4]] )

### For neutrinos

def rho(x,ti,initialCondition): # x is the input structure arrays, ti is a time point
    
    elem=np.ones(4)
    
    for i in np.linspace(0,3,4):
        elem[i] = np.sum(ti * x[i*3] * trigf( ti*x[i*3+1] + x[i*3+2] ) )
    
    return initialCondition + np.array([[ elem[0] , elem[1] ],[elem[2], elem[3] ]])

In [104]:
## Test
xtemp=np.ones(120)
rho(xtemp,0,init)


Out[104]:
array([[ 1.,  0.],
       [ 0.,  0.]])

In [105]:
## Define Hamiltonians for both

def hamilv():
    return delm2E*bM

In [107]:
## The commutator

def commv(x,ti,initialCondition):
    
    return np.dot(hamilv(), rho(x,ti,initialCondition) ) - np.dot(rho(x,ti,initialCondition), hamilv() )
    #return rho(x,ti,initialCondition)

In [108]:
## Test

print bM

print hamilv()

print "neutrino\n",commv(xtemp,0,init)


[[-0.4605305   0.19470917]
 [ 0.19470917  0.4605305 ]]
[[-0.4605305   0.19470917]
 [ 0.19470917  0.4605305 ]]
neutrino
[[ 0.         -0.19470917]
 [ 0.19470917  0.        ]]

In [77]:
nplinspace(0,9,4)


Out[77]:
array([ 0.,  3.,  6.,  9.])

In [78]:
## The COST of the eqn set

regularization = 0.0001
npsum = np.sum
npravel = np.ravel
nplinspace = np.linspace
nparray = np.array

def costvTi(x,ti,initialCondition): # l is total length of x
    
    list = nplinspace(0,3,4)

    fvec = []
    costi = np.zeros(4) + 1.0j* np.zeros(4)
    commvi = npravel(commv(x,ti,initialCondition))
    
    fvecappend = fvec.append
    
    for i in list:
        fvecappend(np.asarray(trigf(ti*x[i*3+1] + x[i*3+2]) ) )
        
    fvec = nparray(fvec)
    
    for i in list:
        costi[i] = ( npsum (x[i*3]*fvec[i] + ti * x[i*3]* fvec[i] * ( 1 -  fvec[i]  ) * x[i*3+1] ) +   ( commvi[i] )  )  

    costiTemp = 0.0
    
    for i in list:
        costiTemp = costiTemp + (np.real(costi[i]))**2 + (np.imag(costi[i]))**2

    
    return costiTemp

In [79]:
print costvTi(xtemp,2,init), costvTi2(xtemp,2,init)


123.726115329 86.9721151792

In [80]:
## Calculate the total cost

def costv(x,t,initialCondition):

    t = np.array(t)
    
    costvTotal = np.sum( costvTList(x,t,initialCondition)  )
        
    return costvTotal
    

def costvTList(x,t,initialCondition):  ## This is the function WITHOUT the square!!! 
        
    t = np.array(t)
    
    costvList = np.asarray([])
    
    for temp in t:
        tempElement = costvTi(x,temp,initialCondition)
        costvList = np.append(costvList, tempElement)
        
    return np.array(costvList)

In [81]:
ttemp = np.linspace(0,10)
print ttemp


[  0.           0.20408163   0.40816327   0.6122449    0.81632653
   1.02040816   1.2244898    1.42857143   1.63265306   1.83673469
   2.04081633   2.24489796   2.44897959   2.65306122   2.85714286
   3.06122449   3.26530612   3.46938776   3.67346939   3.87755102
   4.08163265   4.28571429   4.48979592   4.69387755   4.89795918
   5.10204082   5.30612245   5.51020408   5.71428571   5.91836735
   6.12244898   6.32653061   6.53061224   6.73469388   6.93877551
   7.14285714   7.34693878   7.55102041   7.75510204   7.95918367
   8.16326531   8.36734694   8.57142857   8.7755102    8.97959184
   9.18367347   9.3877551    9.59183673   9.79591837  10.        ]

In [82]:
ttemp = np.linspace(0,10)
print costvTList(xtemp,ttemp,init)
print costv(xtemp,ttemp,init)


[  46.75895815   52.95466345   59.63798009   66.74943131   74.23836831
   82.06538622   90.20247582   98.63171941  107.34330177  116.33340362
  125.60231247  135.15289668  144.98946527  155.11697016  165.54048256
  176.2648731   187.29463531  198.63380443  210.2859366   222.254124
  234.54102932  247.14892915  260.07975984  273.33516195  286.91652148
  300.82500681  315.06160131  329.62713157  344.52229175  359.74766429
  375.30373762  391.19092106  407.40955749  423.95993398  440.84229076
  458.05682881  475.60371615  493.48309324  511.69507741  530.23976665
  549.11724275  568.32757398  587.87081726  607.74702005  627.95622191
  648.4984558   669.37374916  690.58212483  712.12360182  733.99819595]
16371.2362129

In [ ]:

Minimization

Here is the minimization


In [83]:
tlin = np.linspace(0,2,10)
# tlinTest = np.linspace(0,14,10) + 0.5
# initGuess = np.ones(120)
# initGuess = np.asarray(np.split(np.random.rand(1,720)[0],12))
initGuess = np.asarray(np.split(np.random.rand(1,60)[0],12))
    


costvF = lambda x: costv(x,tlin,init)
#costvFTest = lambda x: costv(x,tlinTest,init)

In [84]:
print costv(initGuess,tlin,init)#, costv(initGuess,tlinTest,init)


1681.7441078

In [85]:
## %%snakeviz
# startCG = timeit.default_timer()
#costvFResultCG = minimize(costvF,initGuess,method="CG")
#stopCG = timeit.default_timer()

#print stopCG - startCG

#print costvFResultCG

%%snakeviz startNM = timeit.default_timer() costvFResultNM = minimize(costvF,initGuess,method="Nelder-Mead",options={"maxfun":20000}) stopNM = timeit.default_timer()

print stopNM - startNM

print costvFResultNM


In [86]:
#initGuessIter = costvFResultNM.get("x")

#for TOLERANCE in np.asarray([1e-8,1e-9,1e-12,1e-14,1e-16,1e-19,1e-20,1e-21,1e-22]):
#    costvFResultNMIter = minimize(costvF,initGuessIter,method="Nelder-Mead",tol=TOLERANCE,options={"maxfun":90000,"maxiter":900000})
#    initGuessIter = costvFResultNMIter.get("x")
#    print TOLERANCE,costvFResultNMIter

In [87]:
#%%snakeviz
#startBFGS = timeit.default_timer()
#costvFResultBFGS = minimize(costvF,initGuess,method="BFGS")
#stopBFGS = timeit.default_timer()

#print stopBFGS - startBFGS

#print costvFResultBFGS

initGuessIter = initGuess

for TOLERANCE in np.asarray([1e-19,1e-20,1e-21,1e-22]): costvFResultSLSQP = minimize(costvF,initGuessIter,method="SLSQP",tol=TOLERANCE) initGuessIter = costvFResultSLSQP.get("x") print TOLERANCE,costvFResultSLSQP


In [88]:
%%snakeviz
startSLSQP = timeit.default_timer()
costvFResultSLSQP = minimize(costvF,initGuess,method="SLSQP")
stopSLSQP = timeit.default_timer()

print stopSLSQP - startSLSQP

print costvFResultSLSQP


38.5440781116
  status: 9
 success: False
    njev: 101
    nfev: 6311
     fun: 0.28896301681379261
       x: array([ -5.30301678e+01,  -3.91382575e-01,  -4.01507377e+00,
        -1.36576590e+01,  -4.27664079e-01,  -1.83885858e+00,
        -5.13559334e+01,  -4.08713466e-01,  -2.83458898e+00,
        -3.76909155e+01,  -4.18865014e-01,  -2.19690466e+00,
         1.47807792e-01,   9.89902806e-01,   6.04732405e-01,
         3.86083611e-01,   9.52947021e-01,   9.27661297e-01,
         3.49734440e-02,   1.54668433e-01,   2.77484141e-01,
         9.97729684e-01,   2.55589496e-01,   3.76583497e-01,
         4.99597887e-01,   4.29185026e-01,   9.42297208e-01,
         1.01360200e-01,   9.80960855e-01,   8.87284348e-02,
         4.56351268e-01,   3.93733396e-01,   5.56374785e-01,
         6.86911162e-01,   7.79705696e-01,   7.56021988e-01,
         4.75433319e-01,   5.73444047e-01,   2.81407177e-01,
         7.82924661e-01,   3.57261498e-01,   6.57057099e-01,
         2.99513162e-01,   8.39791283e-01,   3.10298319e-01,
         7.44211517e-01,   1.91419332e-01,   1.54191990e-01,
         6.48335068e-01,   6.24818590e-01,   2.38183741e-02,
         5.38586059e-01,   8.95332824e-01,   5.13949835e-01,
         6.61152656e-01,   9.30903238e-01,   3.03791335e-01,
         9.33829033e-01,   2.95388366e-01,   7.35207851e-01])
 message: 'Iteration limit exceeded'
     jac: array([ -3.61390412e-05,   1.07169036e-01,   2.67649814e-03,
         6.21230528e-03,  -4.09015454e-02,  -6.25101812e-02,
        -4.50477377e-03,   1.75885491e-01,   2.32322156e-01,
         3.65704298e-03,  -1.84931632e-01,  -9.37197991e-02,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00])
     nit: 101
 
*** Profile stats marshalled to file u'/var/folders/mj/1sl30v6x2g5_lnlgdnngtd3c0000gn/T/tmpkv7q2r'. 

In [89]:
#%%snakeviz
#startSLSQPTest = timeit.default_timer()
#costvFResultSLSQPTest = minimize(costvFTest,initGuess,method="SLSQP")
#stopSLSQPTest = timeit.default_timer()

#print stopSLSQPTest - startSLSQPTest

#print costvFResultSLSQPTest

In [90]:
print costvFResultSLSQP.get('x')
print np.asarray(np.split(costvFResultSLSQP.get('x'),12))
print CostOfStructure(np.asarray(np.split(costvFResultSLSQP.get('x'),12)))


[ -5.30301678e+01  -3.91382575e-01  -4.01507377e+00  -1.36576590e+01
  -4.27664079e-01  -1.83885858e+00  -5.13559334e+01  -4.08713466e-01
  -2.83458898e+00  -3.76909155e+01  -4.18865014e-01  -2.19690466e+00
   1.47807792e-01   9.89902806e-01   6.04732405e-01   3.86083611e-01
   9.52947021e-01   9.27661297e-01   3.49734440e-02   1.54668433e-01
   2.77484141e-01   9.97729684e-01   2.55589496e-01   3.76583497e-01
   4.99597887e-01   4.29185026e-01   9.42297208e-01   1.01360200e-01
   9.80960855e-01   8.87284348e-02   4.56351268e-01   3.93733396e-01
   5.56374785e-01   6.86911162e-01   7.79705696e-01   7.56021988e-01
   4.75433319e-01   5.73444047e-01   2.81407177e-01   7.82924661e-01
   3.57261498e-01   6.57057099e-01   2.99513162e-01   8.39791283e-01
   3.10298319e-01   7.44211517e-01   1.91419332e-01   1.54191990e-01
   6.48335068e-01   6.24818590e-01   2.38183741e-02   5.38586059e-01
   8.95332824e-01   5.13949835e-01   6.61152656e-01   9.30903238e-01
   3.03791335e-01   9.33829033e-01   2.95388366e-01   7.35207851e-01]
[[ -5.30301678e+01  -3.91382575e-01  -4.01507377e+00  -1.36576590e+01
   -4.27664079e-01]
 [ -1.83885858e+00  -5.13559334e+01  -4.08713466e-01  -2.83458898e+00
   -3.76909155e+01]
 [ -4.18865014e-01  -2.19690466e+00   1.47807792e-01   9.89902806e-01
    6.04732405e-01]
 [  3.86083611e-01   9.52947021e-01   9.27661297e-01   3.49734440e-02
    1.54668433e-01]
 [  2.77484141e-01   9.97729684e-01   2.55589496e-01   3.76583497e-01
    4.99597887e-01]
 [  4.29185026e-01   9.42297208e-01   1.01360200e-01   9.80960855e-01
    8.87284348e-02]
 [  4.56351268e-01   3.93733396e-01   5.56374785e-01   6.86911162e-01
    7.79705696e-01]
 [  7.56021988e-01   4.75433319e-01   5.73444047e-01   2.81407177e-01
    7.82924661e-01]
 [  3.57261498e-01   6.57057099e-01   2.99513162e-01   8.39791283e-01
    3.10298319e-01]
 [  7.44211517e-01   1.91419332e-01   1.54191990e-01   6.48335068e-01
    6.24818590e-01]
 [  2.38183741e-02   5.38586059e-01   8.95332824e-01   5.13949835e-01
    6.61152656e-01]
 [  9.30903238e-01   3.03791335e-01   9.33829033e-01   2.95388366e-01
    7.35207851e-01]]
0.709506942067

In [91]:
#np.savetxt('./assets/homogen/optimize_ResultSLSQPT2120_Vac.txt', costvFResultSLSQP.get('x'), delimiter = ',')

Functions

Find the solutions to each elements.


In [92]:
# costvFResultSLSQPx = np.genfromtxt('./assets/homogen/optimize_ResultSLSQP.txt', delimiter = ',')

In [93]:
## The first element of neutrino density matrix
xresult = np.asarray(costvFResultSLSQP.get('x'))
#xresult = np.asarray(costvFResultNM.get('x'))
#xresult = np.asarray(costvFResultBFGS.get('x'))

print xresult

plttlin=np.linspace(0,2,100)

pltdata11 = np.array([])
pltdata11Test = np.array([])
pltdata22 = np.array([])
pltdata12 = np.array([])
pltdata21 = np.array([])

for i in plttlin:
    pltdata11 = np.append(pltdata11 ,rho(xresult,i,init)[0,0] )
    
print pltdata11

for i in plttlin:
    pltdata12 = np.append(pltdata12 ,rho(xresult,i,init)[0,1] )
    
print pltdata12

for i in plttlin:
    pltdata21 = np.append(pltdata21 ,rho(xresult,i,init)[1,0] )
    
print pltdata21

#for i in plttlin:
#    pltdata11Test = np.append(pltdata11Test ,rho(xresultTest,i,init)[0,0] )
#    
#print pltdata11Test


for i in plttlin:
    pltdata22 = np.append(pltdata22 ,rho(xresult,i,init)[1,1] )
    
print pltdata22

print rho(xresult,0,init)


[ -5.30301678e+01  -3.91382575e-01  -4.01507377e+00  -1.36576590e+01
  -4.27664079e-01  -1.83885858e+00  -5.13559334e+01  -4.08713466e-01
  -2.83458898e+00  -3.76909155e+01  -4.18865014e-01  -2.19690466e+00
   1.47807792e-01   9.89902806e-01   6.04732405e-01   3.86083611e-01
   9.52947021e-01   9.27661297e-01   3.49734440e-02   1.54668433e-01
   2.77484141e-01   9.97729684e-01   2.55589496e-01   3.76583497e-01
   4.99597887e-01   4.29185026e-01   9.42297208e-01   1.01360200e-01
   9.80960855e-01   8.87284348e-02   4.56351268e-01   3.93733396e-01
   5.56374785e-01   6.86911162e-01   7.79705696e-01   7.56021988e-01
   4.75433319e-01   5.73444047e-01   2.81407177e-01   7.82924661e-01
   3.57261498e-01   6.57057099e-01   2.99513162e-01   8.39791283e-01
   3.10298319e-01   7.44211517e-01   1.91419332e-01   1.54191990e-01
   6.48335068e-01   6.24818590e-01   2.38183741e-02   5.38586059e-01
   8.95332824e-01   5.13949835e-01   6.61152656e-01   9.30903238e-01
   3.03791335e-01   9.33829033e-01   2.95388366e-01   7.35207851e-01]
[ 1.          0.98116114  0.96261383  0.94435475  0.92638062  0.90868816
  0.89127415  0.87413539  0.85726873  0.84067102  0.82433916  0.80827009
  0.79246075  0.77690814  0.76160928  0.7465612   0.731761    0.71720577
  0.70289265  0.6888188   0.67498142  0.66137772  0.64800495  0.63486039
  0.62194133  0.60924512  0.59676909  0.58451064  0.57246718  0.56063614
  0.54901498  0.53760119  0.52639228  0.51538579  0.50457928  0.49397034
  0.48355659  0.47333565  0.46330519  0.45346289  0.44380646  0.43433363
  0.42504216  0.41592983  0.40699443  0.3982338   0.38964576  0.38122821
  0.37297901  0.3648961   0.35697739  0.34922085  0.34162445  0.33418618
  0.32690408  0.31977617  0.31280052  0.30597521  0.29929833  0.29276801
  0.28638238  0.28013961  0.27403787  0.26807536  0.2622503   0.25656093
  0.25100549  0.24558227  0.24028954  0.23512563  0.23008886  0.22517757
  0.22039012  0.21572491  0.21118032  0.20675476  0.20244668  0.19825452
  0.19417675  0.19021184  0.18635829  0.18261463  0.17897937  0.17545107
  0.17202829  0.1687096   0.1654936   0.1623789   0.15936412  0.1564479
  0.15362889  0.15090576  0.14827719  0.14574189  0.14329856  0.14094592
  0.13868272  0.13650772  0.13441967  0.13241736]
[ 2.          1.96242988  1.92541878  1.88896145  1.85305263  1.81768711
  1.78285968  1.74856519  1.71479848  1.68155445  1.64882801  1.61661408
  1.58490764  1.55370367  1.52299719  1.49278324  1.46305691  1.43381328
  1.40504749  1.37675469  1.34893007  1.32156884  1.29466624  1.26821754
  1.24221803  1.21666305  1.19154795  1.16686811  1.14261896  1.11879592
  1.09539448  1.07241014  1.04983842  1.02767488  1.00591513  0.98455477
  0.96358946  0.94301488  0.92282672  0.90302074  0.88359271  0.8645384
  0.84585367  0.82753436  0.80957636  0.79197559  0.77472799  0.75782955
  0.74127626  0.72506418  0.70918935  0.69364788  0.6784359   0.66354956
  0.64898504  0.63473856  0.62080637  0.60718474  0.59386997  0.58085839
  0.56814637  0.5557303   0.54360661  0.53177173  0.52022215  0.50895438
  0.49796496  0.48725044  0.47680744  0.46663256  0.45672247  0.44707384
  0.43768339  0.42854784  0.41966397  0.41102858  0.40263848  0.39449052
  0.38658158  0.37890857  0.37146843  0.3642581   0.35727459  0.3505149
  0.34397609  0.33765521  0.33154937  0.32565569  0.31997132  0.31449343
  0.30921924  0.30414596  0.29927087  0.29459123  0.29010435  0.28580757
  0.28169826  0.27777378  0.27403155  0.27046902]
[ 3.          2.94288358  2.88665518  2.83130502  2.77682343  2.72320082
  2.67042767  2.61849455  2.56739212  2.5171111   2.4676423   2.41897662
  2.37110504  2.32401859  2.27770841  2.23216571  2.18738177  2.14334796
  2.10005571  2.05749655  2.01566206  1.97454392  1.93413386  1.89442371
  1.85540535  1.81707076  1.77941196  1.74242109  1.70609031  1.67041188
  1.63537814  1.60098148  1.56721437  1.53406936  1.50153904  1.4696161
  1.43829329  1.40756341  1.37741936  1.34785409  1.3188606   1.29043199
  1.26256141  1.23524206  1.20846724  1.18223028  1.15652459  1.13134365
  1.10668099  1.08253021  1.05888497  1.035739    1.01308607  0.99092003
  0.96923479  0.94802432  0.92728264  0.90700382  0.88718203  0.86781145
  0.84888634  0.83040103  0.81234988  0.79472733  0.77752787  0.76074602
  0.7443764   0.72841364  0.71285247  0.69768763  0.68291395  0.66852628
  0.65451955  0.64088872  0.62762883  0.61473494  0.60220218  0.59002573
  0.57820082  0.56672271  0.55558673  0.54478827  0.53432273  0.52418559
  0.51437238  0.50487865  0.49570001  0.48683213  0.47827072  0.47001152
  0.46205032  0.45438298  0.44700538  0.43991343  0.43310313  0.42657049
  0.42031156  0.41432245  0.40859931  0.40313832]
[ 4.          3.92441288  3.8499741   3.776672    3.70449497  3.63343152
  3.5634702   3.49459967  3.42680864  3.36008591  3.29442034  3.2298009
  3.16621661  3.10365656  3.04210995  2.98156604  2.92201414  2.86344369
  2.80584415  2.74920511  2.6935162   2.63876713  2.58494771  2.5320478
  2.48005734  2.42896637  2.37876497  2.32944333  2.28099168  2.23340037
  2.18665977  2.14076038  2.09569273  2.05144746  2.00801527  1.96538691
  1.92355325  1.88250521  1.84223377  1.80273     1.76398506  1.72599014
  1.68873654  1.65221561  1.6164188   1.58133759  1.54696356  1.51328836
  1.48030371  1.44800139  1.41637327  1.38541126  1.35510737  1.32545366
  1.29644228  1.26806542  1.24031536  1.21318445  1.18666509  1.16074976
  1.13543101  1.11070145  1.08655376  1.06298069  1.03997504  1.0175297
  0.9956376   0.97429176  0.95348524  0.93321118  0.91346279  0.89423332
  0.8755161   0.85730453  0.83959205  0.82237218  0.80563849  0.78938462
  0.77360428  0.75829121  0.74343923  0.72904224  0.71509416  0.70158899
  0.68852079  0.67588367  0.66367181  0.65187943  0.64050083  0.62953034
  0.61896237  0.60879138  0.59901187  0.58961842  0.58060565  0.57196823
  0.56370089  0.55579843  0.54825568  0.54106754]
[[ 1.  2.]
 [ 3.  4.]]

In [94]:
rho(xresult,1,init)


Out[94]:
array([[ 0.36091634,  0.71708485],
       [ 1.07064479,  1.43210356]])

In [95]:
#np.savetxt('./assets/homogen/optimize_pltdatar11.txt', pltdata11, delimiter = ',')
#np.savetxt('./assets/homogen/optimize_pltdatar22.txt', pltdata22, delimiter = ',')

In [96]:
plt.figure(figsize=(16,9.36))
plt.ylabel('rho11')
plt.xlabel('Time')
plt11=plt.plot(plttlin,pltdata11,"b4-",label="vac_rho11")
plt.plot(plttlin,np.exp(-plttlin)*1,"r+")
#plt.plot(plttlin,pltdata11Test,"m4-",label="vac_rho11Test")
plt.show()
#py.iplot_mpl(plt.gcf(),filename="vac_HG-rho11")


# tls.embed("https://plot.ly/~emptymalei/73/")



In [97]:
plt.figure(figsize=(16,9.36))
plt.ylabel('rho12')
plt.xlabel('Time')
plt12=plt.plot(plttlin,pltdata12,"b4-",label="vac_rho12")
plt.plot(plttlin,np.exp(-plttlin)*2.0,"r+")
#plt.plot(plttlin,pltdata11Test,"m4-",label="vac_rho11Test")
plt.show()
#py.iplot_mpl(plt.gcf(),filename="vac_HG-rho11")


# tls.embed("https://plot.ly/~emptymalei/73/")



In [98]:
plt.figure(figsize=(16,9.36))
plt.ylabel('rho21')
plt.xlabel('Time')
plt11=plt.plot(plttlin,pltdata21,"b4-",label="vac_rho21")
plt.plot(plttlin,np.exp(-plttlin)*3,"r+")
#plt.plot(plttlin,pltdata11Test,"m4-",label="vac_rho11Test")
plt.show()
#py.iplot_mpl(plt.gcf(),filename="vac_HG-rho11")


# tls.embed("https://plot.ly/~emptymalei/73/")



In [99]:
plt.figure(figsize=(16,9.36))
plt.ylabel('Time')
plt.xlabel('rho22')
plt22=plt.plot(plttlin,pltdata22,"r4-",label="vac_rho22")
plt.plot(plttlin,np.exp(-plttlin)*4,"r+")
plt.show()
#py.iplot_mpl(plt.gcf(),filename="vac_HG-rho22")



In [100]:
MMA_optmize_Vac_pltdata = np.genfromtxt('./assets/homogen/MMA_optmize_Vac_pltdata.txt', delimiter = ',')

plt.figure(figsize=(16,9.36))
plt.ylabel('MMArho11')
plt.xlabel('Time')
plt.plot(np.linspace(0,15,4501),MMA_optmize_Vac_pltdata,"r-",label="MMAVacrho11")
plt.plot(plttlin,pltdata11,"b4-",label="vac_rho11")
plt.show()
#py.iplot_mpl(plt.gcf(),filename="MMA-rho11-Vac-80-60")



In [ ]:


In [ ]:

Practice


In [ ]:
xtemp1 = np.arange(4)
xtemp1.shape = (2,2)
print xtemp1
xtemp1[0,1]
np.dot(xtemp1,xtemp1)
xtemp1[0,1]

In [ ]:


In [ ]: