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} = \begin{pmatrix} -0.38729833462 & 0.31622776601\\ 0.31622776601 & 0.38729833462 \end{pmatrix} $$$$ 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 [2]:
# 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( [ [ - 0.38729833462,0.31622776601] , [0.31622776601,0.38729833462] ] )

## sqareroot of 2
sqrt2=np.sqrt(2.0)

Using Mathematica, I can find the 4*2 equations


In [3]:
#r11prime(t)

## The matrix eqn for neutrinos. Symplify the equation to the form A.X=0. Here I am only writing down the LHS.
## Eqn for r11'
# 1/2*( r21(t)*( bM12*delm2E - 2*sqrt2*gF*rb12(t) ) + r12(t) * ( -bM21*delm2E + 2*sqrt2*gF*rb21(t) ) - 1j*r11prime(t)  )
## Eqn for r12'
# 1/2*( r22(t)* ( bM12 ) )

### wait a minute I don't actually need to write down this. I can just do this part in numpy.

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 [4]:
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 [5]:
## The time derivative part

### Here are the initial conditions

init = np.array( [[1,0],[0,0]] )


### For neutrinos

def rho(x,ti,initialCondition): # x is the input structure arrays, ti is a time point

    v11,w11,u11,v12,w12,u12,v21,w21,u21,v22,w22,u22 = x[:12]
        
    elem11= np.sum(ti * v11 * trigf( ti*w11 +u11 ) )
    elem12= np.sum(ti * v12 * trigf( ti*w12 +u12 ) )
    elem21= np.sum(ti * v21 * trigf( ti*w21 +u21 ) )
    elem22= np.sum(ti * v22 * trigf( ti*w22 +u22 ) )
    
    return initialCondition + np.array([[ elem11 , elem12 ],[elem21, elem22]])

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


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

In [7]:
## Define Hamiltonians for both

def hamilv():
    return delm2E*bM

In [8]:
## The commutator

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

In [9]:
## Test

print bM

print hamilv()

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


[[-0.19364917  0.15811388]
 [ 0.15811388  0.19364917]]
[[-0.19364917  0.15811388]
 [ 0.15811388  0.19364917]]
neutrino
[[ 0.         -0.15811388]
 [ 0.15811388  0.        ]]

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

regularization = 0.0001

def costvTi(x,ti,initialCondition): # l is total length of x
    
    v11,w11,u11,v12,w12,u12,v21,w21,u21,v22,w22,u22 = x[:12]

    fvec11 = np.array(trigf(ti*w11 + u11) )  # This is a vector!!!
    fvec12 = np.array(trigf(ti*w12 + u12) )
    fvec21 = np.array(trigf(ti*w21 + u21) )
    fvec22 = np.array(trigf(ti*w22 + u22) )
    
    costi11= ( np.sum (v11*fvec11 + ti * v11* fvec11 * ( 1 -  fvec11  ) * w11 ) + 1.0j*  ( commv(x,ti,initialCondition)[0,0] )  )  
    costi12= ( np.sum (v12*fvec12 + ti * v12* fvec12 * ( 1 -  fvec12  ) * w12 ) + 1.0j*  ( commv(x,ti,initialCondition)[0,1] )  )  
    costi21= ( np.sum (v21*fvec21 + ti * v21* fvec21 * ( 1 -  fvec21  ) * w21 ) + 1.0j*  ( commv(x,ti,initialCondition)[1,0] )  )  
    costi22= ( np.sum (v22*fvec22 + ti * v22* fvec22 * ( 1 -  fvec22  ) * w22 ) + 1.0j*  ( commv(x,ti,initialCondition)[1,1] )  )  

    
    #return (np.real(costi11))**2 + (np.real(costi12))**2+ (np.real(costi21))**2 +  (np.real(costi22))**2 + (np.imag(costi11))**2 + (np.imag(costi12))**2+ (np.imag(costi21))**2 +  (np.imag(costi22))**2
    
    #return np.abs(np.real(costi11)) + np.abs(np.real(costi12))+ np.abs(np.real(costi21)) +  np.abs(np.real(costi22)) + np.abs(np.imag(costi11)) + np.abs(np.imag(costi12))+ np.abs(np.imag(costi21)) +  np.abs(np.imag(costi22))

    return ( (np.real(costi11))**2 + (np.real(costi12))**2+ (np.real(costi21))**2 +  (np.real(costi22))**2 + (np.imag(costi11))**2 + (np.imag(costi12))**2+ (np.imag(costi21))**2 +  (np.imag(costi22))**2 )/v11.size + regularization * ( np.sum(v11**2)+np.sum(v12**2)+np.sum(v21**2) + np.sum(v22**2) + np.sum(w11**2) + np.sum(w12**2)+ np.sum(w21**2)+ np.sum(w22**2) )

In [11]:
costvTi(xtemp,2,init)


Out[11]:
5.9571317039229577

In [12]:
## 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 [13]:
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 [14]:
ttemp = np.linspace(0,10)
print costvTList(xtemp,ttemp,init)
print costv(xtemp,ttemp,init)


[  2.18858658   2.69181119   3.17657819   3.62928532   4.04433065
   4.4227527    4.77017906   5.09476415   5.40551177   5.7111183
   6.01930406   6.33652211   6.66791949   7.01744398   7.38801874
   7.78173467   8.20003235   8.64386006   9.11380383   9.61019022
  10.1331652   10.6827532   11.25890034  11.86150545  12.49044177
  13.14557185  13.82675734  14.53386531  15.26677189  16.02536424
  16.80954131  17.61921376  18.45430348  19.3147428   20.20047349
  21.11144577  22.04761735  23.00895246  23.99542098  25.00699765
  26.04366137  27.10539457  28.19218266  29.30401359  30.44087738
  31.60276587  32.78967231  34.00159123  35.23851811  36.50044933]
765.926679446

In [ ]:

Minimization

Here is the minimization


In [16]:
tlin = np.linspace(0,15,80)
# tlinTest = np.linspace(0,14,10) + 0.5
# initGuess = np.ones(120)
initGuess = np.asarray(np.split(np.random.rand(1,360)[0],12))
    


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

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


13993.6089574

In [33]:
## %%snakeviz
# startCG = timeit.default_timer()
#costFResultCG = minimize(costF,initGuess,method="CG")
#stopCG = timeit.default_timer()

#print stopCG - startCG

#print costFResultCG

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

#print stopBFGS - startBFGS

#print costvFResultBFGS

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

print stopSLSQP - startSLSQP

print costvFResultSLSQP


4675.15557098
  status: 9
 success: False
    njev: 101
    nfev: 36609
     fun: 0.64161943357284112
       x: array([-0.11810821, -0.14214314, -0.16333713, -0.08627392, -0.14821997,
        0.84117308, -0.1085949 , -0.13072789,  0.29896719,  0.21759241,
       -0.20543478, -0.67870319,  0.14599738,  0.06018805,  0.4079748 ,
        0.05534681,  0.56648524,  0.94958886,  0.96791054,  0.8180562 ,
        0.21000418,  0.15450912,  0.00850279,  0.56631572,  0.16299222,
        0.34543721,  0.8018915 ,  0.88520435,  0.67178723,  0.49329804,
        0.57811576,  0.65735436,  0.9211617 ,  0.68178169,  0.93966401,
        0.29612807,  0.58806395,  0.3270831 ,  0.6543035 ,  0.93725984,
        0.11423057,  0.28502284,  0.468195  ,  0.17239023,  0.47910059,
        0.50089486,  0.67071479,  0.21651589,  0.01587124,  0.12851285,
        0.62622347,  0.12987551,  0.47931716,  0.07754401,  0.47246858,
        0.1331831 ,  0.57460681,  0.95425658,  0.04547236,  0.07269621,
        0.84362933,  0.47932419,  0.14981438,  0.3022754 ,  0.90273276,
        0.87598636,  0.22934441,  0.9141215 ,  0.16087128,  0.90651858,
        0.19521705,  0.12530945,  0.1046104 ,  0.40805774,  0.28657555,
        0.75607439,  0.44184653,  0.06308248,  0.47749546,  0.24861533,
        0.72551517,  0.20338495,  0.1117115 ,  0.86307449,  0.75665626,
        0.18563884,  0.61554729,  0.80463095,  0.93366718,  0.18105971,
        0.12135566,  0.57898772,  0.51782359,  0.4277803 ,  0.89023822,
        0.46065527,  0.29290705,  0.83899751,  0.88191146,  0.00218991,
        0.46808954,  0.92191113,  0.67757704,  0.16224957,  0.84798017,
        0.54144285,  0.85290237,  0.2162462 ,  0.24773748,  0.2371869 ,
        0.74047449,  0.84950031,  0.56808539,  0.64934494,  0.69062228,
        0.44739278,  0.6174639 ,  0.82229243,  0.46030636,  0.42341657,
        0.04445216,  0.69837941,  0.6534884 ,  0.64687093,  0.15812323,
        0.09038031,  0.92802568,  0.95477816,  0.31232932,  0.86328365,
        0.4886409 ,  0.68691899,  0.54424476,  0.58748702,  0.79252337,
        0.93775804,  0.54192374,  0.32083177,  0.56406039,  0.7257377 ,
        0.0841441 ,  0.52086914,  0.38575909,  0.18907716,  0.37332975,
        0.60920812,  0.01313042,  0.77018194,  0.47409526,  0.7533137 ,
        0.15401923,  0.78811344,  0.15771501,  0.60909303,  0.02082835,
        0.36860632,  0.28627154,  0.93604481,  0.20804117,  0.77725409,
        0.39175302,  0.54609058,  0.34420298,  0.12047258,  0.76195828,
        0.6268015 ,  0.96302138,  0.8981624 ,  0.287455  ,  0.83827356,
        0.90657454,  0.17181641,  0.92804864,  0.28732885,  0.93102607,
        0.43077317,  0.88025227,  0.75821668,  0.95135773,  0.51753084,
        0.08288749,  0.18303068,  0.30680699,  0.15192403,  0.01295583,
        0.76146352,  0.07690725,  0.77135946,  0.16961728,  0.59996969,
        0.26675961,  0.70171607,  0.52832813,  0.89488016,  0.62353711,
        0.92405285,  0.16656381,  0.74864695,  0.67945372,  0.11117068,
        0.89131093,  0.92305643,  0.21360885,  0.48380386,  0.72049482,
        0.09086005,  0.57841264,  0.07364256,  0.64243569,  0.17623842,
        0.91835335,  0.08323969,  0.6132066 ,  0.21626689,  0.94936106,
        0.58800975,  0.62955895,  0.1003493 ,  0.96235556,  0.72572974,
        0.64835424,  0.35516351,  0.21085828,  0.56840419,  0.0560019 ,
        0.98679132,  0.49686145,  0.7530275 ,  0.46589723,  0.81846472,
        0.33776231,  0.71486705,  0.45283694,  0.52590482,  0.42201638,
        0.01775856,  0.54744717,  0.98507392,  0.06410655,  0.21067701,
        0.54054908,  0.32090426,  0.8284473 ,  0.81916985,  0.10507765,
        0.3345575 ,  0.38438596,  0.22470904,  0.92213725,  0.57822653,
        0.68549963,  0.52002441,  0.05460373,  0.28528302,  0.31494385,
        0.18169133,  0.02882537,  0.0513952 ,  0.4529524 ,  0.47511893,
        0.27338127,  0.14731351,  0.83065245,  0.65753738,  0.80991718,
        0.25338498,  0.12989088,  0.92563785,  0.75722088,  0.59389702,
        0.44363672,  0.77930492,  0.88537432,  0.64094133,  0.83454724,
        0.66850741,  0.72879206,  0.21493765,  0.37386483,  0.36297888,
        0.19318435,  0.82085951,  0.37688856,  0.77516507,  0.20597133,
        0.3324416 ,  0.94619553,  0.23759796,  0.80098143,  0.73659254,
        0.39746134,  0.54735202,  0.87565685,  0.90595497,  0.42910249,
        0.27154169,  0.50835516,  0.3924186 ,  0.52963882,  0.20840199,
        0.59276384,  0.83371111,  0.86255815,  0.41101322,  0.99360601,
        0.24663024,  0.69016301,  0.90811462,  0.40362763,  0.21435907,
        0.43822789,  0.62191815,  0.23860981,  0.1970206 ,  0.4539345 ,
        0.72376581,  0.7741993 ,  0.3874107 ,  0.40225288,  0.02678339,
        0.02294066,  0.31953522,  0.8896455 ,  0.71417087,  0.89544094,
        0.81320062,  0.26431014,  0.6846103 ,  0.33511342,  0.98869604,
        0.70340046,  0.84634226,  0.28928578,  0.65081149,  0.04367166,
        0.65769679,  0.26805362,  0.28789487,  0.65148795,  0.4397962 ,
        0.57420739,  0.91496966,  0.48336202,  0.61568233,  0.82498034,
        0.68998357,  0.67753651,  0.62199147,  0.00939983,  0.3408086 ,
        0.02028933,  0.74362747,  0.47511842,  0.30070992,  0.67952423,
        0.41398671,  0.05282411,  0.98667069,  0.94608183,  0.77152731])
 message: 'Iteration limit exceeded'
     jac: array([ 0.12043606, -0.00588213, -0.005335  , -0.15530581,  0.17606255,
        0.02064314,  0.28843538, -0.06225538, -0.01135841, -0.03998609,
       -0.02716573, -0.00515844,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,  0.        ])
     nit: 101
 
*** Profile stats marshalled to file u'/var/folders/mj/1sl30v6x2g5_lnlgdnngtd3c0000gn/T/tmpu52E6K'. 

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

#print stopSLSQPTest - startSLSQPTest

#print costvFResultSLSQPTest

In [37]:
costvFResultSLSQP.get('x')


Out[37]:
array([-0.11810821, -0.14214314, -0.16333713, -0.08627392, -0.14821997,
        0.84117308, -0.1085949 , -0.13072789,  0.29896719,  0.21759241,
       -0.20543478, -0.67870319,  0.14599738,  0.06018805,  0.4079748 ,
        0.05534681,  0.56648524,  0.94958886,  0.96791054,  0.8180562 ,
        0.21000418,  0.15450912,  0.00850279,  0.56631572,  0.16299222,
        0.34543721,  0.8018915 ,  0.88520435,  0.67178723,  0.49329804,
        0.57811576,  0.65735436,  0.9211617 ,  0.68178169,  0.93966401,
        0.29612807,  0.58806395,  0.3270831 ,  0.6543035 ,  0.93725984,
        0.11423057,  0.28502284,  0.468195  ,  0.17239023,  0.47910059,
        0.50089486,  0.67071479,  0.21651589,  0.01587124,  0.12851285,
        0.62622347,  0.12987551,  0.47931716,  0.07754401,  0.47246858,
        0.1331831 ,  0.57460681,  0.95425658,  0.04547236,  0.07269621,
        0.84362933,  0.47932419,  0.14981438,  0.3022754 ,  0.90273276,
        0.87598636,  0.22934441,  0.9141215 ,  0.16087128,  0.90651858,
        0.19521705,  0.12530945,  0.1046104 ,  0.40805774,  0.28657555,
        0.75607439,  0.44184653,  0.06308248,  0.47749546,  0.24861533,
        0.72551517,  0.20338495,  0.1117115 ,  0.86307449,  0.75665626,
        0.18563884,  0.61554729,  0.80463095,  0.93366718,  0.18105971,
        0.12135566,  0.57898772,  0.51782359,  0.4277803 ,  0.89023822,
        0.46065527,  0.29290705,  0.83899751,  0.88191146,  0.00218991,
        0.46808954,  0.92191113,  0.67757704,  0.16224957,  0.84798017,
        0.54144285,  0.85290237,  0.2162462 ,  0.24773748,  0.2371869 ,
        0.74047449,  0.84950031,  0.56808539,  0.64934494,  0.69062228,
        0.44739278,  0.6174639 ,  0.82229243,  0.46030636,  0.42341657,
        0.04445216,  0.69837941,  0.6534884 ,  0.64687093,  0.15812323,
        0.09038031,  0.92802568,  0.95477816,  0.31232932,  0.86328365,
        0.4886409 ,  0.68691899,  0.54424476,  0.58748702,  0.79252337,
        0.93775804,  0.54192374,  0.32083177,  0.56406039,  0.7257377 ,
        0.0841441 ,  0.52086914,  0.38575909,  0.18907716,  0.37332975,
        0.60920812,  0.01313042,  0.77018194,  0.47409526,  0.7533137 ,
        0.15401923,  0.78811344,  0.15771501,  0.60909303,  0.02082835,
        0.36860632,  0.28627154,  0.93604481,  0.20804117,  0.77725409,
        0.39175302,  0.54609058,  0.34420298,  0.12047258,  0.76195828,
        0.6268015 ,  0.96302138,  0.8981624 ,  0.287455  ,  0.83827356,
        0.90657454,  0.17181641,  0.92804864,  0.28732885,  0.93102607,
        0.43077317,  0.88025227,  0.75821668,  0.95135773,  0.51753084,
        0.08288749,  0.18303068,  0.30680699,  0.15192403,  0.01295583,
        0.76146352,  0.07690725,  0.77135946,  0.16961728,  0.59996969,
        0.26675961,  0.70171607,  0.52832813,  0.89488016,  0.62353711,
        0.92405285,  0.16656381,  0.74864695,  0.67945372,  0.11117068,
        0.89131093,  0.92305643,  0.21360885,  0.48380386,  0.72049482,
        0.09086005,  0.57841264,  0.07364256,  0.64243569,  0.17623842,
        0.91835335,  0.08323969,  0.6132066 ,  0.21626689,  0.94936106,
        0.58800975,  0.62955895,  0.1003493 ,  0.96235556,  0.72572974,
        0.64835424,  0.35516351,  0.21085828,  0.56840419,  0.0560019 ,
        0.98679132,  0.49686145,  0.7530275 ,  0.46589723,  0.81846472,
        0.33776231,  0.71486705,  0.45283694,  0.52590482,  0.42201638,
        0.01775856,  0.54744717,  0.98507392,  0.06410655,  0.21067701,
        0.54054908,  0.32090426,  0.8284473 ,  0.81916985,  0.10507765,
        0.3345575 ,  0.38438596,  0.22470904,  0.92213725,  0.57822653,
        0.68549963,  0.52002441,  0.05460373,  0.28528302,  0.31494385,
        0.18169133,  0.02882537,  0.0513952 ,  0.4529524 ,  0.47511893,
        0.27338127,  0.14731351,  0.83065245,  0.65753738,  0.80991718,
        0.25338498,  0.12989088,  0.92563785,  0.75722088,  0.59389702,
        0.44363672,  0.77930492,  0.88537432,  0.64094133,  0.83454724,
        0.66850741,  0.72879206,  0.21493765,  0.37386483,  0.36297888,
        0.19318435,  0.82085951,  0.37688856,  0.77516507,  0.20597133,
        0.3324416 ,  0.94619553,  0.23759796,  0.80098143,  0.73659254,
        0.39746134,  0.54735202,  0.87565685,  0.90595497,  0.42910249,
        0.27154169,  0.50835516,  0.3924186 ,  0.52963882,  0.20840199,
        0.59276384,  0.83371111,  0.86255815,  0.41101322,  0.99360601,
        0.24663024,  0.69016301,  0.90811462,  0.40362763,  0.21435907,
        0.43822789,  0.62191815,  0.23860981,  0.1970206 ,  0.4539345 ,
        0.72376581,  0.7741993 ,  0.3874107 ,  0.40225288,  0.02678339,
        0.02294066,  0.31953522,  0.8896455 ,  0.71417087,  0.89544094,
        0.81320062,  0.26431014,  0.6846103 ,  0.33511342,  0.98869604,
        0.70340046,  0.84634226,  0.28928578,  0.65081149,  0.04367166,
        0.65769679,  0.26805362,  0.28789487,  0.65148795,  0.4397962 ,
        0.57420739,  0.91496966,  0.48336202,  0.61568233,  0.82498034,
        0.68998357,  0.67753651,  0.62199147,  0.00939983,  0.3408086 ,
        0.02028933,  0.74362747,  0.47511842,  0.30070992,  0.67952423,
        0.41398671,  0.05282411,  0.98667069,  0.94608183,  0.77152731])

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

Functions

Find the solutions to each elements.


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

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

print xresult

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

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

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

#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)


[-0.11810821 -0.14214314 -0.16333713 -0.08627392 -0.14821997  0.84117308
 -0.1085949  -0.13072789  0.29896719  0.21759241 -0.20543478 -0.67870319
  0.14599738  0.06018805  0.4079748   0.05534681  0.56648524  0.94958886
  0.96791054  0.8180562   0.21000418  0.15450912  0.00850279  0.56631572
  0.16299222  0.34543721  0.8018915   0.88520435  0.67178723  0.49329804
  0.57811576  0.65735436  0.9211617   0.68178169  0.93966401  0.29612807
  0.58806395  0.3270831   0.6543035   0.93725984  0.11423057  0.28502284
  0.468195    0.17239023  0.47910059  0.50089486  0.67071479  0.21651589
  0.01587124  0.12851285  0.62622347  0.12987551  0.47931716  0.07754401
  0.47246858  0.1331831   0.57460681  0.95425658  0.04547236  0.07269621
  0.84362933  0.47932419  0.14981438  0.3022754   0.90273276  0.87598636
  0.22934441  0.9141215   0.16087128  0.90651858  0.19521705  0.12530945
  0.1046104   0.40805774  0.28657555  0.75607439  0.44184653  0.06308248
  0.47749546  0.24861533  0.72551517  0.20338495  0.1117115   0.86307449
  0.75665626  0.18563884  0.61554729  0.80463095  0.93366718  0.18105971
  0.12135566  0.57898772  0.51782359  0.4277803   0.89023822  0.46065527
  0.29290705  0.83899751  0.88191146  0.00218991  0.46808954  0.92191113
  0.67757704  0.16224957  0.84798017  0.54144285  0.85290237  0.2162462
  0.24773748  0.2371869   0.74047449  0.84950031  0.56808539  0.64934494
  0.69062228  0.44739278  0.6174639   0.82229243  0.46030636  0.42341657
  0.04445216  0.69837941  0.6534884   0.64687093  0.15812323  0.09038031
  0.92802568  0.95477816  0.31232932  0.86328365  0.4886409   0.68691899
  0.54424476  0.58748702  0.79252337  0.93775804  0.54192374  0.32083177
  0.56406039  0.7257377   0.0841441   0.52086914  0.38575909  0.18907716
  0.37332975  0.60920812  0.01313042  0.77018194  0.47409526  0.7533137
  0.15401923  0.78811344  0.15771501  0.60909303  0.02082835  0.36860632
  0.28627154  0.93604481  0.20804117  0.77725409  0.39175302  0.54609058
  0.34420298  0.12047258  0.76195828  0.6268015   0.96302138  0.8981624
  0.287455    0.83827356  0.90657454  0.17181641  0.92804864  0.28732885
  0.93102607  0.43077317  0.88025227  0.75821668  0.95135773  0.51753084
  0.08288749  0.18303068  0.30680699  0.15192403  0.01295583  0.76146352
  0.07690725  0.77135946  0.16961728  0.59996969  0.26675961  0.70171607
  0.52832813  0.89488016  0.62353711  0.92405285  0.16656381  0.74864695
  0.67945372  0.11117068  0.89131093  0.92305643  0.21360885  0.48380386
  0.72049482  0.09086005  0.57841264  0.07364256  0.64243569  0.17623842
  0.91835335  0.08323969  0.6132066   0.21626689  0.94936106  0.58800975
  0.62955895  0.1003493   0.96235556  0.72572974  0.64835424  0.35516351
  0.21085828  0.56840419  0.0560019   0.98679132  0.49686145  0.7530275
  0.46589723  0.81846472  0.33776231  0.71486705  0.45283694  0.52590482
  0.42201638  0.01775856  0.54744717  0.98507392  0.06410655  0.21067701
  0.54054908  0.32090426  0.8284473   0.81916985  0.10507765  0.3345575
  0.38438596  0.22470904  0.92213725  0.57822653  0.68549963  0.52002441
  0.05460373  0.28528302  0.31494385  0.18169133  0.02882537  0.0513952
  0.4529524   0.47511893  0.27338127  0.14731351  0.83065245  0.65753738
  0.80991718  0.25338498  0.12989088  0.92563785  0.75722088  0.59389702
  0.44363672  0.77930492  0.88537432  0.64094133  0.83454724  0.66850741
  0.72879206  0.21493765  0.37386483  0.36297888  0.19318435  0.82085951
  0.37688856  0.77516507  0.20597133  0.3324416   0.94619553  0.23759796
  0.80098143  0.73659254  0.39746134  0.54735202  0.87565685  0.90595497
  0.42910249  0.27154169  0.50835516  0.3924186   0.52963882  0.20840199
  0.59276384  0.83371111  0.86255815  0.41101322  0.99360601  0.24663024
  0.69016301  0.90811462  0.40362763  0.21435907  0.43822789  0.62191815
  0.23860981  0.1970206   0.4539345   0.72376581  0.7741993   0.3874107
  0.40225288  0.02678339  0.02294066  0.31953522  0.8896455   0.71417087
  0.89544094  0.81320062  0.26431014  0.6846103   0.33511342  0.98869604
  0.70340046  0.84634226  0.28928578  0.65081149  0.04367166  0.65769679
  0.26805362  0.28789487  0.65148795  0.4397962   0.57420739  0.91496966
  0.48336202  0.61568233  0.82498034  0.68998357  0.67753651  0.62199147
  0.00939983  0.3408086   0.02028933  0.74362747  0.47511842  0.30070992
  0.67952423  0.41398671  0.05282411  0.98667069  0.94608183  0.77152731]
[ 1.          0.99187715  0.98394517  0.97620342  0.96865119  0.96128767
  0.95411199  0.94712316  0.94032014  0.93370182  0.92726697  0.92101432
  0.91494253  0.90905016  0.90333571  0.89779763  0.89243428  0.88724397
  0.88222495  0.87737539  0.87269343  0.86817714  0.86382453  0.85963359
  0.85560222  0.85172832  0.8480097   0.84444417  0.84102948  0.83776336
  0.83464348  0.83166752  0.82883309  0.82613781  0.82357925  0.82115497
  0.81886253  0.81669945  0.81466324  0.8127514   0.81096144  0.80929083
  0.80773708  0.80629764  0.80497002  0.80375168  0.80264013  0.80163285
  0.80072735  0.79992114  0.79921173  0.79859667  0.7980735   0.79763979
  0.79729313  0.79703112  0.79685137  0.79675154  0.79672929  0.79678232
  0.79690834  0.7971051   0.79737036  0.79770192  0.79809762  0.79855531
  0.79907288  0.79964825  0.80027937  0.80096422  0.80170083  0.80248723
  0.80332152  0.80420181  0.80512625  0.80609304  0.8071004   0.80814657
  0.80922986  0.81034859  0.81150113  0.81268587  0.81390125  0.81514573
  0.81641782  0.81771607  0.81903904  0.82038534  0.82175362  0.82314255
  0.82455084  0.82597725  0.82742054  0.82887953  0.83035306  0.83184002
  0.8333393   0.83484984  0.83637062  0.83790064]
[ 0.          0.01086764  0.02128417  0.03125703  0.04079389  0.04990269
  0.05859159  0.06686893  0.07474326  0.08222329  0.08931786  0.09603596
  0.10238666  0.10837915  0.11402266  0.11932649  0.12429998  0.12895247
  0.13329332  0.13733186  0.14107743  0.14453928  0.14772665  0.15064867
  0.15331443  0.15573291  0.15791298  0.15986343  0.1615929   0.16310991
  0.16442285  0.16553997  0.16646935  0.16721894  0.16779651  0.16820968
  0.16846589  0.16857241  0.16853633  0.16836457  0.16806388  0.16764081
  0.16710174  0.16645287  0.1657002   0.16484958  0.16390664  0.16287687
  0.16176555  0.16057781  0.15931858  0.15799263  0.15660456  0.15515879
  0.15365961  0.1521111   0.15051721  0.14888172  0.14720827  0.14550035
  0.14376129  0.14199429  0.1402024   0.13838854  0.13655551  0.13470596
  0.13284242  0.13096732  0.12908294  0.12719148  0.12529499  0.12339546
  0.12149474  0.1195946   0.11769669  0.1158026   0.11391381  0.11203172
  0.11015763  0.10829279  0.10643836  0.1045954   0.10276495  0.10094793
  0.09914523  0.09735767  0.095586    0.09383092  0.09209308  0.09037305
  0.08867139  0.08698859  0.08532509  0.0836813   0.08205757  0.08045424
  0.07887158  0.07730984  0.07576924  0.07424996]
[[ 1.  0.]
 [ 0.  0.]]

In [41]:
rho(xresult,6.6,init)


Out[41]:
array([[ 0.80554056, -0.265221  ],
       [-0.25992808,  0.16604378]])

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

In [43]:
plt.figure(figsize=(16,9.36))
plt.ylabel('rho11')
plt.xlabel('Time')
plt11=plt.plot(plttlin,pltdata11,"b4-",label="vac_rho11")
#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 [44]:
plt.figure(figsize=(16,9.36))
plt.ylabel('Time')
plt.xlabel('rho22')
plt22=plt.plot(plttlin,pltdata22,"r4-",label="vac_rho22")
plt.show()
#py.iplot_mpl(plt.gcf(),filename="vac_HG-rho22")



In [45]:
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 [ ]: