def test_read_matdyn_freq_disp(): # Parse matdyn frequency file. In QE 5.x the path_norm and band structure # is also directly written to a file with suffix ".gp", i.e. # "matdyn.freq.disp.gp" fn = unpack_compressed('files/qe_matdyn_disp/matdyn.freq.disp.gz') kk, ff = pwscf.read_matdyn_freq(fn) d = np.loadtxt('files/qe_matdyn_disp/matdyn.freq.disp.gp.gz') assert np.allclose(kpath.get_path_norm(kk), d[:,0]) assert np.allclose(ff, d[:,1:])
def test_read_matdyn(): # matdyn.freq kpoints, freqs = pwscf.read_matdyn_freq('files/matdyn.freq') aae(kpoints, kpoints_ref) aae(freqs, freqs_ref) # matdyn modes: read_matdyn_modes() qpoints, freqs, vecs = pwscf.read_matdyn_modes('files/matdyn.modes', natoms=2) aae(qpoints, qpoints_ref) aae(freqs, freqs_modes_ref) aae(vecs.real, vecs_real_ref) aaae(vecs.imag, vecs_imag_ref)
txt = common.template_replace(templ_txt, rules, conv=True, mode='txt') common.file_write(matdyn_in_fn, txt) common.system("gunzip q2r.fc.gz; matdyn.x < %s; gzip q2r.fc" %matdyn_in_fn) # parse matdyn output and plot # define special points path, used in plot_dis() to plot lines at special # points and make x-labels sp = kpath.SpecialPointsPath(ks=sp_points, ks_frac=sp_points_frac, symbols=sp_symbols) # QE 4.x, 5.x ks, freqs = pwscf.read_matdyn_freq(matdyn_freq_fn) fig,ax = kpath.plot_dis(kpath.get_path_norm(ks_path), freqs, sp, marker='', ls='-', color='k') # QE 5.x ##d = np.loadtxt(matdyn_freq_fn + '.gp') ##fig,ax = kpath.plot_dis(d[:,0], d[:,1:], sp, marker='', ls='-', color='k') # if needed #ax.set_ylim(...) #mpl.plt.show() mpl.plt.savefig('1.pdf') # Band jumps at Gamma # ------------------- # Either use many points in kpath() or split sp_points in two sets: sp_points_1
'XXXFNFREQ': matdyn_freq_fn, } txt = common.template_replace(templ_txt, rules, conv=True, mode='txt') common.file_write(matdyn_in_fn, txt) common.system("gunzip q2r.fc.gz; matdyn.x < %s; gzip q2r.fc" % matdyn_in_fn) # parse matdyn output and plot # define special points path, used in plot_dis() to plot lines at special # points and make x-labels sp = kpath.SpecialPointsPath(ks=sp_points, ks_frac=sp_points_frac, symbols=sp_symbols) # QE 4.x, 5.x ks, freqs = pwscf.read_matdyn_freq(matdyn_freq_fn) fig, ax = kpath.plot_dis(kpath.get_path_norm(ks_path), freqs, sp, marker='', ls='-', color='k') # QE 5.x ##d = np.loadtxt(matdyn_freq_fn + '.gp') ##fig,ax = kpath.plot_dis(d[:,0], d[:,1:], sp, marker='', ls='-', color='k') # if needed #ax.set_ylim(...) #mpl.plt.show()
# &plot nbnd= 6, nks= 101 / # 0.000000 0.000000 0.000000 # 0.0000 0.0000 0.0000 456.2385 456.2385 871.5931 # 0.037500 0.037500 0.000000 # 23.8811 37.3033 54.3776 455.7569 457.2338 869.8832 # .... if __name__ == '__main__': import warnings ## warnings.simplefilter('always') import matplotlib.pyplot as plt import sys from pwtools.pwscf import read_matdyn_freq from pwtools.kpath import plot_dis, get_path_norm if len(sys.argv) > 2: warnings.warn('kpath definition file no longer supported') # QE 5.x: plot matdyn.freq.gp # ##import numpy as np ##data = np.loadtxt(sys.argv[1]) ##path_norm = data[:,0] ##freqs = data[:,1:] ks, freqs = read_matdyn_freq(sys.argv[1]) path_norm = get_path_norm(ks) plt.plot(path_norm, freqs, 'k') plt.show()
# 0.0000 0.0000 0.0000 456.2385 456.2385 871.5931 # 0.037500 0.037500 0.000000 # 23.8811 37.3033 54.3776 455.7569 457.2338 869.8832 # .... if __name__ == '__main__': import warnings warnings.simplefilter('always') import matplotlib.pyplot as plt import sys from pwtools.pwscf import read_matdyn_freq from pwtools.kpath import plot_dis, get_path_norm if len(sys.argv) > 2: warnings.warn('kpath definition file no longer supported') # QE 5.x: plot matdyn.freq.gp # ##import numpy as np ##data = np.loadtxt(sys.argv[1]) ##path_norm = data[:,0] ##freqs = data[:,1:] ks, freqs = read_matdyn_freq(sys.argv[1]) path_norm = get_path_norm(ks) plt.plot(path_norm, freqs, 'k') plt.show()