Ejemplo n.º 1
0
    def plot_cohps_of_neighbors(
        self,
        path_to_COHPCAR="COHPCAR.lobster",
        isites=[],
        onlycation_isites=True,
        only_bonds_to=None,
        per_bond=False,
        summed_spin_channels=False,
        xlim=None,
        ylim=[-10, 6],
        integrated=False,
    ):

        """
        will plot summed cohps (please be careful in the spin polarized case (plots might overlap (exactly!))
        Args:
            isites: list of site ids, if isite==[], all isites will be used to add the icohps of the neighbors
            onlycation_isites: bool, will only use cations, if isite==[]
            only_bonds_to: list of str, only anions in this list will be considered
            per_bond: bool, will lead to a normalization of the plotted COHP per number of bond if True,
            otherwise the sum
            will be plotted
            xlim: list of float, limits of x values
            ylim: list of float, limits of y values
            integrated: bool, if true will show integrated cohp instead of cohp

        Returns:
            plt of the cohps

        """

        # include COHPPlotter and plot a sum of these COHPs
        # might include option to add Spin channels
        # implement only_bonds_to
        cp = CohpPlotter()

        plotlabel, summed_cohp = self.get_info_cohps_to_neighbors(
            path_to_COHPCAR,
            isites,
            only_bonds_to,
            onlycation_isites,
            per_bond,
            summed_spin_channels=summed_spin_channels,
        )

        cp.add_cohp(plotlabel, summed_cohp)
        plot = cp.get_plot(integrated=integrated)
        if xlim is not None:
            plot.xlim(xlim)

        if ylim is not None:
            plot.ylim(ylim)

        return plot
Ejemplo n.º 2
0
    # make COHPs directory
    try:
        if not (os.path.isdir('COHPs')):
            os.makedirs(os.path.join('COHPs'))
    except OSError as e:
        if e.errno != errno.EEXIST:
            print("WARNING: COHPs directory already exists")
            raise

    for idx in idx_list:
        species1 = completecohp.bonds[idx]['sites'][0]
        species2 = completecohp.bonds[idx]['sites'][1]
        plotlabel = str(species1.species_string) + '-' + str(
            species2.species_string)

        cp.add_cohp(plotlabel, completecohp.get_cohp_by_label(label=idx))

        # check which COHP you are plotting
        print("This is a COHP between the following sites: " + str(species1) +
              ' and' + str(species2))

        cohpplot = cp.get_plot(integrated=False)
        cohpplot.ylim([-10, 6])
        cohpplot.savefig(
            'COHPs/cohp_no_%s_%s-%s.pdf' %
            (idx, species1.species_string, species2.species_string))

else:
    print('lobster files are not found !!')
Ejemplo n.º 3
0
 def get_cohp(self, xlim=[-4, 4], ylim=[-10, 6]):
     cohp = CompleteCohp.from_file('LOBSTER', filename=os.path.join(self.path, "COHPCAR.lobster"),
                                   structure_file=os.path.join(self.path, "CONTCAR"))
     plotter = CohpPlotter()
     plotter.add_cohp(self.name, cohp)
     plotter.save_plot(f'{self.path}.png', xlim=xlim, ylim=ylim, img_format='png')