# Example of how to use vasp2boltz.py
# Create a .py file with a content similar to the following
# It is necessary to have ASE installed:
# https://wiki.fysik.dtu.dk/ase/

from ase import io
from ase.lattice.spacegroup import Spacegroup
import vasp2boltz

ao = io.read('POSCAR')
# If you do not have spglib installed, you need to add the spacegroup no.
# e.g. sg = Spacegroup(216) for the 'F -4 3 m' space group
# If you use the conventional cell rather than the primitive unit cell in your
# POSCAR file for e.g. I or F spacegroups, you need to add this information.

# Example 1:
sg = Spacegroup(1)
ao.info = {'spacegroup': sg}

# Example 2. Here the unit cell in the POSCAR file is cubic (conventional):
sg = Spacegroup(216)
ao.info = {'spacegroup': sg, 'unit_cell': 'conventional'}

# Read number of electrons from OUTCAR.
foundnelect = False
try:
    for line in open('OUTCAR', 'r'):
        if 'NELECT' in line:
            nelect = float(line.split()[2])
	    foundnelect = True
except:
    pass
if not foundnelect:
    print 'Number of electrons not found. Please set the number manually in hte.intrans.'
    nelect = 1.0

# The remaining part takes care of writing the files required by BoltzTraP.
bs = vasp2boltz.get_vasp_bandstructure()
vasp2boltz.write_bandstructure_boltztrap(bs)
vasp2boltz.write_structure_boltztrap(ao)
vasp2boltz.write_intrans_boltztrap(n_electrons = nelect)
