In [ ]:
%load_ext aiida
In [ ]:
from aiida import load_profile
import aiida.orm as orm
import sisl
import numpy as np
import matplotlib.pyplot as plt

Initialisation¶

In [ ]:
profile = 'BdG'   # Modify to match name of profile archive was imported into
load_profile(profile)
In [ ]:
(oldwidth, oldheight) = plt.rcParams['figure.figsize']
In [ ]:
plt.rcParams['figure.figsize'] = (2*oldwidth, 2*oldheight)
plt.rcParams.update({'font.size': 32})
In [ ]:
plt.style.use('seaborn-v0_8-deep')
In [ ]:
axes_linewidth = 6
plot_linewidth = 3
plot_markersize = 15

Plots¶

In [ ]:
def get_pdos(node):
    with node.outputs.retrieved.open('aiida.PDOS.xml') as fh:
        geom, E, PDOS = sisl.get_sile_class('PDOS.xml')(fh).read_data()
    return geom, E, PDOS
In [ ]:
def collect_from_aiida_iterator(root_node, func, container='array', dtype=float, ignore_failed=False):
    """Collect results from AiiDA iterator workflow by applying func to each workflow node"""

    if isinstance(root_node, orm.WorkChainNode):
        node_list = root_node.called
    elif isinstance(root_node, list):
        node_list = root_node
    else:
        raise ValueError('First argument should be WorkChainNode or list!')
    
    # Setup container to store results
    n = len(node_list)
    idx_okay = np.full(n, True, dtype=bool)
    if container == 'array':
        res = np.empty(n, dtype=dtype)
    else:
        res = [None]*n

    # Collect results
    for i in range(n):
        try:
            res[i] = func(node_list[i])
        except Exception as e:
            print(e)
            res[i] = np.nan
            idx_okay[i] = False

    if not np.all(idx_okay):
        return res, idx_okay
    else:
        return res
In [ ]:
bulk_Nb_fixeddelta_pdos_model_different_Delta1 = orm.load_node(uuid='1ccd750d-5ee4-4d3b-a4b0-0fa61f3ef8e2')
bulk_Nb_fixeddelta_pdos_model_different_Delta1b = orm.load_node(uuid='8da3e68b-ebfb-4a2c-b6ec-fa2e843b5949')
bulk_Nb_oneshot_pdos_model_different_Delta1a = orm.load_node(uuid='5e477894-fb40-461d-8620-e22686ca5faa')
bulk_Nb_oneshot_pdos_model_different_Delta1b = orm.load_node(uuid='e7a03d85-8070-4588-8019-76744701b947')
In [ ]:
calcnode = bulk_Nb_fixeddelta_pdos_model_different_Delta1
In [ ]:
delta_fixeddelta = collect_from_aiida_iterator(calcnode, lambda node: float(node.inputs.parameters['%block bdgdeltapairingpairing1'].split(' ')[13]))
In [ ]:
pdos_fixeddelta = collect_from_aiida_iterator(calcnode, lambda node: get_pdos(node)[2], dtype=object)
In [ ]:
Es_fixeddelta = collect_from_aiida_iterator(calcnode, lambda node: get_pdos(node)[1], dtype=object)
In [ ]:
idx = np.argsort(delta_fixeddelta)
delta_fixeddelta = delta_fixeddelta[idx]
pdos_fixeddelta = pdos_fixeddelta[idx]
Es_fixeddelta = Es_fixeddelta[idx]
In [ ]:
calcnode = bulk_Nb_fixeddelta_pdos_model_different_Delta1b
In [ ]:
delta_fixeddelta2 = collect_from_aiida_iterator(calcnode, lambda node: float(node.inputs.parameters['%block bdgdeltapairingpairing1'].split(' ')[13]))
In [ ]:
pdos_fixeddelta2 = collect_from_aiida_iterator(calcnode, lambda node: get_pdos(node)[2], dtype=object)
In [ ]:
Es_fixeddelta2 = collect_from_aiida_iterator(calcnode, lambda node: get_pdos(node)[1], dtype=object)
In [ ]:
delta_fixeddelta2 = delta_fixeddelta2[Es_fixeddelta2[1]]
idx = np.argsort(delta_fixeddelta2)
delta_fixeddelta2 = delta_fixeddelta2[idx]
pdos_fixeddelta2 = np.stack(pdos_fixeddelta2[0][Es_fixeddelta2[1]])
pdos_fixeddelta2 = pdos_fixeddelta2[idx]
Es_fixeddelta2 = np.stack(Es_fixeddelta2[0][Es_fixeddelta2[1]])
Es_fixeddelta2 = Es_fixeddelta2[idx]
In [ ]:
delta_fixeddelta = np.concatenate((delta_fixeddelta2, delta_fixeddelta))
pdos_fixeddelta = np.concatenate((pdos_fixeddelta2, np.stack(pdos_fixeddelta)))
Es_fixeddelta = np.concatenate((Es_fixeddelta2, np.stack(Es_fixeddelta)))
In [ ]:
calcnode = bulk_Nb_oneshot_pdos_model_different_Delta1a
In [ ]:
delta_oneshot = collect_from_aiida_iterator(calcnode, lambda node: float(node.inputs.parameters['%block bdgdeltapairingpairing1'].split(' ')[13]))
In [ ]:
pdos_oneshot = collect_from_aiida_iterator(calcnode, lambda node: get_pdos(node)[2], dtype=object)
In [ ]:
Es_oneshot = collect_from_aiida_iterator(calcnode, lambda node: get_pdos(node)[1], dtype=object)
In [ ]:
idx = np.argsort(delta_oneshot)
delta_oneshot = delta_oneshot[idx]
pdos_oneshot = pdos_oneshot[idx]
Es_oneshot = Es_oneshot[idx]
In [ ]:
calcnode = bulk_Nb_oneshot_pdos_model_different_Delta1b
In [ ]:
delta_oneshot2 = collect_from_aiida_iterator(calcnode, lambda node: float(node.inputs.parameters['%block bdgdeltapairingpairing1'].split(' ')[13]))
In [ ]:
pdos_oneshot2 = collect_from_aiida_iterator(calcnode, lambda node: get_pdos(node)[2], dtype=object)
In [ ]:
Es_oneshot2 = collect_from_aiida_iterator(calcnode, lambda node: get_pdos(node)[1], dtype=object)
In [ ]:
delta_oneshot2 = delta_oneshot2[Es_oneshot2[1]]
idx = np.argsort(delta_oneshot2)
delta_oneshot2 = delta_oneshot2[idx]
pdos_oneshot2 = np.stack(pdos_oneshot2[0][Es_oneshot2[1]])
pdos_oneshot2 = pdos_oneshot2[idx]
Es_oneshot2 = np.stack(Es_oneshot2[0][Es_oneshot2[1]])
Es_oneshot2 = Es_oneshot2[idx]
In [ ]:
delta_oneshot = np.concatenate((delta_oneshot2, delta_oneshot))
pdos_oneshot = np.concatenate((pdos_oneshot2, np.stack(pdos_oneshot)))
Es_oneshot = np.concatenate((Es_oneshot2, np.stack(Es_oneshot)))
In [ ]:
dEs = Es_fixeddelta[:,1] - Es_fixeddelta[:,0]
In [ ]:
spin = 0
integrated_differences_total = 100*np.sum(np.abs(np.sum(pdos_fixeddelta[:,spin,:,:], axis=1) - np.sum(pdos_oneshot[:,spin,:,:], axis=1))*dEs.reshape(-1,1), axis=-1) / np.sum(np.sum(pdos_fixeddelta[:,spin,:,:], axis=1)*dEs.reshape(-1,1), axis=-1)
In [ ]:
plt.plot(delta_fixeddelta, integrated_differences_total, 'rs--', linewidth=plot_linewidth, markersize=plot_markersize)
plt.xlabel(r'$\Delta$ [meV]')
plt.ylabel('DOS Integrated Difference [%]')
plt.xscale('log')
ax = plt.gca()
for axis in ['top','bottom','left','right']:
    ax.spines[axis].set_linewidth(axes_linewidth)
#plt.savefig('model-rel-int-diff.pdf', bbox_inches='tight')
plt.show()
In [ ]: