예제 #1
0
def action(index, folder):
  ax = axs[0]
  gap= axs[1]
  from ase.calculators.siesta.import_functions import xv_to_atoms
  atoms = xv_to_atoms('siesta.XV')
  import pyramids.plot.PlotUtility as pu
  
  pu.plot2DBZ(ax,atoms)
  pu.plot2DBZ(gap,atoms)
  eigSteps = dp.getEIGSteps()
  initStep, finalStep = eigSteps[0],eigSteps[-1]
  print initStep, finalStep
  energy = dp.readEigFile('siesta'+str(finalStep)+'.EIG')
  popStart = dp.readEigFile('siesta'+str(finalStep)+'q.EIG') 
  popEnd = dp.readEigFile('siesta'+str(initStep)+'q.EIG')
  part  = np.abs(popStart - popEnd)
  plotted = part[:,3]
  plotted[plotted < 0.1*np.max(plotted)] = 0.0
  norm = 100.0
  kcoor, kweight = dp.readKpoints()
  kcoorAll, klistAll = dp.recoverAllKPoints(kcoor,2*np.pi*atoms.get_reciprocal_cell(),
                                            repeat = [1,1,0], flatten = False)
  diffEnergy = energy[:,4] - energy[:,3]
  outRange = np.ones(diffEnergy.shape)*20
  outRange[diffEnergy > 4.5] = 0.0 
  
  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)
예제 #2
0
def action(index, folder):
    ax = axs[0]
    gap = axs[1]
    from ase.calculators.siesta.import_functions import xv_to_atoms
    atoms = xv_to_atoms('siesta.XV')
    import pyramids.plot.PlotUtility as pu

    pu.plot2DBZ(ax, atoms)
    pu.plot2DBZ(gap, atoms)
    eigSteps = dp.getEIGSteps()
    initStep, finalStep = eigSteps[0], eigSteps[-1]
    print initStep, finalStep
    energy = dp.readEigFile('siesta' + str(finalStep) + '.EIG')
    popStart = dp.readEigFile('siesta' + str(finalStep) + 'q.EIG')
    popEnd = dp.readEigFile('siesta' + str(initStep) + 'q.EIG')
    part = np.abs(popStart - popEnd)
    plotted = part[:, 3]
    plotted[plotted < 0.1 * np.max(plotted)] = 0.0
    norm = 100.0
    kcoor, kweight = dp.readKpoints()
    kcoorAll, klistAll = dp.recoverAllKPoints(kcoor,
                                              2 * np.pi *
                                              atoms.get_reciprocal_cell(),
                                              repeat=[1, 1, 0],
                                              flatten=False)
    diffEnergy = energy[:, 4] - energy[:, 3]
    outRange = np.ones(diffEnergy.shape) * 20
    outRange[diffEnergy > 4.5] = 0.0

    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)
예제 #3
0
def getStructrue():
    if os.path.exists('structure.vasp'):
        from ase.io import read
        atoms = read('structure.vasp', format='vasp')
        #import ase.build
        #ase.build.niggli_reduce(atoms)
    elif os.path.exists('siesta.XV'):
        from ase.calculators.siesta.import_functions import xv_to_atoms
        atoms = xv_to_atoms('siesta.XV')
    return atoms
예제 #4
0
def getStructrue():
  if os.path.exists('structure.vasp'):
    from ase.io import read
    atoms = read('structure.vasp',format='vasp')
    #import ase.build
    #ase.build.niggli_reduce(atoms)
  elif os.path.exists('siesta.XV'):
    from ase.calculators.siesta.import_functions import xv_to_atoms
    atoms = xv_to_atoms('siesta.XV')
  return atoms
예제 #5
0
파일: siesta.py 프로젝트: arosen93/rASE
    def read(self, filename):
        """Read structural parameters from file .XV file
           Read other results from other files
           filename : siesta.XV
        """

        fname = self.getpath(filename)
        if not os.path.exists(fname):
            raise ReadError("The restart file '%s' does not exist" % fname)
        self.atoms = xv_to_atoms(fname)
        self.read_results()
예제 #6
0
 def read_structure(self, structfile):
     # returns ase structure from proper structure file
     structure = ""
     if self.calculator == "VASP":
         structure = read_vasp(
             structfile)  # structure - instance of ASE.Atom class
     if self.calculator == "siesta":
         structure = xv_to_atoms(structfile)
     if self.calculator == "openmx":  # hashfile of openmx.dat (openmx.dat#)
         pos, species, cell = read_openmx_hashfile(structfile)
         structure = Atoms(species)
         structure.set_positions(pos)
         structure.set_cell(cell)
     return structure
예제 #7
0
def action(index, folder):
  from ase.calculators.siesta.import_functions import xv_to_atoms
  atoms = xv_to_atoms('siesta.XV')
  import pyramids.plot.PlotUtility as pu
  pu.plot2DBZ(ax,atoms)
  eigSteps = dp.getEIGSteps()
  initStep, finalStep = eigSteps[0],eigSteps[-1]
  #eigenvalue = dp.readEigFile('siesta'+str(finalStep)+'.EIG')
  part  = np.abs(dp.readEigFile('siesta'+str(finalStep)+'q.EIG') - dp.readEigFile('siesta'+str(initStep)+'q.EIG'))
  norm = 100.0/max(part[:,3])
  kcoor, kweight = dp.readKpoints()
  kcoorAll, klistAll = dp.recoverAllKPoints(kcoor,2*np.pi*atoms.get_reciprocal_cell(),repeat = [1,1,0])
  #evolvingBands = range(3,5)
  ax.scatter(kcoorAll[:,0], kcoorAll[:,1], s=norm*np.abs(part[:,3]),lw=0.0, color= color[index], label=folder)
예제 #8
0
def generateStructPNG(atoms=None, rotation=[0,0,0],camera='perspective',repeat = [1,1,1], cell=False,**args):
  from ase.calculators.siesta.import_functions import xv_to_atoms
  from ase.io import write
  if atoms is None:
    atoms = xv_to_atoms('siesta.XV')
  
  rot = str(rotation[0])+'x,'+str(rotation[1])+'y,'+str(rotation[2])+'z'
  
  if cell:
    showcell = 2
  else:
    showcell = 0
  kwargs = {
      'rotation'      : rot, # text string with rotation (default='' )
      'radii'         : 1.0, # float, or a list with one float per atom
      'colors'        : None,# List: one (r, g, b) tuple per atom
      'show_unit_cell': showcell,   # 0, 1, or 2 to not show, show, and show all of cell
      }
  kwargs.update({
    'run_povray'   : True, # Run povray or just write .pov + .ini files
    'display'      : False,# Display while rendering
    'pause'        : True, # Pause when done rendering (only if display)
    'transparent'  : True,# Transparent background
    'canvas_width' : None, # Width of canvas in pixels
    'canvas_height': 800, # Height of canvas in pixels 
    'camera_dist'  : 12000.,  # Distance from camera to front atom
    'image_plane'  : 0, # Distance from front atom to image plane
    'camera_type'  : camera, # perspective, ultra_wide_angle, orthographic
    'point_lights' : [],             # [[loc1, color1], [loc2, color2],...]
    'area_light'   : [(2., 3., 40.), # location
                      'White',       # color
                      .7, .7, 3, 3], # width, height, Nlamps_x, Nlamps_y
    'background'   : 'White',        # color
    'textures'     : None, # Length of atoms list of texture names
    'celllinewidth': 0.1,  # Radius of the cylinders representing the cell
    })
    
  cell = atoms.cell
  atoms.center()
  atoms = atoms*repeat
  for position in atoms.positions: 
    position -= repeat[0]/2*cell[0,:]
    position -= repeat[1]/2*cell[1,:]
    position -= repeat[2]/2*cell[2,:]
  atoms.cell = cell
  write('struct.pov',atoms, **kwargs)
예제 #9
0
def getTrajactory():
    options = tdapOptions()
    #print(options.laserParam)
    systemLabel = options.label
    NumBlocks = int(
        os.popen('grep -i %s %s.MD_CAR | wc -l' %
                 (systemLabel, systemLabel)).readline().split()[0])
    position_file = open(systemLabel + '.MD_CAR')
    atomNumList = [
        int(i)
        for i in os.popen('head -6 siesta.MD_CAR |tail -1').readline().split()
    ]

    numAtomPositionLine = sum(atomNumList)
    totalNumLine = numAtomPositionLine + 7

    context = position_file.readlines()
    #import ase.calculators.vasp as vinter
    #from ase.visualize import view

    atoms = xv_to_atoms(systemLabel + '.XV')
    atoms.pbc = [True, True, True]
    filename = 'Trajectory'
    from ase.io.trajectory import Trajectory
    if not os.path.exists(filename) or os.path.getmtime(
            filename) < os.path.getmtime(systemLabel + '.MD_CAR'):
        atomsList = []
        for index in range(NumBlocks):
            output = context[index * totalNumLine:(index + 1) * totalNumLine]
            coodinates = np.array(
                [[float(value.replace('\n', '')) for value in line.split()]
                 for line in output[7:]])
            atomsCurrent = atoms.copy()
            atomsCurrent.set_scaled_positions(coodinates)

            atomsList.append(atomsCurrent)
            #poscarFileName = "POSCAR"+str(index)
            #poscarFile=open(poscarFileName,'w')
            #poscarFile.writelines(output)
        from ase.io import write
        write(filename, atomsList, 'traj')
    atomsList = Trajectory(filename)
    #print atomsList
    return atomsList
예제 #10
0
def getTrajactory():
  options = tdapOptions()
  systemLabel = options.label
  NumBlocks=int(os.popen('grep -i '+systemLabel+' '+systemLabel+'.MD_CAR | wc -l').readline().split()[0])
  position_file = open(systemLabel+'.MD_CAR')
  atomNumList = [int(i) for i in os.popen('head -6 siesta.MD_CAR |tail -1').readline().split()]
  
  numAtomPositionLine = sum(atomNumList)
  totalNumLine = numAtomPositionLine + 7
  
  context = position_file.readlines()
  from ase.calculators.siesta.import_functions import xv_to_atoms
  #import ase.calculators.vasp as vinter
  #from ase.visualize import view
  

  atoms = xv_to_atoms(systemLabel+'.XV')
  atoms.pbc = [True,True,True]
  filename = 'Trajectory'
  from ase.io.trajectory import Trajectory
  if not os.path.exists(filename) or os.path.getmtime(filename) < os.path.getmtime(systemLabel+'.MD_CAR'):
    atomsList = []
    for index in range(NumBlocks):
      output=context[index*totalNumLine:(index+1)*totalNumLine]
      coodinates=np.array([[float(value.replace('\n','')) 
                            for value in line.split()] 
                            for line in output[7:]])
      atomsCurrent = atoms.copy()
      atomsCurrent.set_scaled_positions(coodinates)      
      
      atomsList.append(atomsCurrent)                
      #poscarFileName = "POSCAR"+str(index)
      #poscarFile=open(poscarFileName,'w')
      #poscarFile.writelines(output)
    from ase.io import write  
    write(filename,atomsList,'traj')
  atomsList = Trajectory(filename)
  #print atomsList
  return atomsList
예제 #11
0
def action(index, folder):
    from ase.calculators.siesta.import_functions import xv_to_atoms
    atoms = xv_to_atoms('siesta.XV')
    import pyramids.plot.PlotUtility as pu
    pu.plot2DBZ(ax, atoms)
    eigSteps = dp.getEIGSteps()
    initStep, finalStep = eigSteps[0], eigSteps[-1]
    #eigenvalue = dp.readEigFile('siesta'+str(finalStep)+'.EIG')
    part = np.abs(
        dp.readEigFile('siesta' + str(finalStep) + 'q.EIG') -
        dp.readEigFile('siesta' + str(initStep) + 'q.EIG'))
    norm = 100.0 / max(part[:, 3])
    kcoor, kweight = dp.readKpoints()
    kcoorAll, klistAll = dp.recoverAllKPoints(kcoor,
                                              2 * np.pi *
                                              atoms.get_reciprocal_cell(),
                                              repeat=[1, 1, 0])
    #evolvingBands = range(3,5)
    ax.scatter(kcoorAll[:, 0],
               kcoorAll[:, 1],
               s=norm * np.abs(part[:, 3]),
               lw=0.0,
               color=color[index],
               label=folder)
예제 #12
0
파일: base_siesta.py 프로젝트: uu1477/MyAse
 def read(self, filename):
     """Read parameters from file."""
     if not os.path.exists(filename):
         raise ReadError("The restart file '%s' does not exist" % filename)
     self.atoms = xv_to_atoms(filename)
     self.read_results()
예제 #13
0
 def read(self, filename):
     """Read parameters from file."""
     if not os.path.exists(filename):
         raise ReadError("The restart file '%s' does not exist" % filename)
     self.atoms = xv_to_atoms(filename)
     self.read_results()
예제 #14
0
#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)

import ase.dft.kpoints as adk
from ase.calculators.siesta.import_functions import xv_to_atoms
from ase.visualize import view
from graphene import *
import pyramids.plot.PlotUtility as pu


atoms = xv_to_atoms('siesta.XV')
#view(atoms)
reciprocal_vectors = 2*np.pi*atoms.get_reciprocal_cell()
N = 24
mesh = adk.monkhorst_pack([N ,N ,1])+ np.array([0.5/N , 0.5/N , 0.0])
shiftK = np.array([1/3.0 , 2/3.0, 0.0]).dot(reciprocal_vectors)

kpoints = mesh.dot(reciprocal_vectors)[:,:2]/3.0

args={'t0':10.0,'sigma': 4.0, 'omega':2.0, 'phi':0.0, 'parity':1, 'vFermi' : 6.348}
args['A'] = 0.2
args['times'] = np.linspace(0.0, 20.0, 100.0)

energyBandDown = []
energyBandUp = []
예제 #15
0
#!/usr/bin/python
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
from ase.dft.kpoints import get_special_points
from ase.calculators.siesta.import_functions import xv_to_atoms
from ase.lattice import hexagonal

#------------------------------------------------------------------------------

kpath = []
cut = [0]
atom = xv_to_atoms('siesta.XV')
specialKPoints = [r'$M$', r'$\Gamma$', r'$K$', r'$M$']

kpoints, kwgt = dP.readKpoints()
nkpts = kpoints.shape[0]

for i in range(79, 2, -13):
    print i
    kpath.append(i)
cut.append(len(kpath))

kpath.append(6)
kpath.append(5)
for i in range(12, 45, 11):
    print i
    kpath.append(i)
    kpath.append(i - 1)
예제 #16
0
"""
Created on Mon Mar 21 12:31:44 2016

@author: cl-iop
"""
import numpy as np
from scipy.fftpack import fft, ifft
from pyramids.plot.setting import getPropertyFromPosition, setProperty, getColors
from pyramids.io.fdf import tdapOptions
import pyramids.io.result as dp
import matplotlib.pyplot as plt
import os
import ase
from ase.calculators.siesta.import_functions import xv_to_atoms

atom_temp = xv_to_atoms('siesta.XV')
atoms = ase.atoms.Atoms(symbols=atom_temp.get_chemical_symbols(),
                        positions=atom_temp.get_positions(),
                        cell = atom_temp.get_cell())
                        
reciprocal_vectors = 2*np.pi*atoms.get_reciprocal_cell()

kcoor, kweight = dp.readKpoints()
                            
import matplotlib.pyplot as plt
cut = 1
fig = plt.figure()
from mpl_toolkits.mplot3d import Axes3D
ax = fig.add_subplot(1,1,1,projection='3d')

points=np.array([(reciprocal_vectors[0,0:2]*i+
예제 #17
0
    def get_best_individual(self,
                            out="Individuals",
                            calculator="VASP",
                            mode="2D"):
        # returns e_tot/atom of best individual, mode="2D" or "all", uses Individuals file
        # deprecated
        outfile = open(out, "r")
        e_tot_min = 0.
        indx_min = 0
        indx_pop = 1
        indx_pop_min = 1
        for line in outfile:
            test = line.find("data of pop:")
            if test > -1:
                line_sp = line.split()
                pop = str(line_sp[3])
                pop = pop.replace('POP', '')
                indx_pop = int(pop)
                # print(indx_pop)
            test = line.find("individual ")
            if test > -1:
                line_sp = line.split()
                e_tot = float(line_sp[4])
                tmp = str(line_sp[2])
                tmp = tmp.replace(':', '')
                indx = int(tmp)
                if mode == "all":
                    if e_tot < e_tot_min:
                        e_tot_min = e_tot
                        indx_min = int(tmp)
                        indx_pop_min = indx_pop
                if mode == "2D":
                    poscar = "POSCAR_POP" + str(indx_pop) + "_" + str(indx)
                    struct = read_vasp(poscar)
                    cell = struct.get_cell()
                    z = cell[2][2]
                    if e_tot < e_tot_min and z > 8. and e_tot > -25.:  # z>8. -> 2D, e_tot/at > -25. to avoid not converged results
                        e_tot_min = e_tot
                        indx_min = int(tmp)
                        indx_pop_min = indx_pop
        # print(indx_pop_min,indx_min)

        if calculator == "VASP":
            poscar = "POSCAR_POP" + str(indx_pop_min) + "_" + str(indx_min)
            struct = read_vasp(poscar)
            write(filename='POSCAR.best', images=struct, format='vasp')
            write(filename='POSCAR.best.in',
                  images=struct,
                  format='espresso-in')

        if calculator == "siesta":
            outfile = "siesta.XV." + str(indx_min) + ".POP" + str(indx_pop_min)
            struct = xv_to_atoms(outfile)
            write(filename='POSCAR.best', images=struct, format='vasp')
            write(filename='POSCAR.best.in',
                  images=struct,
                  format='espresso-in')

        if calculator == "openmx":
            # raise ValueError('not yet implemented for openmx case')
            outfile = "openmx.dat#." + str(indx_min) + ".POP" + str(
                indx_pop_min)
            pos, species, cell = read_openmx_hashfile(outfile)
            struct = Atoms(species)
            struct.set_positions(pos)
            struct.set_cell(cell)
            write(filename='POSCAR.best', images=struct, format='vasp')
            write(filename='POSCAR.best.in',
                  images=struct,
                  format='espresso-in')

        return e_tot_min
예제 #18
0
kargs=ma.getPropertyFromPosition(xlabel=r'Time',ylabel=r'EField')
ma.setProperty(ax,**kargs)

#for i, k in enumerate(kpath):
#  n = i/nkx
#  if n % 2 == 1:
#    kpath[i] = 2*n*nkx + nkx - i - 1
ax = axs[0]
kpath = np.arange(exe.shape[1])

from ase.calculators.siesta.import_functions import xv_to_atoms
points = special_points['hexagonal']
points['K1']= [-0.3333, 0.333, 0]
points['K2']= [0.666, 0.333, 0]
kline = ['K2','K1','K2']
xticks, kinfo = dp.findBandPath(xv_to_atoms('siesta.XV'),points,kline,toleAngle=0.001)
kpath = kinfo['uc-index']
x = kinfo['distance']
print x
#print list(kpath+1)
evolvingBands = range(exe.shape[2])


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

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

line = []
scatter = []
예제 #19
0
def generateStructPNG(atoms=None,
                      rotation=[0, 0, 0],
                      camera='perspective',
                      repeat=[1, 1, 1],
                      cell=False,
                      **args):
    from ase.calculators.siesta.import_functions import xv_to_atoms
    from ase.io import write
    if atoms is None:
        atoms = xv_to_atoms('siesta.XV')

    rot = str(rotation[0]) + 'x,' + str(rotation[1]) + 'y,' + str(
        rotation[2]) + 'z'

    if cell:
        showcell = 2
    else:
        showcell = 0
    kwargs = {
        'rotation': rot,  # text string with rotation (default='' )
        'radii': 1.0,  # float, or a list with one float per atom
        'colors': None,  # List: one (r, g, b) tuple per atom
        'show_unit_cell':
        showcell,  # 0, 1, or 2 to not show, show, and show all of cell
    }
    kwargs.update({
        'run_povray':
        True,  # Run povray or just write .pov + .ini files
        'display':
        False,  # Display while rendering
        'pause':
        True,  # Pause when done rendering (only if display)
        'transparent':
        True,  # Transparent background
        'canvas_width':
        None,  # Width of canvas in pixels
        'canvas_height':
        800,  # Height of canvas in pixels 
        'camera_dist':
        12000.,  # Distance from camera to front atom
        'image_plane':
        0,  # Distance from front atom to image plane
        'camera_type':
        camera,  # perspective, ultra_wide_angle, orthographic
        'point_lights': [],  # [[loc1, color1], [loc2, color2],...]
        'area_light': [
            (2., 3., 40.),  # location
            'White',  # color
            .7,
            .7,
            3,
            3
        ],  # width, height, Nlamps_x, Nlamps_y
        'background':
        'White',  # color
        'textures':
        None,  # Length of atoms list of texture names
        'celllinewidth':
        0.1,  # Radius of the cylinders representing the cell
    })

    cell = atoms.cell
    atoms.center()
    atoms = atoms * repeat
    for position in atoms.positions:
        position -= repeat[0] / 2 * cell[0, :]
        position -= repeat[1] / 2 * cell[1, :]
        position -= repeat[2] / 2 * cell[2, :]
    atoms.cell = cell
    write('struct.pov', atoms, **kwargs)
예제 #20
0
def action(index, folder):
  timeEn, T, E_ks, E_tot, Vol, P  = dP.getEnergyTemperaturePressure()
  deltaE = E_ks[start:,] - E_ks[2]
  atoms = xv_to_atoms('siesta.XV')
  return index, folder, timeEn, deltaE, atoms