Esempio n. 1
0
def h5get_mfit_ev(nmesh_fac=10, fsave='results.h5', path='/lapw'):
    '''Calculate and save Murnaghan fiting results in fsave.
    Interpolated e-v and p-v data on volume mesh with a factor a
    nmesh_fac of the original one are also stored.
    '''
    # Get e,v data.
    with h5py.File(fsave, 'r') as f:
        e_list = f[path + '/etot_list'][...]
        v_list = f['/vol_list'][...]

    # fitting
    murnpars = get_ev_fit(v_list, e_list)

    vh = np.linspace(v_list[0], v_list[-1], nmesh_fac * len(v_list) - 1)
    eh = Murnaghan(murnpars, vh)
    ph = Murnaghan_pv(murnpars, vh) * units.eVA_GPa
    with h5py.File(fsave, 'a') as f:
        if path + '/eosfit' in f:
            del f[path + '/eosfit']
        f[path + '/eosfit/e0'] = murnpars[0]
        f[path + '/eosfit/b0'] = murnpars[1]
        f[path + '/eosfit/bp'] = murnpars[2]
        f[path + '/eosfit/v0'] = murnpars[3]
        f[path + '/eosfit/v_list'] = vh
        f[path + '/eosfit/e_list'] = eh
        f[path + '/eosfit/p_list'] = ph
    splot.xy2_plot([v_list, vh], [e_list, eh], ['o', '-'], ['raw', 'fitting'],
                   xlabel='V ($\AA^3$/primitive cell)',
                   ylabel='E (eV/primitive cell)',
                   fsave=path + '_evfit.pdf')
    splot.xy_plot(vh,
                  ph,
                  xlabel='V ($\AA^3$/primitive cell)',
                  ylabel='P (GPa)',
                  fsave=path + '_pvfit.pdf')
Esempio n. 2
0
def compare_pv_plot(path_list, fres='results.h5'):
    '''Compare lapw/lapwso/lapwsog in a plot.
    '''
    v_list = []
    p_list = []
    pattern_list = []
    label_list = []
    with h5py.File(fres, 'r') as f:
        postfix=''
        for path in path_list:
            if path in f:
                label_list.append(path)
                p_list.append(f['/'+path+'/eosfit/p_list'][()])
                v_list.append(f['/'+path+'/eosfit/v_list'][()])
                pattern_list.append('o')
                postfix += path.split('/')[0]
        if v_list != []:
            splot.xy2_plot(v_list, p_list, pattern_list, label_list,
                    xlabel='V ($\AA^{3}$/primitive cell)',
                    ylabel='P (GPa)',
                    fsave='pv_{}.pdf'.format(postfix))