Exemplo n.º 1
0
def basis_convergence(root):
    # Settings
    species = ['zr', 'o']
    l_max_pairs = [{
        'zr': 4,
        'o': 3
    }, {
        'zr': 5,
        'o': 4
    }, {
        'zr': 6,
        'o': 5
    }, {
        'zr': 7,
        'o': 6
    }]
    gw_settings = GWInput(taskname="g0w0",
                          nempty=2000,
                          ngridq=[2, 2, 2],
                          skipgnd=False,
                          n_omega=32,
                          freqmax=1.0)

    data = process_gw_calculations(root, species, l_max_pairs, gw_settings)

    # TODO API for generating basis labels needs to change
    l_max_values = [
        OrderedDict([('zr', 4), ('o', 3)]),
        OrderedDict([('zr', 5), ('o', 4)]),
        OrderedDict([('zr', 6), ('o', 5)]),
        OrderedDict([('zr', 7), ('o', 6)])
    ]

    energy_indices = ['i0', 'i1', 'i2', 'i3', 'i4', 'i5', 'i6']
    energy_cutoff = [80, 100, 120, 150, 180, 200, 250]

    settings = {
        'rgkmax': 8,
        'l_max_values': l_max_values,
        'n_img_freq': 32,
        'q_grid': [2, 2, 2],
        'n_empty_ext': [2000] * len(l_max_values),
        # Extensions, not energies
        'max_energy_cutoffs': energy_indices
    }

    # Post-process
    basis_labels = get_basis_labels(root, settings)

    plot_data(l_max_pairs, data, basis_labels)
    print_results(data, energy_cutoff, '(4,3)')
    print_results(data, energy_cutoff, '(5,4)')
    print_results(data, energy_cutoff, '(6,5)')
    print_results(data, energy_cutoff, '(7,6)')
    plot_65_data(data, basis_labels)

    return
Exemplo n.º 2
0
def basis_convergence(root):
    """
    Main routine for plotting basis convergence
    :param root:
    :return:
    """
    # Settings
    species = ['zr', 'o']
    l_max_pairs = [{'zr': 6, 'o': 5}, {'zr': 7, 'o': 6}]
    gw_settings = GWInput(taskname="g0w0",
                          nempty=3000,
                          ngridq=[2, 2, 2],
                          skipgnd=False,
                          n_omega=32,
                          freqmax=1.0)

    data = process_gw_calculations(root, species, l_max_pairs, gw_settings)

    # TODO API for generating basis labels needs to change
    l_max_values = [
        OrderedDict([('zr', 6), ('o', 5)]),
        OrderedDict([('zr', 7), ('o', 6)])
    ]

    energy_indices = ['i0', 'i1', 'i2', 'i3', 'i4', 'i5']
    energy_cutoffs = [80, 100, 120, 150, 180, 200]

    settings = {
        'rgkmax': 8,
        'l_max_values': l_max_values,
        'n_img_freq': 32,
        'q_grid': [2, 2, 2],
        'n_empty_ext': [gw_settings.nempty] * len(l_max_values),
        # Extensions, not energies
        'max_energy_cutoffs': energy_indices
    }

    # Post-process
    basis_labels = get_basis_labels(root, settings)

    print_results(data, energy_cutoffs, '(6,5)')
    print_results(data, energy_cutoffs, '(7,6)')

    # Plot just for set 9
    # plot_data(l_max_pairs, data, basis_labels)
    plot_65_data(data, basis_labels)
    quit()

    # Plot for set 8 and set 9
    set8_data = get_set8_data()
    plot_data_for_set8_and_set9(set8_data, data)

    return
Exemplo n.º 3
0
def gw_basis_convergence(root: str):
    """
    Plot the quasi particle - KS gap w.r.t bs LO basis, for l-max = (4, 3)
    """
    D = OrderedDict

    info = """  Converge QP gap w.r.t the s-channel LOs of Zr
    """

    print(info)

    lmax_32 = 0
    plot_delta_E_qp = True
    plot_sigma = False
    save_plots = False

    max_energy_exts_set4_spd = ['i0', 'i1', 'i2', 'i3']  # 'i4'

    settings_set4_spd = {'rgkmax': 8,
                         'l_max_values': [D([('zr', 3), ('o', 2)])],
                         'n_img_freq': 32,
                         'q_grid': [2, 2, 2],
                         'n_empty_ext': [2000],
                         'max_energy_cutoffs': max_energy_exts_set4_spd
                        }

    # S out of core
    data_set4 = parse_gw_results(root, settings_set4_spd)
    delta_E_qp_set4 = data_set4['delta_E_qp'][:, lmax_32] * ha_to_mev
    E_qp_set4 = data_set4['E_qp'][:, lmax_32] * ha_to_mev
    E_ks_set4 = data_set4['E_ks'][:, lmax_32] * ha_to_mev


    basis_labels = get_basis_labels(root, settings_set4_spd, verbose=True)
    basis_labels_set4 = combine_species_basis_labels(basis_labels, species_per_line=True)['(3,2)']
    n_los_set4 = n_local_orbitals(basis_labels)['(3,2)']

    # Give some changes in QP gap w.r.t. calculations
    print('s out of core')
    print('KS:', E_ks_set4)
    print('QP:', E_qp_set4)
    print('QP-KS:', delta_E_qp_set4)
    process_basis_numbers(delta_E_qp_set4, basis_labels_set4)

    # Total number of LOs per calculation (i.e. sum Zr and O basis sizes together)
    n_los_set4 = sum_los_per_species(n_los_set4)

    # S in core
    data_set4_in_core = parse_gw_results(root, settings_set4_spd, dir_prefix='s_in_core_')
    delta_E_qp_s_core = data_set4_in_core['delta_E_qp'][:, lmax_32] * ha_to_mev
    E_qp_set4_s_core = data_set4_in_core['E_qp'][:, lmax_32] * ha_to_mev
    E_ks_set4_s_core = data_set4_in_core['E_ks'][:, lmax_32] * ha_to_mev

    print('s in core')
    print('KS:', E_ks_set4_s_core)
    print('QP:', E_qp_set4_s_core)
    print('QP-KS:', delta_E_qp_s_core)
    quit()


    # --------------------------------------
    # QP vs LO basis size, for l-max = (4,3)
    # --------------------------------------
    if plot_delta_E_qp:

        fig, ax = plt.subplots()
        ax.set_xlabel('N LOs')
        ax.set_ylabel('Quasiparticle Gap - KS Gap at Gamma (meV)')

        ax.plot(n_los_set4, delta_E_qp_set4, color='blue', marker='o', markersize=8)
        for i, txt in enumerate(basis_labels_set4):
           ax.annotate(txt, (n_los_set4[i], delta_E_qp_set4[i]))

        if save_plots:
            plt.savefig('qp_convergence_lmax43.ps', dpi=300, facecolor='w', edgecolor='w',
                        orientation='portrait', papertype=None, transparent=True, bbox_inches=None, pad_inches=0.1)
        plt.show()


    # ----------------------------------------------------------------------
    # Plot VBT and CBB real self-energies w.r.t. LO energy cut-off
    # for set 3, only
    # ----------------------------------------------------------------------
    if plot_sigma:
        print("Requires rewriting")
        pass
        # # What we expect: VBT converges with the oxygen LOs, and is well-converged
        # re_self_energy_VBM = data_set4['re_self_energy_VBM'][:, lmax_32] * ha_to_mev
        # fig, ax = plt.subplots()
        #
        # fig.set_size_inches(12, 10)
        # plt.rcParams.update({'font.size': 11})
        # ax.tick_params(axis='both', which='major', labelsize=14)
        #
        # ax.set_xlim(82, 120)
        # ax.set_xlabel('N LOs', fontsize=16)
        # ax.set_ylabel('Re{Self Energy} at VBM (meV)', fontsize=16)
        # ax.plot(n_los_set4, re_self_energy_VBM, 'ro', markersize=10)
        # for i, txt in enumerate(basis_labels_set4):
        #     ax.annotate(txt, (n_los_set4[i], re_self_energy_VBM[i]))
        #
        # if save_plots:
        #     plt.savefig('VBM_convergence_set3_lmax43.jpeg', dpi=300, facecolor='w', edgecolor='w',
        #                 orientation='portrait', transparent=True, bbox_inches=None, pad_inches=0.1)
        #
        # plt.show()
        #
        # # CBm is strongly dependent on the number of Zr LOs, and is still not converged.
        # re_self_energy_CBm = data_set4['re_self_energy_CBm'][:, lmax_32] * ha_to_mev
        # fig, ax = plt.subplots()
        #
        # fig.set_size_inches(12, 10)
        # plt.rcParams.update({'font.size': 11})
        # ax.tick_params(axis='both', which='major', labelsize=14)
        #
        # ax.set_xlim(82, 120)
        # ax.set_xlabel('N LOs', fontsize=16)
        # ax.set_ylabel('Re{Self Energy} at CBm (meV)', fontsize=16)
        # ax.plot(n_los_set4, re_self_energy_CBm, 'ro', markersize=10)
        # for i, txt in enumerate(basis_labels_set4):
        #     ax.annotate(txt, (n_los_set4[i], re_self_energy_CBm[i]))
        #
        # if save_plots:
        #     plt.savefig('CBm_convergence_set3_lmax43.jpeg', dpi=300, facecolor='w', edgecolor='w',
        #                 orientation='portrait', transparent=True, bbox_inches=None, pad_inches=0.1)
        #
        # plt.show()

    return
Exemplo n.º 4
0
def gw_basis_convergence(root: str):
    """
    Plot the quasi particle - KS gap w.r.t bs LO basis, for l-max = (4, 3)
    """
    D = OrderedDict

    info = """ Highest d-states are removed from the core and put into the valence.
    i10 is ~ converged for all O and all but the p-channel of Zr.
    As such, i12 - 18 attempt to converge the p-channel.
    Quasi-particle gaps shows a linear decrease as N LOs in the p-channel are increased.
    This was witnessed in the d-channel prior to removing semi-core d-states, hence set_pd will remove 
    semi-core p-states.
    i 18 falls off a cliff, hence excluded.
    """
    print(info)

    lmax_32 = 0
    plot_delta_E_qp = True
    plot_sigma = False
    save_plots = False

    # The drop in energy for i18 is enormous
    max_energy_exts_set4 = [
        'i0', 'i1', 'i8', 'i12', 'i13', 'i14', 'i15', 'i16', 'i17'
    ]

    settings_set4 = {
        'rgkmax': 8,
        'l_max_values': [D([('zr', 3), ('o', 2)])],
        'n_img_freq': 32,
        'q_grid': [2, 2, 2],
        'n_empty_ext': [2000],
        'max_energy_cutoffs': max_energy_exts_set4
    }

    data_set4 = parse_gw_results(root, settings_set4)
    delta_E_qp_set4 = data_set4['delta_E_qp'][:, lmax_32] * ha_to_mev
    basis_labels = get_basis_labels(root, settings_set4)
    basis_labels_set4 = combine_species_basis_labels(
        basis_labels, species_per_line=True)['(3,2)']
    n_los_set4 = n_local_orbitals(basis_labels)['(3,2)']

    # Give some changes in QP gap w.r.t. calculations
    print(delta_E_qp_set4)
    process_basis_numbers(delta_E_qp_set4, basis_labels_set4)

    # Total number of LOs per calculation (i.e. sum Zr and O basis sizes together)
    n_los_set4 = sum_los_per_species(n_los_set4)

    # --------------------------------------
    # QP vs LO basis size, for l-max = (4,3)
    # --------------------------------------
    if plot_delta_E_qp:

        fig, ax = plt.subplots()
        ax.set_xlabel('N LOs')
        ax.set_ylabel('Quasiparticle Gap - KS Gap at Gamma (meV)')

        ax.plot(n_los_set4,
                delta_E_qp_set4,
                color='blue',
                marker='o',
                linestyle='solid',
                linewidth=3,
                markersize=8)
        for i, txt in enumerate(basis_labels_set4):
            ax.annotate(txt, (n_los_set4[i], delta_E_qp_set4[i]))

        if save_plots:
            plt.savefig('qp_convergence_lmax43.ps',
                        dpi=300,
                        facecolor='w',
                        edgecolor='w',
                        orientation='portrait',
                        papertype=None,
                        transparent=True,
                        bbox_inches=None,
                        pad_inches=0.1)
        plt.show()

        # Set 3 by itself, where one is primarily looking at the l=2 channel of Zr.
        # for i in range(0, delta_E_qp_set3.size):
        #     print(max_energy_exts_set3[i], delta_E_qp_set3[i])
        #
        # fig, ax = plt.subplots()
        # fig.set_size_inches(12, 10)
        # plt.rcParams.update({'font.size': 11})   # Affects fonts of the labels only
        # ax.tick_params(axis='both', which='major', labelsize=14)
        #
        # ax.set_xlim(80, 125)
        # ax.set_ylim(1580, 1660)
        # ax.set_xlabel('N LOs', fontsize=16)
        # ax.set_ylabel('Quasiparticle Gap - KS Gap at Gamma (meV)', fontsize=16)
        # ax.plot(n_los_set3, delta_E_qp_set3, 'ro', markersize=10)
        # for i, txt in enumerate(basis_labels_set3):
        #     ax.annotate(txt, (n_los_set3[i], delta_E_qp_set3[i]))

        # Note, can use plt. or fig. to save and show
        if save_plots:
            # ALso note that ps cuts off the edges, hence using jpeg
            plt.savefig('qp_convergence_set3_lmax43.jpeg',
                        dpi=300,
                        facecolor='w',
                        edgecolor='w',
                        orientation='portrait',
                        transparent=True,
                        bbox_inches=None,
                        pad_inches=0.1)

        plt.show()

    # ----------------------------------------------------------------------
    # Plot VBT and CBB real self-eneries w.r.t. LO energy cut-off
    # for set 3, only
    # ----------------------------------------------------------------------
    if plot_sigma:

        # What we expect: VBT converges with the oxygen LOs, and is well-converged
        re_self_energy_VBM = data_set4[
            're_self_energy_VBM'][:, lmax_32] * ha_to_mev
        fig, ax = plt.subplots()

        fig.set_size_inches(12, 10)
        plt.rcParams.update({'font.size': 11})
        ax.tick_params(axis='both', which='major', labelsize=14)

        ax.set_xlim(82, 120)
        ax.set_xlabel('N LOs', fontsize=16)
        ax.set_ylabel('Re{Self Energy} at VBM (meV)', fontsize=16)
        ax.plot(n_los_set4, re_self_energy_VBM, 'ro', markersize=10)
        for i, txt in enumerate(basis_labels_set4):
            ax.annotate(txt, (n_los_set4[i], re_self_energy_VBM[i]))

        if save_plots:
            plt.savefig('VBM_convergence_set3_lmax43.jpeg',
                        dpi=300,
                        facecolor='w',
                        edgecolor='w',
                        orientation='portrait',
                        transparent=True,
                        bbox_inches=None,
                        pad_inches=0.1)

        plt.show()

        # CBm is strongly dependent on the number of Zr LOs, and is still not converged.
        re_self_energy_CBm = data_set4[
            're_self_energy_CBm'][:, lmax_32] * ha_to_mev
        fig, ax = plt.subplots()

        fig.set_size_inches(12, 10)
        plt.rcParams.update({'font.size': 11})
        ax.tick_params(axis='both', which='major', labelsize=14)

        ax.set_xlim(82, 120)
        ax.set_xlabel('N LOs', fontsize=16)
        ax.set_ylabel('Re{Self Energy} at CBm (meV)', fontsize=16)
        ax.plot(n_los_set4, re_self_energy_CBm, 'ro', markersize=10)
        for i, txt in enumerate(basis_labels_set4):
            ax.annotate(txt, (n_los_set4[i], re_self_energy_CBm[i]))

        if save_plots:
            plt.savefig('CBm_convergence_set3_lmax43.jpeg',
                        dpi=300,
                        facecolor='w',
                        edgecolor='w',
                        orientation='portrait',
                        transparent=True,
                        bbox_inches=None,
                        pad_inches=0.1)

        plt.show()

    return
Exemplo n.º 5
0
def gw_basis_convergence(root:str):
    """
    Plot the quasipartilce-KS gap w.r.t bs LO basis, for l-max = (4, 3(
    """
    D = OrderedDict

    lmax_43 = 0
    plot_delta_E_qp = True
    plot_sigma = False
    save_plots = False

    # Set 2
    max_energy_exts_set2 = [90, 160, 230, 300]
    settings_set2 =  {'rgkmax': 7,
                      'l_max_values': [D([('zr', 4), ('o', 3)])],
                      'n_img_freq': 32,
                      'q_grid': [2, 2, 2],
                      'n_empty_ext': [1000],
                      'max_energy_cutoffs': max_energy_exts_set2}

    data_set2 = parse_gw_results(root + "/A1_var_cutoff", settings_set2)
    delta_E_qp_set2 = data_set2['delta_E_qp'][:, lmax_43] * ha_to_mev
    basis_labels = get_basis_labels(root + "/A1_var_cutoff", settings_set2)
    basis_labels_set2 = combine_species_basis_labels(basis_labels,  species_per_line=True)['(4,3)']
    n_los_set2 = n_local_orbitals(basis_labels)['(4,3)']

    # Set 3
    # i3 wouldn't work and i7. GW VBT and CBB get f****d up, hence omitted
    #                              i0    i1   i2   i4   i5   i6
    # energy_cutoffs = {'zr': {0: [150, 200, 250, 200, 120, 120],
    #                          1: [150, 200, 250, 200, 120, 120],
    #                          2: [300, 300, 300, 350, 350, 400],
    #                          3: [150, 200, 250, 200, 120, 120],
    #                          4: [150, 200, 250, 200, 120, 120]},
    #
    #                    'o': {0: [150, 200, 250, 200, 120, 120],
    #                          1: [150, 200, 250, 200, 120, 120],
    #                          2: [150, 200, 250, 200, 120, 120],
    #                          3: [150, 200, 250, 200, 120, 120]}
    #                   }

    #max_energy_exts_set3 = ['i0', 'i1', 'i2', 'i4', 'i5', 'i6', 'i7']
    max_energy_exts_set3 = ['i5', 'i6', 'i7']

    settings_set3 = {'rgkmax': 7,
                     'l_max_values': [D([('zr', 4), ('o', 3)])],
                     'n_img_freq': 32,
                     'q_grid': [2, 2, 2],
                     'n_empty_ext': [1000], # Note in some cases, I actually used 2000 in input
                     'max_energy_cutoffs':max_energy_exts_set3 }

    data_set3 = parse_gw_results(root + "/A1_set3", settings_set3)
    delta_E_qp_set3 = data_set3['delta_E_qp'][:, lmax_43] * ha_to_mev
    basis_labels = get_basis_labels(root + "/A1_set3", settings_set3)
    n_los_set3 = n_local_orbitals(basis_labels)['(4,3)']
    basis_labels_set3 = combine_species_basis_labels(basis_labels,  species_per_line=True)['(4,3)']


    # Give some changes in QP gap w.r.t. calculations
    process_basis_numbers(delta_E_qp_set2, max_energy_exts_set2)
    process_basis_numbers(delta_E_qp_set3, max_energy_exts_set3)

    # Total number of LOs per calculation (i.e. sum Zr and O basis sizes together)
    n_los_set2 = sum_los_per_species(n_los_set2)
    n_los_set3 = sum_los_per_species(n_los_set3)

    # --------------------------------------
    # QP vs LO basis size, for l-max = (4,3)
    # --------------------------------------
    if plot_delta_E_qp:

        # Set 2 and 3
        fig, ax = plt.subplots()
        ax.set_xlabel('N LOs')
        ax.set_ylabel('Quasiparticle Gap - KS Gap at Gamma (meV)')

        ax.plot(n_los_set2, delta_E_qp_set2, color='blue', marker='o', linestyle='solid', linewidth=3, markersize=8)
        for i, txt in enumerate(basis_labels_set2):
           ax.annotate(txt, (n_los_set2[i], delta_E_qp_set2[i]))

        ax.plot(n_los_set3, delta_E_qp_set3, 'ro', markersize=8)

        if save_plots:
            plt.savefig('qp_convergence_lmax43.ps', dpi=300, facecolor='w', edgecolor='w',
                        orientation='portrait', papertype=None, transparent=True, bbox_inches=None, pad_inches=0.1)
        plt.show()

        # Set 3 by itself, where one is primarily looking at the l=2 channel of Zr.
        for i in range(0, delta_E_qp_set3.size):
            print(max_energy_exts_set3[i], delta_E_qp_set3[i])

        fig, ax = plt.subplots()
        fig.set_size_inches(12, 10)
        plt.rcParams.update({'font.size': 11})   # Affects fonts of the labels only
        ax.tick_params(axis='both', which='major', labelsize=14)

        ax.set_xlim(80, 125)
        ax.set_ylim(1580, 1660)
        ax.set_xlabel('N LOs', fontsize=16)
        ax.set_ylabel('Quasiparticle Gap - KS Gap at Gamma (meV)', fontsize=16)
        ax.plot(n_los_set3, delta_E_qp_set3, 'ro', markersize=10)
        for i, txt in enumerate(basis_labels_set3):
            ax.annotate(txt, (n_los_set3[i], delta_E_qp_set3[i]))

        # Note, can use plt. or fig. to save and show
        if save_plots:
            # ALso note that ps cuts off the edges, hence using jpeg
            plt.savefig('qp_convergence_set3_lmax43.jpeg', dpi=300, facecolor='w', edgecolor='w',
                        orientation='portrait', transparent=True, bbox_inches=None, pad_inches=0.1)

        plt.show()

    # ----------------------------------------------------------------------
    # Plot VBT and CBB real self-eneries w.r.t. LO energy cut-off
    # for set 3, only
    # ----------------------------------------------------------------------
    if plot_sigma:

        # What we expect: VBT converges with the oxygen LOs, and is well-converged
        re_self_energy_VBM = data_set3['re_self_energy_VBM'][:, lmax_43] * ha_to_mev
        fig, ax = plt.subplots()

        fig.set_size_inches(12, 10)
        plt.rcParams.update({'font.size': 11})
        ax.tick_params(axis='both', which='major', labelsize=14)

        ax.set_xlim(82, 120)
        ax.set_xlabel('N LOs', fontsize=16)
        ax.set_ylabel('Re{Self Energy} at VBM (meV)', fontsize=16)
        ax.plot(n_los_set3, re_self_energy_VBM, 'ro', markersize=10)
        for i, txt in enumerate(basis_labels_set3):
            ax.annotate(txt, (n_los_set3[i], re_self_energy_VBM[i]))

        if save_plots:
            plt.savefig('VBM_convergence_set3_lmax43.jpeg', dpi=300, facecolor='w', edgecolor='w',
                        orientation='portrait', transparent=True, bbox_inches=None, pad_inches=0.1)

        plt.show()

        # CBm is strongly dependent on the number of Zr LOs, and is still not converged.
        re_self_energy_CBm = data_set3['re_self_energy_CBm'][:, lmax_43] * ha_to_mev
        fig, ax = plt.subplots()

        fig.set_size_inches(12, 10)
        plt.rcParams.update({'font.size': 11})
        ax.tick_params(axis='both', which='major', labelsize=14)

        ax.set_xlim(82, 120)
        ax.set_xlabel('N LOs', fontsize=16)
        ax.set_ylabel('Re{Self Energy} at CBm (meV)', fontsize=16)
        ax.plot(n_los_set3, re_self_energy_CBm, 'ro', markersize=10)
        for i, txt in enumerate(basis_labels_set3):
            ax.annotate(txt, (n_los_set3[i], re_self_energy_CBm[i]))

        if save_plots:
            plt.savefig('CBm_convergence_set3_lmax43.jpeg', dpi=300, facecolor='w', edgecolor='w',
                        orientation='portrait', transparent=True, bbox_inches=None, pad_inches=0.1)

        plt.show()

    return
Exemplo n.º 6
0
def gw_basis_convergence(root: str):
    """
    Plot the quasi particle - KS gap w.r.t bs LO basis, for l-max = (4, 3)
    """
    D = OrderedDict

    info = """  This run does two things:
    i0 - i5 converge the p-channel of Zr
    i6 - i9 check the sensitivity of large values in check l-channel
    
    One sees that Zr d is already converged at 11 LOs, and Zr-f is converged at 10 LOs
    Some sensitivity w.r.t the Zr-p, within ~ 4 meV spread. p at 11 LOs looks converged to ~ 2 meV
    For increasing Zr-s from 9 to 12 LOs, we get the outlier at the bottom of the plot: i.e. ~ 7 meV change
    As such, the calculation following this one should take the highest s out of the core and converge the Zr-s channel
    """

    print(info)

    lmax_32 = 0
    plot_delta_E_qp = True
    plot_sigma = False
    save_plots = False

    max_energy_exts_set4_pd = [
        'i0', 'i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7', 'i8', 'i9'
    ]

    settings_set4_pd = {
        'rgkmax': 8,
        'l_max_values': [D([('zr', 3), ('o', 2)])],
        'n_img_freq': 32,
        'q_grid': [2, 2, 2],
        'n_empty_ext': [2000],
        'max_energy_cutoffs': max_energy_exts_set4_pd
    }

    data_set4 = parse_gw_results(root, settings_set4_pd)
    delta_E_qp_set4 = data_set4['delta_E_qp'][:, lmax_32] * ha_to_mev
    basis_labels = get_basis_labels(root, settings_set4_pd, verbose=True)
    basis_labels_set4 = combine_species_basis_labels(
        basis_labels, species_per_line=True)['(3,2)']
    n_los_set4 = n_local_orbitals(basis_labels)['(3,2)']

    # Give some changes in QP gap w.r.t. calculations
    print(delta_E_qp_set4)
    process_basis_numbers(delta_E_qp_set4, basis_labels_set4)

    # Total number of LOs per calculation (i.e. sum Zr and O basis sizes together)
    n_los_set4 = sum_los_per_species(n_los_set4)

    # --------------------------------------
    # QP vs LO basis size, for l-max = (4,3)
    # --------------------------------------
    if plot_delta_E_qp:

        fig, ax = plt.subplots()
        ax.set_xlabel('N LOs')
        ax.set_ylabel('Quasiparticle Gap - KS Gap at Gamma (meV)')

        ax.plot(n_los_set4,
                delta_E_qp_set4,
                color='blue',
                marker='o',
                markersize=8)
        for i, txt in enumerate(basis_labels_set4):
            ax.annotate(txt, (n_los_set4[i], delta_E_qp_set4[i]))

        if save_plots:
            plt.savefig('qp_convergence_lmax43.ps',
                        dpi=300,
                        facecolor='w',
                        edgecolor='w',
                        orientation='portrait',
                        papertype=None,
                        transparent=True,
                        bbox_inches=None,
                        pad_inches=0.1)
        plt.show()

    # ----------------------------------------------------------------------
    # Plot VBT and CBB real self-energies w.r.t. LO energy cut-off
    # for set 3, only
    # ----------------------------------------------------------------------
    if plot_sigma:
        print("Requires rewriting")
        pass
        # # What we expect: VBT converges with the oxygen LOs, and is well-converged
        # re_self_energy_VBM = data_set4['re_self_energy_VBM'][:, lmax_32] * ha_to_mev
        # fig, ax = plt.subplots()
        #
        # fig.set_size_inches(12, 10)
        # plt.rcParams.update({'font.size': 11})
        # ax.tick_params(axis='both', which='major', labelsize=14)
        #
        # ax.set_xlim(82, 120)
        # ax.set_xlabel('N LOs', fontsize=16)
        # ax.set_ylabel('Re{Self Energy} at VBM (meV)', fontsize=16)
        # ax.plot(n_los_set4, re_self_energy_VBM, 'ro', markersize=10)
        # for i, txt in enumerate(basis_labels_set4):
        #     ax.annotate(txt, (n_los_set4[i], re_self_energy_VBM[i]))
        #
        # if save_plots:
        #     plt.savefig('VBM_convergence_set3_lmax43.jpeg', dpi=300, facecolor='w', edgecolor='w',
        #                 orientation='portrait', transparent=True, bbox_inches=None, pad_inches=0.1)
        #
        # plt.show()
        #
        # # CBm is strongly dependent on the number of Zr LOs, and is still not converged.
        # re_self_energy_CBm = data_set4['re_self_energy_CBm'][:, lmax_32] * ha_to_mev
        # fig, ax = plt.subplots()
        #
        # fig.set_size_inches(12, 10)
        # plt.rcParams.update({'font.size': 11})
        # ax.tick_params(axis='both', which='major', labelsize=14)
        #
        # ax.set_xlim(82, 120)
        # ax.set_xlabel('N LOs', fontsize=16)
        # ax.set_ylabel('Re{Self Energy} at CBm (meV)', fontsize=16)
        # ax.plot(n_los_set4, re_self_energy_CBm, 'ro', markersize=10)
        # for i, txt in enumerate(basis_labels_set4):
        #     ax.annotate(txt, (n_los_set4[i], re_self_energy_CBm[i]))
        #
        # if save_plots:
        #     plt.savefig('CBm_convergence_set3_lmax43.jpeg', dpi=300, facecolor='w', edgecolor='w',
        #                 orientation='portrait', transparent=True, bbox_inches=None, pad_inches=0.1)
        #
        # plt.show()

    return
Exemplo n.º 7
0
def gw_basis_convergence(root: str):
    """
    Plot the quasi particle - KS gap w.r.t to the LO basis

    Have one data point for converged QP gap with l-max = (3, 2)

    Then plot for several LOs in the channels
        l-max = (4, 2)
        l-max = (3, 3)
        l-max = (5, 3)
        l-max = (4, 4)
    """
    D = OrderedDict

    # --------------------------------------------
    # Extra Zr l-Channel. l_max(Zr, O) = (4, 2)
    # zr_lmax4_o_lmax2_rgkmax8
    # --------------------------------------------
    settings_zr = {'rgkmax': 8,
                   'l_max_values': [D([('zr', 4), ('o', 2)])],
                   'n_img_freq': 32,
                   'q_grid': [2, 2, 2],
                   'n_empty_ext': [2000],
                   'max_energy_cutoffs': ['i0', 'i1', 'i2', 'i3', 'i4']
                   }

    data_set_zr = parse_gw_results(root, settings_zr)
    E_qp_zr = data_set_zr['E_qp'][:, 0] * ha_to_mev
    E_ks_zr = data_set_zr['E_ks'][:, 0] * ha_to_mev
    delta_E_qp_zr = data_set_zr['delta_E_qp'][:, 0] * ha_to_mev
    assert np.allclose(E_ks_zr, 3865.10677893), "KS gap shouldn't change"

    # Get LO labels
    basis_labels = get_basis_labels(root, settings_zr, verbose=True)
    basis_labels_zr = combine_species_basis_labels(basis_labels, species_per_line=True)['(4,2)']
    n_los_zr = n_local_orbitals(basis_labels)['(4,2)']
    print('Zr Calculation:', basis_labels_zr)


    # --------------------------------------------
    # Extra O l-channel. l_max(Zr, O) = (3, 3)
    # zr_lmax3_o_lmax3_rgkmax8
    # --------------------------------------------
    max_energy_exts_o = ['i0', 'i1', 'i2']
    settings_o = {'rgkmax': 8,
                  'l_max_values': [D([('zr', 3), ('o', 3)])],
                  'n_img_freq': 32,
                  'q_grid': [2, 2, 2],
                  'n_empty_ext': [2000],
                  'max_energy_cutoffs': max_energy_exts_o
                  }

    data_set_o = parse_gw_results(root, settings_o)
    E_qp_o = data_set_o['E_qp'][:, 0] * ha_to_mev
    E_ks_o = data_set_o['E_ks'][:, 0] * ha_to_mev
    delta_E_qp_o = data_set_o['delta_E_qp'][:, 0] * ha_to_mev
    assert np.allclose(E_ks_o, 3865.10677893), "KS gap shouldn't change"

    # Get LO labels
    basis_labels = get_basis_labels(root, settings_o, verbose=True)
    basis_labels_o = combine_species_basis_labels(basis_labels, species_per_line=True)['(3,3)']
    n_los_o = n_local_orbitals(basis_labels)['(3,3)']
    print('O Calculation:', basis_labels_o)

    # Report Details
    print('Quasi-particle gap w.r.t LOs in Zr l=4 channel (O l=2):', E_qp_zr)
    print('Quasi-particle minus gap w.r.t LOs in Zr l=4 channel (O l=2):', delta_E_qp_zr)

    print('Quasi-particle gap w.r.t LOs in O l=3 channel (Zr l=3):', E_qp_o)
    print('Quasi-particle minus gap w.r.t LOs in O l=3 channel (Zr l=3):', delta_E_qp_o)


    # ------------------------------------------------
    # Using prior Zr and O bases, increase Zr l-channel
    # l_max(Zr, O) = (5, 3)
    # zr_lmax5_o_lmax3_rgkmax8
    # ------------------------------------------------
    settings_zr = {'rgkmax': 8,
                   'l_max_values': [D([('zr', 5), ('o', 3)])],
                   'n_img_freq': 32,
                   'q_grid': [2, 2, 2],
                   'n_empty_ext': [2000],
                   'max_energy_cutoffs': ['i1', 'i2', 'i3', 'i4']  # i0 failed => 'i0',ignore it for now
                   }

    data_set_zr = parse_gw_results(root, settings_zr)
    E_qp_zr = data_set_zr['E_qp'][:, 0] * ha_to_mev
    E_ks_zr = data_set_zr['E_ks'][:, 0] * ha_to_mev
    print("KS gap has changed by 0.3 meV when moving to the (5, 3) basis\n"
          "I assume this is ok, BUT should not")
    delta_E_qp_zr = data_set_zr['delta_E_qp'][:, 0] * ha_to_mev
    assert np.allclose(E_ks_zr, 3865.3788929), "KS gap shouldn't change"

    # Get LO labels
    basis_labels = get_basis_labels(root, settings_zr, verbose=True)
    basis_labels_zr = combine_species_basis_labels(basis_labels, species_per_line=True)['(5,3)']
    n_los_zr = n_local_orbitals(basis_labels)['(5,3)']
    print('Zr Calculation (5,3):', basis_labels_zr)


    # ------------------------------------------------
    # Using prior Zr and O bases, increase O l-channel
    # l_max(Zr, O) = (4, 4)
    # zr_lmax4_o_lmax4_rgkmax8
    # ------------------------------------------------
    settings_o = {'rgkmax': 8,
                   'l_max_values': [D([('zr', 4), ('o', 4)])],
                   'n_img_freq': 32,
                   'q_grid': [2, 2, 2],
                   'n_empty_ext': [2000],
                   'max_energy_cutoffs': ['i0', 'i1', 'i2']
                   }

    data_set_o = parse_gw_results(root, settings_o)
    E_qp_o = data_set_o['E_qp'][:, 0] * ha_to_mev
    E_ks_o = data_set_o['E_ks'][:, 0] * ha_to_mev
    delta_E_qp_o = data_set_o['delta_E_qp'][:, 0] * ha_to_mev
    print(E_ks_o)
    assert np.allclose(E_ks_o, 3865.3788929), "KS gap shouldn't change"

    # Get LO labels
    basis_labels = get_basis_labels(root, settings_o, verbose=True)
    basis_labels_o = combine_species_basis_labels(basis_labels, species_per_line=True)['(4,4)']
    n_los_o = n_local_orbitals(basis_labels)['(4,4)']
    print('O Calculation:', basis_labels_o)

    print('Quasi-particle gap w.r.t LOs in Zr l=5 channel (O l=3):', E_qp_zr)
    print('Quasi-particle minus gap w.r.t LOs in Zr l=5 channel (O l=3):', delta_E_qp_zr)

    print('Quasi-particle gap w.r.t LOs in O l=4 channel (Zr l=4):', E_qp_o)
    print('Quasi-particle minus gap w.r.t LOs in O l=4 channel (Zr l=4):', delta_E_qp_o)


    # Do plot of Oxygen only, as that effect seems to be large
    # TODO Add set 6 converged data point
    # This has opened the gap a fair bit - should check tbe basis and see if another channel also affects results

    # if plot_delta_E_qp:
    #     fig, ax = plt.subplots()
    #     ax.set_xlabel('N LOs')
    #     ax.set_ylabel('Quasiparticle Gap - KS Gap at Gamma (meV)')
    #
    #     print(n_los_o)
    #     print(delta_E_qp_o)
    #
    #     ax.plot(n_los_o['o'], delta_E_qp_o, color='blue', marker='o', markersize=8)
    #
    #     for i, txt in enumerate(basis_labels_o):
    #        ax.annotate(txt, (n_los_o['o'][i], delta_E_qp_o[i]))
    #
    #     if save_plots:
    #         plt.savefig('qp_convergence_lmax43.ps', dpi=300, facecolor='w', edgecolor='w',
    #                     orientation='portrait', papertype=None, transparent=True, bbox_inches=None, pad_inches=0.1)
    #     plt.show()



    return
Exemplo n.º 8
0
def gw_basis_convergence(root: str):
    """
    Plot the quasipartilce-KS gap w.r.t basis l-max, for
    several max lo energies.
    """
    D = OrderedDict

    # Details required for generating directory extension
    l_max_values = [
        D([('zr', 3), ('o', 2)]),
        D([('zr', 4), ('o', 3)]),
        D([('zr', 5), ('o', 4)]),
        D([('zr', 6), ('o', 5)])
    ]

    # Makes more sense to specifiy the extensions rather than use:
    # max_energy_exts = max_energy_ext_per_directory(energy_cutoffs)
    # Same with n_empty_ext
    max_energy_exts = [90, 160, 230, 300]

    settings = {
        'rgkmax': 7,
        'l_max_values': l_max_values,
        'n_img_freq': 32,
        'q_grid': [2, 2, 2],
        'n_empty_ext': [800, 1000, 1300, 2000],
        'max_energy_cutoffs': max_energy_exts
    }

    # Parse data
    data = parse_gw_results(root, settings)
    delta_E_qp = data['delta_E_qp']

    # Print some data
    process_basis_numbers(l_max_values,
                          delta_E_qp,
                          max_energy_exts,
                          max_energy=300)

    # Generate plots
    save_plots = False
    plot_delta_E_qp = True
    plot_sigma = False

    # -----------------
    # Plot delta_E_qp
    # -----------------
    if plot_delta_E_qp:

        # --------------------------------------------------------------
        # Plot 1
        # --------------------------------------------------------------
        x = np.arange(0, len(l_max_values))
        x_labels = [
            "(" + ",".join(str(l) for l in l_pair.values()) + ")"
            for l_pair in l_max_values
        ]

        gw_plot = Plot(x, [],
                       x_label='l_max (Zr, O)',
                       y_label='Quasiparticle Gap - KS Gap at Gamma (meV)',
                       xticklabels=x_labels,
                       legend_title='Max LO Energy (Ha)',
                       linewidth=3)

        for i, energy in enumerate(max_energy_exts):
            gw_plot.plot_data(x,
                              delta_E_qp[i, :] * ha_to_mev,
                              label=str(energy))

        if save_plots:
            save_options = {
                'file_name': 'qp_convergence_lmax_and_los.jpeg',
                'dpi': 300,
                'facecolor': 'w',
                'edgecolor': 'w',
                'orientation': 'landscape',
                'bbox_inches': 'tight'
            }
            gw_plot.save(save_options)

        gw_plot.show()

        # --------------------------------------------------------------
        # Second plot. Same as above but label every point with the basis
        # --------------------------------------------------------------
        fig, ax = plt.subplots()
        fig.set_size_inches(14, 10)
        plt.rcParams.update({'font.size': 16})

        ax.set_xlabel('l_max (Zr, O)', fontsize=16)
        ax.set_ylabel('Quasiparticle Gap - KS Gap at Gamma (meV)', fontsize=16)

        ax.set_xticks(x)
        ax.set_xticklabels(x_labels)
        ax.tick_params(axis='both', which='major', labelsize=16)

        # Overlay lines for each LO energy cutoff
        for i, energy in enumerate(max_energy_exts):
            ax.plot(x, delta_E_qp[i, :] * ha_to_mev, marker='o', markersize=8)

        basis_labels = get_basis_labels(root, settings)

        # Set basis label for each marker
        for j, l_max in enumerate(['(3,2)', '(4,3)', '(5,4)', '(6,5)']):
            for i, energy in enumerate(max_energy_exts):
                label = ''
                for species in ['zr', 'o']:
                    label += species.capitalize(
                    ) + ': ' + basis_labels[l_max][species][i].rstrip() + '.\n'
                ax.annotate(label.rstrip(),
                            (x[j], delta_E_qp[i, j] * ha_to_mev))

        if save_plots:
            plt.savefig('qp_convergence_set2_basis_labels.jpeg',
                        dpi=300,
                        facecolor='w',
                        edgecolor='w',
                        orientation='landscape',
                        transparent=True,
                        bbox_inches='tight',
                        pad_inches=1.)

        plt.show()

    # ----------------------------------------------------------------------
    # Plot VBT and CBB real self-eneries w.r.t. basis and energy parameter
    # ----------------------------------------------------------------------
    if plot_sigma:
        re_self_energy_VBM = data['re_self_energy_VBM']
        r_sigma_VBM_plot = Plot(x, [],
                                x_label='l_max (Zr, O)',
                                y_label='Re{Self Energy} at VBM (meV) ',
                                xticklabels=x_labels,
                                legend_title='Max LO Energy Param (Ha)',
                                linewidth=3)

        for i, energy in enumerate(max_energy_exts):
            r_sigma_VBM_plot.plot_data(x,
                                       re_self_energy_VBM[i, :] * ha_to_mev,
                                       label=str(energy))
        r_sigma_VBM_plot.show()

        re_self_energy_CBm = data['re_self_energy_CBm']
        r_sigma_CBm_plot = Plot(x, [],
                                x_label='l_max (Zr, O)',
                                y_label='Re{Self Energy} at CBm (meV) ',
                                xticklabels=x_labels,
                                legend_title='Max LO Energy Param (Ha)',
                                linewidth=3)

        for i, energy in enumerate(max_energy_exts):
            r_sigma_CBm_plot.plot_data(x,
                                       re_self_energy_CBm[i, :] * ha_to_mev,
                                       label=str(energy))
        r_sigma_CBm_plot.show()

    return