Example #1
0
def write_vasp_input(dirpath,
                     incarfile,
                     prim_kpointsfile,
                     prim_poscarfile,
                     super_poscarfile,
                     speciesfile,
                     sort=True,
                     extra_input_files=[],
                     strict_kpoints=False):
    """ Write VASP input files in directory 'dirpath' """
    print "Setting up VASP input files:", dirpath

    # read prim and prim kpoints
    print "  Reading KPOINTS:", prim_kpointsfile
    prim_kpoints = kpoints.Kpoints(prim_kpointsfile)
    if prim_poscarfile != None:
        print "  Reading KPOINTS reference POSCAR:", prim_poscarfile
        prim = poscar.Poscar(prim_poscarfile)
    else:
        prim = None

    # read species, super poscar, incar, and generate super kpoints
    print "  Reading SPECIES:", speciesfile
    species_settings = species.species_settings(speciesfile)
    print "  Reading supercell POS:", super_poscarfile
    super = poscar.Poscar(super_poscarfile, species_settings)
    print "  Reading INCAR:", incarfile
    super_incar = incar.Incar(incarfile, species_settings, super, sort)
    print "  Generating supercell KPOINTS"
    if strict_kpoints:
        super_kpoints = prim_kpoints
    else:
        super_kpoints = prim_kpoints.super_kpoints(prim, super)

    # write main input files
    print "  Writing supercell POSCAR:", os.path.join(dirpath, 'POSCAR')
    super.write(os.path.join(dirpath, 'POSCAR'), sort)
    print "  Writing INCAR:", os.path.join(dirpath, 'INCAR')
    super_incar.write(os.path.join(dirpath, 'INCAR'))
    print "  Writing supercell KPOINTS:", os.path.join(dirpath, 'KPOINTS')
    super_kpoints.write(os.path.join(dirpath, 'KPOINTS'))
    print "  Writing POTCAR:", os.path.join(dirpath, 'POTCAR')
    write_potcar(os.path.join(dirpath, 'POTCAR'), super, species_settings,
                 sort)

    # copy extra input files
    if len(extra_input_files):
        print "  Copying extra input files",
    for s in extra_input_files:
        print "    ", s
        shutil.copy(s, dirpath)

    print "  DONE\n"
    sys.stdout.flush()
Example #2
0
def write_quantum_espresso_input(dirpath,
                                 infilename,
                                 super_poscarfile,
                                 speciesfile,
                                 sort=True,
                                 extra_input_files=[],
                                 strict_kpoints=False):
    """ Write Quantum Espresso input files in directory 'dirpath' """
    print "Setting up Quantum Espresso input files:", dirpath

    # read Infile for K_POINTS, CELL_PARAMETERS, and generate super kpoints
    print "  Reading Infile:", infilename
    myinfile = infile.Infile(infilename, None, None, sort)
    print "  Reading SPECIES:", speciesfile
    species_settings = species.species_settings(speciesfile)
    print "  Reading K_POINTS from:", infilename
    prim_kpoints = myinfile.cards["K_POINTS"]
    print "  Reading K_POINTS reference positions from CELL_PARAMETERS:", infilename
    prim = poscar.Poscar(infilename, species_settings)
    print "  Reading supercell POS:", super_poscarfile
    super = poscar.Poscar(super_poscarfile, species_settings)
    print "  Generating supercell KPOINTS"
    if strict_kpoints:
        super_kpoints = prim_kpoints
    else:
        super_kpoints = prim_kpoints.super_kpoints(prim, super)

    #get raw infile name (without directories)
    directories = re.split("/", infilename)
    if len(directories) > 1:
        infilename = directories[-1]

    # write main input file
    print "  Writing supercell positions to Infile"
    myinfile.rewrite_poscar_info(super)
    print "  Writing supercell K_POINTS to Infile"
    myinfile.cards["K_POINTS"] = super_kpoints
    print "  Writing Infile:", os.path.join(dirpath, infilename)
    myinfile.write(os.path.join(dirpath, infilename))

    # copy extra input files
    print "  Copying extra input files",
    for s in extra_input_files:
        print s,
        shutil.copy(s, dirpath)
    print ""

    print "Quantum Espresso input files complete\n"
    sys.stdout.flush()
Example #3
0
def write_vasp_input(dirpath, incarfile, prim_kpointsfile, prim_poscarfile, super_poscarfile, speciesfile, sort=True, extra_input_files=[], strict_kpoints=False):
    """ Write VASP input files in directory 'dirpath' """
    print "Setting up VASP input files:", dirpath

    # read prim and prim kpoints
    print "  Reading KPOINTS:", prim_kpointsfile
    prim_kpoints = kpoints.Kpoints(prim_kpointsfile)
    if prim_poscarfile != None:
        print "  Reading KPOINTS reference POSCAR:", prim_poscarfile
        prim = poscar.Poscar(prim_poscarfile)
    else:
        prim = None

    # read species, super poscar, incar, and generate super kpoints
    print "  Reading SPECIES:", speciesfile
    species_settings = species.species_settings(speciesfile)
    print "  Reading supercell POS:", super_poscarfile
    super = poscar.Poscar(super_poscarfile, species_settings)
    print "  Reading INCAR:", incarfile
    super_incar = incar.Incar(incarfile, species_settings, super, sort)
    print "  Generating supercell KPOINTS"
    if strict_kpoints:
        super_kpoints = prim_kpoints
    else:
        super_kpoints = prim_kpoints.super_kpoints(prim, super)


    # write main input files
    print "  Writing supercell POSCAR:", os.path.join(dirpath,'POSCAR')
    super.write(os.path.join(dirpath,'POSCAR'), sort)
    print "  Writing INCAR:", os.path.join(dirpath,'INCAR')
    super_incar.write(os.path.join(dirpath,'INCAR'))
    print "  Writing supercell KPOINTS:", os.path.join(dirpath,'KPOINTS')
    super_kpoints.write(os.path.join(dirpath,'KPOINTS'))
    print "  Writing POTCAR:", os.path.join(dirpath,'POTCAR')
    write_potcar(os.path.join(dirpath,'POTCAR'), super, species_settings, sort)

    # copy extra input files
    if len(extra_input_files):
        print "  Copying extra input files",
    for s in extra_input_files:
        print "    ", s
        shutil.copy(s,dirpath)
    
    print "  DONE\n"
    sys.stdout.flush()
Example #4
0
 def __init__(self, incarfile, prim_kpointsfile, prim_poscarfile, super_poscarfile, speciesfile, sort=False):
     """ Construct a VaspIO object
        
         Args:
             incarfile:  path to INCAR file
             prim_kpointsfile: path to primitive KPOINTS file
             prim_poscarfile: path to primitive POSCAR file
             super_poscarfile: path to POSCAR file for this configuration
             speciesfile: path to SPECIES file
          
         This functions reads the input files and generates self.kpoints appropriate for self.poscar 
         given that 'prim_kpointsfile' is for 'prim_poscarfile'.
     """
     prim = poscar.Poscar(prim_poscarfile)
     prim_kpoints = kpoints.Kpoints(prim_kpointsfile)
     
     
     self.species = species.species_settings(speciesfile)
     self.poscar = poscar.Poscar(super_poscarfile, self.species)
     self.incar = incar.Incar(incarfile, self.species, self.poscar, sort)
     self.kpoints = prim_kpoints.super_kpoints(prim, self.poscar)