Exemplo n.º 1
0
  def main( self ):
    (options, args) = self.par()
    input_name  = options.input_name
    output_name = options.output_name
    pt = PT.Cart
    if options.direct:
      pt = PT.Direct
    # end if
    output_name += "."+PTD[pt]

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    input_file  = IO( input_name,'POSCAR', "r", sysopts )
    input_file.read()
    geom = input_file.geom()

    fileio = 'POSCAR'
    opts = { 'pt' : pt }
    if options.xyz:
      output_name += '.xyz'
      fileio = 'xyz'
      opts = { 'pt' : PT.Cart }
    else:
      output_name += '.POSCAR'
    # end if
    output_file = IO( output_name,fileio, "w+", sysopts )
    output_file.geom( geom )
    output_file.write( opts )
Exemplo n.º 2
0
  def main( self ):
    (opts, args) = self.parse()

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    inp = IO( opts.input,'POSCAR', "r", sysopts )
    inp.read()
    geom = inp.geom()

    if opts.select != None:
      aid = int(opts.select)
      cmd = "select"
    if opts.delete != None:
      aid = int(opts.delete)
      cmd = "delete"
    # end if

    atom = geom.get(aid)
    atom.info()

    if geom.pt == PT.Cart:
      dp = geom.position( atom, PT.Direct )
      cp = atom.position
    else:
      dp = atom.position
      cp = geom.position( atom, PT.Cart )
    # end if

    print " Frac : %21.16f%21.16f%21.16f" % (dp[0],dp[1],dp[2])
    print " Cart : %21.16f%21.16f%21.16f" % (cp[0],cp[1],cp[2])
Exemplo n.º 3
0
  def main( self ):
    (options, args) = self.par()
    input_name  = options.input_name
    output_name = options.output_name
    ref_name    = options.ref_name
    ul = options.ul
    ll = options.ll

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    # read input geometry
    input_file = IO( input_name, 'POSCAR', 'r', sysopts )
    input_file.read()

    ref_file = IO( ref_name, 'POSCAR', 'r', sysopts )
    ref_file.read()

    # geom check
    igeom = input_file.geom()
    rgeom = ref_file.geom()

    print "Reference: " + ref_name + "  New: " + input_name
    dgeom = rgeom.diff( igeom, ll, ul, options.newno )

    # output
    opts = { 'pt' : PT.Cart }
    output_file = IO( output_name, 'diff', "w+", sysopts )
    output_file.geom( dgeom )
    output_file.write( opts )
Exemplo n.º 4
0
  def main( self ):
    (opts, args) = self.parse()
    opts_sys = { "verbose" : self.verbose, "debug" : self.debug }

    try:
      inp  = IO( opts.input,'POSCAR', "r", opts_sys )
      inp.read()
    except:
      if self.debug:
        raise
      else:
        print "Input not found:", opts.input
        sys.exit(1)

    geom = inp.geom()

    try:
      band=[]
      with open(opts.band) as f:
        for line in f:
          line = line.split()
          if len(line) == 0:
            continue
          if line[0] == 'tot' or line[0] == 'band':
            continue
          # print len(line)
          band.append([string.atoi(line[0]), string.atof(line[10]) ])
    except:
      raise
    else:
      print band
      # sys.exit(1)

    fileio = 'POSCAR'
    if opts.cart:
      opts_pt = { 'pt' : PT.Cart }
    else:
      opts_pt = { 'pt' : PT.Direct }

    if opts.xyz:
      opts.output += '.xyz'
      fileio = 'xyz'
      opts_pt = { 'pt' : PT.Cart }
    else:
      opts.output += '.POSCAR'
    # end if
    try:
      out = IO( opts.output, fileio, "w+", opts_sys )
      out.geom( geom )
      if len(band) != 0:
        out_geom = out.geom()
        out_geom.band(band)
      out.write( opts )
    except:
      if self.debug:
        raise
      else:
        print "Output failed:", opts.output
        sys.exit(1)
Exemplo n.º 5
0
  def main( self ):
    (options, args) = self.par()

    try:
      atomlist  = self.cfgarri( 'atomlist' )
    except:
      print ' Error: no atomlist'
      return 0
    # end try

    try:
      reference = self.cfg( 'reference' )
    except:
      reference = None
    # end try

    try:
      origo_vec = self.cfgarrf( 'origo_vec' )
    except:
      origo_vec = numpy.zeros(3)
    # end try

    try:
      vacancy = self.cfgarri( 'vacancy' )
    except:
      vacancy = None
    # end try

    try:
      lat_vec = self.cfgarrf( 'lat_vec' )
    except:
      lat_vec = None
    # end try


    sysopts = { "verbose" : self.verbose, "debug" : self.debug }
    input_file = options.input_name
    input_upot = IO( input_file, 'UPOT', "r", sysopts )
    input_upot.read()

    ref = None
    if reference != None :
      reference_upot = FIO( reference, 'UPOT', "r", sysopts )
      reference_upot.read()
      ref = reference_upot.handler
    # end if

    avg_cl_shift = input_upot.command( 'average', { 'atomlist'  : atomlist, 
                                                    'lat_vec'   : lat_vec,
                                                    'origo_vec' : origo_vec,
                                                    'vacancy'   : vacancy,
                                                    'reference' : ref } )
    # end if
    print
    print ' Average Potential:', avg_cl_shift
    print
Exemplo n.º 6
0
  def main( self ):
    (opts, args) = self.parse()

    opts_sys = { "verbose" : self.verbose, "debug" : self.debug }

    (embed,eno) = opts.embed.split( ":" )
    eno = string.atoi( eno )

    (host,hno)  = opts.host.split( ":" )
    hno = string.atoi( hno )

    # read input
    # IO  filename  type  mode  options
    try:
      embedio = IO( embed, 'POSCAR', 'r', opts_sys )
      embedio.read()
    except:
      if self.debug:
        raise
      else:
        print "Input not found:", embedio
        sys.exit(1)
    # end try

    try:
      hostio = IO( host, 'POSCAR', 'r', opts_sys )
      hostio.read()
    except:
      if self.debug:
        raise
      else:
        print "Input not found:", host
        sys.exit(1)
    # end try

    host_geom = hostio.geom()
    #               where what
    # self = host
    host_geom.embed( hno, embedio.geom(), eno )
    host_geom.normalize()

    # write output
    # IO  filename  type  mode  options
    try:
      out = IO( opts.output, 'POSCAR', "w+", opts_sys )
      out.geom( host_geom )
      if opts.cart:
        out.write( { 'pt' : PT.Cart } )
      else:
        out.write( { 'pt' : PT.Direct } )
    except:
      if self.debug:
        raise
      else:
        print "Output failed:", opts.output
        sys.exit(1)
Exemplo n.º 7
0
  def main( self ):
    (opts, args) = self.parse()

    opts_sys = { "verbose" : self.verbose, "debug" : self.debug }

    # read input
    # IO  filename  type  mode  options
    try:
      inp = IO( opts.input, 'POSCAR', 'r', opts_sys )
      inp.read()
    except:
      if self.debug:
        raise
      else:
        print "Input not found:", opts.input
        sys.exit(1)
    # end try

    # do transformation
    # LX  transfile type options
    try:
      trs = LX( opts.trans, 'TF', opts_sys )
      trs.geom( inp.geom() )
      # build & process
      geom = trs.read()
    except:
      if self.debug:
        raise
      else:
        print "Transformation error:", opts.trans
        sys.exit(1)
    # end try

    # write output
    # IO  filename  type  mode  options
    try:
      out = IO( opts.output, 'POSCAR', "w+", opts_sys )
      out.geom( geom )
      if opts.cart:
        out.write( { 'pt' : PT.Cart } )
      else:
        out.write( { 'pt' : PT.Direct } )
    except:
      if self.debug:
        raise
      else:
        print "Output failed:", opts.output
        sys.exit(1)
Exemplo n.º 8
0
  def main( self ):
    (options, args) = self.par()

    try:
      msc = self.cfgarri( 'msc' )
      msc = msc.reshape([3,3])
    except:
      print ' Error: no supercell matrix'
      return 0
    # end try

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }
    input_file = options.input_name
    input_pos = IO( input_file, 'POSCAR', "r", sysopts )
    input_pos.read()

    super_geom = input_pos.geom().supercell( msc )
Exemplo n.º 9
0
  def main( self ):
    (options, args) = self.par()
    input_name  = options.input_name
    trans_name  = options.trans_name
    output_name = options.output_name

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    # read input geometry
    input_file = IO( input_name, 'POSCAR', 'r', sysopts )
    input_file.read()

    # transform
    trans_file = LX( trans_name, 'TF', sysopts )
    trans_file.geom( input_file.geom() )
    geom = trans_file.read()

    # output
    opts = { 'pt' : PT.Cart }
    output_file = IO( output_name, 'POSCAR', "w+", sysopts )
    output_file.geom( geom )
    output_file.write( opts )
Exemplo n.º 10
0
  def main( self ):
    (options, args) = self.par()
    input_name  = options.input_name
    select = int(options.select)

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    input_file  = IO( input_name,'POSCAR', "r", sysopts )
    input_file.read()
    geom = input_file.geom()
    atom = geom.get(select)
    atom.info()

    if geom.pt == PT.Cart:
      dp = geom.position( atom, PT.Direct )
      cp = atom.position
    else:
      dp = atom.position
      cp = geom.position( atom, PT.Cart )
    # end if

    print " Frac : %21.16f%21.16f%21.16f" % (dp[0],dp[1],dp[2])
    print " Cart : %21.16f%21.16f%21.16f" % (cp[0],cp[1],cp[2])
Exemplo n.º 11
0
  def main( self ):
    (options, args) = self.par()
    input_name  = options.input_name
    output_name = options.output_name
    diff_name   = options.diff_name

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    # read input geometry
    input_file = IO( input_name, 'POSCAR', 'r', sysopts )
    input_file.read()

    diff_file = IO( diff_name, 'diff', 'r', sysopts )
    diff_file.read()

    geom  = input_file.geom()
    dgeom = diff_file.geom()
    pgeom = geom.patch( dgeom )

    # output
    opts = { 'pt' : PT.Cart }
    output_file = IO( output_name, 'POSCAR', "w+", sysopts )
    output_file.geom( pgeom )
    output_file.write( opts )
Exemplo n.º 12
0
  def main( self ):
    (opts, args) = self.parse()

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    ### begin reference
    try:
      print opts.reference,":"
      ref = IO( opts.reference, 'UPOT', "r", sysopts )
      ref.read()
    except:
      if self.debug:
        raise
      else:
        print "Reference failed:", opts.reference
        sys.exit(1)
    # end try

    # set geoms
    gref = ref.geom()

    # check furthest in reference
    if not opts.max == None:
      (origo,max) = opts.max.split(":")
      origo = int(origo)
      max = float(max)
      gref.furthest( origo, max )
      return
    # end if
    ### end reference

    ### begin input
    try:
      inp = IO( opts.input, 'UPOT', "r", sysopts )
      print opts.input,":"
      inp.read()
    except:
      if self.debug:
        raise
      else:
        print "Input failed:", opts.input
        sys.exit(1)
    # end try
    gref.geom = inp.geom()
    ### end input

    if not opts.compare == None:
      complist = {}
      pairs = opts.compare.split(",")
      for p in pairs:
        (k,v) = p.split(":")
        complist[k] = v
      # end for
      print
      ref.compare( complist )
      return
    # end if

    # warning: geoms should have the same lattice
    # generate match table
    if not opts.match == None:
      if not opts.cache == None:
        match = open( opts.cache, 'wb' )
      # end if
      gref.match( opts.match )
      # write out match cache
      if not opts.cache == None:
        pickle.dump(gref.geom_match,match,-1)
        return
      # end if
    # end if

    if not opts.average == None:
      if not opts.cache == None:
        match = open( opts.cache, 'rb' )
        gref.geom_match = pickle.load( match )
        match.close()
      else:
        raise Exception( "Cache error" )
      # end if

      print
      ref.average( opts.average.split(":") )
Exemplo n.º 13
0
  def main( self ):
    (opts, args) = self.parse()

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    ### begin reference
    try:
      print opts.reference,":"
      ref = IO( opts.reference, 'ASEPOT', "r", sysopts )
      ref.read()
    except:
      if self.debug:
        raise
      else:
        print "Reference failed:", opts.reference
        sys.exit(1)
    # end try

    # set geoms
    gref = ref.geom()
    if opts.poscar:
      out = IO( 'vsasepot.ref.POSCAR', 'POSCAR', "w+", sysopts )
      out.geom( gref )
      out.write()
    # end if

    # G2012-04-27
    if not opts.origo == None:
      gref.shift_origo(opts.origo)
    # end if

    # check furthest in reference
    if not opts.rho == None:
      rho = float( opts.rho )
      crop = gref.cart_select( rho )
      if crop.ac == 0:
        print "EMPTY SELECTION, SET SMALLER RHO"
        sys.exit(1)

      out = 'ref.crop.POSCAR'
      out = IO( out, 'POSCAR', "w+", sysopts )
      out.geom( crop )
      out.write()

      # for atom in crop.atoms:
      #   atom.info()
      # # end for
    # end if
    ### end reference


    ### begin input
    try:
      inp = IO( opts.input, 'ASEPOT', "r", sysopts )
      print opts.input,":"
      inp.read()
    except:
      if self.debug:
        raise
      else:
        print "Input failed:", opts.input
        sys.exit(1)
    # end try
    igeom = inp.geom()
    igeom.geom = crop
    ### end input

    if not opts.vacancy == None:
      vaclist = opts.vacancy.split(",")
      for i in range(0,len(vaclist)):
        vaclist[i] = int(vaclist[i])
      # end for
      crop = inp.average( vaclist )
      out  = 'inp.crop.POSCAR'
      out  = IO( out, 'POSCAR', "w+", sysopts )
      out.geom( crop )
      out.write()
      return
    # end if

    if not opts.compare == None:
      complist = {}
      pairs = opts.compare.split(",")
      for p in pairs:
        (k,v) = p.split(":")
        complist[k] = v
      # end for
      print
      ref.compare( complist )
      return
    # end if

    # warning: geoms should have the same lattice
    # generate match table
    if not opts.match == None:
      if not opts.cache == None:
        match = open( opts.cache, 'wb' )
      # end if
      gref.match( opts.match )
      # write out match cache
      if not opts.cache == None:
        pickle.dump(gref.geom_match,match,-1)
        return
      # end if
    # end if

    if not opts.average == None:
      if not opts.cache == None:
        match = open( opts.cache, 'rb' )
        gref.geom_match = pickle.load( match )
        match.close()
      else:
        raise Exception( "Cache error" )
      # end if

      print
      ref.average( opts.average.split(":") )
Exemplo n.º 14
0
  def main( self ):
    (opts, args) = self.parse()

    width = 3
    sig   = opts.sigma
    amp   = opts.amp
    wsig  = width * sig

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }
    try:
      inp = IO( opts.inp, 'UEIG', "r", sysopts )
      inp.read()
    except:
      if self.debug:
        raise
      else:
        print "Input failed:", opts.inp
        sys.exit(1)
    # end try

    mu = 0.0

    inp_ueig = inp.handler

    # grid for k-point: eig occ
    kp = opts.kp - 1
    sp = opts.sp - 1 
    inp_grid = inp_ueig.grid(kp,sp)
    # print inp_grid

    # create input fine grid
    low  = inp_ueig.grid_min(kp,sp) - wsig
    high = inp_ueig.grid_max(kp,sp) + wsig

    #print low, high
    rate = opts.rate
    grid_range = high - low
    maxrate = int(math.ceil( grid_range * rate ) )
    # print maxrate
    fine_range = np.arange( maxrate ) / float(maxrate)
    # print fine_range

    # shifted fine grid
    inp_fine_grid = fine_range * grid_range - abs( low )
    # print inp_fine_grid

    # compound grid
    inp_comp_grid = np.concatenate((inp_grid[:,0], inp_fine_grid))
    inp_comp_grid = np.sort(inp_comp_grid)
    # print inp_comp_grid

    # init grid: eig, fx,  d/dx fx
    inp_comp_grid = np.vstack( ( inp_comp_grid, 
                                 np.zeros( len( inp_comp_grid ) ), 
                                 np.zeros( len( inp_comp_grid ) ) ) )
    # print inp_comp_grid[0]
    # sys.exit(0)

    # generating DOS
    gendos( amp, sig, inp_grid, inp_comp_grid, opts.python )

    if opts.test:
      sys.exit(1)

    # output
    out_name = opts.out + "_kp_" + str(opts.kp) + "_sp_" + str(opts.sp)
    out = open( out_name , 'w')
    out.write( "" )

    i_range=len(inp_grid)
    j_range=len(inp_comp_grid[0])

    # create & write out dos
    dos = np.zeros( (j_range,3) )
    for j in range(0,j_range):
      dos[j,0] = inp_comp_grid[0,j]
      dos[j,1] = inp_comp_grid[1,j]
      dos[j,2] = inp_comp_grid[2,j]
      out.write( "%12.6f %12.6f %12.6f\n" % (dos[j,0],dos[j,1],dos[j,2]) )
    out.close()

    # dump dos
    save(dos,out_name)
    # plot
    plot(dos)