In [1]:
import numpy as np
from numpy import linalg as LA
from numpy import array
from numpy import pi
import matplotlib.pyplot as plt
import sys
import math

if "/home/dominique/Code/PG/Source" not in sys.path:
    sys.path.append("/home/dominique/Code/PG/Source")

import phase_fluctuations as PF
from phase_fluctuations import TbModel, TbParams, SWaveModel, DWaveModel
from MCMC import MCMCDriver
import scipy.constants as cst
def K_to_meV(in_temp):
    return cst.physical_constants["Boltzmann constant in eV/K"][0] * in_temp * 1000.0

In [2]:
%load_ext autoreload
%autoreload 2

In [3]:
%who
%matplotlib inline


DWaveModel	 K_to_meV	 LA	 MCMCDriver	 PF	 SWaveModel	 TbModel	 TbParams	 array	 
cst	 math	 np	 pi	 plt	 sys	 

In [4]:
%install_ext https://raw.githubusercontent.com/rasbt/python_reference/master/ipython_magic/watermark.py
%load_ext watermark


Installed watermark.py. To use it, type:
  %load_ext watermark

In [71]:
%watermark?

In [10]:
a = np.empty(5, dtype=bool)
a[:] = False
print a


[False False False False False]

In [89]:
test = {"a":1, "b":2}
test.update({"a":3})
test.get("c", 3)


Out[89]:
3

In [90]:
a = np.array([[1, -2j], [2j, 5]])
a


Out[90]:
array([[ 1.+0.j,  0.-2.j],
       [ 0.+2.j,  5.+0.j]])

In [91]:
w, v = LA.eigh(a)

In [92]:
print w
print v


[ 0.17157288  5.82842712]
[[-0.92387953+0.j         -0.38268343+0.j        ]
 [ 0.00000000+0.38268343j  0.00000000-0.92387953j]]

In [93]:
v.conj().transpose()


Out[93]:
array([[-0.92387953-0.j        ,  0.00000000-0.38268343j],
       [-0.38268343-0.j        ,  0.00000000+0.92387953j]])

In [94]:
np.dot(v.conj().transpose(), np.dot(a, v))


Out[94]:
array([[  1.71572875e-01+0.j,  -3.01625044e-16+0.j],
       [ -8.86369157e-17+0.j,   5.82842712e+00+0.j]])

In [95]:
np.dot(v, np.dot(a, v.conj().transpose()))


Out[95]:
array([[ 1.58578644 -4.32596667e-17j, -2.00000000 -1.41421356e+00j],
       [-2.00000000 +1.41421356e+00j,  4.41421356 +4.32596667e-17j]])

In [96]:
b= np.array([1, 2, 4, 5])
print b.shape
print b
c = np.reshape(b, (4, 1))
print c
d = b.transpose()
print d


(4,)
[1 2 4 5]
[[1]
 [2]
 [4]
 [5]]
[1 2 4 5]

In [97]:
e= np.linspace(1.0, 15, num=8, endpoint=True)
o = np.linspace(1.0, 3.0, num=3, endpoint=True)
ee=np.reshape(e, (e.shape[0], 1))
mat = o+ee

fac = np.ones(8)
mat2 = np.dot(fac, mat)

print e
print o
print mat
print mat2


[  1.   3.   5.   7.   9.  11.  13.  15.]
[ 1.  2.  3.]
[[  2.   3.   4.]
 [  4.   5.   6.]
 [  6.   7.   8.]
 [  8.   9.  10.]
 [ 10.  11.  12.]
 [ 12.  13.  14.]
 [ 14.  15.  16.]
 [ 16.  17.  18.]]
[ 72.  80.  88.]

In [98]:
%watermark -a "Dominique" -d -t -u -v -h -m -g


Dominique Last updated: 11/03/2015 14:50:43 

CPython 2.7.6
IPython 3.0.0

compiler   : GCC 4.8.2
system     : Linux
release    : 3.13.0-45-generic
machine    : i686
processor  : i686
CPU cores  : 2
interpreter: 32bit
host name  : fermi
Git hash   : 0c2d43e78bffea131be1876ed5d3a54bb48182a6

In [99]:
import git
from datetime import datetime
from time import mktime
import time
repo = git.Repo("/home/dominique/Code/PG/")
heads = repo.heads
master = heads[0]
commit_id = master.commit.binsha.encode('hex')
commit_datetime = time.strftime("%a, %d %b %Y %H:%M", time.localtime(master.commit.committed_date))
out = {"id": commit_id, "time": commit_datetime}

TB Model

Instantiation


In [100]:
T_CST = 0.25
MY_PARAMS = {"width":32, "chem_potential": 0.0,
                 "hopping_constant": T_CST, "J_constant": 1.0 * T_CST,
                 "g_constant": 1.0 * T_CST, "delta": 1.0 * T_CST,
                 "use_assaad": False, "broadening_delta": 0.01 * T_CST}
MY_MODEL = TbModel(MY_PARAMS)

Modification


In [101]:
TB_PARAMS = {"width":32, "chem_potential": 0.0,
                 "hopping_constant": T_CST, "J_constant": 0.0,
                 "g_constant": 0.0, "delta": 0.0, "use_assaad": True}
MY_MODEL.set_params(TB_PARAMS)
print MY_MODEL._use_assaad


True

In [102]:
print MY_MODEL._broadening_delta


0.0025

In [103]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)

x_axis_ampl = 4.5
nb_ticks = min(1001, max(101, 1 + MY_MODEL.lattice.n_sites))
xvalues = np.linspace(-x_axis_ampl, x_axis_ampl, nb_ticks, endpoint=True)

#ymin = 0.0
#ymax = 0.5
xmin = -x_axis_ampl
xmax = x_axis_ampl

ax.set_xlim([xmin, xmax])
#ax.set_ylim([0.0, 1.0])
ax.set_xticks(np.linspace(int(xmin), int(xmax), 9,endpoint=True))
#ax.set_yticks(np.linspace(xmin, xmax, 5,endpoint=True))
#ax.set_xticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])
#ax.set_yticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])

dos_values = np.real(MY_MODEL.get_dos())

ax.plot(xvalues/ T_CST, dos_values)


Out[103]:
[<matplotlib.lines.Line2D at 0xaff9674c>]

S Wave

Instantiation


In [104]:
T_CST = 0.25
BCS_PARAMS = {"width":4, "chem_potential": 0.0,
                 "hopping_constant": T_CST, "J_constant": 0.1 * T_CST,
                 "g_constant": 1.0 * T_CST, "delta": 1.0 * T_CST, "use_assaad": True,
                 "uniform_phase": True, "temperature": 25}
MY_MODEL = SWaveModel(BCS_PARAMS)

Modification


In [105]:
BCS_PARAMS = {"width":15, "use_assaad": True,
                 "uniform_phase": False,  "temperature": 1.75*250.0,
                 "J_constant": 0.112 * T_CST, "g_constant": 3.3 * T_CST}
MY_MODEL.set_params(BCS_PARAMS)
print MY_MODEL._uniform_phase
#print MY_MODEL._use_assaad
#print MY_MODEL._hamiltonian
#print MY_MODEL._eigen_values
#print MY_MODEL._unitary_matrix
#print MY_MODEL.d1phase_array


False

In [106]:
print MY_MODEL
print "temp: ", K_to_meV(MY_MODEL.temperature), "meV"


Class: <class 'phase_fluctuations.SWaveModel'>
Seed: 1234567890
Uniform phase: False
Temperature: 437.5 K

Base class:
Class: <class 'phase_fluctuations.SWaveModel'>
broadening delta: 0.0025 eV
use Assad: True
is up to date: False

Lattice: 
Class: <class 'phase_fluctuations.PairingParams'>
J constant: 0.028 eV
U constant: -0.825 eV
g constant: 0.825 eV
delta: 0.25 eV

Base class:
Class: <class 'phase_fluctuations.PairingParams'>
Width: 15
Chemical potential: 0.0 eV
Hopping constant: 0.25 eV
Number of sites: 
225
temp:  37.70082925 meV

In [107]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)

x_axis_ampl = 4.5
nb_ticks = min(1001, max(101, 1 + MY_MODEL.lattice.n_sites))
xvalues = np.linspace(-x_axis_ampl, x_axis_ampl, nb_ticks, endpoint=True)

#ymin = 0.0
#ymax = 0.5
xmin = -x_axis_ampl
xmax = x_axis_ampl

ax.set_xlim([xmin, xmax])
#ax.set_ylim([0.0, 1.0])
ax.set_xticks(np.linspace(int(xmin), int(xmax), 9,endpoint=True))
#ax.set_yticks(np.linspace(xmin, xmax, 5,endpoint=True))
#ax.set_xticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])
#ax.set_yticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])

dos_values = np.real(MY_MODEL.get_dos())

ax.plot(xvalues / T_CST, dos_values)


Out[107]:
[<matplotlib.lines.Line2D at 0xaff7d66c>]

In [108]:
print MY_MODEL._use_assaad
#print MY_MODEL._eigen_values
#print MY_MODEL._hamiltonian


True

In [109]:
#T_CST = 1.0
BCS_PARAMS = {"width":15}
MY_MODEL.set_params(BCS_PARAMS)
print MY_MODEL._uniform_phase
#print MY_MODEL._use_assaad
#print MY_MODEL._hamiltonian
#print MY_MODEL._eigen_values
#print MY_MODEL._unitary_matrix
#print MY_MODEL.d1phase_array


False

MC Driver

Instantiation


In [110]:
MC_Params = {"seed": 222315, "intervals": 100,
             "target_snapshots": 10}
MY_DRIVER = MCMCDriver(MY_MODEL, MC_Params)

Modification


In [111]:
MC_PARAMS = {"intervals": 100,
             "target_snapshots": 20}
MY_DRIVER.set_params(MC_PARAMS)
print MY_MODEL._uniform_phase


False

In [112]:
print MY_DRIVER
print MY_DRIVER.params


Class: <class 'MCMC.MCMCDriver'>
Seed: 222315
Intervals: 100
Target snapshots: 20
Observable list: []

MC Object:
Class: <class 'phase_fluctuations.SWaveModel'>
Seed: 1234567890
Uniform phase: False
Temperature: 437.5 K

Base class:
Class: <class 'phase_fluctuations.SWaveModel'>
broadening delta: 0.0025 eV
use Assad: True
is up to date: False

Lattice: 
Class: <class 'phase_fluctuations.PairingParams'>
J constant: 0.028 eV
U constant: -0.825 eV
g constant: 0.825 eV
delta: 0.25 eV

Base class:
Class: <class 'phase_fluctuations.PairingParams'>
Width: 15
Chemical potential: 0.0 eV
Hopping constant: 0.25 eV
Number of sites: 
225

Results: None
{'intervals': 100, 'seed': 222315, 'target_snapshots': 20}

In [113]:
MY_DRIVER.mc_object.temperature = 150

In [114]:
MY_DRIVER.thermalize(20000)

In [115]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)

x_axis_ampl = 4.5
nb_ticks = min(1001, max(101, 1 + MY_MODEL.lattice.n_sites))
xvalues = np.linspace(-x_axis_ampl, x_axis_ampl, nb_ticks, endpoint=True)

#ymin = 0.0
#ymax = 0.5
xmin = -x_axis_ampl
xmax = x_axis_ampl

ax.set_xlim([xmin, xmax])
#ax.set_ylim([0.0, 1.0])
ax.set_xticks(np.linspace(int(xmin), int(xmax), 9,endpoint=True))
#ax.set_yticks(np.linspace(xmin, xmax, 5,endpoint=True))
#ax.set_xticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])
#ax.set_yticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])

dos_values = np.real(MY_DRIVER.compute_average_dos())

ax.plot(xvalues/T_CST, dos_values)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-115-b5f45fc213ea> in <module>()
     17 #ax.set_yticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])
     18 
---> 19 dos_values = np.real(MY_DRIVER.compute_average_dos())
     20 
     21 ax.plot(xvalues/T_CST, dos_values)

AttributeError: 'MCMCDriver' object has no attribute 'compute_average_dos'

In [7]:
#300K
temps = [150, 225, 300, 450, 600, 1000]
names = ['../Source/result_' + str(temp)+'.txt' for temp in temps]
input_files = [np.loadtxt(name) for name in names]

In [8]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)

x_axis_ampl = 4.2
nb_ticks = 1001
xvalues = np.linspace(-x_axis_ampl*0.25, x_axis_ampl*0.25, nb_ticks, endpoint=True)

#ymin = 0.0
#ymax = 0.5
xmin = -x_axis_ampl
xmax = x_axis_ampl

ax.set_xlim([xmin, xmax])
ax.set_ylim([0.0, 2.0])
ax.set_xticks(np.linspace(int(xmin), int(xmax), 9,endpoint=True))
#ax.set_yticks(np.linspace(xmin, xmax, 5,endpoint=True))
#ax.set_xticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])
#ax.set_yticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])


for i in range(len(input_files)):
    ax.plot(xvalues/ 0.25, input_files[i], ls = '-', label = str(temps[i]))

ax.legend(loc=2)
plt.savefig("DOS.pdf")



In [9]:
#200K
out = np.loadtxt('result.txt')

In [10]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)

x_axis_ampl = 4.2
nb_ticks = 1001
xvalues = np.linspace(-x_axis_ampl*0.25, x_axis_ampl*0.25, nb_ticks, endpoint=True)

#ymin = 0.0
#ymax = 0.5
xmin = -x_axis_ampl
xmax = x_axis_ampl

ax.set_xlim([xmin, xmax])
#ax.set_ylim([0.0, 1.0])
ax.set_xticks(np.linspace(int(xmin), int(xmax), 9,endpoint=True))
#ax.set_yticks(np.linspace(xmin, xmax, 5,endpoint=True))
#ax.set_xticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])
#ax.set_yticklabels(['%1.1f'  %elem for elem in np.linspace(xmin, xmax,5,endpoint=True)])

ax.plot(xvalues/ 0.25, out)


Out[10]:
[<matplotlib.lines.Line2D at 0x2e198d0>]

In [ ]: