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
Inquiry about Denchar equivalence in sisl #290
Comments
Hey! While you wait for Nick's answer, which will have probably other ways to do it, I just want to let you know that a first version of the visualization module that I was developing has been already merged to sisl. For now, you can install it from github, as there has not been a release since then:
(where [viz] is to add the extra dependencies that only the visualization module uses). You can also of course just Then, you can use it to plot wavefunctions like this: import sisl
import sisl.viz
sisl.get_sile("file.fdf").plot.wavefunction(i=4, k=(0,0,0)) For this, you will need to have the hamiltonian (in any of its forms; HSX, TSHS, nc file) and the basis files of each atom (i.e. .ion or .ion.xml files). If you want to write the grid to a file, you can just store the plot in a variable, and find the grid under its plot = sisl.get_sile("file.fdf").plot.wavefunction(i=4, k=(0,0,0))
# The grid where the wf is stored can be found at plot.grid.
wfgrid = plot.grid
# Write it
wfgrid.write("wf4.cube") However, note that the visualization module is already very flexible on visualizing grids, so you can try to use the settings of the plot that can be tweaked. For example, you can quickly switch the visualization from 3d to 2d or 1d, toggle the geometry, apply some transforms.... # Check all the available settings
print(plot.settings)
# You can update the settings using update_settings
plot.update_settings(axes=[0,1], plot_geom=False, transforms=["square"]) You could also plot from the terminal:
But there is no direct way to store the grid to a file using this by now. Documentation for all the visualization module is already written and I hope it can be quite illustrative of all the options. For some reason it was failing when Nick tried to build it, but I was just going to look into it when I saw your issue :) Hope it helps! |
Thank you very much @pfebrer for the help. I am eager to test the new software. I successfully installed viz where i can see it clearly in my home directory. |
Great! Thanks for checking it out. I see that Nick commented out the CLI when he merged. That is because we are still not sure how the CLI should look like for plotting stuff. So basically, for now you would have to do it using python as I mentioned here: import sisl
import sisl.viz
sisl.get_sile("file.fdf").plot.wavefunction(i=4, k=(0,0,0)) Otherwise you could go to the place where sisl is installed and modify the file if __name__ == "__main__":
splot() then you could use
as a replacement for |
Thank you very much for the quick reply. The reason i am asking is because if i do not do that I will get a figure such as: |
For now you'll have to set the geometry before writing the file. Hadn't thought about this! wfgrid = plot.grid
wfgrid.geometry = sisl.Geometry.new("zeroPG.XV")
wfgrid.write("wf.cube") Sorry there isn't a faster way for now :) You can check what each setting means by getting the help of the plot that you just got. I.e.: help(plot) |
Sorry, there's a faster way: if you use the hamiltonian instead of the fdf file, it will use the last geometry of the siesta run I believe. That is: import sisl
import sisl.viz
plot = sisl.get_sile("file.TSHS").plot.wavefunction(i=4) # I'm using the TSHS, but it could be HSX or the nc hamiltonian
plot.grid.write("wf4.cube") If you want to set any other geometry then you'll have to do it as in the previous comment. Let me know if it works for you! |
@pfebrer thank you very much for the reply. The code did not show any error. However, the final result remained the same. Any reason why? 2- Concerning the last suggestion i got the following error when i used HSX file: Thank you and looking forward to your reply. |
Hmm, and when you do: sisl.Geometry.new("file.XV").plot() are the atoms inside the unit cell? |
Can you send me the files (fdf, H, .ion and XV) so that I can check? |
Here are the files(fdf, H, .ion and XV) |
Doing
Do you have the hamiltonian in some other form (.TSHS or .nc)? Because probably it was using a different one when it worked. |
Yes you will get that error because you need to use my fdf :) |
Yes, of course I used your fdf, sorry :) Hmm I don't know why I get this, maybe you can send the entire folder |
The hsx file implementation is not really good and may be buggy. I would heavily suggest you to use tshs or nc file format as @pfebrer suggests. But we don't know if you are using 4.1? |
Also indices in python are 0 based, so |
1- @pfebrer I should be more clear, when i used sisl.get_sile(""0.158_P_G.fdf"").plot.wavefunction(i=4, k=(0,0,0)) |
That's what I did, but for some reason I get the error.
TS.HS.Save true You can use it in regular siesta calculations.
No need to send it then :) You can try with the TSHS hamiltonian, should work. |
@zerothi @pfebrer Hello again! |
Could you send the full error message? I think I know what it is though. I forgot the .TSHS doesn't has the basis stored. So you actually have to pass a geometry with a basis: geometry = sisl.get_sile("file.fdf").read_geometry(output=True) # This will read it from your XV
plot = sisl.get_sile("158PG.TSHS").plot.wavefunction(i=4, k=(0,0,0), geometry=geometry) but I think it should be equivalent to the sisl.get_sile("file.fdf").plot.wavefunction(i=4, k=(0,0,0)) approach. Because it is actually using the XV file. At least this is how I meant it. It makes no sense to plot the wavefunction using the input structure 😅. So, if you see different results, then I will need to check what's wrong with the code. If not, are you sure the XV coordinates are inside the unit cell? When you do this: sisl.Geometry.new("file.XV").plot() do atoms show up inside the drawn unit cell? If not, what happens if you: plot = sisl.get_sile("file.fdf").plot.wavefunction(i=4, k=(0,0,0))
plot.geometry.plot().show()
# and
plot.H.geometry.plot().show() By the way, you are the first person that it's not me trying the |
The entire error is: Which i got the same when I used: 158PGtxtfile.txt |
Aah ok depending on where you are running you need to show the plot for it to display: sisl.Geometry.new("file.XV").plot().show() |
You can send me the .TSHS and I can try again :) |
158PGtshsfile.zip |
@el-abed have you seen these tutorials: They both create wavefunction outputs, but also real-space charges. This is what @pfebrer's backend does behind the scenes :) |
Oh! So I will have to start using Jupiter to be able to see what is going on more clearly. @zerothi Thank you! will have a look when I can. |
@zerothi I think the issue @el-abed is having might be because of some bug with the writing of the grid to a "cube" file. If I do: plot = sisl.get_sile("0.158_P_G.fdf").plot.wavefunction(i=50)
plot.show() which I don't know if makes sense -maybe there is some bug in plotting the wavefunction-. But the geometry is inside the unit cell (I don't do any modification to the coordinates, you can check at Now if I write the grid: plot.grid.write("wf.cube") it shows up in VESTA like this: |
Seeing the |
Yeah, the I would recommend 3 systems, and ideally both in a non-orthogonal and orthogonal configuration (so 6 systems, really ;))
Then start with trying to recreate the density from denchar and using sisl. import sisl
DM = sisl.get_sile("RUN.fdf").read_density_matrix()
grid = sisl.Grid(0.02, geometry=DM.geometry)
DM.density(grid)
grid.write("same_uc.cube")
# now compare with denchar orthogonal cell
grid = sisl.Grid(0.02, sc=[10, 10, 100])
DM.density(grid)
grid.write("sq_uc.cube") this should compare how sisl works for skewed and non-skewed unit-cells. :) Once this is cleared, then it will be easier to do the wavefunction (they are more or less the same with some details regarding phases etc.
Yeah, that would be the cause. Some viewers don't like this, but I really don't know vesta, could you try with vmd or xcrysden? |
Yep, tried to turn the negative value to positive and now the third axis is fine (ofc the modified one is not): I tried in vmd but I don't know how to see the volume data (it shows me nothing 😅). I read the cube specifications and it says this:
|
Yeah ok. So it is a general limitation. I am not surprised your geometry is now outside the unit-cell ;) You'll have to pass a grid with a supercell that is corrected in order to get the correct lattice vectors, perhaps just doing: sc = H.geometry.sc.copy()
sc.cell[1, :] *= -1
grid = Grid(0.02, sc=sc)
eigenstate.wavefunction(grid) or something similar, that should do things correctly. But still, the lowest plane seems off? |
Like I said, just take one or two points. It doesn't really matter which ones. Perhaps this: WaveFuncKPointsScale ReciprocalLatticeVectors
%block WaveFuncKPoints
0.000 0.000 0.000 1 3 5
0.25 0.2 0.0 1 3 5
%endblock WaveFuncKPoints then you could compare with the same When the grids have the same shape you can easily check by subtracting the two and finding the difference. For the skewed lattices it probably needs visual inspections. Thanks! :) |
then you could compare with the same k-points in sisl (k=[0,0,0] ; k = [0.25, 0.2, 0]). When i did that, the following errors were shown: plot = sisl.get_sile("siesta.TSHS").plot.wavefunction(k=[0,0,0] ; k = [0.25, 0.2, 0])
|
As for your suggestion using denchar the k points selected were empty files. Not sure what is going on |
Hmm... First, I would suggest you write the grid's to a cube file and use an external tool to visualize. But @pfebrer should know what goes wrong? plot = sisl.get_sile("RUN.fdf").plot.wavefunction(...) or something @pfebrer may correct me here. But again, if you follow this and store the grid to a cube file. Then you can plot it in vesta/xcrysden/vmd.
Could you attach your fdf files? |
Yes, you need to do it from the fdf as Nick said. But it's probably better to do first the "raw" version as Nick said as well :) |
nick.zip |
Which tool were you using for visualization? I can see that denchar does not write correct atomic coordinates and this is what's causing some incompatibilities. The simplest thing is to manually edit the cube files and change something like this: $> head *.cube
siesta.K2.WF.3.REAL.cube
siesta.K2.WF.3.REAL.cube
0 0.000000 0.000000 0.000000
50 0.192829 0.000000 0.000000
50 0.000000 0.192829 0.000000
50 0.000000 0.000000 0.385659
-0.10658E-01 -0.10681E-01 -0.10936E-01 -0.10378E-01 -0.83976E-02 -0.67459E-02
-0.58670E-02 -0.59373E-02 -0.71887E-02 -0.10049E-01 -0.15923E-01 -0.28054E-01 into this: $> head *.cube
siesta.K2.WF.3.REAL.cube
siesta.K2.WF.3.REAL.cube
1 0.000000 0.000000 0.000000
50 0.192829 0.000000 0.000000
50 0.000000 0.192829 0.000000
50 0.000000 0.000000 0.385659
8 0.0 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
-0.10658E-01 -0.10681E-01 -0.10936E-01 -0.10378E-01 -0.83976E-02 -0.67459E-02
-0.58670E-02 -0.59373E-02 -0.71887E-02 -0.10049E-01 -0.15923E-01 -0.28054E-01 note the change of the 0 to 1, and also an added line. This should make them readable with various plotters. I'll check with Siesta about this. |
1-Vesta is the only software i have for visualization. Any other suggestions? |
I think the same fix could be done for vesta, could you see whether it works by doing the above edits. I guess it wont be fixed in denchar anytime soon. I am not an expert in that code, so it is a bit problematic for me... |
May I ask what the numbers 8 and 0 stand for though? |
it is formatted like this: However, you are not going to use it for anything, so it doesn't really matter. ;) |
lol |
It would be nice to check that sisl can reproduce the same grids :) |
I did get the same issue when i used the commands for sisl. So the errors did match |
could you share the code you used for sisl |
so using python3 Then i tried |
Could you please try and use the tutorial I linked previously? I.e. this Be sure to save the grid. And also note that you should have the same number of grid-points to compare numerical quantities. |
Hello again, I really want to learn everything about sisl but i feel the manual needs more insight or more tutorials. Hope to hearing from you soon |
No, the code is not applicable to only graphene. Please try and have a go and try and understand how they function together.
I really want to improve the manual, so any suggestion is very much welcome! |
1- There is the HS, HSX, TSHS files which are related to Hamiltonian. |
But http://zerothi.github.io/sisl/tutorials/tutorial_siesta_2.html is really a step by step procedure. I don't know what else to do? What is it about that tutorial that is not clear? |
So the way i understood so far is that we open python and start with the following code: 1-For example where did siesta 2 come from? Why matplotlib is a comment? Even without comment it had an issue with inline 2- To be fair i was able to read the Hamiltonian. That was done but I was not sure was it reading from TSHS file or HSX? How many types do we have? 3-I want to focus on the band structure or PDOS example. After my siesta run is successful which had both PDOS and Band BLOCKS, I really did not understand how can I use my defined PDOS and Band structure blocks to get fat bands? I really want to help because I even asked my colleagues if I misunderstood it. Same reaction :( I hope you take this as a way we can make the tutorial better. |
The link is a jupyter notebook. I have to assume users are Python knowledgeable, I can't have everything in a tutorial. So if you are not familiar with python, and in this case jupyter notebooks, then this is the reason for your initial question.
Also, note that this original issue is not related at all with PDOS and fatbands. Denchar does an entirely different thing. Regarding your colleagues, what question did you ask them, if it was sisl specific and they have never used the tool, then how could they know ;) |
1- I think I understand the main issue and that is on me. If I collect all the bits and pieces in that page and put them into a python file like Papior.py Then use python Papior.py I will be able to get PDOS and band structure is that correct? |
|
Thank you a lot for your help and sorry for taking away the DENCHAR post. |
|
I guess my question is for large systems where we already introduced DOS and band blocks, why should we redefine them again in the python code? That is the only thing i do not understand. |
But if you already calculated it with siesta, then there is no point in doing it with sisl, it is just calculating the same thing again? |
**Good afternoon,
I recently asked about utilizing denchar for my calculations. Nick mentioned that it could be possible to do denchar calculations using sisl and I would like to test it to calculate the HOMO and LUMO of my systems. May I ask how can I properly use sgrid to find them? **
Version details
For example in denchar we can start by using
denchar -k 3 -w 4 file.fdf
which will plot only the wave-function with (original) index 4 of the third k-point in the (WFSX) file. How can we do the same with sisl? I assume it would be in sgrid in this case. How? Which nc file should I find? Thank you and looking forward to your thoughts
EL-abed
The text was updated successfully, but these errors were encountered: