Ejemplo n.º 1
0
def plot_single_snapshot_results_qm_gaps(snapnum,
                                         snapnums_results_d,
                                         results_d,
                                         name='frequency',
                                         func_to_apply=lambda x: x,
                                         ylabel=r'$\nu_{3}$ frequency (cm$^{-1}$)',
                                         symbol='\omega'):

    results_snap_d = get_single_snapshot_results(snapnum,
                                                 snapnums_results_d,
                                                 results_d)

    fig, ax = plt.subplots()

    gaps_0_1 = []
    gaps_1_2 = []
    gaps_2_3 = []
    n_mm_ticks_0_1 = []
    n_mm_ticks_1_2 = []
    n_mm_ticks_2_3 = []

    for n_mm in possible_keys:
        try:
            gap_0_1 = func_to_apply(results_snap_d[1][n_mm][0]) - func_to_apply(results_snap_d[0][n_mm][0])
            gaps_0_1.append(gap_0_1)
            n_mm_ticks_0_1.append(n_mm)
        except:
            pass
        try:
            gap_1_2 = func_to_apply(results_snap_d[2][n_mm][0]) - func_to_apply(results_snap_d[1][n_mm][0])
            gaps_1_2.append(gap_1_2)
            n_mm_ticks_1_2.append(n_mm)
        except:
            pass
        try:
            gap_2_3 = func_to_apply(results_snap_d[3][n_mm][0]) - func_to_apply(results_snap_d[2][n_mm][0])
            gaps_2_3.append(gap_2_3)
            n_mm_ticks_2_3.append(n_mm)
        except:
            pass

    ax.plot(n_mm_ticks_0_1, gaps_0_1, marker='s', color='red',
            label='$\Delta {symbol}_{{1-0\,\mathrm{{QM}}}}$'.format(**locals()))
    ax.plot(n_mm_ticks_1_2, gaps_1_2, marker='p', color='green',
            label='$\Delta {symbol}_{{2-1\,\mathrm{{QM}}}}$'.format(**locals()))
    ax.plot(n_mm_ticks_2_3, gaps_2_3, marker='*', color='blue',
            label='$\Delta {symbol}_{{3-2\,\mathrm{{QM}}}}$'.format(**locals()))

    ax.set_xscale('symlog', basex=2)
    ax.xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())

    ax.set_ylim(ax.get_ylim()[::-1])
    y_formatter = mpl.ticker.ScalarFormatter(useOffset=False)
    ax.yaxis.set_major_formatter(y_formatter)
    ax.tick_params(direction='out')
    ax.set_xlabel('# IL pairs treated as point charges')
    ax.set_ylabel(r'difference in {}'.format(ylabel))
    # ax.set_title('snapshot {} gaps'.format(snapnum))
    ax.legend(loc='best', fancybox=True, framealpha=0.50)
    filename = '{}_convergence_snap{}_gaps.pdf'.format(name, snapnum)
    print('Saving {}'.format(filename))
    fig.savefig(filename, bbox_inches='tight')

    ax.set_xscale('linear')

    rlim = -5
    ax.set_xticks(possible_keys[:rlim + 1])
    ax.set_xlim((possible_keys[0], possible_keys[rlim]))
    filename = '{}_convergence_snap{}_{}_gaps.pdf'.format(name, snapnum, possible_keys[rlim])
    print('Saving {}'.format(filename))
    fig.savefig(filename, bbox_inches='tight')

    plt.close(fig)

    return
Ejemplo n.º 2
0
def plot_single_snapshot_results(snapnum,
                                 snapnums_results_d,
                                 results_d,
                                 name='frequency',
                                 func_to_apply=lambda x: x,
                                 ylabel=r"$\nu_{3}$ frequency (cm$^{-1}$)",
                                 inp_fig=None,
                                 inp_ax=None,
                                 do_manip_fig=True,
                                 do_manip_ax=True):

    results_snap_d = get_single_snapshot_results(snapnum, snapnums_results_d, results_d)

    fig, ax = plt.subplots()
    if inp_fig:
        fig = inp_fig
    if inp_ax:
        ax = inp_ax

    for n_qm in sorted(results_snap_d):
        ticks = []
        results = []
        for n_mm in possible_keys:
            if len(results_snap_d[n_qm][n_mm]) > 0:
                if n_mm + n_qm >= 256:
                    ticks.append(256)
                else:
                    ticks.append(n_mm + n_qm)
                results.append(func_to_apply(results_snap_d[n_qm][n_mm][0]))

        ax.plot(ticks,
                results,
                marker=markers[n_qm],
                label=labels[n_qm],
                color=colors[n_qm])

    if do_manip_ax:
        ax.set_xscale('symlog', basex=2)
        ax.xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
        y_formatter = mpl.ticker.ScalarFormatter(useOffset=False)
        ax.yaxis.set_major_formatter(y_formatter)
        ax.tick_params(direction='out')
        ax.set_xlabel("total # of IL pairs included")
        ax.set_ylabel(ylabel)
        # ax.set_title("snapshot {}".format(snapnum))
        ax.legend(loc='best', fancybox=True, framealpha=0.50)
    if do_manip_fig:
        filename = '{}_convergence_snap{}.pdf'.format(name, snapnum)
        print('Saving {}'.format(filename))
        fig.savefig(filename, bbox_inches='tight')

    if do_manip_ax:
        ax.set_xscale('linear')
        rlim = -5
        ax.set_xticks(possible_keys[:rlim + 1])
        ax.set_xlim((possible_keys[0], possible_keys[rlim]))
    if do_manip_fig:
        filename = '{}_convergence_snap{}_{}.pdf'.format(name, snapnum, possible_keys[rlim])
        print('Saving {}'.format(filename))
        fig.savefig(filename, bbox_inches='tight')

        plt.close(fig)

    return