Ejemplo n.º 1
0
class FeffLdosTest(unittest.TestCase):
    filepath1 = os.path.join(test_dir, "feff.inp")
    filepath2 = os.path.join(test_dir, "ldos")
    l = LDos.from_file(filepath1, filepath2)

    reci_feffinp = os.path.join(test_dir_reci, "feff.inp")
    reci_ldos = os.path.join(test_dir_reci, "ldos")
    reci_dos = LDos.from_file(reci_feffinp, reci_ldos)

    def test_init(self):
        efermi = FeffLdosTest.l.complete_dos.efermi
        self.assertEqual(
            efermi, -11.430, "Did not read correct Fermi energy from ldos file"
        )

    def test_complete_dos(self):
        complete_dos = FeffLdosTest.l.complete_dos
        self.assertEqual(
            complete_dos.as_dict()["spd_dos"]["s"]["efermi"],
            -11.430,
            "Failed to construct complete_dos dict properly",
        )

    def test_as_dict_and_from_dict(self):
        l2 = FeffLdosTest.l.charge_transfer_to_string()
        d = FeffLdosTest.l.as_dict()
        l3 = LDos.from_dict(d).charge_transfer_to_string()
        self.assertEqual(l2, l3, "Feffldos to and from dict does not match")

    def test_reci_init(self):
        efermi = FeffLdosTest.reci_dos.complete_dos.efermi
        self.assertEqual(
            efermi, -9.672, "Did not read correct Fermi energy from ldos file"
        )

    def test_reci_complete_dos(self):
        complete_dos = FeffLdosTest.reci_dos.complete_dos
        self.assertEqual(
            complete_dos.as_dict()["spd_dos"]["s"]["efermi"],
            -9.672,
            "Failed to construct complete_dos dict properly",
        )

    def test_reci_charge(self):
        charge_trans = FeffLdosTest.reci_dos.charge_transfer
        self.assertEqual(charge_trans["0"]["Na"]["s"], 0.241)
        self.assertEqual(charge_trans["1"]["O"]["tot"], -0.594)
Ejemplo n.º 2
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.º 3
0
class FeffLdosTest(unittest.TestCase):

    filepath1 = os.path.join(test_dir, 'feff.inp')
    filepath2 = os.path.join(test_dir, 'ldos')
    l = LDos.from_file(filepath1, filepath2)

    def test_init(self):
        efermi = FeffLdosTest.l.complete_dos.efermi
        self.assertEqual(efermi, -11.430,
                         "Did not read correct Fermi energy from ldos file")

    def test_complete_dos(self):
        complete_dos = FeffLdosTest.l.complete_dos
        self.assertEqual(complete_dos.as_dict()['spd_dos']["s"]['efermi'],
                         -11.430,
                         "Failed to construct complete_dos dict properly")

    def test_as_dict_and_from_dict(self):
        l2 = FeffLdosTest.l.charge_transfer_to_string()
        d = FeffLdosTest.l.as_dict()
        l3 = LDos.from_dict(d).charge_transfer_to_string()
        self.assertEqual(l2, l3, "Feffldos to and from dict does not match")
Ejemplo n.º 4
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.º 5
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.º 6
0
 def test_as_dict_and_from_dict(self):
     l2 = FeffLdosTest.l.charge_transfer_to_string()
     d = FeffLdosTest.l.as_dict()
     l3 = LDos.from_dict(d).charge_transfer_to_string()
     self.assertEqual(l2, l3, "Feffldos to and from dict does not match")
Ejemplo n.º 7
0
 def test_as_dict_and_from_dict(self):
     l2 = FeffLdosTest.l.charge_transfer_to_string()
     d = FeffLdosTest.l.as_dict()
     l3 = LDos.from_dict(d).charge_transfer_to_string()
     self.assertEqual(l2, l3, "Feffldos to and from dict does not match")
Ejemplo n.º 8
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()