In [1]:
!ipython locate profile
In [2]:
%install_ext https://raw.githubusercontent.com/rasbt/python_reference/master/ipython_magic/watermark.py
%load_ext watermark
In [3]:
import numpy as np
from numpy import linalg as LA
from numpy import array
from numpy import pi
In [120]:
import matplotlib.pyplot as plt
import sys
import math
from scipy.optimize import curve_fit
import pickle
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
def meV_to_K(in_temp):
return in_temp / 1000.0 / cst.physical_constants["Boltzmann constant in eV/K"][0]
def func(x, a, b, c):
return a * np.exp(-b * x) + c
def func_short(x, a, b):
return a * np.exp(-b * x)
def func_combined(x, a, b, d):
return a * np.exp(-b * x) / np.power(x, d)
def func_power(x, a, b):
return a * np.power(x, b)
def func_exponent(x, a, b):
#return a * np.power(x - 290.112982064, b)
return a * np.exp(-np.power(x - 290.112982064, b))
def func_full(x, a, b, c):
return a * np.exp(-np.abs(b) * x) / np.power(x, c)
In [5]:
%load_ext autoreload
%autoreload 2
In [6]:
%who
%matplotlib inline
In [7]:
%watermark -a "Dominique" -d -t -u -v -h -m -g
We pick the following parameters:
This means that we have the following physical properties
In [150]:
Tc_mf = meV_to_K(0.5*250)
print meV_to_K(pi/2.0)
print 1.0/0.89
print cst.physical_constants["Boltzmann constant"]
In [151]:
print '$T_c^{MF} = $', Tc_mf, "K"
T_KT = meV_to_K(0.1*250)
print r"$T_{KT} = $", T_KT, "K"
In [10]:
T_CST = 0.25
BCS_PARAMS = {"width":4, "chem_potential": 0.0,
"hopping_constant": T_CST, "J_constant": 0.1 * T_CST / 0.89,
"g_constant": 0.25, "delta": 1.0 * T_CST, "use_assaad": True,
"uniform_phase": True, "temperature": 100}
MY_DWAVE_MODEL = DWaveModel(BCS_PARAMS)
In [11]:
print MY_DWAVE_MODEL
In [12]:
BCS_PARAMS = {"width":20, "use_assaad": True,
"uniform_phase": True, "temperature": 1.75*145.0}
MY_DWAVE_MODEL.set_params(BCS_PARAMS)
print MY_DWAVE_MODEL
print "temp: ", K_to_meV(MY_DWAVE_MODEL.temperature), "meV"
In [13]:
BCS_PARAMS = {"width":20, "use_assaad": True,
"uniform_phase": False, "temperature": 1.75*145.0}
MY_DWAVE_MODEL.set_params(BCS_PARAMS)
print MY_DWAVE_MODEL._uniform_phase
In [14]:
MC_Params = {"seed": 222315, "intervals": 100,
"target_snapshots": 15, "observable_list":["correlation_length"]}
MY_DRIVER = MCMCDriver(MY_DWAVE_MODEL, MC_Params)
In [15]:
MC_PARAMS_MP = {"intervals": BCS_PARAMS["width"]**2 / 2,
"target_snapshots": 25,
"algorithm":"metropolis"}
MC_PARAMS_CLUSTER = {"intervals": 5,
"target_snapshots": 25,
"algorithm":"cluster"}
MY_DRIVER.set_params(MC_PARAMS_CLUSTER)
print MY_DWAVE_MODEL._uniform_phase
In [16]:
print MY_DRIVER
print MY_DRIVER.params
In [17]:
#MY_DRIVER.mc_object.set_params({"temperature": 2.0 * 145.0})
#MY_DRIVER.thermalize(20000)
MY_DRIVER.mc_object.set_params({"temperature": 1.05 * 290.0 * 1.05 / 1.12})
MY_DRIVER.thermalize(50)
In [18]:
MY_DRIVER.execute()
In [19]:
result = MY_DRIVER.result
data = result.observable_results["correlation_length"]
print data["length_values"]
print data["correlation_values"]
print result
x_data = np.sqrt(data["length_values"])
y_data = data["correlation_values"]
In [20]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)
ymin = 0.0
ymax = 1.0
ax.plot(x_data, y_data)
ax.set_ylim([ymin, ymax])
popt, pcov = curve_fit(func_short, x_data[1:], y_data[1:])
print popt
ax.plot(x_data, func_short(x_data, 2.0*popt[0], 2.0*popt[1]))
print "corr length:", 1.0/popt[1]
In [21]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)
ax.plot(x_data[1:], np.log(y_data[1:]))
ax.plot(x_data[1:], np.log(popt[0]) - popt[1] * x_data[1:])
Out[21]:
In [22]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)
plt.imshow(MY_DRIVER.mc_object.xy_lattice, cmap=plt.cm.hot, interpolation='none')
plt.colorbar()
Out[22]:
In [23]:
#Cf http://matplotlib.org/examples/pylab_examples/quiver_demo.html
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)
plt.quiver(np.cos(MY_DRIVER.mc_object.xy_lattice), np.sin(MY_DRIVER.mc_object.xy_lattice))
Out[23]:
In [24]:
MY_DRIVER.mc_object.make_wolff_step(np.pi/2.0)
In [25]:
dimension = MY_DRIVER.mc_object.xy_lattice.shape[0]
cluster = np.reshape(MY_DRIVER.mc_object.cluster, (dimension, dimension))
plt.imshow(cluster, cmap=plt.cm.hot, interpolation='none')
plt.colorbar()
Out[25]:
In [26]:
print pi
print 5.65226755763 / (2.0 * pi), 3.77251040313 / (2.0 * pi)
In [27]:
neigh = MY_DRIVER.mc_object.lattice.get_neighbors()
In [40]:
results = pickle.load( open( "data_new.txt", "rb" ) )
data = results[0].observable_results["correlation_length"]
In [31]:
datas = {}
temps =np.array([])
for elem in results:
temps = np.append(temps, elem.bcs_params['temperature'])
temps = np.unique(temps)
for temp in temps:
datas[temp] = np.array([elem for elem in results if elem.bcs_params['temperature']==temp])
In [33]:
x_datas = {}
y_datas = {}
for temp in temps:
x_datas[temp] = np.sqrt(datas[temp][0].observable_results["correlation_length"]["length_values"])
y_datas[temp] = np.zeros((x_datas[temp].size))
total_sum = 0
for elem in datas[temp]:
y_datas[temp] +=\
elem.observable_results["correlation_length"]["correlation_values"]
y_datas[temp] /= datas[temp].size
In [127]:
fig, ax = plt.subplots(figsize = (14, 12), dpi=100, frameon=False)
corr_lens = {}
chosen_fun = func_power
for temp in temps[:1]:
x_data = x_datas[temp]
y_data = y_datas[temp]
print temp
ax.plot(x_data, y_data, label=str(temp))
#popt, pcov = curve_fit(func, x_data[0:], y_data[0:])
popt, pcov = curve_fit(chosen_fun, x_data[1:], y_data[1:])
print "temp: ", temp, "params: ", popt, r"$\eta$: ", -popt[1]
corr_lens[temp] = 1.0/popt[1]
ax.plot(x_data, chosen_fun(x_data, popt[0], popt[1]))
chosen_fun = func_full
for temp in temps[1:]:
x_data = x_datas[temp]
y_data = y_datas[temp]
print temp
ax.plot(x_data, y_data, label=str(temp))
#popt, pcov = curve_fit(func, x_data[0:], y_data[0:])
popt, pcov = curve_fit(chosen_fun, x_data[1:], y_data[1:])
print "temp: ", temp, "params: ", popt, "length: ", 1.0/popt[1], 1.0/popt[-1]
corr_lens[temp] = 1.0/popt[1]
ax.plot(x_data, chosen_fun(x_data, popt[0], popt[1], popt[2]))
ax.legend()
plt.savefig("transition.pdf")
In [126]:
fig, ax = plt.subplots(figsize = (14, 12), dpi=100, frameon=False)
x_es = np.sort(np.array(corr_lens.keys()))
y_es = np.array([corr_lens[elem] for elem in x_es])
ax.plot(x_es[1:], y_es[1:])
ax.grid(True)
plt.savefig("corr_length.pdf")
In [125]:
popt, pcov = curve_fit(func_exponent, x_es[1:], y_es[1:])
nu = popt[1]
print "nu", popt[1]
fig, ax = plt.subplots(figsize = (14, 12), dpi=100, frameon=False)
ax.plot(x_es[1:], y_es[1:])
ax.plot(x_es[1:-1], func_exponent(x_es[1:-1], popt[0], popt[1]))
ax.grid(True)
In [93]:
fig, ax = plt.subplots(figsize = (10, 8), dpi=100, frameon=False)
temp = 275.0
x_data = x_datas[temp]
y_data = y_datas[temp]
print x_data.shape
print y_data.shape
print x_es.shape
print data["length_values"].shape
l_values = y_data
popt, pcov = curve_fit(func, x_data, y_data)
ax.plot(np.sqrt(data["length_values"]), np.log(l_values - popt[2]))
ax.plot(np.sqrt(data["length_values"]), np.log(popt[0]) - popt[1] * np.sqrt(data["length_values"]))
Out[93]:
In [128]:
results = pickle.load( open( "dos_alltemps.txt", "rb" ) )
In [129]:
datas = {}
temps =np.array([])
for elem in results:
temps = np.append(temps, elem.bcs_params['temperature'])
temps = np.unique(temps)
for temp in temps:
datas[temp] = np.array([elem for elem in results if elem.bcs_params['temperature']==temp])
In [132]:
print temps
print datas[275.0][0]
In [135]:
x_datas = {}
y_datas = {}
for temp in temps:
x_datas[temp] = datas[temp][0].observable_results["DOS"]["omega_mesh"]
y_datas[temp] = np.zeros((x_datas[temp].size))
total_sum = 0
for elem in datas[temp]:
y_datas[temp] +=\
elem.observable_results["DOS"]["DOS_values"]
y_datas[temp] /= datas[temp].size
In [183]:
fig, ax = plt.subplots(figsize = (8, 14), dpi=100, frameon=False)
#for i in range(len(temps)):
selected_temps = [0,1, 2, 3, 4, 6, 8]
for i in range(len(selected_temps)):
temp = temps[selected_temps[i]]
x_data = x_datas[temp]
y_data = y_datas[temp] + i * 0.7
ax.plot(x_data, y_data, label=(r'T={:3.2f}$T_{{KT}}$').format(temp/T_KT))
ax.legend()
plt.savefig("all_dos.pdf")
In [ ]: