Exemple #1
0
def write_geom( name = "output", sysopts = { "verbose" : False, "debug" : False }, geom = None, position_type = PositionTypes.Cart ):
    output = FileIO( name + ".xyz",'xyz', "w+", sysopts )
    output.geom( geom )
    output.write()

    output = FileIO( name + ".POSCAR",'POSCAR', "w+", sysopts )
    output.geom( geom )
    output.write( { "position_type" : position_type } )
Exemple #2
0
  def main( self ):
    (options, args) = self.opt_parser.parse_args()
    input_name  = options.input_name
    output_name = options.output_name
    direct = options.direct

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

    try:
      input_file  = FileIO( input_name,'POSCAR', "r", sysopts )
    except Exception as ex:
      print 'Error: ' + str( ex )
    # end try

    input_file.read()
    geom = input_file.geom()
    # geom.check()

    position_type = PositionTypes.Cart
    if direct:
      position_type = PositionTypes.Direct
    # end if

    try:
      output_file = FileIO( output_name,'POSCAR', "w+", sysopts )
      output_file.geom( geom )
      output_file.write( { 'position_type' : position_type } )
    except Exception as ex:
      print 'Error: ' + str( ex )
Exemple #3
0
  def main( self ):
    (options, args) = self.opt_parser.parse_args()
    direct = options.direct

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }
    input_desc = options.input_desc
    (input_file,input_sym,input_no) = input_desc.split( ":" )
    input_no = string.atoi( input_no )

    embed_desc = options.embed_desc
    (embed_file,embed_sym,embed_no) = embed_desc.split( ":" )
    embed_no = string.atoi( embed_no )

    try:
      input_poscar = FileIO( input_file, 'POSCAR', "r", sysopts )
      embed_poscar = FileIO( embed_file, 'POSCAR', "r", sysopts )
    except Exception as ex:
      print ' Error: ' + str( ex )
      return 0
    # end try
    input_poscar.read()
    embed_poscar.read()
    
    geom = input_poscar.geom()
    geom.embed( embed_poscar.geom(), embed_sym, embed_no, input_sym, input_no )
    
    geom.gen_species()
    geom.order()

    position_type = PositionTypes.Cart
    if direct:
      position_type = PositionTypes.Direct
    # end if

    write_geom( 'embed', sysopts, geom, position_type )
Exemple #4
0
  def main( self ):
    (options, args) = self.opt_parser.parse_args()
    try:
      sigma = self.getoptf( 'sigma' )
    except:
      sigma = 0.100
    # end try

    try:
      alpha = self.getoptf( 'alpha' )
    except:
      alpha = 2.000
    # end try

    try:
      kpt = self.getoptf( 'kpt' )
    except:
      kpt = 1
    # end try

    try:
      channels = self.getopti( 'channels' )
    except:
      channels = 2048
    # end try


    sysopts = { "verbose" : self.verbose, "debug" : self.debug }
    input_file = options.input_file
    try:
      input_ueig = FileIO( input_file, 'UEIG', "r", sysopts )
    except:
      if self.debug:
        raise
      print ' Error: ' + input_file
      return 0
    # end try
    input_ueig.read()
    # print input_ueig.handler.ibuffer.lines

    avg_cl_shift = input_ueig.command( 'gendos', { 'sigma' : sigma, 
                                                   'alpha' : alpha, 
                                                   'kpt' : kpt,
                                                   'channels' : channels} )
Exemple #5
0
  def main( self ):
    (opts, args) = self.parse()
    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    a = string.atof(opts.amin)
    b = string.atof(opts.bsub)

    # read inputs
    min_file = FileIO( opts.min_name, 'CHGCAR', "r", sysopts )
    min_file.read()

    sub_file = FileIO( opts.sub_name, 'CHGCAR', "r", sysopts )
    sub_file.read()

    min_file.command('add', { 's': sub_file, 'a' : a, 'b' : b} )
    min_file.handler.path = 'diff.CHGCAR'
    min_file.handler.opts = 'w+'
    min_file.handler.buffer = min_file.handler.obuffer
    min_file.write( { 'diff' : True } )
Exemple #6
0
  def main( self ):
    (options, args) = self.opt_parser.parse_args()

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }
    input_file = options.input_file
    try:
      input_dat = FileIO( input_file, 'dat', "r", sysopts )
    except:
      if self.debug:
        raise
      print ' Error: ' + input_file
      return 0
    # end try
    input_dat.read()

    avg_cl_shift = input_dat.command( 'average' )

    # end if
    print
    print ' Average Potential (line):', avg_cl_shift
    print
Exemple #7
0
  def main( self ):
    (options, args) = self.opt_parser.parse_args()
    input_name  = options.input_name
    output_name = options.output_name
    trans_name  = options.trans_name
    direct = options.direct
    
    sysopts = { "verbose" : self.verbose, "debug" : self.debug }

    # position type
    position_type = PositionTypes.Cart
    if direct:
      position_type = PositionTypes.Direct
    # end if

    # read inputs
    try:
      input_file = FileIO( input_name, 'POSCAR', "r", sysopts )
    except Exception as ex:
      print ' Error: ' + str( ex )
      return 0
    # end try
    input_file.read()
    geom = input_file.geom()

    try:
      trans = Transform()
      trans.build()
      trans.process( trans_name, geom )
    except Exception as ex:
      print ' No transformation: ' + str( ex )
      if self.verbose:
        raise
    # end try
    
    geom.gen_species()
    geom.order()
    write_geom( output_name, sysopts, geom, position_type )
Exemple #8
0
  def main( self ):
    (options, args) = self.opt_parser.parse_args()
    try:
      atomlist  = self.getoptarri( 'atomlist' )
    except:
      print ' Error: no atomlist'
      return 0
    # end try

    # print atomlist

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

    try:
      origo = self.getoptarrf( 'origo' )
    except:
      origo = nump.zero(3)
    # end try

    try:
      ono = self.getopti( 'ono' )
    except:
      ono = None
    # end try

    try:
      lv = self.getoptarrf( 'lv' )
    except:
      lv = None
    # end try

    try:
      rmin = self.getoptf( 'rmin' )
    except:
      rmin = None
    # end try

    try:
      rmax = self.getoptf( 'rmax' )
    except:
      rmax = None
    # end try


    sysopts = { "verbose" : self.verbose, "debug" : self.debug }
    input_file = options.input_file
    try:
      input_upot = FileIO( input_file, 'UPOT', "r", sysopts )
    except:
      if self.debug:
        raise
      print ' Error: ' + input_file
      return 0
    # end try

    if reference != None :
      try:
        reference_upot = FileIO( reference, 'UPOT', "r", sysopts )
        reference_upot.read()
      except:
        if self.debug:
          raise
        print ' Error: ' + reference
        return 0
      # end try
    # end if
    input_upot.read()
#    if reference != None:
#      input_upot.command( 'reference', { 'reference_upot' : reference_upot } )
#    # end if

    if reference != None:
      ref = reference_upot.handler
    else:
      ref = None
    # end if

    avg_cl_shift = input_upot.command( 'average', { 'atomlist' : atomlist, 
                                                    'lv' : lv, 
                                                    'origo' : origo,
                                                    'reference' : ref,
                                                    'ono' : ono } )
    # end if
    print
    print ' Average Potential:', avg_cl_shift
    print
Exemple #9
0
  def main( self ):
    (options, args) = self.opt_parser.parse_args()
    try:
      scale = self.getoptarri( 'scale' )
    except:
      print ' Error: no scale'
      return 0
    # end try

    try:
      shift = self.getoptarrf( 'shift' )
    except:
      shift = numpy.zeros( 3 )
    # end try

    sysopts = { "verbose" : self.verbose, "debug" : self.debug }
    input_file = options.input_file
    try:
      input_poscar = FileIO( input_file, 'POSCAR', "r", sysopts )
    except Exception as ex:
      print ' Error: ' + str( ex )
      return 0
    # end try
    input_poscar.read()

    geom = input_poscar.geom()

    for s in geom.species:
      output_file = str( s ) + "-" + input_file + ".wsgen"
      # print output_file
      try:
        output_in = open( output_file, "w+" )
      except Exception as ex:
        print ' Error: ' + str( ex )
        return 0
      # end try

      output_in.write( "transformation\n" )
      output_in.write( "%9.6f %9.6f %9.6f\n" % (scale[0], 0.000000, 0.000000) )
      output_in.write( "%9.6f %9.6f %9.6f\n" % (0.000000, scale[1], 0.000000) )
      output_in.write( "%9.6f %9.6f %9.6f\n" % (0.000000, 0.000000, scale[2]) )
      output_in.write( "userdef\n" )

      for lv in geom.lattice_vectors:
        output_in.write( "%20.16f %20.16f %20.16f\n" % (lv[0], lv[1], lv[2]) )
      # end for

      output_in.write( "%d\n" % geom.species[s] )
      # find specie s
      for atom in geom.atoms:
        if atom.symbol() == s:
          pos = geom.position( atom, PositionTypes.Cart )
          output_in.write( "%20.16f %20.16f %20.16f\n" % (pos[0], pos[1], pos[2]) )
        # end if
      # end for
      output_in.write( "\n%20.16f %20.16f %20.16f\n" % (shift[0], shift[1], shift[2]) )
      output_in.close()

    # end for s

    # check geom
    output_file = "primitive.xyz"
    try:
      output_xyz = open( output_file, "w+" )
    except Exception as ex:
      print ' Error: ' + str( ex )
      return 0
    # end try
    output_xyz.write( "%d\n\n" % geom.number_of_atoms() )
    for s in geom.species:
      for atom in geom.atoms:
        if atom.symbol() == s:
          pos = geom.position( atom, PositionTypes.Cart )
          output_xyz.write( "%2s %20.16f %20.16f %20.16f\n" % (s, pos[0], pos[1], pos[2]) )
        # end if
      # end for
    # end for
    output_xyz.close()