*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 1c841eef authored by Kappl, Patrick's avatar Kappl, Patrick
Browse files

Remove accidentially added plot script from repo

parent a6bb0e55
No related branches found
No related tags found
No related merge requests found
Pipeline #4408 passed with stages
in 1 minute and 24 seconds
# %%
import h5py
import matplotlib.pyplot as plt
from matplotlib import rc
from matplotlib import rcParams
from mpl_toolkits.axes_grid1 import make_axes_locatable
import colorcet as cc
import numpy as np
import os
plt.style.use("default")
# rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
# rc("text", usetex=True)
rcParams["text.usetex"] = True
plt.rcParams['text.latex.preamble'] = [r"""
\usepackage{helvet}
\usepackage[helvet]{sfmath}
"""]
rcParams["legend.fontsize"] = 12
rcParams["font.family"] = "sans-serif"
# %matplotlib inline
# plt.rcParams['text.usetex'] = True
# # plt.rcParams['font.family'] = 'sans-serif'
# # plt.rcParams['font.sans-serif'] = 'ph'
# plt.rcParams['legend.fontsize'] = 12
# %%
directory = "D:/Patrick/02_Studieren/04_Doktorat/Jackknife/DmftRuns"
# file_name = "two_particle_4_worms.hdf5"
# file_name = "U4_b2_w2_n1e5-2019-07-02-Tue-14-55-45.hdf5"
# file_name = "U4_b2_w4_n1e5_2019-18-06-Tue-15-53-26.hdf5"
# file_name = "U4_b2_w8_n1e5-2019-07-02-Tue-13-06-26.hdf5"
# file_name = "U4_b2_w16_n1e5-2019-07-02-Tue-14-56-27.hdf5"
# file_name = "U4_b2_w16_n1e4-2019-07-03-Wed-13-15-39.hdf5"
# file_name = "U4_b2_w16_n1e3-2019-07-03-Wed-14-07-05.hdf5"
# file_name = "U4_b2_w16_n1e5-2019-08-01-Thu-13-32-07.hdf5"
file_name = "U4_b2_w64_n1e5-2019-07-31-Wed-14-25-02.hdf5"
file_path = os.path.join(directory, file_name)
f_g = h5py.File(file_path, "r")
n_worm_groups = f_g[".config"].attrs["general.wormsteps"]
print("n_worm_steps=" + str(n_worm_groups))
worm_groups = [s + "/ineq-001/" for s in f_g.keys()
if (("worm-" in s) and (s != "worm-last"))]
g0s = np.array([f_g[worm_group + "g0iw/value"][...]
for worm_group in worm_groups])
compound_indexes = list(f_g[worm_groups[0] + "g4iw-worm/"].keys())
g4s = []
for worm_group in worm_groups:
g4_groups = [worm_group + "g4iw-worm/" + i + "/value"
for i in compound_indexes]
g4 = np.array([f_g[g4_group][...] for g4_group in g4_groups])
g4s.append(g4)
g4s = np.array(g4s)
mean_g = np.array(f_g["worm-001/ineq-001/g4iw-worm/00001/value"][...])
error_g = np.array(f_g["worm-001/ineq-001/g4iw-worm/00001/error"][...])
n_nus_g = mean_g.shape[0]
print("n_nus=" + str(n_nus_g))
n_omegas_g = mean_g.shape[2]
print("n_omegas=" + str(n_omegas_g))
f_g.close()
# %%
# Plot real part of 2-particle Green's function from w2dynamics
omega_g = 0
n = n_nus_g // 2
plt.matshow(np.real(mean_g[:, :, omega_g + n_omegas_g//2]), origin="lower",
extent=[-n, n, -n, n])
plt.title(r"$\mathrm{Re}\ G^{(2)}_{\nu,\nu'}(\omega=$" + str(omega_g) + "$)$")
plt.xlabel(r"$\nu$")
plt.ylabel(r"$\nu'$")
plt.colorbar()
ax = plt.gca()
ax.xaxis.set_ticks_position("bottom")
# ax.xaxis.tick_bottom()
# ax.XAxis.set_ticks_postion("bottom")
plt.show()
# %%
# Plot error of the 2-particle Green's function from w2dynamics
omega_g = 0
n = n_nus_g // 2
max_ = np.amax(np.real(mean_g[:, :, omega_g + n_omegas_g//2]))
min_ = np.amin(np.real(mean_g[:, :, omega_g + n_omegas_g//2]))
plt.matshow(error_g[:, :, omega_g + n_omegas_g//2], origin="lower",
extent=[-n, n, -n, n], vmin=min_, vmax=max_)
plt.title(r"$\mathrm{Re}\ G^{(2)}_{\nu,\nu'}(\omega=$" + str(omega_g) + "$)$")
plt.xlabel(r"$\nu$")
plt.ylabel(r"$\nu'$")
plt.colorbar()
ax = plt.gca()
ax.xaxis.set_ticks_position("bottom")
plt.show()
# %%
# Plot a 1D slice of the 2-particle Green's function
omega_g = 0
n = 15
xvalues = [x - n_nus_g//2 + 0.5 for x in range(n_nus_g)]
plt.errorbar(xvalues,
np.real(mean_g[:, n + n_nus_g//2, omega_g + n_omegas_g//2]),
yerr=error_g[:, n + n_nus_g//2, omega_g + n_omegas_g//2],
label="$\\nu={}$".format(n + 0.5), linewidth=1, elinewidth=0.5,
color="red", ecolor="cyan", capsize=1)
plt.xlabel(r"$\nu'$", fontsize=12)
plt.ylabel(r"$\mathrm{Re}\ G^{(2)}$", fontsize=12)
plt.title("$\\omega={}$".format(omega_g))
plt.axhline(linewidth=0.5)
plt.axvline(linewidth=0.5)
plt.legend()
plt.show()
# %%
# Plot a 1D slice of the errors of the 2-particle Green's function
omega_g = 0
n = 0
xvalues = [x - n_nus_g//2 + 0.5 for x in range(n_nus_g)]
plt.plot(xvalues, error_g[:, n + n_nus_g//2, omega_g + n_omegas_g//2], "x-",
color="red", label="$\\nu={}$".format(n + 0.5))
plt.xlabel(r"$\nu'$", fontsize=12)
plt.ylabel(r"$\Delta G^{(2)}$", fontsize=12)
plt.title("$\\omega={},\\ Nmeas=1e3$".format(omega_g))
plt.axhline(linewidth=0.5)
plt.axvline(linewidth=0.5)
plt.legend()
plt.show()
# %%
# Plot covariance matrix of 1P Green's function
n = g0s.shape[-1] // 2
covariance = np.cov(g0s[:, 0, 0, :].T)
# correlation = np.corrcoef(g0s[:,0,0,:].T)
plt.matshow(np.real(covariance), extent=[-n, n, n, -n], cmap=cc.m_kbc_r)
plt.title(r"$\mathrm{Re}\ \mathrm{Cov}(G(\nu),G(\nu'))$")
plt.xlabel(r"$\nu$")
plt.ylabel(r"$\nu'$")
plt.colorbar()
ax = plt.gca()
ax.xaxis.set_ticks_position("bottom")
plt.setp([tick.label1 for tick in ax.xaxis.get_major_ticks()], rotation=60,
ha="right", va="center", rotation_mode="anchor")
plt.show()
# %%
# Plot nu-nu covarinace of 2P Green's function
omega_g = 0
n = n_nus_g // 2
g_slice = np.diagonal(g4s[:, 0, :, :, omega_g + n_omegas_g//2], axis1=1,
axis2=2, offset=0)
covariance = np.cov(g_slice.T)
plt.matshow(np.real(covariance), origin="upper", extent=[-n, n, n, -n],
cmap=cc.m_kbc_r)
plt.title(r"$\mathrm{Re}\ \mathrm{Cov}(G^{2}(0,\nu,\nu),G^{2}(0,\nu',\nu'))$")
plt.xlabel(r"$\nu$")
plt.ylabel(r"$\nu'$")
plt.colorbar()
ax = plt.gca()
ax.xaxis.set_ticks_position("bottom")
plt.show()
# %%
# Plot nu-nu correlation of 2P Green's function
def plot_real_nu_nu_correlation_of_2p_greens_function(fig_name=None):
omega_g = 0
n = n_nus_g // 2
g_slice = np.diagonal(g4s[:, 0, :, :, omega_g + n_omegas_g//2], axis1=1,
axis2=2, offset=0)
correlation = np.corrcoef(g_slice.T)
plt.figure(figsize=cm2inch(16, 12))
# plt.matshow(np.real(correlation), origin="upper", extent=[-n, n, n, -n],
# vmin=-1, vmax=1, cmap="seismic")
# plt.pcolormesh(range(-n_nus_g//2, n_nus_g//2 + 1),
# range(-n_nus_g//2, n_nus_g//2 + 1), np.real(correlation),
# vmin=-1, vmax=1, cmap="seismic")
plt.imshow(np.real(correlation), vmin=-1, vmax=1, cmap="seismic",
extent=[-n, n, n, -n])
# plt.title(r"$\mathrm{Re}\ \mathrm{Corr}(G^{2}(0,\nu,\nu),G^{2}$" +
# r"$(0,\nu',\nu'))$")
plt.xlabel(r"$\nu$ High", fontsize=16)
plt.ylabel(r"$\nu'$", fontsize=16)
ax = plt.gca()
# ax.xaxis.set_ticks_position("bottom")
ax.tick_params(axis="both", which="major", labelsize=16)
# plt.colorbar()
divider = make_axes_locatable(plt.gca())
cax = divider.append_axes("right", "5%", pad="3%")
plt.colorbar(cax=cax)
# ax.axis("tight")
# plt.colorbar(use_gridspec=True)
plt.tight_layout()
if fig_name is None:
plt.show()
else:
plt.savefig(fig_name, bbox_inches="tight", pad_inches=0)
return
# %%
plt.close('all')
arr = np.arange(100).reshape((10, 10))
fig = plt.figure(figsize=(4, 4))
im = plt.imshow(arr)
divider = make_axes_locatable(plt.gca())
cax = divider.append_axes("right", "5%", pad="3%")
plt.colorbar(im, cax=cax)
plt.tight_layout()
# %%
def cm2inch(*tupl):
inch = 2.54
if isinstance(tupl[0], tuple):
return tuple(i/inch for i in tupl[0])
else:
return tuple(i/inch for i in tupl)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment