Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projected bandstructure cannot mix colors #179

Open
bugaboo opened this issue Mar 12, 2025 · 3 comments
Open

Projected bandstructure cannot mix colors #179

bugaboo opened this issue Mar 12, 2025 · 3 comments

Comments

@bugaboo
Copy link

bugaboo commented Mar 12, 2025

If I understand the current implementation correctly, for any (k, E) point of the bandstructure the color will be determined solely by the highest projection component. For example, if a point is 0.31 s character and 0.30 p character, then it will be only red, but 0.30 s and 0.31 p point will be colored blue.

@lllangWV
Copy link
Member

lllangWV commented Mar 12, 2025

No, the projections are summed together. The sum of all projections should equal to 1 or close to it.

For instance if you do

pyprocar.bandsplot(... orbitals=[0,3])

This will sum the projection contribution from all atoms, spins, s orbitals, and the p_z orbitals.

if you do

pyprocar.bandsplot(... orbitals=[0,3], atoms=[0])

This will sum the projection contribution from the first atom, spins, s orbitals, and the p_z orbitals.

Does this answer your question or am I misunderstanding?

@bugaboo
Copy link
Author

bugaboo commented Mar 12, 2025

When I do bandsplot(... mode="overlay_orbitals"), the code plots s, p, d line segments separately without combining the colors, as far as I can tell. In the case when the d component is the largest, this would make the line segment purely green.
Also, the projections only add up to ~1 if the states are well described by l=0,1,2 orbitals centered on atoms.

@lllangWV
Copy link
Member

In the case when the d component is the largest, this would make the line segment purely green.

Yes, this is what happens

For overlay_orbitals we separate the weights by l orbitals s, p, d, f. Essentially, we are adding 4 totals band structures. We achieve the effect by scaling the color and linewidth by the weight and choosing a sequential colormap that increases the lightness value monotonically.

Here is a summary of the implementation in eps_plot:452-505

For SrVO3 weight has a length of 3 for s, p, d

for iweight, weight in enumerate(weights):
    ....
    for ispin in spins:
         ...
         for iband in range(self.ebs.nbands):
               segments = np.delete(segments, np.where(x[1:] == x[:-1])[0], axis=0)
                    lc = LineCollection(
                        segments,
                        cmap=plt.get_cmap(color_map[iweight]),
                        norm=norm,
                        alpha=self.config.opacity[ispin],
                    )
                    lc.set_array(weight[:, iband, ispin]) # scaling of the color happens here
                    lc.set_linewidth(weight[:, iband, ispin] * linewidth[ispin]) # Scaling of the linewidth happens here
                    handle = self.ax.add_collection(lc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants