<jupyter_start><jupyter_text>How to use Boltztrap2 pymatgen interfaceAuthor: <NAME>, UCLouvain, <EMAIL>, <EMAIL>Warning: under development. Please if you find any bug or issues contact me.Here you find how to use boltztrap2 directly through pymatgen.Examples of what it is possible to do with it and which quantities can be computed from the band structure are provided.Boltztrap2 needs to be installed.Spin polarized is now implemented.This notebook was tested with pymatgen == 2v2020.7.3. It should work with higher version too.<jupyter_code>%notebook inline
from pymatgen.electronic_structure.boltztrap2 import *
from monty.serialization import loadfn<jupyter_output><empty_output><jupyter_text>Load DFT data  Deprecated LoadersPlease, do not use them anymore. They will be removed any time soon.<jupyter_code>data = VasprunLoader().from_file('boltztrap2_data/vasprun-PbTe_uniform_bs.xml')
bs = loadfn('boltztrap2_data/PbTe_bandstructure.json')
loader = BandstructureLoader(bs,data.structure)<jupyter_output>/home/tardo/github/matgenb/notebooks/boltztrap2.py:220: UserWarning: Deprecated Loader. Use VasprunBSLoader instead.
  warnings.warn("Deprecated Loader. Use VasprunBSLoader instead.")<jupyter_text>New unique loaderYou can load both vasprun or band structure pmg obj or directly from a vasprun.xml file.<jupyter_code>vrun = Vasprun('boltztrap2_data/vasprun-PbTe_uniform_bs.xml',parse_projected_eigen=True)
data = VasprunBSLoader(vrun)
bs = vrun.get_band_structure()
nele = vrun.parameters['NELECT']
st = vrun.final_structure
data = VasprunBSLoader(bs,structure=st,nelect=nele)
data = VasprunBSLoader.from_file('boltztrap2_data/vasprun-PbTe_uniform_bs.xml')<jupyter_output><empty_output><jupyter_text>Interpolator<jupyter_code># set curvature=False to speed up in case you do not need effective mass or hall coeficients
bztInterp = BztInterpolator(data,lpfac=10,energy_range=1.5,curvature=True)<jupyter_output><empty_output><jupyter_text>Compute and plot the band structure on standard symmetry path<jupyter_code>sbs = bztInterp.get_band_structure()
list(sbs.bands.values())[0].shape
from pymatgen.electronic_structure.plotter import BSPlotter
BSPlotter(sbs).show()<jupyter_output><empty_output><jupyter_text>On a specific kpoint path<jupyter_code># define the path as a list
kpaths = [['L','K']]
# set the fractional coordinates of the kpoint as a dict
kp_lbl = {'L':np.array([0.5,0.5,0.5]),'K': np.array([0.375, 0.375, 0.75 ])}
sbs = bztInterp.get_band_structure(kpaths,kp_lbl)
BSPlotter(sbs).show()<jupyter_output><empty_output><jupyter_text>Compute and plot Dos<jupyter_code>tot_dos = bztInterp.get_dos()
len(tot_dos.energies)
# set progress=True to show a progress bar
tot_proj_dos = bztInterp.get_dos(partial_dos=True,progress=False)
len(tot_proj_dos.get_spd_dos().values())
from pymatgen.electronic_structure.plotter import DosPlotter
pltdos = DosPlotter(sigma=0.05)
pltdos.add_dos_dict(tot_proj_dos.get_element_dos())
pltdos.show()<jupyter_output><empty_output><jupyter_text>Save and Load coefficientsTo save time in large systems, the coefficient of the interpolation can be saved in a file and read them later to avoid to recalculate them.<jupyter_code># set fname argument to specify a different file name
bztInterp = BztInterpolator(data,lpfac=10,energy_range=1.5,curvature=True,
                            save_bztInterp=True,fname='bztInterp.json.gz')
len(bztInterp.coeffs)
bztInterp = BztInterpolator(data,load_bztInterp=True,fname='bztInterp.json.gz')
len(bztInterp.coeffs)<jupyter_output><empty_output><jupyter_text>Transport Properties  Only w.r.t. the chemical potential<jupyter_code>bztTransp = BztTransportProperties(bztInterp,temp_r = np.arange(300,1300,300))
print('\t'.join(['Temp', '\mu', 'rows', 'columns tensor']))
for p in bztTransp.Conductivity_mu, bztTransp.Seebeck_mu, bztTransp.Kappa_mu, \
         bztTransp.Effective_mass_mu, bztTransp.Power_Factor_mu, bztTransp.Carrier_conc_mu:
    print('\t'.join([str(i) for i in p.shape]))<jupyter_output>Temp	\mu	rows	columns tensor
4	3252	3	3
4	3252	3	3
4	3252	3	3
4	3252	3	3
4	3252	3	3
4	3252<jupyter_text>Compute them w.r.t. specific doping levels<jupyter_code>bztTransp.compute_properties_doping(doping=10.**np.arange(16,23))
print('\t'.join(['Temp', 'Doping', 'rows', 'columns tensor']))
for p in bztTransp.Conductivity_doping, bztTransp.Seebeck_doping, bztTransp.Kappa_doping, \
         bztTransp.Carriers_conc_doping,bztTransp.Effective_mass_doping, bztTransp.Power_Factor_doping:
    print('\t'.join([str(i) for i in p['n'].shape]))<jupyter_output>Temp	Doping	rows	columns tensor
4	7	3	3
4	7	3	3
4	7	3	3
4	7
4	7	3	3
4	7	3	3<jupyter_text>Compute both together<jupyter_code>bztTransp = BztTransportProperties(bztInterp,temp_r = np.arange(300,1300,300), doping=10.**np.arange(16,23))<jupyter_output><empty_output><jupyter_text>Save and Load transport propertiesThe tranport properties can be saved into a file and loaded later.<jupyter_code># set fname argument to specify a different file name
bztTransp = BztTransportProperties(bztInterp,temp_r = np.arange(300,1300,300), doping=10.**np.arange(16,23),
                                   save_bztTranspProps=True,fname='bztTranspProps.json.gz')
bztTransp = BztTransportProperties(bztInterp,load_bztTranspProps=True,fname='bztTranspProps.json.gz')<jupyter_output><empty_output><jupyter_text>Plotter<jupyter_code>bztPlotter = BztPlotter(bztTransp,bztInterp)
bztPlotter.plot_props('C','mu','temp')
bztPlotter.plot_props('S','mu','temp',temps=[600,900,1200])
bztPlotter.plot_props('S','doping','temp', temps=[600,900,1200], dop_type='p').show()
bztPlotter.plot_props('S','temp','doping',doping=[1e16,1e20], dop_type='n').show()
bztPlotter.plot_props('K','mu','temp',temps=[600,900,1200]).show()
bztPlotter.plot_props('H','mu','temp',temps=[600,900,1200]).show()
bztPlotter.plot_props('Po','doping','temp',temps=[600,900,1200],dop_type='p').show()
bztPlotter.plot_props('E','doping','temp').show()
bztPlotter.plot_props('Ca','mu','temp',temps=[600,900,1200]).show()
bztPlotter.plot_bands().show()
bztPlotter.plot_dos(T=200).show()<jupyter_output>10000
{'fraction_non_alphanumeric': 0.12356227407163983, 'fraction_numerical': 0.03812027604337825, 'mean_word_length': 7.634042553191489, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '420793', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2437, 'n_tokens_neox': 2272, 'n_words': 427, 'path': 'notebooks/2019-01-04-How to use Boltztra2 interface.ipynb', 'repo_name': 'fraricci/matgenb', 'size': '6130'}