Ejemplo n.º 1
0
 def get_odos(self, stack=True, xlim=[-10, 10], ylim=[0, 50], sigma=0.15):
     dos_vasprun = Vasprun(os.path.join(self.path, "vasprun.xml"), parse_projected_eigen=True)
     dos_data = dos_vasprun.complete_dos
     plotter = DosPlotter(stack=stack, sigma=sigma)
     o_dos = dos_data.get_spd_dos()
     plotter.add_dos_dict(o_dos)
     plotter.save_plot(f'{self.path}-odos.png', img_format=u'png', xlim=xlim, ylim=ylim)
Ejemplo n.º 2
0
class DosPlotterTest(unittest.TestCase):

    def setUp(self):
        try:
            import scipy
        except ImportError:
            raise SkipTest("scipy not present. Skipping...")
        with open(os.path.join(test_dir, "complete_dos.json"), "r") as f:
            self.dos = CompleteDos.from_dict(json.load(f))
            self.plotter = DosPlotter(sigma=0.2, stack=True)

    def test_add_dos_dict(self):
        try:
            import scipy
        except ImportError:
            raise SkipTest("scipy not present. Skipping...")
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 0)
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 4)

    def test_get_dos_dict(self):
        try:
            import scipy
        except ImportError:
            raise SkipTest("scipy not present. Skipping...")
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        for el in ["Li", "Fe", "P", "O"]:
            self.assertIn(el, d)
Ejemplo n.º 3
0
def get_dos_plot(args):
    v = Vasprun(args.dos_file)
    dos = v.complete_dos

    all_dos = OrderedDict()
    all_dos["Total"] = dos

    structure = v.final_structure

    if args.site:
        for i in range(len(structure)):
            site = structure[i]
            all_dos["Site " + str(i) + " " + site.specie.symbol] = \
                dos.get_site_dos(site)

    if args.element:
        syms = [tok.strip() for tok in args.element[0].split(",")]
        all_dos = {}
        for el, dos in dos.get_element_dos().items():
            if el.symbol in syms:
                all_dos[el] = dos
    if args.orbital:
        all_dos = dos.get_spd_dos()

    plotter = DosPlotter()
    plotter.add_dos_dict(all_dos)
    return plotter.get_plot()
Ejemplo n.º 4
0
def get_dos_plot(args):
    """
    Plot DOS.

    Args:
        args (dict): Args from argparse.
    """
    v = Vasprun(args.dos_file)
    dos = v.complete_dos

    all_dos = OrderedDict()
    all_dos["Total"] = dos

    structure = v.final_structure

    if args.site:
        for i, site in enumerate(structure):
            all_dos["Site " + str(i) + " " +
                    site.specie.symbol] = dos.get_site_dos(site)

    if args.element:
        syms = [tok.strip() for tok in args.element[0].split(",")]
        all_dos = {}
        for el, dos in dos.get_element_dos().items():
            if el.symbol in syms:
                all_dos[el] = dos
    if args.orbital:
        all_dos = dos.get_spd_dos()

    plotter = DosPlotter()
    plotter.add_dos_dict(all_dos)
    return plotter.get_plot()
Ejemplo n.º 5
0
def plot_dos(args):
    v = Vasprun(args.filename[0])
    dos = v.complete_dos

    all_dos = OrderedDict()
    all_dos["Total"] = dos

    structure = v.final_structure

    if args.site:
        for i in xrange(len(structure)):
            site = structure[i]
            all_dos["Site " + str(i) + " " + site.specie.symbol] = \
                dos.get_site_dos(site)

    if args.element:
        syms = [tok.strip() for tok in args.element[0].split(",")]
        all_dos = {}
        for el, dos in dos.get_element_dos().items():
            if el.symbol in syms:
                all_dos[el] = dos
    if args.orbital:
        all_dos = dos.get_spd_dos()

    plotter = DosPlotter()
    plotter.add_dos_dict(all_dos)
    if args.file:
        plotter.get_plot().savefig(args.file[0])
    else:
        plotter.show()
Ejemplo n.º 6
0
def dos_graph_soc(rawdatadir, savedir):
    dosrun = Vasprun("{}/vasprun.xml".format(rawdatadir),
                     soc=True,
                     parse_dos=True)
    dos = dosrun.complete_dos

    orbitals = {
        "s": Orbital.s,
        "p_y": Orbital.py,
        "p_z": Orbital.pz,
        "p_x": Orbital.px,
        "d_xy": Orbital.dxy,
        "d_yz": Orbital.dyz,
        "d_z2-r2": Orbital.dz2,
        "d_xz": Orbital.dxz,
        "d_x2-y2": Orbital.dx2
    }
    spinor_component = {
        "mtot": SpinNonCollinear.mtot,
        "mx": SpinNonCollinear.mx,
        "my": SpinNonCollinear.my,
        "mz": SpinNonCollinear.mz
    }

    for m in spinor_component:
        dosplot = DosPlotter()
        if m == "mtot":
            dosplot.add_dos("Total DOS with SOC", dos.tdos)
        dosplot.add_dos_dict(dos.get_element_dos())
        plt = dosplot.get_plot(xlim=[-3, 3],
                               soc=True,
                               spinor_component=spinor_component[m],
                               element_colors=True)
        plt.grid()
        plt.savefig("{}/DOSGraph_{}_{}".format(savedir, m,
                                               "DOS by Element with SOC"))
        plt.close()

    for m in spinor_component:
        dosplot = DosPlotter()
        if m == "mtot":
            dosplot.add_dos("Total DOS with SOC", dos.tdos)
        dosplot.add_dos_dict(dos.get_orbital_dos())
        plt = dosplot.get_plot(xlim=[-3, 3],
                               soc=True,
                               spinor_component=spinor_component[m])
        plt.grid()
        plt.savefig("{}/DOSGraph_{}_{}".format(savedir, m,
                                               "DOS by Orbital with SOC"))
        plt.close()

    # Get detailed info about band gap (source: vasprun.xml)
    dos_graph_soc.e_fermi = float(dosrun.efermi)
    dos_graph_soc.electronic_gap = \
        dosrun.tdos.get_gap_alt(xlim=[-3,3],e_fermi=dos_graph_soc.e_fermi,
                                tol=0.001,abs_tol=False,
                                spin=SpinNonCollinear.mtot)

    return
Ejemplo n.º 7
0
def main():
    parser = argparse.ArgumentParser(
        description='''Convenient DOS Plotter for Feff runs.
    Author: Alan Dozier
    Version: 1.0
    Last updated: April, 2013''')

    parser.add_argument('filename',
                        metavar='filename',
                        type=str,
                        nargs=1,
                        help='ldos%% file set to plot')
    parser.add_argument('filename1',
                        metavar='filename1',
                        type=str,
                        nargs=1,
                        help='feff.inp input file ')
    parser.add_argument('-s',
                        '--site',
                        dest='site',
                        action='store_const',
                        const=True,
                        help='plot site projected DOS')
    parser.add_argument('-e',
                        '--element',
                        dest='element',
                        action='store_const',
                        const=True,
                        help='plot element projected DOS')
    parser.add_argument('-o',
                        '--orbital',
                        dest="orbital",
                        action='store_const',
                        const=True,
                        help='plot orbital projected DOS')

    args = parser.parse_args()
    f = LDos.from_file(args.filename1[0], args.filename[0])
    dos = f.complete_dos

    all_dos = OrderedDict()
    all_dos['Total'] = dos

    structure = f.complete_dos.structure

    if args.site:
        for i, site in enumerate(structure):
            all_dos['Site ' + str(i) + " " + site.specie.symbol] = \
                dos.get_site_dos(site)
    if args.element:
        all_dos.update(dos.get_element_dos())
    if args.orbital:
        all_dos.update(dos.get_spd_dos())

    plotter = DosPlotter()
    plotter.add_dos_dict(all_dos)
    plotter.show()
Ejemplo n.º 8
0
    def get_dos(self, dos):
        task_id = dos['task_id']
        dos_obj = self.vaspdb.get_dos(task_id)
        energies = dos_obj.energies
        efermi = dos_obj.efermi
        gap = dos_obj.get_gap()
        densities_up = dos_obj.densities[Spin.up]
        densities_dn = dos_obj.densities[Spin.down]
        #densities = densities_up + densities_dn
        densities = dos_obj.get_densities()
        #print('Fermi energy: {}'.format(efermi))
        #print('gap: {}'.format(gap))
        tdos = np.vstack((energies, densities))
        #print(tdos)
        #print(type(densities))

        plotter = DosPlotter()

        # Adds a DOS with a label.
        #plotter.add_dos("Total DOS", dos)

        # Alternatively, you can add a dict of DOSs. This is the typical
        # form returned by CompleteDos.get_spd/element/others_dos().
        #plotter.add_dos_dict({"dos1": dos1, "dos2": dos2})
        dosplot = plotter.add_dos_dict(dos_obj.get_element_dos())
        #dosplot = plotter.add_dos_dict(dos_obj.get_spd_dos())
        #plotter.show()

        self.head = [
            'energies', 'total_dos', 'total_dos_spin_up', 'total_dos_spin_down'
        ]
        self.unit = ['eV', '', '', '']
        self.data = np.vstack(
            (energies, densities, densities_up, -densities_dn)).T
        self.parameter = dos['input']['incar']
Ejemplo n.º 9
0
class DosPlotterTest(unittest.TestCase):
    def setUp(self):
        with open(os.path.join(test_dir, "complete_dos.json"), "r") as f:
            self.dos = CompleteDos.from_dict(json.load(f))
            self.plotter = DosPlotter(sigma=0.2, stack=True)

    def test_add_dos_dict(self):
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 0)
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 4)

    def test_get_dos_dict(self):
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        for el in ["Li", "Fe", "P", "O"]:
            self.assertIn(el, d)
Ejemplo n.º 10
0
class DosPlotterTest(unittest.TestCase):
    def setUp(self):
        with open(os.path.join(test_dir, "complete_dos.json"), "r",
                  encoding='utf-8') as f:
            self.dos = CompleteDos.from_dict(json.load(f))
            self.plotter = DosPlotter(sigma=0.2, stack=True)

    def test_add_dos_dict(self):
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 0)
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 4)

    def test_get_dos_dict(self):
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        for el in ["Li", "Fe", "P", "O"]:
            self.assertIn(el, d)

    # Minimal baseline testing for get_plot. not a true test. Just checks that
    # it can actually execute.
    def test_get_plot(self):
        # Disabling latex is needed for this test to work.
        from matplotlib import rc
        rc('text', usetex=False)
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        plt = self.plotter.get_plot()
        self.plotter.save_plot("dosplot.png")
        self.assertTrue(os.path.isfile("dosplot.png"))
        os.remove("dosplot.png")
Ejemplo n.º 11
0
class DosPlotterTest(unittest.TestCase):
    def setUp(self):
        with open(os.path.join(test_dir, "complete_dos.json"), "r",
                  encoding='utf-8') as f:
            self.dos = CompleteDos.from_dict(json.load(f))
            self.plotter = DosPlotter(sigma=0.2, stack=True)

    def test_add_dos_dict(self):
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 0)
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 4)

    def test_get_dos_dict(self):
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        for el in ["Li", "Fe", "P", "O"]:
            self.assertIn(el, d)

    # Minimal baseline testing for get_plot. not a true test. Just checks that
    # it can actually execute.
    def test_get_plot(self):
        # Disabling latex is needed for this test to work.
        from matplotlib import rc
        rc('text', usetex=False)
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        plt = self.plotter.get_plot()
        self.plotter.save_plot("dosplot.png")
        self.assertTrue(os.path.isfile("dosplot.png"))
        os.remove("dosplot.png")
Ejemplo n.º 12
0
class DosPlotterTest(unittest.TestCase):

    def setUp(self):
        with open(os.path.join(test_dir, "complete_dos.json"), "r",
                  encoding='utf-8') as f:
            self.dos = CompleteDos.from_dict(json.load(f))
            self.plotter = DosPlotter(sigma=0.2, stack=True)

    def test_add_dos_dict(self):
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 0)
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        self.assertEqual(len(d), 4)

    def test_get_dos_dict(self):
        self.plotter.add_dos_dict(self.dos.get_element_dos(),
                                  key_sort_func=lambda x: x.X)
        d = self.plotter.get_dos_dict()
        for el in ["Li", "Fe", "P", "O"]:
            self.assertIn(el, d)
Ejemplo n.º 13
0
def main():
    parser = argparse.ArgumentParser(description='''Convenient DOS Plotter for Feff runs.
    Author: Alan Dozier
    Version: 1.0
    Last updated: April, 2013''')

    parser.add_argument('filename', metavar='filename', type=str, nargs=1,
                        help='ldos%% file set to plot')
    parser.add_argument('filename1', metavar='filename1', type=str, nargs=1,
                        help='feff.inp input file ')
    parser.add_argument('-s', '--site', dest='site', action='store_const',
                        const=True, help='plot site projected DOS')
    parser.add_argument('-e', '--element', dest='element', action='store_const',
                        const=True, help='plot element projected DOS')
    parser.add_argument('-o', '--orbital', dest="orbital", action='store_const',
                        const=True, help='plot orbital projected DOS')

    args = parser.parse_args()
    f = LDos.from_file(args.filename1[0], args.filename[0])
    dos = f.complete_dos

    all_dos = OrderedDict()
    all_dos['Total'] = dos

    structure = f.complete_dos.structure

    if args.site:
        for i, site in enumerate(structure):
            all_dos['Site ' + str(i) + " " + site.specie.symbol] = \
                dos.get_site_dos(site)
    if args.element:
        all_dos.update(dos.get_element_dos())
    if args.orbital:
        all_dos.update(dos.get_spd_dos())

    plotter = DosPlotter()
    plotter.add_dos_dict(all_dos)
    plotter.show()
Ejemplo n.º 14
0
def main():
    parser = argparse.ArgumentParser(
        description="""Convenient DOS Plotter for Feff runs.
    Author: Alan Dozier
    Version: 1.0
    Last updated: April, 2013"""
    )

    parser.add_argument("filename", metavar="filename", type=str, nargs=1, help="ldos%% file set to plot")
    parser.add_argument("filename1", metavar="filename1", type=str, nargs=1, help="feff.inp input file ")
    parser.add_argument("-s", "--site", dest="site", action="store_const", const=True, help="plot site projected DOS")
    parser.add_argument(
        "-e", "--element", dest="element", action="store_const", const=True, help="plot element projected DOS"
    )
    parser.add_argument(
        "-o", "--orbital", dest="orbital", action="store_const", const=True, help="plot orbital projected DOS"
    )

    args = parser.parse_args()
    f = LDos.from_file(args.filename1[0], args.filename[0])
    dos = f.complete_dos

    all_dos = OrderedDict()
    all_dos["Total"] = dos

    structure = f.complete_dos.structure

    if args.site:
        for i, site in enumerate(structure):
            all_dos["Site " + str(i) + " " + site.specie.symbol] = dos.get_site_dos(site)
    if args.element:
        all_dos.update(dos.get_element_dos())
    if args.orbital:
        all_dos.update(dos.get_spd_dos())

    plotter = DosPlotter()
    plotter.add_dos_dict(all_dos)
    plotter.show()
Ejemplo n.º 15
0
    '/home/jinho93/oxides/perobskite/lanthanum-aluminate/periodic_step/vasp/stengel/001/vca/AlO2'
)
os.chdir(
    '/home/jinho93/oxides/perobskite/lanthanum-aluminate/slab/14/asym/to_Al')
# os.chdir('/home/jinho93/new/oxides/perobskite/lanthanum-aluminate/slab/7')
vrun = Vasprun('vasprun.xml')
cdos = vrun.complete_dos
s = vrun.final_structure

dsp = DosPlotter()

dos_dict = {}
i: Site
for n, i in enumerate(s.sites):
    if i.species_string == 'La':
        dos_dict[f'{n}'] = cdos.get_site_dos(i)

dsp.add_dos_dict(dos_dict)

dsp.show(xlim=(-10, 5), ylim=(0, 2))

# %%

aldos = cdos.get_site_dos(s.sites[0])
dx = aldos.energies[1] - aldos.energies[0]
o = np.sum(
    aldos.get_densities(Spin.up)[np.logical_and(aldos.energies > -2,
                                                aldos.energies < 0)]) * dx
print(o)
# %%
Ejemplo n.º 16
0
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.electronic_structure.plotter import DosPlotter
from collections import OrderedDict

vaspout = Vasprun("vasprun.xml")

dos = vaspout.complete_dos

all_dos = OrderedDict()
all_dos["Total"] = dos

plt = DosPlotter()
plt.add_dos_dict(all_dos)
plt = plt.get_plot(xlim=[-10,10],ylim=[0,1.5])
plt.savefig('dos.pdf')

Ejemplo n.º 17
0
def main():
    """
    Main function.
    """
    parser = argparse.ArgumentParser(
        description="""Convenient DOS Plotter for Feff runs.
    Author: Alan Dozier
    Version: 1.0
    Last updated: April, 2013""")

    parser.add_argument(
        "filename",
        metavar="filename",
        type=str,
        nargs=1,
        help="ldos%% file set to plot",
    )
    parser.add_argument("filename1",
                        metavar="filename1",
                        type=str,
                        nargs=1,
                        help="feff.inp input file ")
    parser.add_argument(
        "-s",
        "--site",
        dest="site",
        action="store_const",
        const=True,
        help="plot site projected DOS",
    )
    parser.add_argument(
        "-e",
        "--element",
        dest="element",
        action="store_const",
        const=True,
        help="plot element projected DOS",
    )
    parser.add_argument(
        "-o",
        "--orbital",
        dest="orbital",
        action="store_const",
        const=True,
        help="plot orbital projected DOS",
    )

    args = parser.parse_args()
    f = LDos.from_file(args.filename1[0], args.filename[0])
    dos = f.complete_dos

    all_dos = {}
    all_dos["Total"] = dos

    structure = f.complete_dos.structure

    if args.site:
        for i, site in enumerate(structure):
            all_dos["Site " + str(i) + " " +
                    site.specie.symbol] = dos.get_site_dos(site)
    if args.element:
        all_dos.update(dos.get_element_dos())
    if args.orbital:
        all_dos.update(dos.get_spd_dos())

    plotter = DosPlotter()
    plotter.add_dos_dict(all_dos)
    plotter.show()
Ejemplo n.º 18
0
from pymatgen.io.vasp import Vasprun, Element
from pymatgen.electronic_structure.plotter import DosPlotter

v = Vasprun('AgTe_dos/vasprun.xml')
cdos = v.complete_dos


element_dos = cdos.get_element_dos()
element_orbital = cdos.get_element_spd_dos(el=Element("Te"))

#print(cdos.pdos)

#px = cdos.get_site_orbital_dos(site=v.final_structure.sites[0],orbital=0)
#py = cdos.get_site_orbital_dos(site=v.final_structure.sites[0],orbital=2)
#pz = cdos.get_site_orbital_dos(site=v.final_structure.sites[0],orbital=1)


plotter = DosPlotter(zero_at_efermi=True)
plotter.add_dos_dict(element_dos)
#plotter.add_dos_dict(px)
#plotter.add_dos_dict(py)
#plotter.add_dos_dict(pz)

plotter.show(xlim=[-4, 4], ylim=[0, 10])
Ejemplo n.º 19
0
def dos_graph(rawdatadir,
              savedir,
              total_dos=True,
              by_element=False,
              by_orbital=False):
    dosrun = Vasprun("{}/vasprun.xml".format(rawdatadir), parse_dos=True)
    dos = dosrun.complete_dos

    # Get basic plot
    dos_graph.e_fermi = float(dosrun.efermi)
    dos_graph.band_gap = float(dosrun.eigenvalue_band_properties[0])
    dosplot = DosPlotter()
    #dosplot = DosPlotter(sigma=0.1)
    if total_dos == True:
        dosplot.add_dos("Total DOS", dos)
    if by_element == True:
        dosplot.add_dos_dict(dos.get_element_dos())
    if by_orbital == True:
        dosplot.add_dos_dict(dos.get_spd_dos())
    plt = dosplot.get_plot(xlim=[-3, 3], ylim=[-15, 15], element_colors=True)
    plt.grid()
    plt.savefig("{}/DOSGraph".format(savedir))
    plt.close()

    # Get plot for comparison with SOC total DOS plot
    dosplot = DosPlotter()
    dosplot.add_dos("Total DOS without SOC", dos)
    dosplot.add_dos_dict(dos.get_element_dos())
    plt = dosplot.get_plot_total(xlim=[-3, 3], element_colors=True)
    plt.grid()
    plt.savefig("{}/DOSGraph_tot_DOS by Element without SOC".format(savedir))
    plt.close()

    dosplot = DosPlotter()
    orbitals = {
        "s": Orbital.s,
        "p_y": Orbital.py,
        "p_z": Orbital.pz,
        "p_x": Orbital.px,
        "d_xy": Orbital.dxy,
        "d_yz": Orbital.dyz,
        "d_z2-r2": Orbital.dz2,
        "d_xz": Orbital.dxz,
        "d_x2-y2": Orbital.dx2
    }
    dosplot.add_dos("Total DOS without SOC", dos)
    dosplot.add_dos_dict(dos.get_orbital_dos())
    plt = dosplot.get_plot_total(xlim=[-3, 3])
    plt.grid()
    plt.savefig("{}/DOSGraph_tot_DOS by Orbital without SOC".format(savedir))
    plt.close()
    """
    # Get quick info about band gap (source: EIGENVAL)
    eigenval = Eigenval("{}/EIGENVAL".format(rawdatadir))
    dos_graph.band_properties = eigenval.eigenvalue_band_properties
    """
    # Get detailed info about band gap and CB/VB in each spin channel
    # (source: vasprun.xml)
    dos_graph.majority_vbm = \
        dosrun.tdos.get_cbm_vbm_alt(xlim=[-3,3],e_fermi=dos_graph.e_fermi,
                                    tol=0.3,abs_tol=True,spin=Spin.up)[1]
    dos_graph.majority_cbm = \
        dosrun.tdos.get_cbm_vbm_alt(xlim=[-3,3],e_fermi=dos_graph.e_fermi,
                                    tol=0.3,abs_tol=True,spin=Spin.up)[0]
    dos_graph.minority_vbm = \
        dosrun.tdos.get_cbm_vbm_alt(xlim=[-3,3],e_fermi=dos_graph.e_fermi,
                                    tol=0.3,abs_tol=True,spin=Spin.down)[1]
    dos_graph.minority_cbm = \
        dosrun.tdos.get_cbm_vbm_alt(xlim=[-3,3],e_fermi=dos_graph.e_fermi,
                                    tol=0.3,abs_tol=True,spin=Spin.down)[0]
    dos_graph.majority_gap = \
        dosrun.tdos.get_gap_alt(xlim=[-3,3],e_fermi=dos_graph.e_fermi,
                                tol=0.3,abs_tol=True,spin=Spin.up)
    dos_graph.minority_gap = \
        dosrun.tdos.get_gap_alt(xlim=[-3,3],e_fermi=dos_graph.e_fermi,
                                tol=0.3,abs_tol=True,spin=Spin.down)
    dos_graph.electronic_gap = \
        dosrun.tdos.get_gap_alt(xlim=[-3,3],e_fermi=dos_graph.e_fermi,
                                tol=0.3,abs_tol=True,spin=None)

    return
Ejemplo n.º 20
0
# coding: utf-8
# Copyright (c) Henniggroup.
# Distributed under the terms of the MIT License.

from __future__ import division, print_function, unicode_literals, \
    absolute_import

"""
reads in vasprun.xml file and plots the density of states 
"""

# To use matplotlib on Hipergator, uncomment the following 2 lines:
# import matplotlib
# matplotlib.use('Agg')

from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.electronic_structure.plotter import DosPlotter

if __name__ == "__main__":
    # readin the density of states from vasprun.xml file
    run = Vasprun("vasprun.xml", parse_projected_eigen=True)
    complete_dos = run.complete_dos
    print('cbm and vbm ', complete_dos.get_cbm_vbm())
    print('gap = ', complete_dos.get_gap())
    # get orbital projected DOS.    
    spd_dos = complete_dos.get_spd_dos()
    plotter = DosPlotter()
    plotter.add_dos_dict(spd_dos)
    plotter.save_plot('dos.eps')
Ejemplo n.º 21
0
                    help='feff.inp input file ')
parser.add_argument('-s', '--site', dest='site', action='store_const',
                    const=True, help='plot site projected DOS')
parser.add_argument('-e', '--element', dest='element', action='store_const',
                    const=True, help='plot element projected DOS')
parser.add_argument('-o', '--orbital', dest="orbital", action='store_const',
                    const=True, help='plot orbital projected DOS')

args = parser.parse_args()
f = FeffLdos.from_file(args.filename1[0], args.filename[0])
dos = f.complete_dos

all_dos = OrderedDict()
all_dos['Total'] = dos

structure = f.complete_dos.structure

if args.site:
    for i in xrange(len(structure)):
        site = structure[i]
        all_dos['Site ' + str(i) + " " + site.specie.symbol] = \
            dos.get_site_dos(site)
if args.element:
    all_dos.update(dos.get_element_dos())
if args.orbital:
    all_dos.update(dos.get_spd_dos())

plotter = DosPlotter()
plotter.add_dos_dict(all_dos)
plotter.show()
Ejemplo n.º 22
0
#!/nfshome/villa/anaconda3/bin/python

from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.electronic_structure.plotter import BSPlotter, DosPlotter

vaspout = Vasprun("./vasprun.xml")

# Initializes plotter with some optional args. Defaults are usually
# fine,
complete_dos = vaspout.complete_dos
plt = DosPlotter()
plt.add_dos_dict(complete_dos.get_spd_dos())
tdos = vaspout.tdos
# Adds a DOS with a label.
plt.add_dos("Total", tdos)
#plt.get_plot()

plt.save_plot('dos_mg.pdf', img_format='pdf', xlim=[-7, 6], ylim=[0, 20])
Ejemplo n.º 23
0
                    help='plot element projected DOS')
parser.add_argument('-o',
                    '--orbital',
                    dest="orbital",
                    action='store_const',
                    const=True,
                    help='plot orbital projected DOS')

args = parser.parse_args()
f = FeffLdos.from_file(args.filename1[0], args.filename[0])
dos = f.complete_dos

all_dos = OrderedDict()
all_dos['Total'] = dos

structure = f.complete_dos.structure

if args.site:
    for i in xrange(len(structure)):
        site = structure[i]
        all_dos['Site ' + str(i) + " " + site.specie.symbol] = \
            dos.get_site_dos(site)
if args.element:
    all_dos.update(dos.get_element_dos())
if args.orbital:
    all_dos.update(dos.get_spd_dos())

plotter = DosPlotter()
plotter.add_dos_dict(all_dos)
plotter.show()
Ejemplo n.º 24
0
    out = Outcar('./OUTCAR')
    print('Total Magnetic Moment:', out.total_mag)

if make_dosplot:
    # read in BSDOSPlotter function to plot DOS and BS
    from pymatgen.electronic_structure.plotter import DosPlotter

    # make and save a plot of the band structure and DOS
    dos = vsp.complete_dos
    energy_range = (-10, 7)  # eV, change if desired to change plotting range

    # create DosPlotter object with smearing
    edosplot = DosPlotter(sigma=dos_smearing)
    # plot Total DOS and element-projected dos
    edosplot.add_dos("Total DOS", dos)
    edosplot.add_dos_dict(dos.get_element_dos())
    plt = edosplot.get_plot(xlim=energy_range)
    plt.plot((-20, 20), (0, 0), 'k--')
    plt.savefig('Element_DOS_plot.png')

    # create DosPlotter object with smearing
    odosplot = DosPlotter(sigma=dos_smearing)
    # plot Total DOS and orbital-projected dos
    odosplot.add_dos("Total DOS", dos)
    odosplot.add_dos_dict(dos.get_spd_dos())
    plt = odosplot.get_plot(xlim=energy_range)
    plt.plot((-20, 20), (0, 0), 'k--')
    plt.savefig('Orbital_DOS_plot.png')

    print('Generated DOS plots')
Ejemplo n.º 25
0
import numpy as np

os.chdir(
    '/home/jinho93/oxides/perobskite/lanthanum-aluminate/periodic_step/vasp/from-2012/1.0ps/full'
)
os.chdir(
    '/home/jinho93/oxides/perobskite/lanthanum-aluminate/periodic_step/vasp/from-100/300k'
)
os.chdir(
    '/home/jinho93/oxides/perobskite/lanthanum-aluminate/periodic_step/vasp/from-100/ini'
)
vrun = Vasprun('vasprun.xml')
cdos = vrun.complete_dos

dsp = DosPlotter()

dsp.add_dos_dict(cdos.get_element_dos())

dsp.show()

eldos = cdos.get_element_dos()
for i, j in eldos.items():
    if i == Element.La:
        tmp = [cdos.energies - cdos.efermi, j.densities[Spin.up]]
        tmp = np.transpose(np.array(tmp))
        np.savetxt('La.dat', tmp)
    elif i == Element.O:
        tmp = [cdos.energies - cdos.efermi, j.densities[Spin.up]]
        tmp = np.transpose(np.array(tmp))
        np.savetxt('O.dat', tmp)
Ejemplo n.º 26
0
# coding: utf-8
# Copyright (c) Henniggroup.
# Distributed under the terms of the MIT License.

from __future__ import division, print_function, unicode_literals, \
    absolute_import
"""
reads in vasprun.xml file and plots the density of states 
"""

# To use matplotlib on Hipergator, uncomment the following 2 lines:
# import matplotlib
# matplotlib.use('Agg')

from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.electronic_structure.plotter import DosPlotter

if __name__ == "__main__":
    # readin the density of states from vasprun.xml file
    run = Vasprun("vasprun.xml", parse_projected_eigen=True)
    complete_dos = run.complete_dos
    print('cbm and vbm ', complete_dos.get_cbm_vbm())
    print('gap = ', complete_dos.get_gap())
    # get orbital projected DOS.
    spd_dos = complete_dos.get_spd_dos()
    plotter = DosPlotter()
    plotter.add_dos_dict(spd_dos)
    plotter.save_plot('dos.eps')
Ejemplo n.º 27
0
from pymatgen.io.vasp import Vasprun, Element
from pymatgen.electronic_structure.plotter import DosPlotter

v = Vasprun('AgTe_dos/vasprun.xml')
cdos = v.complete_dos
element_dos = cdos.get_element_dos()
element_orbital = cdos.get_element_spd_dos(el=Element("Ag"))

plotter = DosPlotter()
plotter.add_dos_dict(element_orbital)
plotter.show(xlim=[-4, 4], ylim=[0, 10])
Ejemplo n.º 28
0
spd_dos = cdos.get_spd_dos
#print spd_dos
element_dos = cdos.get_element_dos
#element_spd_dos = cdos.get_element_spd_dos(el)
dosplotter = DosPlotter()
Totaldos = dosplotter.add_dos('Total DOS', tdos)
Integrateddos = dosplotter.add_dos('Integrated DOS', idos)
#Pdos = dosplotter.add_dos('Partial DOS',pdos)
#Spd_dos =  dosplotter.add_dos('spd DOS',spd_dos)
#Element_dos = dosplotter.add_dos('Element DOS',element_dos)
#Element_spd_dos = dosplotter.add_dos('Element_spd DOS',element_spd_dos)
dos_dict = {
    'Total DOS': tdos,
    'Integrated DOS': idos
}  #'Partial DOS':pdos,'spd DOS':spd_dos,'Element DOS':element_dos}#'Element_spd DOS':element_spd_dos
add_dos_dict = dosplotter.add_dos_dict(dos_dict)
get_dos_dict = dosplotter.get_dos_dict()
dos_plot = dosplotter.get_plot()
##dosplotter.save_plot("MAPbI3_dos",img_format="png")
##dos_plot.show()
bsplotter = BSPlotter(bs)
bs_plot_data = bsplotter.bs_plot_data()
bs_plot = bsplotter.get_plot()
#bsplotter.save_plot("MAPbI3_bs",img_format="png")
#bsplotter.show()
ticks = bsplotter.get_ticks()
print ticks
bsplotter.plot_brillouin()
bsdos = BSDOSPlotter(
    tick_fontsize=10,
    egrid_interval=20,
Ejemplo n.º 29
0
from pymatgen.io.vasp import Vasprun
from pymatgen.electronic_structure.plotter import DosPlotter

dsp = DosPlotter()

vrun = Vasprun('vasprun.xml')

dsp.add_dos_dict(
    vrun.complete_dos.get_site_spd_dos(vrun.final_structure.sites[0]))

dsp.show()
Ejemplo n.º 30
0
from pymatgen.io.vasp import Vasprun
from pymatgen.electronic_structure.plotter import DosPlotter
from pymatgen.io.vasp.outputs import Vasprun, Procar
from pymatgen.core.ion import Ion

v = Vasprun('vasprun.xml')
cdos = v.complete_dos
#el = cdos.Structure.composition
eles = cdos.structure.composition.elements

for ele in eles:
    plotter = DosPlotter()
    ele_or_dos = cdos.get_element_spd_dos(ele)
    plotter.add_dos_dict(ele_or_dos)
    plotter.show(xlim=[-8, 8], ylim=[0, 1000])

exit(0)
print cdos.Structure
#print el.elements
#exit(0)

#orbital_dos = cdos.get_spd_dos()
#plotter = DosPlotter()
#plotter.add_dos_dict(orbital_dos)
#plotter.show(xlim=[-8, 8], ylim=[0, 1000])





Ejemplo n.º 31
0
        'second': (0.5, 0.6),
    }
    for key, val in en.items():
        s: PeriodicSite = None
        dosN = Dos(cdos.efermi, cdos.energies,
                   {k: np.zeros(d.shape)
                    for k, d in cdos.densities.items()})
        dosMetal = Dos(
            cdos.efermi, cdos.energies,
            {k: np.zeros(d.shape)
             for k, d in cdos.densities.items()})
        for s in find_ind(cdos.structure, *val):
            if s.specie.__str__() == 'N':
                sum_orbital(dosN, cdos.get_site_spd_dos(s)[OrbitalType.p])
            elif s.specie.__str__() == 'Ni':
                sum_orbital(dosMetal, cdos.get_site_spd_dos(s)[OrbitalType.d])

        dosN.densities = dosN.get_smeared_densities(0.03)
        dosMetal.densities = dosMetal.get_smeared_densities(0.03)

        sum_spin(dosN)
        sum_spin(dosMetal)

        dosN = integrate(dosN)
        dosMetal = integrate(dosMetal)

        dp.add_dos_dict({key + "dosN": dosN, key + "dosM": dosMetal})
    dp.show()
    # write_dos(key + '_N_mag.dat', integrate(dosN))
    # write_dos(key + '_Cu_mag.dat', integrate(dosMetal))
Ejemplo n.º 32
0
import os
from pymatgen.electronic_structure.plotter import DosPlotter
from pymatgen.io.vasp.outputs import Vasprun, Element, Dos

os.chdir('/home/jinho93/molecule/ddt/vasp/2-sub/triplet/')
vrun = Vasprun('vasprun.xml')
# mpr = MPRester('DhmFQPuibZo8JtXn')
dos = vrun.complete_dos
# dos: CompleteDos = mpr.get_dos_by_material_id('mp-352')
eldos = dos.get_element_dos()
dos.get_site_spd_dos()
dos.get_site_t2g_eg_resolved_dos()
i: Element
j: Dos
print(vrun.final_structure.composition.element_composition)
#for i, j in eldos.items():
#    vasprun.final_structure.num_sites
#eldos.pop(Element.Mo)
#eldos.pop(Element.S)
dsp = DosPlotter()
dsp.add_dos_dict(eldos)
dsp.show(xlim=(-3, 5))
Ejemplo n.º 33
0
#%%

from matplotlib.pyplot import xlim
from pymatgen.io.vasp.outputs import Vasprun, Element
from pymatgen.electronic_structure.plotter import DosPlotter

path = '/home/jinho93/oxides/perobskite/lanthanum-aluminate/bulk/hse/dos/'
# path = '/home/jinho93/oxides/perobskite/lanthanum-aluminate/periodic_step/vasp/stengel/bulk/dos/'
vrun = Vasprun(path + 'vasprun.xml')
dsp = DosPlotter(zero_at_efermi=True)
dsp.add_dos_dict(vrun.complete_dos.get_element_spd_dos(Element.La))
dsp.show(xlim=(-10, 8))

# %%