Figure 5 - anomalous density vs layer¶

In [1]:
%load_ext autoreload
%autoreload 2
%matplotlib inline

from aiida import load_profile
load_profile()

from aiida.orm import load_node
import numpy as np
import matplotlib.pyplot as plt
In [6]:
size_axis_labels = 20
size_tick_labels = 18
size_legend = 20
size_plabel = 24

# single column figure: width = 10
# double column = width=20
In [2]:
calc_conv = load_node('8339cb63-71f8-42da-b45f-594a319a5934') # unrelaxed (21 layer)
dos_PBE21 = load_node('088a45d5-cbb9-4c13-b9ce-0c5b15b374ac') # DOS for unrelaxed 21 layer
calc_conv2 = load_node('4cca4380-324c-4ec3-9e4a-c8f38122237e') # unrelaxed with surface phonon softening
calc_conv3 = load_node('4bdfc8d3-f414-40c5-8c79-48c14db19bab') # relaxed


def get_delta(node, verbose=False):
    from aiida_kkr.tools.plot_kkr import get_rms_kkrcalc_from_remote
    try:
        _, _, _, _, res = get_rms_kkrcalc_from_remote(node, **{'l-independent delta:': None})
        d = np.array(res['l-independent delta:'])
    except ValueError:
        from masci_tools.io.common_functions import search_string
        d = []
        if node.is_finished:
            with node.outputs.retrieved.open('out_kkr') as f:
                txt = f.readlines()
                itmp = search_string('l-independent delta:', txt)
                while itmp>=0:
                    d.append(float(txt.pop(itmp).split()[-1]))
                    itmp = search_string('l-independent delta:', txt)
                d = np.array(d)
    if verbose:
        print('Delta=', d)
    if len(d)==0:
        print('no Delta values')
        d = []
    return d * 13.6*1000 * 10

# extract delta values
deltas = get_delta(calc_conv)[:-1].reshape(-1, 21) 
deltas2 = get_delta(calc_conv2)[:-1].reshape(-1, 21)
deltas3 = get_delta(calc_conv3)[:-1].reshape(-1, 21)
In [27]:
plt.figure(figsize=(10, 10))

plt.subplot(2,1,1)

means = []

plt.plot(deltas[-1,:11], 'o-', label='constant $\lambda$', lw=3 ,ms=10)
# plt.legend(fontsize='xx-large')
plt.ylabel('$\overline{\chi}$ (a.u.)', fontsize=size_axis_labels, labelpad = 10)
plt.xticks(range(11), [f'' for i in range(1,12)])
plt.yticks([0.88, 0.92, 0.96, 1.0, 1.04], fontsize=size_tick_labels)

def add_dos(ylim=None):
    plt.twinx()
    for i, (dos, name, ls) in enumerate(zip([dos_PBE21],
                                        ['21 Nb(110)'],
                                        ['s--']
                                       )):
        xlbl, x, xunit = dos.outputs.dos_data_interpol.get_x(); x = x[0]
        ix0 = np.where(abs(x)==abs(x).min())[0][0]
        ylbl, y, yunit = dos.outputs.dos_data_interpol.get_y()[0]
        plt.plot(y[:len(y)//2+1,ix0][3:], ls, ms=10, lw=4, color='grey', label=name)    
    plt.ylabel('DOS @ $E_\mathrm{F}$ (1/eV)', fontsize=size_axis_labels, rotation=270, labelpad = 25,)
    plt.yticks([1.2, 1.3, 1.4, 1.5, 1.6], fontsize=size_tick_labels)
    if ylim is not None:
        plt.ylim(ylim[0], ylim[1])

add_dos([1.2, 1.65])
plt.annotate(xy = (9.2, 1.465), xytext=(8.2, 1.465), arrowprops=dict(arrowstyle="->, head_width=0.5", lw=4, color='grey', ), text='')
plt.annotate(xy = (2.5, 1.57), xytext=(1.5, 1.57), arrowprops=dict(arrowstyle="<-, head_width=0.5", color='C0', lw=4, ), text='')

plt.subplot(2,1,2)
plt.plot(deltas[-1,:11], '^-', label='unrelaxed ($\lambda=1.21\,\mathrm{eV}$)', lw=3 ,ms=10)
means.append(np.mean(deltas[-1,:11]))
# plt.axhline(means[-1], lw=3 ,ls='-', color='C0')

# variable lambda
plt.plot(deltas2[-1,:11], 's--' , label='unrelaxed, variable $\lambda$ ($\lambda_0=1.15\,\mathrm{eV}$)', lw=3 ,ms=10)

means.append(np.mean(deltas[-1,:11]))
# plt.axhline(means[-1], lw=3 ,ls='--', color='C1')

# relaxed
plt.plot(deltas3[-1,:11], 'o-' , label='relaxed ($\lambda=1.23\,\mathrm{eV}$)', lw=3 ,ms=10)
means.append(np.mean(deltas[-1,:11]))
# plt.axhline(means[-1], lw=3 ,ls='--', color='C2')

#1.15309583424 1.2085712351999998 1.1095080191999995 1.2269771807327998

# bulk
plt.axhline(0.98945, ls=':', lw=3, color='grey', label='bulk ($\lambda=1.11\,\mathrm{eV}$)') # bulk lambda


plt.ylabel('$\overline{\chi}$ (a.u.)', fontsize=size_axis_labels, labelpad = 10)
plt.legend(fontsize=size_legend)
plt.ylim(0.7, 1.9)
plt.xticks(range(11), [f'{i}' for i in range(1,12)], fontsize=size_tick_labels)
plt.yticks([0.8, 1.0, 1.2, 1.4, 1.6, 1.8], fontsize=size_tick_labels)
plt.xlabel('layer index', fontsize=size_axis_labels, labelpad = 12)

plt.tight_layout()
plt.subplots_adjust(hspace=0.05, )

plt.annotate(xycoords='figure fraction', xy = (0.11, 0.01), text='surface', fontsize=size_tick_labels, weight="bold")
plt.annotate(xycoords='figure fraction', xy = (0.82, 0.01), text='center', fontsize=size_tick_labels, weight="bold")

plt.annotate(xycoords='figure fraction', xy = (0.005, 0.97), text='(a)', fontsize=size_plabel, weight="bold")
plt.annotate(xycoords='figure fraction', xy = (0.005, 0.5), text='(b)', fontsize=size_plabel, weight="bold")



plt.savefig('Fig5.png', dpi=150)
plt.savefig('Fig5.pdf')

plt.show()
No description has been provided for this image
In [ ]: