class BSPlotterProjectedTest(unittest.TestCase): def setUp(self): with open(os.path.join(test_dir, "Cu2O_361_bandstructure.json"), "r", encoding="utf-8") as f: d = json.load(f) self.bs = BandStructureSymmLine.from_dict(d) self.plotter = BSPlotterProjected(self.bs) warnings.simplefilter("ignore") def tearDown(self): warnings.simplefilter("default") # Minimal baseline testing for get_plot. not a true test. Just checks that # it can actually execute. def test_methods(self): self.plotter.get_elt_projected_plots().close() self.plotter.get_elt_projected_plots_color().close() self.plotter.get_projected_plots_dots({ "Cu": ["d", "s"], "O": ["p"] }).close() self.plotter.get_projected_plots_dots_patom_pmorb( { "Cu": ["dxy", "s", "px"], "O": ["px", "py", "pz"] }, { "Cu": [3, 5], "O": [1] }, ).close()
class BSPlotterProjectedTest(unittest.TestCase): def setUp(self): with open(os.path.join(test_dir, "Cu2O_361_bandstructure.json"), "r", encoding='utf-8') as f: d = json.load(f) self.bs = BandStructureSymmLine.from_dict(d) self.plotter = BSPlotterProjected(self.bs) warnings.simplefilter("ignore") def tearDown(self): warnings.resetwarnings() # Minimal baseline testing for get_plot. not a true test. Just checks that # it can actually execute. def test_methods(self): self.plotter.get_elt_projected_plots().close() self.plotter.get_elt_projected_plots_color().close() self.plotter.get_projected_plots_dots({'Cu': ['d', 's'], 'O': ['p']}) self.plotter.get_projected_plots_dots_patom_pmorb( { 'Cu': ['dxy', 's', 'px'], 'O': ['px', 'py', 'pz'] }, { 'Cu': [3, 5], 'O': [1] })
class BSPlotterProjectedTest(unittest.TestCase): def setUp(self): with open(os.path.join(test_dir, "Cu2O_361_bandstructure.json"), "r", encoding='utf-8') as f: d = json.load(f) self.bs = BandStructureSymmLine.from_dict(d) self.plotter = BSPlotterProjected(self.bs) # Minimal baseline testing for get_plot. not a true test. Just checks that # it can actually execute. def test_methods(self): self.plotter.get_elt_projected_plots() self.plotter.get_elt_projected_plots_color() self.plotter.get_projected_plots_dots({'Cu': ['d', 's'], 'O': ['p']})
class BSPlotterProjectedTest(unittest.TestCase): def setUp(self): with open(os.path.join(test_dir, "Cu2O_361_bandstructure.json"), "r", encoding='utf-8') as f: d = json.load(f) self.bs = BandStructureSymmLine.from_dict(d) self.plotter = BSPlotterProjected(self.bs) # Minimal baseline testing for get_plot. not a true test. Just checks that # it can actually execute. def test_methods(self): self.plotter.get_elt_projected_plots() self.plotter.get_elt_projected_plots_color() self.plotter.get_projected_plots_dots({'Cu': ['d', 's'], 'O': ['p']})
def plot_elt_projected_bands(ylim=(-5, 5), fmt="pdf"): """ Plot separate band structures for each element where the size of the markers indicates the elemental character of the eigenvalue. Args: ylim (tuple): minimum and maximum energies for the plot's y-axis. fmt (str): matplotlib format style. Check the matplotlib docs for options. """ vasprun = Vasprun("vasprun.xml", parse_projected_eigen=True) bs = vasprun.get_band_structure("KPOINTS", line_mode=True) bspp = BSPlotterProjected(bs) bspp.get_elt_projected_plots(ylim=ylim).savefig("elt_projected_bands.{}".format(fmt)) plt.close()
def plot_elt_projected_bands(ylim=(-5, 5), fmt='pdf'): """ Plot separate band structures for each element where the size of the markers indicates the elemental character of the eigenvalue. Args: ylim (tuple): minimum and maximum energies for the plot's y-axis. fmt (str): matplotlib format style. Check the matplotlib docs for options. """ vasprun = Vasprun('vasprun.xml', parse_projected_eigen=True) bs = vasprun.get_band_structure('KPOINTS', line_mode=True) bspp = BSPlotterProjected(bs) bspp.get_elt_projected_plots(ylim=ylim).savefig( 'elt_projected_bands.{}'.format(fmt)) plt.close()
class BSPlotterProjectedTest(unittest.TestCase): def setUp(self): with open(os.path.join(test_dir, "Cu2O_361_bandstructure.json"), "r", encoding='utf-8') as f: d = json.load(f) self.bs = BandStructureSymmLine.from_dict(d) self.plotter = BSPlotterProjected(self.bs) warnings.simplefilter("ignore") def tearDown(self): warnings.resetwarnings() # Minimal baseline testing for get_plot. not a true test. Just checks that # it can actually execute. def test_methods(self): self.plotter.get_elt_projected_plots().close() self.plotter.get_elt_projected_plots_color().close() self.plotter.get_projected_plots_dots({'Cu': ['d', 's'], 'O': ['p']}) self.plotter.get_projected_plots_dots_patom_pmorb( {'Cu': ['dxy', 's', 'px'], 'O': ['px', 'py', 'pz']}, {'Cu': [3, 5], 'O': [1]} )
def plot_elt_projected_bands(ylim=(-5, 5), fmt='pdf'): """ Plot separate band structures for each element where the size of the markers indicates the elemental character of the eigenvalue. Args: ylim (tuple): minimum and maximum energies for the plot's y-axis. fmt (str): matplotlib format style. Check the matplotlib docs for options. """ vasprun = Vasprun('vasprun.xml', parse_projected_eigen=True) bs = vasprun.get_band_structure('KPOINTS', line_mode=True) bspp = BSPlotterProjected(bs) ax = bspp.get_elt_projected_plots(ylim=ylim).gcf().gca() ax.set_xticklabels([r'$\mathrm{%s}$' % t for t in ax.get_xticklabels()]) ax.set_yticklabels([r'$\mathrm{%s}$' % t for t in ax.get_yticklabels()]) if fmt == "None": return ax else: plt.savefig('elt_projected_bands.{}'.format(fmt)) plt.close()
#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) bsplotterprojected = BSPlotterProjected(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 bsdos = BSDOSPlotter( tick_fontsize=10, egrid_interval=20, legend_fontsize=28, dos_projection="orbitals", bs_legend=None, fig_size=(110, 85)) #bs_projection="HPbCIN",dos_projection="HPbCIN") #projected_plots_dots = bsplotterprojected.get_projected_plots_dots({'Pb':['s','p'],'I':['s','p']}) elements = bsplotterprojected.get_elt_projected_plots(vbm_cbm_marker=True) bds = bsdos.get_plot(bs, cdos) bsplotter.plot_brillouin()