Exemple #1
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 #2
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 #3
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 #4
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 #5
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()