def drawBands(ax, bandType='e', label=''): """ Draw the KS Energy and Total Energy in the ax """ X, Ek, xticks, xticklabels = tdp.getBands() if bandType == 'e': eFermi = tdp.getFermiEnergy() Ek = Ek - eFermi ylabel = 'Energy(eV)' else: ylabel = r'$\omega$(cm$^{-1}$)' alpha = 1.0 color = 'b' for ispin in range(Ek.shape[2]): for iband in range(1, Ek.shape[1]): ax[0].plot(X, Ek[:, iband, ispin], lw=3.0, ls='-', color=color, alpha=alpha, label=label) kargs = ma.getPropertyFromPosition(index=None, xlabel=r'', ylabel=ylabel, title='', xticks=xticks, yticks=None, xticklabels=xticklabels, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def drawRMSD(ax, selected=None, label='', init=0): """ Draw the KS Energy and Total Energy in the ax """ systemLabel, timestep = tdp.getSystemLabelTimpstep() if selected == None: selected = range(0, tdp.getNumStep(), int(1.0 / timestep)) tdp.splitMDCAR() time, distance, velocity = tdp.calculateRMSD(selected, init=init) #os.remove('POSCAR') ax.plot(time, distance, linewidth=3.0, label='RMSD' + label) #,color=ma.colors[0]) kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)', ylabel=r'RMSD($\AA$)', title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def drawRDF(ax, step=None, label=''): """ Draw the KS Energy and Total Energy in the ax """ if step == None: step = tdp.getNumStep() systemLabel, timestep = tdp.getSystemLabelTimpstep() tdp.splitMDCAR() hist, bin_edges = tdp.calculateRDF(step - 1) ax.plot(bin_edges[:-1], hist, linewidth=3.0, label='RDF ' + str( (step) * timestep) + ' fs' + label) #,color=ma.colors[0] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Radius($\AA$)', ylabel=r'RDF(a.u.)', title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def plotDistribution(ax, step, bins=100, intepNum=2000, ylimits=[0, 1], **kargs): xlabel = 'Energy (eV)' ylabel = 'FD' yticklabels = [] eDos, dos, par = dp.calculateDOS(step, ref=False, interp=False, bins=bins) distribution = (np.abs(par)) / ((dos) + 1E-10) def interp(xin, yin, xout): from scipy.interpolate import interp1d spline = interp1d(xin, yin, kind='cubic') return spline(xout) x = np.linspace(eDos[0], eDos[-1], intepNum) y = interp(eDos, distribution, x) #print (np.abs(yDosInterp)+0.001).min() ax.fill_between(x, y, color='b') #print yDosInterp.min() kargs = ma.getPropertyFromPosition(xlabel=xlabel, ylabel=ylabel, ylimits=ylimits, **kargs) ma.setProperty(ax, **kargs)
def drawEnergy(ax, relative = False, divided = 1.0, popFirstStep = True, label = ''): """ Draw the KS Energy and Total Energy in the ax """ X, temp, E_KS, Etot, volume, pressure = tdp.getEnergyTemperaturePressure() refEnergy=E_KS[0] if relative: E_KS = E_KS - refEnergy Etot = Etot - refEnergy if popFirstStep: ax.plot(X[1:],E_KS[1:]/divided,'-',linewidth=3.0,label = 'KS'+ label)#,color=ma.colors[0] ax.plot(X[1:],Etot[1:]/divided,'--',linewidth=3.0,label = 'Total'+ label)#,color=ma.colors[2] else: ax.plot(X,E_KS/divided,'-',linewidth=3.0,label = 'KS' + label)#,color=ma.colors[0] ax.plot(X,Etot/divided,'--',linewidth=3.0,label = 'Total' + label)#,color=ma.colors[2] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)',ylabel=r'Energy(eV)',title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def animate(i): i = i % len(dataAndAtoms) z = (dataAndAtoms[i][0] - pho0)[slide, :, :] atoms = dataAndAtoms[i][1] print z.min(), z.max() axs[0].contourf(x, y, z, 100, vmin=vmin, vmax=vmax, cmap=cm.jet) for pos, Z in zip(atoms.positions, atoms.numbers): axs[0].scatter(pos[2], pos[1], c=tuple(cpk_colors[Z]), s=400 * covalent_radii[Z]) setProperty( axs[0], **getPropertyFromPosition(0, xlimits=[2, 6], ylimits=[2, 6], xlabel=r'distance($\AA$)', ylabel=r'distance($\AA$)')) scatter.set_data(time[selectedTimeSteps[i]], light[selectedTimeSteps[i], 2]) setProperty( axs[1], **getPropertyFromPosition(1, xlabel=r'time(fs)', ylabel=r'E-Field(a.u.)')) plt.tight_layout()
def plotTemperature(ax, label=''): time, T, E_ks, E_tot, Vol, P = dp.getEnergyTemperaturePressure() ax.plot(time, T, lw=3, label=label) kargs = ma.getPropertyFromPosition(xlabel='Time (fs)', ylabel=r'T (K)', title='Temperature') ma.setProperty(ax, **kargs)
def plotTotalEnergy(ax, label=''): time, T, E_ks, E_tot, Vol, P = dp.getEnergyTemperaturePressure() ax.plot(time, E_tot - E_tot[0], '-', lw=2, alpha=1, label=label) kargs = ma.getPropertyFromPosition(ylabel=r'E (eV)', xlabel='T (fs)', title='Excitation Energy') ma.setProperty(ax, **kargs)
def case(indexCase, folderCase): data = scanFolder(getTime) selectedProcesses = ['evolve','DHSCF','PostSCF','siesta'] #,'TDbuildD' explainations = ['Propagation', 'Build H', 'Postprocess','Total'] #,'Build DM' image = data[-1][-1]['Prg.tot'] pieData = image[selectedProcesses[:-1]] other = image[selectedProcesses[-1]] - np.sum(pieData.values) ax = axsall[1][indexCase] explode = np.zeros(len(pieData)) + 0.04 explode[0] = 0.07 patches, texts, autotexts = ax.pie(pieData.values, explode=explode, labels=explainations[:-1], labeldistance = 0.2, autopct='%.0f%%',pctdistance = 0.7, shadow=True, textprops={'fontsize':'xx-large','color':'gold'}) for text in texts: text.set_fontsize(0) kargs=ma.getPropertyFromPosition(indexCase + 3, title='') ma.setProperty(ax,**kargs) for key,label in zip(selectedProcesses,explainations): totalTimes = np.array([time['Prg.tot'][key] for index, folder, time in data])/60.0 situations = np.array([int(folder) for index, folder, time in data]) ax = axsall[0][indexCase] ax.semilogy(situations, totalTimes,'-o', mew = 3, alpha=0.8 ,ms=12, label = label) # from scipy.optimize import curve_fit # popt, pcov = curve_fit(errorFunc, situations, totalTimes) # xfit = np.linspace(2,25,1000) # ax.semilogy(xfit, errorFunc(xfit,*popt),'--',lw=3, ) ax.grid(which='major',axis=u'both') kargs=ma.getPropertyFromPosition(indexCase, ylabel=r'Clock Time (Mimute)',title=folderCase, #xlimits = [0,10] ) ma.setProperty(ax,**kargs)
def plotExcitation(ax, label=''): time, exe = dp.getExcitedElectrons() ax.plot(time, exe - exe[0],'-', lw=2) kargs=ma.getPropertyFromPosition(ylabel=r'n(e)', xlabel='Time (fs)', title='Excited Electrons') print exe[-1] - exe[0] ma.setProperty(ax,**kargs)
def plotRMSD(ax, label=''): dp.getTrajactory() import pyramids.process.struct as pps time, distance = pps.calculateRMSD() ax.plot(time, distance, lw=2, label=label) kargs=ma.getPropertyFromPosition(xlabel='Time (fs)', ylabel=r'$\langle u \rangle^\frac{1}{2}$ ($\AA$)', title='RMSD') ma.setProperty(ax,**kargs)
def plotExcitation(ax, label=''): time, exe = dp.getExcitedElectrons() ax.plot(time, exe - exe[0], '-', lw=2) kargs = ma.getPropertyFromPosition(ylabel=r'n(e)', xlabel='Time (fs)', title='Excited Electrons') #print exe[-1] - exe[0] ma.setProperty(ax, **kargs)
def plotEField(ax, label=''): time, Efield = dp.getEField() directions = ['x', 'y', 'z'] for direct in range(3): if max(Efield[:,direct]) > 1E-10: ax.plot(time,Efield[:,direct], label=directions[direct], lw=2, alpha=1.0) kargs=ma.getPropertyFromPosition(ylabel=r'$\varepsilon$ (a.u.)',xlabel='Time(fs)', title='Electric Field') ma.setProperty(ax,**kargs)
def plotAField(ax, label=''): time, Afield = dp.getAField() #directions = ['x', 'y', 'z'] for direct in range(3): if max(Afield[:, direct]) > 1E-10: ax.plot(time, Afield[:, direct], label=label, lw=2, alpha=1.0) kargs = ma.getPropertyFromPosition(ylabel=r'$\varepsilon$(a.u.)', xlabel='Time(fs)', title='vector Field') ma.setProperty(ax, **kargs)
def plotRMSD(ax, label=''): dp.getTrajactory() import pyramids.process.struct as pps time, distance = pps.calculateRMSD() ax.plot(time, distance, lw=2, label=label) kargs = ma.getPropertyFromPosition( xlabel='Time (fs)', ylabel=r'$\langle u \rangle^\frac{1}{2}$ ($\AA$)', title='RMSD') ma.setProperty(ax, **kargs)
def case(indexCase, folderCase): data = scanFolder(getTime) selectedProcesses = ['evolve', 'DHSCF', 'PostSCF', 'siesta'] #,'TDbuildD' explainations = ['Propagation', 'Build H', 'Postprocess', 'Total'] #,'Build DM' image = data[-1][-1]['Prg.tot'] pieData = image[selectedProcesses[:-1]] other = image[selectedProcesses[-1]] - np.sum(pieData.values) ax = axsall[1][indexCase] explode = np.zeros(len(pieData)) + 0.04 explode[0] = 0.07 patches, texts, autotexts = ax.pie(pieData.values, explode=explode, labels=explainations[:-1], labeldistance=0.2, autopct='%.0f%%', pctdistance=0.7, shadow=True, textprops={ 'fontsize': 'xx-large', 'color': 'gold' }) for text in texts: text.set_fontsize(0) kargs = ma.getPropertyFromPosition(indexCase + 3, title='') ma.setProperty(ax, **kargs) for key, label in zip(selectedProcesses, explainations): totalTimes = np.array( [time['Prg.tot'][key] for index, folder, time in data]) / 60.0 situations = np.array([int(folder) for index, folder, time in data]) ax = axsall[0][indexCase] ax.semilogy(situations, totalTimes, '-o', mew=3, alpha=0.8, ms=12, label=label) # from scipy.optimize import curve_fit # popt, pcov = curve_fit(errorFunc, situations, totalTimes) # xfit = np.linspace(2,25,1000) # ax.semilogy(xfit, errorFunc(xfit,*popt),'--',lw=3, ) ax.grid(which='major', axis=u'both') kargs = ma.getPropertyFromPosition( indexCase, ylabel=r'Clock Time (Mimute)', title=folderCase, #xlimits = [0,10] ) ma.setProperty(ax, **kargs)
def plotKpoints(kpts): #Plot the K points from pyramids.plot.setting import setProperty, getPropertyFromPosition fig, ax = plt.subplots(1,1) ax.plot(kpts[:,0],kpts[:,1],'o') setProperty(ax,**getPropertyFromPosition(title='K points',xlabel=r'$k_x(1/\AA)$',ylabel=r'$k_y(1/\AA)$')) plt.axis('equal') plt.tight_layout() plt.savefig('Kpoints.pdf',dpi=600) plt.show() #plt.close() #unit = reciprocal_vectors/grid #KIndex = np.dot(kpts,np.linalg.inv(unit)) + [nkx/2, nky/2, nkz/2] #kIndex = np.array(KIndex, dtype=int) #skpts = np.array([kpts + np.dot([i,j,k],reciprocal_vectors) # for i in [0,-1,1] for j in [0,-1,1] for k in [0,-1,1]]) #skIndex = np.array(np.dot(skpts,np.linalg.inv(unit)) + [0.5,0.5,0], dtype=int) #print kIndex.shape, #skIndex.shape #print kIndex #Ef = 6.0 #T = 300 #qOrder = 2 #susp = np.zeros([qOrder,qOrder,qOrder],dtype=float) # # #for ik, ikpt in enumerate(kpts): # kxy = kIndex[ik] # for i in range(-qOrder,qOrder): # for j in range(-qOrder,qOrder): # for k in range(-qOrder,qOrder): # qxy = (kxy + np.array([i,j,k])) % np.array([nkx,nky,nkz]) # iq = qxy[0]*nky*nkz + qxy[1]*nkz + qxy[2] # #susp[i,j,k] = susFunc(eigValueAllK,ik,iq,Ef,T) # pass #print susp #if __name__ == "__main__": # nkx = 12 # nky = 12 # nkz = 1 # # Read the structure information from POSCAR # from ase.io import read # atoms = read('POSCAR') # # Generate K points, # # Selection: Monkhorst-Pack or Line-Mode # grid = np.array([nkx,nky,nkz],dtype=int) # kpts = getMPKpts(atoms,grid) # #kpts = getBandKpoints(atoms,npoints=50) # x, v, u = calculateEigenPairs(kpts) # plotBands(x, v) # plotKpoints(kpts)
def drawPartition(ax, label = ''): """ Draw the KS Energy and Total Energy in the ax """ X,qo = tdp.getPartition() ax.plot(X,qo,'-',linewidth=3.0,label = 'Partitions '+ label)#,color=ma.colors[0] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)',ylabel=r'Partition',title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def plotBands(xall,eigValueAllK): from pyramids.plot.setting import setProperty, getPropertyFromPosition fig, ax = plt.subplots(1,1) #Plot the eigenvalues for index in range(eigValueAllK.shape[0]): ax.plot(xall[index,:],eigValueAllK[index,:],'ob',lw=1) setProperty(ax,**getPropertyFromPosition(title='Energy Bands',xlabel=r'',ylabel=r'Energy(eV)',xticklabels=[])) #Set tight layout and output plt.axis('tight') plt.tight_layout() plt.savefig('Bands.pdf',dpi=600) plt.show()
def drawPressure(ax, label = ''): """ Draw the KS Energy and Total Energy in the ax """ X, temp, E_KS, Etot, volume, pressure = tdp.getEnergyTemperaturePressure() ax.plot(X,pressure,'-',linewidth=3.0,label = 'Pressure '+ label)#,color=ma.colors[0] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)',ylabel=r'Pressure(KBar)',title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def plotDOS(ax, step, ylimits=[0,None], bins=100, **kargs): xlabel = 'Energy (eV)' ylabel = 'DOS' eDosInterp, yDosInterp, yParInterp = dp.calculateDOS(step,bins=bins) ax.fill_between(eDosInterp, yParInterp, color='b') ax.fill_between(eDosInterp,-yParInterp, color='r') ax.fill_between(eDosInterp, yDosInterp, lw=3, color='g',alpha=0.2) kargs = ma.getPropertyFromPosition(xlabel=xlabel, ylabel=ylabel, ylimits=ylimits, yticklabels=[], **kargs) ma.setProperty(ax,**kargs)
def animate(i): i = i % len(dataAndAtoms) z = (dataAndAtoms[i][0]-pho0)[slide,:,:] atoms = dataAndAtoms[i][1] print z.min(), z.max() axs[0].contourf(x, y, z, 100,vmin = vmin,vmax =vmax, cmap = cm.jet) for pos, Z in zip(atoms.positions, atoms.numbers): axs[0].scatter(pos[2],pos[1],c=tuple(cpk_colors[Z]),s=400*covalent_radii[Z]) setProperty(axs[0],**getPropertyFromPosition(0,xlimits=[2,6],ylimits=[2,6], xlabel = r'distance($\AA$)',ylabel = r'distance($\AA$)')) scatter.set_data(time[selectedTimeSteps[i]],light[selectedTimeSteps[i],2]) setProperty(axs[1],**getPropertyFromPosition(1, xlabel = r'time(fs)',ylabel = r'E-Field(a.u.)')) plt.tight_layout()
def plotDOS(ax, step, ylimits=[0, None], bins=100, **kargs): xlabel = 'Energy (eV)' ylabel = 'DOS' eDosInterp, yDosInterp, yParInterp = dp.calculateDOS(step, bins=bins) ax.fill_between(eDosInterp, yParInterp, color='b') ax.fill_between(eDosInterp, -yParInterp, color='r') ax.fill_between(eDosInterp, yDosInterp, lw=3, color='g', alpha=0.2) kargs = ma.getPropertyFromPosition(xlabel=xlabel, ylabel=ylabel, ylimits=ylimits, yticklabels=[], **kargs) ma.setProperty(ax, **kargs)
def drawRDF(ax,step=None, label = ''): """ Draw the KS Energy and Total Energy in the ax """ if step == None: step = tdp.getNumStep() systemLabel,timestep = tdp.getSystemLabelTimpstep() tdp.splitMDCAR() hist,bin_edges = tdp.calculateRDF(step-1) ax.plot(bin_edges[:-1],hist,linewidth=3.0,label='RDF '+str((step)*timestep)+' fs'+ label) #,color=ma.colors[0] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Radius($\AA$)',ylabel=r'RDF(a.u.)',title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def drawPartition(ax, label=''): """ Draw the KS Energy and Total Energy in the ax """ X, qo = tdp.getPartition() ax.plot(X, qo, '-', linewidth=3.0, label='Partitions ' + label) #,color=ma.colors[0] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)', ylabel=r'Partition', title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def drawPressure(ax, label=''): """ Draw the KS Energy and Total Energy in the ax """ X, temp, E_KS, Etot, volume, pressure = tdp.getEnergyTemperaturePressure() ax.plot(X, pressure, '-', linewidth=3.0, label='Pressure ' + label) #,color=ma.colors[0] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)', ylabel=r'Pressure(KBar)', title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def drawRMSD(ax,selected=None, label = '', init = 0): """ Draw the KS Energy and Total Energy in the ax """ systemLabel,timestep = tdp.getSystemLabelTimpstep() if selected == None: selected = range(0,tdp.getNumStep(),int(1.0/timestep)) tdp.splitMDCAR() time,distance,velocity = tdp.calculateRMSD(selected, init=init) #os.remove('POSCAR') ax.plot(time,distance,linewidth=3.0,label='RMSD'+ label)#,color=ma.colors[0]) kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)',ylabel=r'RMSD($\AA$)',title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def plotDistribution(ax, step, bins=100, intepNum=2000, ylimits=[0,1], **kargs): xlabel = 'Energy (eV)' ylabel = 'FD' yticklabels=[] eDos, dos, par = dp.calculateDOS(step, ref=False, interp=False,bins=bins) distribution = ((par))/((dos)+1E-10) def interp(xin,yin,xout): from scipy.interpolate import interp1d spline = interp1d(xin, yin, kind='cubic') return spline(xout) x = np.linspace(eDos[0], eDos[-1], intepNum) y = interp(eDos, distribution, x) #print (np.abs(yDosInterp)+0.001).min() ax.fill_between(x, y, color='b') #print yDosInterp.min() kargs = ma.getPropertyFromPosition(xlabel=xlabel, ylabel=ylabel, ylimits=ylimits, **kargs) ma.setProperty(ax,**kargs)
def drawEnergy(ax, relative=False, divided=1.0, popFirstStep=True, label=''): """ Draw the KS Energy and Total Energy in the ax """ X, temp, E_KS, Etot, volume, pressure = tdp.getEnergyTemperaturePressure() refEnergy = E_KS[0] if relative: E_KS = E_KS - refEnergy Etot = Etot - refEnergy if popFirstStep: ax.plot(X[1:], E_KS[1:] / divided, '-', linewidth=3.0, label='KS' + label) #,color=ma.colors[0] ax.plot(X[1:], Etot[1:] / divided, '--', linewidth=3.0, label='Total' + label) #,color=ma.colors[2] else: ax.plot(X, E_KS / divided, '-', linewidth=3.0, label='KS' + label) #,color=ma.colors[0] ax.plot(X, Etot / divided, '--', linewidth=3.0, label='Total' + label) #,color=ma.colors[2] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)', ylabel=r'Energy(eV)', title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def action(index,folder): ls = ['-','-','-','-'] ax = axs[0] time, Efield = dP.getEField() #directions = ['x', 'y', 'z'] for direct in range(3): if max(Efield[:,direct]) > 1E-10: ax.plot(time,Efield[:,direct], label=folder,lw=2,alpha=0.5) kargs=ma.getPropertyFromPosition(ylabel=r'$\varepsilon$(a.u.)',xlabel='Time(fs)', title='Electric Field') ma.setProperty(ax,**kargs) ax.ticklabel_format(style='sci',axis='y',scilimits=[0,0]) #------------------------------------------------------------------------------ ax = axs[1] time, T, E_ks, E_tot, Vol, P = dP.getEnergyTemperaturePressure(ave=True) # for i in range(2,E_ks.shape[0]-1): # if E_ks[i+1] - (E_ks[i] + E_ks[i-1])*0.5 > 2.0: # E_ks[i+1] = (E_ks[i] + E_ks[i-1])*0.5 ax.plot(time[2:], E_ks[2:] - E_ks[2],'-', lw=1, alpha=1, label=folder) kargs=ma.getPropertyFromPosition(ylabel=r'E(eV)',title='Excitation Energy') ma.setProperty(ax,**kargs)
def drawEigenvalue(ax, label = ''): """ Draw the KS Energy and Total Energy in the ax """ X,eo = tdp.getEigenvalues() X,qo = tdp.getPartition() countEleState = 0 countHolState = 0 countNormalState = 0 for i in range(eo.shape[1]): if eo[0,i] > 0.03 and qo[0,i] > 0.2: if countEleState == 0: ax.plot(X,eo[:,i],'-',linewidth=3.0,color=ma.colors[0],label='Electron'+ label) else: ax.plot(X,eo[:,i],'-',linewidth=3.0,color=ma.colors[0]) countEleState += 1 elif eo[0,i] < -0.03 and qo[0,i] < 1.8: if countHolState == 0: ax.plot(X,eo[:,i],'-',linewidth=3.0,color=ma.colors[1],label='Hole'+ label) else: ax.plot(X,eo[:,i],'-',linewidth=3.0,color=ma.colors[1]) countHolState +=1 else: if countNormalState == 0: ax.plot(X,eo[:,i],'--',linewidth=3.0,color='grey',alpha=0.7,label='Normal'+ label) else: ax.plot(X,eo[:,i],'--',linewidth=3.0,color='grey',alpha=0.7) countNormalState +=1 #ax.plot(X,eo,'-',linewidth=qo,label = 'Eigenvalues')#,color=ma.colors[0] kargs = ma.getPropertyFromPosition(index=None, xlabel=r'Time(fs)',ylabel=r'Eigenvalues(eV)',title='', xticks=None, yticks=None, xticklabels=None, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
def drawBands(ax,bandType='e', label = ''): """ Draw the KS Energy and Total Energy in the ax """ X, Ek, xticks, xticklabels = tdp.getBands() if bandType == 'e': eFermi = tdp.getFermiEnergy() Ek = Ek - eFermi ylabel = 'Energy(eV)' else: ylabel = r'$\omega$(cm$^{-1}$)' alpha = 1.0 color = 'b' for ispin in range(Ek.shape[2]): for iband in range(1,Ek.shape[1]): ax[0].plot(X,Ek[:,iband,ispin],lw=3.0,ls='-',color=color,alpha=alpha,label=label) kargs = ma.getPropertyFromPosition(index=None, xlabel=r'',ylabel=ylabel,title='', xticks=xticks, yticks=None, xticklabels=xticklabels, yticklabels=None, xlimits=None, ylimits=None) ma.setProperty(ax, **kargs)
# interpXimge = np.linspace(data[0][xDownIndex], data[0][xUpIndex-1], 2000) # splinesimge = interp1d(data[0][xDownIndex:xUpIndex], data[1][xDownIndex:xUpIndex],kind='cubic') # overEimge = splinesimge(interpXimge) # # interpXreal = np.linspace(data[0][xDownIndex], data[0][xUpIndex-1], 2000) # splinesreal = interp1d(data[0][xDownIndex:xUpIndex], data[3][xDownIndex:xUpIndex],kind='cubic') # overEreal = splinesreal(interpXreal) # # interpXeels = np.linspace(data[0][xDownIndex], data[0][xUpIndex-1], 2000) # splineseels = interp1d(data[0][xDownIndex:xUpIndex], data[4][xDownIndex:xUpIndex],kind='cubic') # overEeels = splineseels(interpXeels) # plt.plot(interpX,splines(interpX)/np.max(splines(interpX)),'-o',markersize=5.0,linewidth=4.0,color=colors[i],alpha=0.6,label=data[2]) plt.plot(data[0],i*3+data[1]/np.max(data[1]),'--',markersize=10.0,linewidth=3.0,color=colors[i+1],alpha=0.65) plt.plot(data[0],i*3+data[3]/np.max(data[3]),'-',markersize=10.0,linewidth=3.0,color=colors[i+1],alpha=0.65) # plt.plot(interpXreal,i*3+interpXreal-interpXreal,'-',markersize=10.0,linewidth=6.0,color=colors[i+1],alpha=0.65) plt.fill_between(data[0],i*3+(data[4])/np.max(data[4]),i*3,linewidth=3.0,color=colors[i+1],alpha=0.5,) # plt.plot(interpX,splines(interpX),'-o',markersize=5.0,linewidth=4.0,color=colors[i],alpha=0.6,label=data[2]) # plt.plot(data[0],data[1]/np.max(data[1]),'-o',linewidth=4.0,color=colors[i+1],alpha=0.6,label=data[2]) # plt.plot(data[0],data[1]/float(data[2]),'-o',linewidth=4.0,color=colors[i+1],alpha=0.6,label=data[2]) args = getPropertyFromPosition(xlimits=xlimits,ylimits=ylimits, ylabel='EELs',xlabel='Energy(eV)')#,vline=data[3]) setProperty(ax,**args) #plt.show() plt.tight_layout() #plt.savefig('dielectriFunctionVariable(without over E or maxabsorbance).pdf',dpi=600) plt.savefig('EEls.eps',i=800) plt.savefig('EEls.png',i=800) #plt.savefig('dielectriFunctionVariable1-1.jpg',dpi=600)
#Sk = S[iblock*S.shape[1]:(iblock+1)*S.shape[1],:] #Hk = H[iblock*H.shape[1]:(iblock+1)*H.shape[1],:] #Hcase.append(Hk) #eig=np.sort(np.linalg.eigvals(np.linalg.inv(Sk).dot(Hk))*13.60580) #eig -= ef comp -= ef if index == 1: x.append(float(efield)*1.0) else: x.append(float(efield)) z.append(comp.flatten()) os.chdir('..') HAll.append(Hcase) ax.plot(x,z,'-o',c=c[index],alpha=0.7) os.chdir('..') ax.plot([],[],'-o',c=c[0],alpha=0.7,label=folders[0]) ax.plot([],[],'-o',c=c[1],alpha=0.7,label=folders[1]) setProperty(ax,**getPropertyFromPosition(title=struct, xlabel=r'$\varepsilon$(Ry/Bohr/e)', ylabel='Eigenvalues(eV)', ylimits=[-2,2])) saveTypes = ['.pdf'] plt.tight_layout() for save_type in saveTypes: plt.savefig(struct+save_type,transparent=True,dpi=600)
maxPeak = energyArray[np.argmax(absorbanceSum)], np.max(absorbanceSum) maxMinusPeak = energyArray[np.argmin(absorbanceSum)], np.min(absorbanceSum) xlimits = [0, 8]#maxPeak[0]*1.5] ylimits = None#[0, 50]#[0, maxPeak[1]] from scipy.signal import argrelextrema extrema = argrelextrema(absorbanceSum, np.greater) maxPeakValue = max(absorbanceSum) peaks = [] for extreme in extrema[0]: peakPosition, peakValue = energyArray[extreme]/4.3, absorbanceSum[extreme] if peakValue > 0.01 * maxPeakValue: peaks.append((peakPosition,peakValue)) # axs.text(peakPosition, maxPeakValue*0.7,'%3.2f' % peakPosition, fontsize='large',rotation=90) peaks = np.array(peaks) axs[0].semilogy(energyArray/guassFieldEnergy,absorbanceSumHHG,'-',linewidth=2.,color='black',label='Total',alpha=0.5) axs[1].plot(energyArray/guassFieldEnergy,absorbanceSumHHG,'-',linewidth=2.,color='red',label='Total') args1 = getPropertyFromPosition(xlimits=xlimits,ylimits=ylimits, ylabel='absorbance',xlabel='Order') args2 = getPropertyFromPosition(xlimits=xlimits,ylimits=None, ylabel='absorbance',xlabel='Order') setProperty(axs[0],**args1) setProperty(axs[1],**args2) #plt.tight_layout() plt.savefig('HHG.pdf',dpi=600)
omega = 0.5 L = 10.0 k = (1/L)*2*np.pi x = np.linspace(0,L,100) t0 = 100 def gaussian(t, t0): return np.exp(-(t-t0)**2/(t0*0.66)**2) ax0 = fig.add_subplot(3,1,1) light = np.sin(omega*0.0 + k*x) line, = ax0.plot(x,light) comp, = ax0.plot([0,L],[0,0],'--') kargs=getPropertyFromPosition(xlabel=r'distance',ylabel=r'EField') setProperty(ax0,**kargs) ax1 = fig.add_subplot(3,1,2,sharex=ax0) light2 = np.sin(omega*0.0 + k*x) line2, = ax1.plot(x,light2) kargs=getPropertyFromPosition(xlabel=r'distance',ylabel=r'EField') setProperty(ax1,**kargs) ax2 = fig.add_subplot(3,1,3) interval = np.linspace(0,2*t0,500) ax2.plot(interval,np.sin(omega*interval)*gaussian(interval,t0)) scatter, = ax2.plot(0,np.sin(omega*0),'o') kargs=getPropertyFromPosition(xlabel=r'Time',ylabel=r'EField') setProperty(ax2,**kargs)
fig=plt.figure(figsize=A4_LANDSCAPE)#_LANDSCAPE plt.subplots_adjust(left=0.1, bottom=0.10, right=0.95, top=0.95, wspace=0.3, hspace=0.05) axs = [fig.add_subplot(2,1,1), fig.add_subplot(2,1,2)] colors = getColors(4) chargeData=np.loadtxt('AECHARGE') kargs=getPropertyFromPosition(1,'Charge(e)',r'r($\AA$)') axs[0].plot(chargeData[:,0],chargeData[:,1],':',linewidth=3,label='Down',color=colors[1]) axs[0].plot(chargeData[:,0],chargeData[:,2],'--',linewidth=3,label='Up',color=colors[2]) axs[0].plot(chargeData[:,0],chargeData[:,3],'-',linewidth=3,label='Core',color=colors[0]) axs[0].legend(fontsize=16,loc=1) kargs['xlimits'] = [0,6] kargs['xticklabels'] = [] setProperty(axs[0],**kargs) numWFfiles=int(os.popen('ls AEWFNR* |wc -l').readline()) print numWFfiles waveData = [] lineTypes=['-','--',':'] orbitalType=['s','p','d','f'] for indexFile in range(min(numWFfiles,3)): waveData=np.loadtxt('AEWFNR'+str(indexFile)) axs[1].plot(waveData[:,0],waveData[:,1],lineTypes[indexFile],linewidth=3,label=orbitalType[indexFile],color=colors[indexFile]) kargs=getPropertyFromPosition(2,'Wavefunction',r'r($\AA$)') axs[1].legend(fontsize=16,loc=1) kargs['xlimits'] = [0,15]
ax = axs[exEnergy] tolerance = 0.5 for ie, e in enumerate(deltaE[1:-2]): if np.abs(deltaE[ie] - deltaE[ie - 1]) > tolerance and np.abs( deltaE[ie] - deltaE[ie + 1]) > tolerance: deltaE[ie] = (deltaE[ie - 1] + deltaE[ie + 1]) / 2 ax.plot(timeEn[2:], deltaE, '-', c=c[index], lw=2, alpha=1) maxElectrons.append(exe.max()) maxEnergies.append(deltaE.max()) minEnergies.append(deltaE.min()) kargs = ma.getPropertyFromPosition( exElectron, ylabel=r'n(e)', title='Excited Electrons', ylimits=[0, np.max(maxElectrons)], xlimits=None, ) ma.setProperty(axs[exElectron], **kargs) kargs = ma.getPropertyFromPosition( exEnergy, ylabel=r'E(eV)', ylimits=[np.min(minEnergies), np.max(maxEnergies)], title='Excitation Energy') ma.setProperty(axs[exEnergy], **kargs) plt.tight_layout() for save_type in ['.pdf', '.png']: filename = SaveName + save_type plt.savefig(filename, dpi=800)
time, msd = dp.readMSD() nocc = int(float(os.popen('grep "starting charge" result').readline().split()[-1])/2.0) fig, axs = plt.subplots(2,2,sharex=True,figsize=(8,5)) axs = axs.flatten() norm, kweight = readData('pwscf.norm.dat') excite = (norm - norm[0,:,:]) for ib in range(excite.shape[2]): excite[:,:,ib] *= kweight #pass step = min(time.shape[0]-1, excite.shape[0]) axs[0].plot(time[1:step+1], (excite[:step,:,:nocc]).sum(axis=(1,2))) axs[0].plot(time[1:step+1], (excite[:step,:,nocc:]).sum(axis=(1,2))) args = ma.getPropertyFromPosition(0,title='Excited electrons',ylabel='n (e)') ma.setProperty(axs[0],**args) Efield = [[float(i) for i in line.split()] for line in open('TDEFIELD')] Efield = np.array(Efield)/1E5 ppu.plotTotalEnergy(axs[2]) ppu.plotEField(axs[1]) f = os.popen('grep "first current is " result') current = np.array([[float(i) for i in line.split()[-3:]] for line in f.readlines()]) for idir in range(3): axs[3].plot(time[1:], current[:,idir],'-',label=['x','y','z'][idir]) args = ma.getPropertyFromPosition(3,title='Current',ylabel='j (a.u.)') ma.setProperty(axs[3],**args)
maxEnergies = [] minEnergies = [] for [(index, folder), (timeEn,deltaE, T)] in data: eField = float(folder) * 13.6/0.529 ax = axs[exTemp] ax.plot(timeEn, T,'-', c=c[index], lw=2, alpha=1) ax = axs[exEnergy] ax.plot(timeEn, deltaE,'-', c=c[index], label=r'%5.2f $V/\AA$' % eField, lw=2, alpha=1) kargs=ma.getPropertyFromPosition(exEnergy, ylabel=r'E(eV)', title='Excitation Energy', xlabel='Time (fs)', #ylimits=[0,np.max(maxElectrons)], xlimits=None,) ma.setProperty(axs[exEnergy],**kargs) kargs=ma.getPropertyFromPosition(exTemp, ylabel=r'T(K)', #ylimits=[np.min(minEnergies),np.max(maxEnergies)], title='Temperature') ma.setProperty(axs[exTemp],**kargs) plt.tight_layout() for save_type in ['.pdf','.png']: filename = SaveName + save_type plt.savefig(filename,dpi=800)
absorbanceSum += absorbance axs.fill_between(energyArray/8.56,absorbance,0.0,color=colors[i],label=direct,alpha=0.6) os.chdir('..') maxPeak = energyArray[np.argmax(absorbanceSum)], np.max(absorbanceSum) maxMinusPeak = energyArray[np.argmin(absorbanceSum)], np.min(absorbanceSum) xlimits = [0.1, 8]#maxPeak[0]*1.5] ylimits = [0, maxPeak[1]] from scipy.signal import argrelextrema extrema = argrelextrema(absorbanceSum, np.greater) maxPeakValue = max(absorbanceSum) peaks = [] for extreme in extrema[0]: peakPosition, peakValue = energyArray[extreme], absorbanceSum[extreme] if peakValue > 0.05 * maxPeakValue: peaks.append((peakPosition,peakValue)) axs.text(peakPosition, maxPeakValue*0.7,'%3.2f' % peakPosition, fontsize='large',rotation=90) peaks = np.array(peaks) #axs.semilogy(energyArray/8.56,absorbanceSum,'-',linewidth=2.,color='black',label='Total',alpha=0.5) axs.plot(energyArray/8.56,absorbanceSum,'-',linewidth=2.,color='black',label='Total') args = getPropertyFromPosition(xlimits=xlimits,ylimits=ylimits, ylabel='absorbance',xlabel='energy(eV)') setProperty(axs,**args) plt.tight_layout() #plt.savefig('dielectriFunction.pdf',dpi=600)
#print timeEf.shape, eField.shape ax.plot(timeEf, eField * 13.6 / 0.529) maxElectrons.append(exe.max()) maxEnergies.append(deltaE.max()) minEnergies.append(deltaE.min()) kargs = ma.getPropertyFromPosition( exElectron, ylabel=r'n(e)', title='Excited Electrons', xlabel='Time (fs)', xlimits=[0, 40], #ylimits=[0,np.max(maxElectrons)], ) ma.setProperty(axs[exElectron], **kargs) kargs = ma.getPropertyFromPosition( exEnergy, ylabel=r'E (eV)', xlimits=[0, 40], #ylimits=[np.min(minEnergies),np.max(maxEnergies)], title='Excitation Energy') ma.setProperty(axs[exEnergy], **kargs) kargs = ma.getPropertyFromPosition( efield, ylabel=r'E ($V/\AA$)', xlabel='Time (fs)', xlimits=[0, 40], #ylimits=[np.min(minEnergies),np.max(maxEnergies)], title='Electric Field') ma.setProperty(axs[efield], **kargs)
eDosInterp = np.linspace(bin_edges[0], bin_edges[-2], 2E4) yDosInterp = interp(bin_edges[:-1], hist, eDosInterp) eDosPartInterp = np.linspace(bin_edges[0], bin_edges[-2], 2E4) yDosPartInterp = interp(bin_edges[:-1], hist_o, eDosPartInterp) ax.plot(eDosInterp, yDosInterp, '.g', lw=3) ax.fill_between(eDosPartInterp[:1E4], (yDosInterp - yDosPartInterp)[:1E4], color='b') ax.fill_between(eDosPartInterp[1E4:], (yDosPartInterp)[1E4:], color='r') ma.setProperty( ax, **ma.getPropertyFromPosition(0, xlabel=xlabel, ylabel='DOS', xlimits=xlimits, ylimits=[0, None], yticklabels=[])) ax = axs[1] ax.fill_between(ePart, yPart, 0.0, lw=4, color='b') def FermiDiracDistrib(E, T): return 1.0 / (np.exp((E) / T) + 1) from scipy.optimize import curve_fit popt, pcov = curve_fit(FermiDiracDistrib, ePart, yPart) print popt
import numpy as np import matplotlib.pyplot as plt from pyramids.plot.setting import getPropertyFromPosition, setProperty from gpaw.tddft import photoabsorption_spectrum import os print os.path.abspath('.') name = os.path.abspath('.').split('/')[-1] fig, ax = plt.subplots(1, 1, figsize=(6, 6 / 2**0.5)) colors = ['r', 'g', 'b'] direct = ['x', 'y', 'z'] for i in range(3): photoabsorption_spectrum(name + str(i) + '.dm', name + str(i) + '.spec', width=0.5) data = np.loadtxt(name + str(i) + '.spec') ax.plot(data[:, 0], data[:, 1], colors[i], label=direct[i]) setProperty( ax, **getPropertyFromPosition(title=r'Absorption spectrum of ' + name, xlabel='eV', ylabel='Absorption (arbitrary units)')) plt.tight_layout() for save_type in ['.pdf', '.png']: filename = name + save_type plt.savefig(filename, dpi=600)
def plotAllEnergies(ax, label=''): time, T, E_ks, E_tot, Vol, P = dp.getEnergyTemperaturePressure() ax.plot(time, E_tot - E_tot[0],'-', lw=2, alpha=1, label=label) ax.plot(time, E_ks - E_ks[0],'-', lw=2, alpha=1, label=label) kargs=ma.getPropertyFromPosition(ylabel=r'E(eV)',xlabel='T (fs)', title='Excitation Energy') ma.setProperty(ax,**kargs)
for k in kcoorAll: ct1 = ax.scatter(k[:,0], k[:,1], norm*plotted, color = colors[index], marker='h', alpha=1.0, lw=0.0) ct2 = gap.scatter(k[:,0], k[:,1], outRange, cmap=cmap, c=diffEnergy, vmin = 1.0, vmax = 5.0, marker='h', alpha=1.0, lw=0.00) ax.scatter([], [], 60, color = colors[index], label=folder, alpha=1.0, lw=0.0) if index ==0 : #plt.colorbar(ct2,ax=ax,extendrect=False) plt.colorbar(ct2,ax=gap,extendrect=False) fig, axs = plt.subplots(1,2,figsize=(10,5),sharex=True,sharey=True) SaveName = __file__.split('/')[-1].split('.')[0] cmap = 'gist_rainbow' colors = 'b', 'lime', 'yellow', 'r' pu.scanFolder(action) setProperty(axs[0],**getPropertyFromPosition(0, title='Excitation', xticklabels=[], yticklabels=[], #xlabel=r'$k_x (\AA^{-1})$', ylabel="$k_y (\AA^{-1})$", )) setProperty(axs[1],**getPropertyFromPosition(1, title='Energy Difference', xlimits=[-2,2], ylimits=[-2,2], xticklabels=[], yticklabels=[], #xlabel=r'$k_x (\AA^{-1})$', ylabel="$k_y (\AA^{-1})$", )) # --------------------------------------Final---------------------------------- plt.tight_layout() for save_type in ['.pdf']: filename = SaveName + save_type plt.savefig(filename, orientation='portrait',dpi=600)
lw=2, alpha=1) ax = axs[efield] #print timeEf.shape, eField.shape ax.plot(timeEf, eField*13.6/0.529) maxElectrons.append(exe.max()) maxEnergies.append(deltaE.max()) minEnergies.append(deltaE.min()) kargs=ma.getPropertyFromPosition(exElectron, ylabel=r'n(e)', title='Excited Electrons', xlabel = 'Time (fs)', xlimits=[0,40], #ylimits=[0,np.max(maxElectrons)], ) ma.setProperty(axs[exElectron],**kargs) kargs=ma.getPropertyFromPosition(exEnergy, ylabel=r'E (eV)', xlimits=[0,40], #ylimits=[np.min(minEnergies),np.max(maxEnergies)], title='Excitation Energy') ma.setProperty(axs[exEnergy],**kargs) kargs=ma.getPropertyFromPosition(efield, ylabel=r'E ($V/\AA$)', xlabel = 'Time (fs)', xlimits=[0,40], #ylimits=[np.min(minEnergies),np.max(maxEnergies)], title='Electric Field') ma.setProperty(axs[efield],**kargs) kargs=ma.getPropertyFromPosition(ipiTemp, ylabel=r'T (K)', xlabel = 'Time (fs)', xlimits=[0,40], #ylimits=[np.min(minEnergies),np.max(maxEnergies)], title='Temperature') ma.setProperty(axs[ipiTemp],**kargs)
lw=3, ) axin.plot( time, ref, '-', lw=3, ) axin.fill_between(time, E_ks, ref, color='r', alpha=0.8, label=r'$\Delta$') #axin.text(10.0,-0.10,r'$\Delta$',transform=axin.transAxes,fontsize=100) #ax.annotate('eqweqweqeqw$\Delta$',(0,0.0),(0,0),fontsize=50,arrowprops={ 'arrowstyle': '->'}) #() kargs = ma.getPropertyFromPosition(ylabel=r'Excitation enegy', xlabel='Time', xticklabels=[], yticklabels=[]) ma.setProperty(axin, **kargs) def getEnergy(index, folder): time, T, E_ks, E_tot, Vol, P = dP.getEnergyTemperaturePressure(ave=True) return index, folder, E_ks def errorFunc(x, A, B): return A * np.exp(B / x) os.chdir('../../Data/') print os.listdir('.') for ufolder in os.listdir('.'): if os.path.isdir(ufolder):
selectedProcesses = ['evolve','DHSCF','PostSCF','siesta'] #,'TDbuildD' explainations = ['Propagation', 'Build H', 'Postprocess','Total'] #,'Build DM' image = data[-1][-1]['Prg.tot'] pieData = image[selectedProcesses[:-1]] other = image[selectedProcesses[-1]] - np.sum(pieData.values) ax = axs[1] explode = np.zeros(len(pieData)) + 0.04 explode[0] = 0.07 patches, texts, autotexts = ax.pie(pieData.values, explode=explode, labels=explainations[:-1], labeldistance = 0.2, autopct='%.0f%%',pctdistance = 0.7, shadow=True, textprops={'fontsize':'xx-large','color':'gold'}) for text in texts: text.set_fontsize('xx-large') plt.axis('tight') for key,label in zip(selectedProcesses,explainations): totalTimes = np.array([time['Prg.tot'][key] for index, folder, time in data])/3600.0 situations = [int(folder) for index, folder, time in data] ax = axs[0] ax.plot(situations, totalTimes,'-o', ms=12, label = label) kargs=ma.getPropertyFromPosition(ylabel=r'Clock Time (hour)',title='Clock Time') ma.setProperty(ax,**kargs) plt.tight_layout() for save_type in ['.pdf','.eps']: filename = SaveName + save_type plt.savefig(filename,dpi=800)
lw=0.0) if index == 0: #plt.colorbar(ct2,ax=ax,extendrect=False) plt.colorbar(ct2, ax=gap, extendrect=False) fig, axs = plt.subplots(1, 2, figsize=(10, 5), sharex=True, sharey=True) SaveName = __file__.split('/')[-1].split('.')[0] cmap = 'gist_rainbow' colors = 'b', 'lime', 'yellow', 'r' pu.scanFolder(action) setProperty( axs[0], **getPropertyFromPosition( 0, title='Excitation', xticklabels=[], yticklabels=[], #xlabel=r'$k_x (\AA^{-1})$', ylabel="$k_y (\AA^{-1})$", )) setProperty( axs[1], **getPropertyFromPosition( 1, title='Energy Difference', xlimits=[-2, 2], ylimits=[-2, 2], xticklabels=[], yticklabels=[], #xlabel=r'$k_x (\AA^{-1})$', ylabel="$k_y (\AA^{-1})$", ))
exY = np.array([Z[i][ext] for ext in extreme]) #miX = np.array([d[ext,0] for ext in extremM]) #miY = np.array([Z[i][ext] for ext in extremM]) ax1.scatter(q * np.ones(exY.shape[0]), exY, 30, lw=0.0) #ax1.scatter(q*np.ones(miY.shape[0]),miY,miX*30,lw=0.0,color='r') #print extreme #ax.fill_between(E,C[i],color='r',zs=i*0.01, zdir='z') shift = -i * 0.0 #ax.plot(E[selectIndex],Z[i][selectIndex], lw=1, color=c[i]) ax.fill_between(E[selectIndex], Z[i][selectIndex] + shift, shift, lw=3, color=c[i]) axs[2].plot(q * np.ones(exX.shape[0]), exX, 'or') ax.plot(exX, exY, 'ob') args = ma.getPropertyFromPosition( #ylimits=[None,0.2], xlimits=[None,5], grid=False, title='EELS spectra: $%s$' % label, #ylabel=r'q($\AA^{-1}$)', xlabel='Energy(eV)') ma.setProperty(ax, **args) #from mpl_toolkits.axes_grid1.inset_locator import mark_inset #mark_inset(axs[0], axs[1], loc1=2, loc2=3, fc="none", ec="0.5",ls='--',lw=3,zorder=100) plt.tight_layout() for save_type in ['.png', '.pdf']: filename = SaveName + save_type plt.savefig(filename, orientation='portrait', dpi=600)
os.popen('grep "number of electrons" result').readline().split()[-1]) / 2.0) fig, axs = plt.subplots(2, 2, sharex=True, figsize=(8, 5)) axs = axs.flatten() norm, kweight = readData('pwscf.norm.dat') excite = (norm - norm[0, :, :]) for ib in range(excite.shape[2]): excite[:, :, ib] *= kweight #pass time = np.array(range(excite.shape[0] + 1)) step = min(time.shape[0] - 1, excite.shape[0]) axs[0].plot(time[1:step + 1], (excite[:step, :, :nocc]).sum(axis=(1, 2))) axs[0].plot(time[1:step + 1], (excite[:step, :, nocc:]).sum(axis=(1, 2))) args = ma.getPropertyFromPosition(0, title='Excited electrons', ylabel='n (e)') ma.setProperty(axs[0], **args) Efield = [[float(i) for i in line.split()] for line in open('TDEFIELD')] Efield = np.array(Efield) / 1E5 ppu.plotTotalEnergy(axs[2]) ppu.plotEField(axs[1]) f = os.popen('grep "current is " result') current = np.array([[float(i) for i in line.split()[-3:]] for line in f.readlines()]) for idir in range(3): axs[3].plot(time[1:], current[:, idir], '-', label=['x', 'y', 'z'][idir]) args = ma.getPropertyFromPosition(3, title='Current', ylabel='j (a.u.)') ma.setProperty(axs[3], **args)
ax = axs[exElectron] ax.plot(timeEl,exe,'-',alpha=0.8, label=folder,c=c[index], markerfacecolor='w',lw=2) #------------------------------------------------------------------------------ ax = axs[exEnergy] tolerance = 0.5 for ie, e in enumerate(deltaE[1:-2]): if np.abs(deltaE[ie] - deltaE[ie-1]) > tolerance and np.abs(deltaE[ie] - deltaE[ie+1]) > tolerance: deltaE[ie] = (deltaE[ie - 1] + deltaE[ie + 1])/2 ax.plot(timeEn[2:], deltaE,'-', c=c[index], lw=2, alpha=1) maxElectrons.append(exe.max()) maxEnergies.append(deltaE.max()) minEnergies.append(deltaE.min()) kargs=ma.getPropertyFromPosition(exElectron, ylabel=r'n(e)', title='Excited Electrons', ylimits=[0,np.max(maxElectrons)], xlimits=None,) ma.setProperty(axs[exElectron],**kargs) kargs=ma.getPropertyFromPosition(exEnergy, ylabel=r'E(eV)', ylimits=[np.min(minEnergies),np.max(maxEnergies)], title='Excitation Energy') ma.setProperty(axs[exEnergy],**kargs) plt.tight_layout() for save_type in ['.pdf','.png']: filename = SaveName + save_type plt.savefig(filename,dpi=800)
def plotTemperature(ax, label=''): time, T, E_ks, E_tot, Vol, P = dp.getEnergyTemperaturePressure() ax.plot(time, T, lw=3, label=label) kargs=ma.getPropertyFromPosition(xlabel='Time (fs)', ylabel=r'T (K)', title='Temperature') ma.setProperty(ax,**kargs)