zerothi / sisl

Electronic structure Python package for post analysis and large scale tight-binding DFT/NEGF calculations
https://zerothi.github.io/sisl
Mozilla Public License 2.0
181 stars 58 forks source link

Inquiry about Denchar equivalence in sisl #290

Open el-abed opened 3 years ago

el-abed commented 3 years ago

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

el-abed commented 3 years ago

I tried both denchar and sisl and got the following shape: image Which is why i asked the question before in the previous post. I will try again soon otherwise I will send the entire folder and hope we can get to the bottom of this

zerothi commented 3 years ago

Hello again, So I did specify that I want to plot the gamma using WaveFunckPoints block. But since we did 10 10 1 that means we will have more than one k point to worry about. My question is which one? It will be troublesome to plot them all using VESTA.

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 k-points in sisl (k=[0,0,0] ; k = [0.25, 0.2, 0]).

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! :)

el-abed commented 3 years ago

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]) File "", line 1 plot = sisl.get_sile("siesta.TSHS").plot.wavefunction(k=[0,0,0] ; k = [0.25, 0.2, 0]) ^ SyntaxError: invalid syntax

plot = sisl.get_sile("siesta.TSHS").plot.wavefunction(k=[0,0,0], k = [0.25, 0.2, 0]) File "", line 1 SyntaxError: keyword argument repeated plot = sisl.get_sile("siesta.TSHS").plot.wavefunction(k=[0,0,0]) The plot has been initialized correctly, but the current settings were not enough to generate the figure. (Error: wavefunction: Cannot create wavefunction since no atoms have an associated basis-orbital on a real-space grid)

el-abed commented 3 years ago

As for your suggestion using denchar the k points selected were empty files. Not sure what is going on

zerothi commented 3 years ago

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? I think it has to do with not reading from the fdf file. So you should change to:

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.

As for your suggestion using denchar the k points selected were empty files. Not sure what is going on

Could you attach your fdf files?

pfebrer commented 3 years ago

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 :)

el-abed commented 3 years ago

nick.zip Here is the entire folder. I am really not sure why nothing is working out ?

zerothi commented 3 years ago

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.

el-abed commented 3 years ago

1-Vesta is the only software i have for visualization. Any other suggestions? 2- Do you reckon it can be fixed?

zerothi commented 3 years ago

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...

el-abed commented 3 years ago

May I ask what the numbers 8 and 0 stand for though? Also I changed it and still the same result

zerothi commented 3 years ago

it is formatted like this: Z 0. x y z (Z atomic number), (x, y, z are coordinates).

However, you are not going to use it for anything, so it doesn't really matter. ;)

el-abed commented 3 years ago

lol fair enough! So what happens next? How can I help further?

zerothi commented 3 years ago

It would be nice to check that sisl can reproduce the same grids :) I.e. do the same with sisl as with denchar and check that they actually match :)

el-abed commented 3 years ago

I did get the same issue when i used the commands for sisl. So the errors did match

zerothi commented 3 years ago

could you share the code you used for sisl

el-abed commented 3 years ago

so using python3 import sisl import sisl.viz plot = sisl.get_sile("siesta.TSHS").plot.wavefunction(k=(0,0,0))

Then i tried sisl.get_sile("STRUCT5.fdf").plot.wavefunction(i=3,k=(0,0,0))

zerothi commented 3 years ago

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.

el-abed commented 3 years ago

Hello again, I really tried to understand the manual suggested last time and how to apply for example fat bands, PDOS, LDOS and band structure calculations using sisl to the systems, But I honestly am confused since the code seems to be applicable to only graphene. 1-I am not sure for example which Hamiltonian should i be using once I have done a SIESTA run. 2- If I have graphene/hbn or a perovskite and need to use sisl to find the band structure, is it feasible? 3- If i only want to use sisl to extract fatbands, PDOS, LDOS and so on, is it doable? Or do i have to use 1 core SIESTA job within sisl to get the Hamoltonian?

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

zerothi commented 3 years ago

No, the code is not applicable to only graphene. Please try and have a go and try and understand how they function together. 1) Don't you only have 1 Hamiltonian after a succesful Siesta run? 2) yes. 3) yes it is doable in sisl if you have the Hamiltonian.

I really want to improve the manual, so any suggestion is very much welcome!

el-abed commented 3 years ago

1- There is the HS, HSX, TSHS files which are related to Hamiltonian. To improve the manual, i really think a step by step procedure to be able to use sisl would be very helpful. How to find fatbands for example? What to do exactly after a siesta run? What commands are needed to get the run right from the first time? I do not see that in the link. I see a code but not sure how to use it. I really want to see this succeed. Hope that makes more sense.

zerothi commented 3 years ago

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?

el-abed commented 3 years ago

So the way i understood so far is that we open python and start with the following code: import os os.chdir('siesta_2') import numpy as np from sisl import * import matplotlib.pyplot as plt %matplotlib inline

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.

zerothi commented 3 years ago

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.

  1. The tutorial is based on the directory where I did the examples, if you know what chdir does, then this should be clear
  2. If you can read the Hamiltonian, then you are ready. Either file you read is fine, they both contain the same information.
  3. Please carefully go through the tutorial I linked and try and understand how you can change the lines to get different fat-bands. It is not clear to me whether you have issues understanding what a fatband plot is or what sisl does/can do. If you have the PDOS for all states + the bandstructure, then you can easily plot the fatbands...

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 ;) I really want to improve the tutorial, but I still don't know where you go wrong. From your questions it seems you at least lack some basic python knowledge.

el-abed commented 3 years ago

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?
2- My other comment is if I already have my Hamiltonian within certain K pts and energy range, do I still have to define K and E?

zerothi commented 3 years ago
  1. Yes, you could do that.
  2. TSHS and HSX contains the Hamiltonian at no specific k-point. You can generate the Hamlitonian for any k using that information.
el-abed commented 3 years ago

Thank you a lot for your help and sorry for taking away the DENCHAR post. But: 2- I do not understand. How can we extract the k pts and energy range we chose in our fdf file without defining them in the python code? Or should i just reintroduce E and K?

zerothi commented 3 years ago
  1. I think you are misunderstanding what the Hamiltonian contains and what the E and k means? Please consider what each of them mean in the context of analysing DOS, how are k and E related to the DOS and examine the importance of the sampling of these as well.
el-abed commented 3 years ago

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.

zerothi commented 3 years ago

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? However, in some cases it may be a lot easier to do convergence tests in sisl than in siesta since siesta requires a couple of SCF steps before analysis.