Beispiel #1
0
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()
Beispiel #2
0
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)
Beispiel #3
0
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 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()
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
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)
Beispiel #8
0
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)
Beispiel #9
0
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)
Beispiel #10
0
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)
Beispiel #11
0
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)
Beispiel #12
0
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)  
Beispiel #13
0
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)
Beispiel #14
0
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)
Beispiel #15
0
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)
Beispiel #16
0
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)
Beispiel #17
0
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)
Beispiel #18
0
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)
Beispiel #19
0
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) 
Beispiel #20
0
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()
Beispiel #21
0
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)
Beispiel #22
0
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)
Beispiel #23
0
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)
Beispiel #24
0
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)
Beispiel #25
0
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) 
Beispiel #26
0
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)
Beispiel #27
0
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)
Beispiel #28
0
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) 
Beispiel #29
0
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)
Beispiel #30
0
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)
Beispiel #31
0
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)
Beispiel #32
0
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) 
#--------------------------------------------------------------------------------------------
fig, axs = plt.subplots(2, 1, sharex=True, sharey=False, figsize=(10, 8))  #
data = scanFolder(action)
c = ma.getColors(len(data))

for line in data:
    index, folder = line[0]
    ax = axs[1]
    cts = ax.plot(line[1][0],
                  line[1][2] - line[1][2][0],
                  lw=3,
                  label=folder,
                  c=c[index])
    kargs = ma.getPropertyFromPosition(xlabel='Time (fs)',
                                       ylabel=r'E/atom (eV)',
                                       title='Excitation Energy')
    ma.setProperty(ax, **kargs)
    ax = axs[0]
    if index == 5:
        cts = ax.plot(line[2][0],
                      line[2][1][:, 2],
                      lw=1,
                      c=c[index],
                      label='400 nm')
        kargs = ma.getPropertyFromPosition(xlabel='Time (fs)',
                                           ylabel=r'$\varepsilon$ (a.u.)',
                                           title='Electric Field')
        #plt.colorbar(cts,ax=ax)
        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)
Beispiel #35
0
  lines = os.popen('grep "TDAP: Afield: Current" result').readlines()
  data = []
  for line in lines:
    #print line.split()
    data.append([float(i) for i in line.split()[4:7]])
  data = np.array(data)
  return data

data = readCurrent()

from pyramids.io.fdf import tdapOptions
options = tdapOptions()
timestep = options.tdTimeStep[0]

fig, axs = plt.subplots(2,1,sharex=True,sharey=False)#,figsize=(10,6)
ax = axs[0]
for i in range(3):
  ax.plot(np.arange(data.shape[0])*timestep,data[:,i],
          label=['x','y','z'][i],lw=2, alpha=1.0)


args = ma.getPropertyFromPosition()
ma.setProperty(ax,**args)

ax = axs[1]
ppu.plotEField(ax,label='efield')

plt.tight_layout()
for save_type in ['.png']:
  filename = SaveName + save_type
  plt.savefig(filename,orientation='portrait',dpi=600)
import numpy as np
import matplotlib.pyplot as plt
import pyramids.io.result as dp
import pyramids.plot.setting as ma
import pyramids.plot.PlotUtility as pu
import os

from ase.dft.kpoints import special_paths, special_points

ax = axs[1]
import pyramids.plot.PlotUtility as pu
pu.plotEField(ax)

timeE, Efield = dp.getEField()
lightScat, = ax.plot(0, Efield[0, 0], 'o')
kargs = ma.getPropertyFromPosition(xlabel=r'Time', ylabel=r'EField')
ma.setProperty(ax, **kargs)

ax = axs[0]
kpath = np.arange(exe.shape[1])
x = kpath
#print list(kpath+1)
evolvingBands = range(exe.shape[2])

excited = np.abs(exe[1, kpath, :] - exe[0, kpath, :])
norm = 100.0 / np.max(exe[:, kpath, :] - exe[0, kpath, :])
eigenvalue = eigen[0, kpath, :]

#print eigenvalue.shape, excited.shape, x.shape

line = []
Beispiel #37
0
      deltaE[ie] = (deltaE[ie - 1] + deltaE[ie + 1])/2
      
  ax.plot(timeEn[2:], deltaE,'-', c=c[index],
          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)],
Beispiel #38
0
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)
Beispiel #39
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 20 06:28:23 2016

@author: cl-iop
"""
import numpy as np
import matplotlib.pyplot as plt
import pyramids.io.result as dp
import pyramids.plot.setting as ma
numSample = 20
thetas = np.linspace(0,np.pi/2.0,numSample)
x = 0.2*np.sin(thetas)
y1 = np.load('intense.npy')
y2 = np.load('angle.npy')
fig, ax = plt.subplots(1,1,sharex=False,sharey=False,figsize=(8,6))
ax.plot(x,y1,'-',label = 'intense')
ax.plot(x,y2,'o',label = 'angle')
kargs = ma.getPropertyFromPosition(ylabel=r'', xlabel=r'$A \sin\theta$',title='')
ma.setProperty(ax,**kargs)

plt.tight_layout()
SaveName = __file__.split('/')[-1].split('.')[0] 
for save_type in ['.pdf']:
  plt.savefig(SaveName+save_type,transparent=True,dpi=600)
Beispiel #40
0
import numpy as np
import matplotlib.pyplot as plt
from pyramids.plot.setting import getColors
from pyramids.plot.setting import A4_LANDSCAPE
from pyramids.plot.setting import getPropertyFromPosition
from pyramids.plot.setting import setProperty
import os
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)):
Beispiel #41
0
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)
Beispiel #42
0

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)
    #                               ,lw=0.0,color='b',alpha=0.7)
    #    else:
    #      part = abs(exe[0,kpt,i] - exe[:,kpt,i])
    #      s = ax.fill_between(time, eigen[:,kpt,i] - norm*part,
    #                               eigen[:,kpt,i] + norm*part
    #                               ,lw=0.0,color='r',alpha=0.7)
    ax.plot(time, eigen[:, kpt, evolvingBands], '-', lw=0.2, c='k', alpha=0.8)

    #print exe[-1,kpt,:]
    #  axin, imag = pu.insertStruct(ax, width="50%", height=1.5, loc=2,
    #                               rotation=[0,0,0],
    #                               camera='perspective', cell=True)

    kargs = ma.getPropertyFromPosition(ylabel=r'Eigenvalues(eV)',
                                       xlabel='Time(fs)',
                                       title='Population',
                                       hline=[0.0],
                                       xlimits=[np.min(time),
                                                np.max(time)],
                                       ylimits=[
                                           np.min(eigen[:, kpt,
                                                        evolvingBands]),
                                           np.max(eigen[:, kpt, evolvingBands])
                                       ])
    ma.setProperty(ax, **kargs)
    #------------------------------------------------------------------------------
    plt.tight_layout()
    for save_type in ['.pdf']:
        filename = SaveName + save_type
        plt.savefig(filename, dpi=400)
    epsilon = fft(dipole)[:numStep/2] 
    epsilon = (np.real(epsilon),np.imag(epsilon))
    
    absorbance = epsilon[0]*energyArray/4.1356
    
    if i == 0:
        absorbanceSum = absorbance
    else:
        absorbanceSum += absorbance
    
    axs.fill_between(energyArray,absorbance,linewidth=0.0,color=colors[i],label=direct,alpha=0.6)
    os.chdir('..')
    

xlimits = [0,20]   
peaks = []
for j in range(1,len(absorbanceSum)-1):
    if energyArray[j] > xlimits[0] and energyArray[j] < xlimits[1]:    
        if absorbanceSum[j] >= absorbanceSum[j-1] and absorbanceSum[j] >= absorbanceSum[j+1]:
            if absorbanceSum[j] > 0.5: # energyArray[j] < 22.0 and  
                peaks.append(energyArray[j])
            #print energyArray[j], absorbanceSum[j]
     
print peaks
axs.plot(energyArray,absorbanceSum,'-',linewidth=1.5,color='black',label='Total')
args = getPropertyFromPosition(xlimits=xlimits,ylimits=[0,max(absorbanceSum)],ylabel='Absorbance',xlabel='Energy(eV)',vline=peaks)
setProperty(axs,**args)

plt.tight_layout()
plt.savefig('dielectriFunction.pdf',dpi=600)
#plt.plot(2*np.real(y))
Beispiel #45
0
    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)
Beispiel #46
0
nocc = int(float(os.popen('grep "starting charge" result').readline().split()[-1])/2.0)
print nocc
fig, axs = plt.subplots(1,2,sharex=True,figsize=(8,5))

ax = axs[0]
norm, kweight = readData('pwscf.norm.dat')
excite = (norm - norm[0,:,:])
for ib in range(excite.shape[2]):
    excite[:,:,ib] *= kweight
    #pass
#print excite
time = np.arange(excite.shape[0]) * dt
ax.plot(time, (excite[:,:,:nocc]).sum(axis=(1,2)))
ax.plot(time, (excite[:,:,nocc:]).sum(axis=(1,2)))

args = ma.getPropertyFromPosition(0,title='Excited electrons',ylabel='n (e)')
ma.setProperty(ax,**args)

ax = axs[1]

value, kweight = readData('pwscf.value.dat')
#print norm
ax.plot(time, value[:,0,:],'-')

args = ma.getPropertyFromPosition(0,title='Excited electrons',ylabel='n (e)')
ma.setProperty(ax,**args)



plt.tight_layout()
Beispiel #47
0
    time,
    E_ks,
    '-',
    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('.')
Beispiel #48
0
    
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)
Beispiel #49
0
        color = 'r'

    s = ax.fill_between(x,
                        eig[kpath, i] - norm * part,
                        eig[kpath, i] + norm * part,
                        lw=0.0,
                        color=color,
                        alpha=0.7)
    ax.plot(x, eig[kpath, i], '--', lw=1.5, c='grey')

plt.axis('tight')
kargs = ma.getPropertyFromPosition(
    ylabel=r'Eigenvalues(eV)',
    xlabel='',
    xticks=cut,
    xticklabels=specialKPoints,
    xlimits=[cut[0], cut[-1]],
    vline=cut,
    title='Population',
    hline=[0.0],
)
#xlimits=[np.min(time),np.max(time)],
#ylimits=[np.min(eigen[:,kpt,evolvingBands]),
#         np.max(eigen[:,kpt,evolvingBands])])
ma.setProperty(ax, **kargs)
#------------------------------------------------------------------------------
plt.tight_layout()
for save_type in ['.pdf']:
    filename = SaveName + save_type
    plt.savefig(filename, dpi=400)
Beispiel #50
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 20 06:28:23 2016

@author: cl-iop
"""
import numpy as np
import matplotlib.pyplot as plt
import pyramids.io.result as dp
import pyramids.plot.setting as ma

numSample = 20
thetas = np.linspace(0, np.pi / 2.0, numSample)
x = 0.2 * np.sin(thetas)
y1 = np.load('intense.npy')
y2 = np.load('angle.npy')
fig, ax = plt.subplots(1, 1, sharex=False, sharey=False, figsize=(8, 6))
ax.plot(x, y1, '-', label='intense')
ax.plot(x, y2, 'o', label='angle')
kargs = ma.getPropertyFromPosition(ylabel=r'',
                                   xlabel=r'$A \sin\theta$',
                                   title='')
ma.setProperty(ax, **kargs)

plt.tight_layout()
SaveName = __file__.split('/')[-1].split('.')[0]
for save_type in ['.pdf']:
    plt.savefig(SaveName + save_type, transparent=True, dpi=600)
Beispiel #51
0
    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)
Beispiel #52
0
#from ase.calculators.siesta.import_functions import xv_to_atoms
#atoms = xv_to_atoms('siesta.XV')

import os

atoms = dp.getStructrue()

  
# --------------------------------------a----------------------------------   
ax = axs[iStruct]

generateStructPNG(atoms,cell=True,repeat = [5,3,1])
insertImag(ax)
#confStructrueFigure(ax)

kargs = getPropertyFromPosition(iStruct,r'',"",title='Structure',)
setProperty(ax,**kargs)     
# --------------------------------------b----------------------------------   
ax = axs[iBZone]
reciprocal_vectors = 2*np.pi*atoms.get_reciprocal_cell()
#print reciprocal_vectors
points=np.array([(reciprocal_vectors[0,0:2]*i+
                  reciprocal_vectors[1,0:2]*j+
                  reciprocal_vectors[2,0:2]*k) 
                  for i in range(-1,2) 
                  for j in range(-1,2)
                  for k in range(-0,1)])

from scipy.spatial import Voronoi
from pyramids.plot.PlotUtility import voronoi_plot_2d
vor = Voronoi(points)
Beispiel #53
0
import os
import pyramids.io.result as dp
from pyramids.io.result import getHomo
SaveName = __file__.split('/')[-1].split('.')[0]
fig1, ax = plt.subplots(1,1,sharey=True,sharex=True,figsize=(8,6))
eigenvalues = dp.readEigFile()

k = np.arange(eigenvalues.shape[0])
print k
k = []
for i in range(120,785,95):
  k.append(i)
  k.append(i+47)
for i in range(785,746,-1):
  k.append(i)

k = np.array(k) - 1

y = eigenvalues
#plotedBand = getHomo()

ax.plot(np.arange(k.shape[0]),eigenvalues[k,:],'-o')

args = ma.getPropertyFromPosition(xlabel=r'$n_k$', ylimits=[-2,2],
                                  ylabel=r'Eigenvalues(eV)')
ma.setProperty(ax,**args)
plt.tight_layout()

for save_type in ['.pdf']:
  filename = SaveName + save_type
  plt.savefig(filename,orientation='portrait',dpi=600)
      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)