def plot(ax, var): directions = ['x', 'y', 'z'] linestyle = '-', '--', '-.' from scipy.fftpack import fft import numpy as np for idir in range(3): length = var.current.shape[0] // 2 #print(length) beta = 1E-3 fftc = fft(var.current[:, idir] * np.exp(-beta * var.time)) resE = 4.1356 / var.time[-1] energy = np.arange(length) * resE #/ 2 ax[1].plot(energy, np.abs(np.real(fftc[:length])), ls=linestyle[idir], label=directions[idir]) ax[0].plot(energy, -np.imag(fftc[:length]), ls=linestyle[idir], label=directions[idir]) import py3ramids.plot.setting as ma ma.setProperty( ax[1], ylabel='Im $\epsilon$ (a.u.)', xlabel='Energy (eV)', ylimits=[0, 0.02], #xlimits=[0,8] ) ma.setProperty( ax[0], ylabel='Re $\epsilon$ (a.u.)', xlabel='Energy (eV)', ylimits=[-0.02, 0.02], #xlimits=[0,10] )
def plotLineWidth(ax, filename, modes=None, **kargs): data = np.loadtxt(filename) all_modes = set(data[:, 3]) nmodes = len(all_modes) all_bands = set(data[:, 1]) nbnd = len(all_bands) #print(data.shape) #print(data[:,1:5].reshape([-1,nmodes,4])) data_ref = data[:, 1:5].reshape([-1, nmodes, 4]) #print() #print(data) for i in range(nmodes): if modes != None and i not in modes: continue else: mode = data_ref[:, i, :] seq = np.argsort(mode[:, 1]) ax.plot(mode[seq, 1], mode[seq, 3], '-', label=str(i + 1)) kargs = ma.getPropertyFromPosition( ylabel=r'Im($\epsilon$) (meV)', xlabel='Energy (eV)', ylimits=[0, None], xlimits=[-2, 2], #title=filename, vline=[0]) ma.setProperty(ax, **kargs)
def plot(ax, var): steps = min(var.time.shape[0], var.energy[0].shape[0], var.energy[1].shape[0]) ax.plot(var.time[:steps], var.energy[0][:steps], '-', label='Total') ax.plot(var.time[:steps], var.energy[1][:steps], '--', label='KS') print('energy:', var.energy[1][-1] - var.energy[1][0]) import py3ramids.plot.setting as ma ma.setProperty(ax, ylabel='Energy (eV)', xlabel='Time (fs)')
def plot(ax, var): directions = ['x','y','z'] linestyle = '-','--','-.' for idir in range(3): steps = min(var.time.shape[0],var.eField.shape[0]) ax.plot(var.time[:steps], var.eField[:steps,idir], ls=linestyle[idir], label=directions[idir]) #ax.plot(var.time, var.energy[1], '--', label='KS') import py3ramids.plot.setting as ma ma.setProperty(ax, ylabel=r'E Field (V/$\mathrm{\AA}$)', xlabel='Time (fs)')
def plot(ax, var): directions = ['x', 'y', 'z'] linestyle = '-', '--', '-.' dim = min(var.time.shape[0], var.current.shape[0]) for idir in range(var.current.shape[1]): ax.plot(var.time[:dim], var.current[:dim, idir], ls=linestyle[idir], label=directions[idir]) import py3ramids.plot.setting as ma ma.setProperty(ax, ylabel='Current (a.u.)', xlabel='Time (fs)')
def plot(axs, filename='epw.pristine.out'): titles = 'ik', 'ibnd', 'enk (eV)', 'Re[Sigma] (meV)', 'Im[Sigma] (meV)', 'Z', 'lam' dataAll = getData(filename, process=2) ax = axs ax.plot(dataAll[:, 2], dataAll[:, 4], 'o-', lw=3, label=filename) kargs = ma.getPropertyFromPosition(ylabel=r'Im($\epsilon$) (meV)', xlabel='Energy (eV)', ylimits=[0, None], xlimits=[-2, 2], vline=[0]) ma.setProperty(axs, **kargs)
def plot(ax, var): directions = 'x', 'y', 'z' linestyle = '-', '--', '-.' for idir in range(3): ax.plot(var.time, var.aField[:var.time.shape[0], idir], ls=linestyle[idir], label=directions[idir]) #ax.plot(var.time, var.energy[1], '--', label='KS') import py3ramids.plot.setting as ma ma.setProperty(ax, ylabel=r'A Field (Bohr$^{-1}$)', xlabel='Time (fs)', minortick=True)
def plot(ax, var): directions = ['x', 'y', 'z'] linestyle = '-', '--', '-.' #for idir in range(3): if len(var.cartime) == 0: return dim = min(var.cartime.shape[0], var.carrier[0].shape[0]) ax.plot(var.cartime[:dim], var.carrier[0][:dim], ls=linestyle[0], label='Electron') ax.plot(var.cartime[:dim], var.carrier[0][:dim], ls=linestyle[1], label='Hole') import py3ramids.plot.setting as ma ma.setProperty(ax, ylabel='Carrier (e)', xlabel='Time (fs)')
def plot(iv, ax): label = '' ax.plot([], [], label=label) kargs = ma.getPropertyFromPosition(xlabel='', ylabel=r'', title='') ma.setProperty(ax, **kargs) ma.add_label(iv, ax) columes = (4, 5, 6, 10) lineK = np.array([[ float(v) for i, v in enumerate(line.replace(')', ' ').split()) if i in columes ] for line in open('bandK')]) lineK[:, -1] = 1E-6 meshK = np.array([[ float(v) for i, v in enumerate(line.replace(')', ' ').split()) if i in columes ] for line in open('meshK')]) lines = 'K_POINTS tpiba\n' print(meshK.shape[0], lineK.shape[0]) lines += '%i\n' % (meshK.shape[0] + lineK.shape[0]) for points in [meshK, lineK]: for point in points: print(point) lines += '%12.6f\t%12.6f\t%12.6f\t%12.6f\n' % (point[0], point[1], point[2], point[3]) print(lines) open('kout', 'w').write(lines) #data[:,-1] = 1E-5 #print(data) #print(np.loadtxt(file, usecols=(4,5,6))) return kargs
def plot(ax, var): magmon = var.getMagMon() for i in range(3): ax.plot(var.time, magmon[:, i], '-', label='xyz'[i]) import py3ramids.plot.setting as ma ma.setProperty(ax, ylabel='Mag Mon (Bohr/cell)', xlabel='Time (fs)')
if dataType is complex: vData = np.absolute(data) else: vData = data for i, frame in enumerate(vData): if data.shape[0] == 1: ax = axs else: ax = axs[i] vmax = frame.max() nRow, nCol = frame.shape ct = ax.imshow(frame, cmap='binary', vmax=vmax, vmin=0, aspect='auto', extent=[1, nCol + 1, 0.5, nRow + 0.5]) plt.colorbar(ct, ax=ax) kargs = ma.getPropertyFromPosition(xlabel='', ylabel=r'', title='') ma.setProperty(ax, **kargs) fig.align_ylabels(axs) plt.tight_layout() #plt.axis('equal') SaveName = filename if args.plot: for save_type in ['.png']: filename = SaveName + save_type plt.savefig(filename, dpi=600, transparent=True)
from __future__ import print_function import matplotlib.pyplot as plt import py3ramids.plot.setting as ma import ase.dft.band_structure as bs from ase.io import read atoms = read('POSCAR',format='vasp') dftband = bs.BandStructure.read('band.json') #data = dftband.todict() from ase.dft.kpoints import bandpath kpts = bandpath([[0.333,0.666,0.0],[0.5,0.0,0.0],[0.0,0.0,0.0],[0.666,0.333,0.0]],atoms.cell,npoints=90) fig, ax = plt.subplots(1,1,sharex=True,figsize=(6,8)) x = kpts[-2] y = dftband.energies[0] - 4.74503 ax.plot(x,y) print(kpts[0]) ma.setProperty(ax, ylimits=[-2,2], vline=kpts[-1])