-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
mnt: changed index ordering of spin-charge quantities #516
Conversation
bc973e1
to
f3ea4b4
Compare
Codecov Report
@@ Coverage Diff @@
## main #516 +/- ##
==========================================
- Coverage 87.16% 87.08% -0.08%
==========================================
Files 353 353
Lines 45277 45407 +130
==========================================
+ Hits 39466 39543 +77
- Misses 5811 5864 +53
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Isn't it a bit weird for PDOS? Because if you calculate it in sisl you need to to the calculation separately per spin channel and therefore you'll get spin 0 and spin 1. Don't you think this will create inconsistencies? You could create a class for storing PDOS that would retain the information of what each data corresponds to, then you could have a method that converts from one to the other. A Also, with the current ordering, you have to implement checks for non polarized calculations. For example, every time you want to select: nonpol = PDOS.ndim == 2
if nonpol:
selected = PDOS[2, 3]
else:
selected = PDOS[2, :, 3] If the spin index was at the end or the beggining you could select in all cases with |
I think you are misreading? The PDOS have ordering While I agree that the non-polarized check is necessary (should we add a dimension of 1?) the others are as you suggest? Spin first... Or did I miss something? |
As for the polarized case, I have been wondering about some flag for |
Oh great, I didn't look at the ordering, I just went by your comment here:
So I thought in general you were doing something like |
Yes, this is actually the only case where I am not sure exactly what to do. Take a look at |
ok, moved it to the start ;) |
By the way, this will break the pdos plot and spin textured bands in |
Ok, thanks for the heads up, I think once @ahkole and @juijan confirms, this should just go in. |
This one feels more weird to me because in the result value of |
So would you rather have spin last? Always? |
Now I'm starting to doubt, because when |
I don't have a strong preference for either choice. One way to look at it is that values returned for [total, x, y, z] are separate quantities, in which case having the spin as the first dimension seems like a natural choice, which would also support If spin is not the last index, I would lean toward adding a dimension of size 1 in the unpolarized case, to always have the same number of dimensions. At the end of the day, there probably is no perfect solution, and there is also a case to be made for keeping the current order and not breaking existing scripts. A more consistent solution would always be to return arrays of the shape used in spin-orbit case and using zero as a fill value for spin (un)polarized case. In this way, a user wouldn't have to think about what the spin type of the calculation is. However, this seems like a waste of memory. |
Thanks for your comments! I can also see your points about different operators and thus always having it the first. This would make things much simpler, and easier to explain in documentation. So what would you say to that solution?
|
I'm in favor of |
I am beginning to think the |
This will also force the |
The latest commit should have fixed all remaining routines. I'll give this until next week, then I'll merge. @pfebrer you should get a ping once it is merged, then you can fix the viz stuff? |
It might be a bit weird in the beginning, but I think it might be better to have consistency across the code base. So while it might be a bit unnatural that the velocity has dimensions |
@pfebrer I have tried to see if I could understand how you did it in viz, I think I grasp some of it, but also lots I don't ;)
|
I wouldn't bother understanding the current framework, as it will work in a very different (hopefully simpler) way :) Here I would just do the changes so that current functionality is not broken, and any new functionality should be added to the new design. I have not changed anything in the Otherwise if you think the PR can be merged before the next release the changes can be done there. Apart from the changes that you did, I think that there should be changes to the handling of PDOS requests, because currently the |
Ok. :)
Agreed. Lets wait with tbtrans then, but a check for the dimensions of the changes I did would be great.
I plan on getting this PR in before releasing, basically all I need is this PR 🤞
Yes, this was where i was not sure how to do it, for instance the density plots still does up/down, whereas PDOS would now be total/z. And |
The PDOS file read returns now total/z, right? So to be consistent one would have to calculate total/z from the Hamiltonian and the WFSX file reads, no? |
Could there be a utility function to convert from one to the other (I know it's a simple operation but I think the code will look easier to understand if I call a function with an explicit name) |
yes, do PDOS for both spin, and convert to total/z |
I can not push to this branch, if you give me rights I can try to do the changes |
you can make a PR against this branch, that should be easier for now. I cannot make a single branch open, AFAIK, since this is my private repo it complicates things, I should have begun with an organisational repo... |
The PDOS file's |
thanks, fixed! |
Before the resulting charge arrays were not strictly the same order. Now we always have indices such as: states, spin, orbitals which means that spin is not the last index anymore. Furthermore for polarized calculations we will return spin dimension as: total, Sz to make it more compatible with the SOC cases. This will perhaps confuse users in the beginning (those who were used to the old ordering), but in the long run this should be easier to handle since users don't need to put in checks for polarized vs non-colinear calculations.
All routines has been reworked and ordered to have the Cartesian directions as the first dimension. This might be a bit weird at first, but the benefit is simpler internal code and a coherence between all routines. Specifically the PDOS was troublesome since it had varying dimensions and for polarized it was up/down, whereas now it is total/z. This will require end-users to accommodate, which is annoying, but needed. Also fixed bug in displacement calculation.
77d73d1
to
f823a45
Compare
@pfebrer now I get this error when running:
I tried to figure out where the 2nd array came from, but I can't seem to dig it out... |
I think my changes were gone when you rebased and force pushed (?) |
that is weird, I thought rebase should always do the merges as well.. Ok, I'll have a look |
But did you pull my changes locally? |
At least this is what I think I did! :( I will merge your 501-viz-fixes branch locally, and push it, you don't need to do anything. Thanks! |
Just don't delete your branch ;) |
Ok! |
I fixed this, cherry-picked your commit... Thanks! |
Before the resulting charge arrays were not strictly the same order. Now we always have indices such as:
states, spin, orbitals
which means that spin is not the last index anymore.
Furthermore for polarized calculations we will return spin dimension as:
total, Sz
to make it more compatible with the SOC cases.
This will perhaps confuse users in the beginning (those who were used to the old ordering), but in the long run this should be easier to handle since users don't need to put in checks for polarized vs non-colinear calculations.
This closes #501
CHANGELOG