In [1]:
!pwd
In [1]:
# ---------- for python2
from __future__ import print_function
from __future__ import division
In [2]:
# ---------- import
import pickle
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
%matplotlib inline
In [3]:
# ---------- setting for plot
plt.rcParams['pdf.fonttype'] = 42 # embed fonts in PDF using type42 (True type)
In [4]:
# ---------- If you don't use seaborn, comment out this cell
import seaborn as sns
sns.set_style('whitegrid', {'axes.edgecolor': 'black', 'axes.linewidth': 1.5})
sns.set_context('talk', font_scale=2.0)
#sns.set_palette('deep')
sns.set_palette("dark")
In [20]:
def load_rslt():
with open('./pkl_data/rslt_data.pkl', 'rb') as rdata:
rslt_data = pickle.load(rdata, encoding='latin1') # encoding='latin1' was added by fang
return rslt_data
In [9]:
!ls pkl_data
In [16]:
rslt_data = load_rslt()
# ---------- sort by Energy
rslt_data.sort_values(by=['Energy']).head(10)
Out[16]:
In [17]:
# ---------- Number of structures
ndata = len(rslt_data)
print('Number of data: {}'.format(ndata))
# ---------- check success and error
nsuccess = rslt_data['Energy'].count()
nerror = ndata - nsuccess
print('Success: {}'.format(nsuccess))
print('Error: {}'.format(nerror))
# ---------- minimum
Emin = rslt_data['Energy'].min()
print('Emin: {} eV'.format(Emin))
# ---------- magmom (absolute value)
magmom = np.abs(rslt_data['Magmom'])
magmax = magmom.max()
In [18]:
# ---------- figure
plt.figure(figsize=(10, 6))
# ---------- axis
plt.xlim([-2, ndata+2])
plt.ylim([-1, 20])
# ---------- hline at zero
plt.hlines(0.0, -2, 5000, 'k', '--')
# ---------- plot
plt.plot(rslt_data['Struc_ID'], rslt_data['Energy'] - Emin, 'o', ms=15, mew=2.0, alpha=0.6)
# ---------- title and label
#plt.title('Random search for Si$_{8}$')
plt.xlabel('Number of trials')
plt.ylabel('Energy (eV/cell)')
# ---------- save figure
#plt.savefig('Si8_RS.png', bbox_inches='tight') # PNG
#plt.savefig('Si8_RS.png', bbox_inches='tight', dpi=300) # high dpi PNG
#plt.savefig('Si8_RS.pdf', bbox_inches='tight') # PDF
Out[18]:
In [19]:
# ---------- plot
plt.xlim([0, magmax+2])
plt.ylim([-5, 30])
plt.plot(magmom, rslt_data['Energy'] - Emin, 'ob', ms=15, mew=1.5, alpha=0.5)
# ---------- title and label
plt.title('Random search for Y$_2$Co$_{17}$')
plt.xlabel('Magnetic moment ($\mu_\mathrm{B}$/cell)')
plt.ylabel('Energy (eV/cell)')
# ---------- save figure
#plt.savefig('Y2Co17_E_mag.png', bbox_inches='tight') # PNG
#plt.savefig('Y2Co17_E_mag.png, bbox_inches='tight', dpi=300) # PNG high dpi
#plt.savefig('Y2Co17_E_mag.pdf', bbox_inches='tight') # PDF
In [ ]: