Top Page > Browsing Overlap matrix between different group of atoms Date: 2022/03/11 07:32 Name: Wei Li   Dear Developers,I know the analysis_example script can read the out file and print the Kohn-Sham Hamiltonian element and overlap matrix in atoms/orbitals.My question is if there is a way to get the overlap matrix between selected atom groups.Assume a system consists of A-B. Both A and B have many atoms. We are interested in coupling between A and B. Is there a way to obtain the overlap matrix (coupling) between A and B?thank you very much!Wei Page: Re: Overlap matrix between different group of atoms ( No.1 ) Date: 2022/03/16 12:02 Name: Naoya Yamaguchi Hi,You can get a copy of the input `dat` file named `temporal_12345.input` after calling a function of `read_scfout`, and you can find the global atom index through an array of `natn`. From the global atom index and copy of the input file, you can classify the local atom index into A or B.Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.2 ) Date: 2022/03/16 07:17 Name: Wei Li  Hi Naoya,thank you very much for your reply.along with this question, would you please point me how to obtain the Hamiltonian matrix of different atoms, as I understand the diagonal elements should be zero. However, I use analysis_example script for the examples of 5-atoms system (met.scfout), it gives the following:Kohn-Sham Hamiltonian spin=0global index=1 local index=0 (global=1, Rn=0)-0.6726552 0.0000000 -0.0000000 0.0000000 0.0000000 -0.3505570 -0.0000000 0.0000000-0.0000000 -0.0000000 -0.3505269 0.0000000 0.0000000 0.0000000 0.0000000 -0.3505570not sure here why diagonal element is nonzero?Also, it outputs the real and imaginary parts of the Hamiltonian elements separately? So this means the Kohn-Sham Hamiltonian elements should be a complex value? Or only real or imaginary part will be needed?It seems the Hamiltonian and overlap matrix is also defined in terms of neighboring atoms and orbitals. But I just want to obtain the Hamiltonian matrix between different global atoms, could you please point me how to do that? If there are N atoms in the system, we expect to obtain a NxN Hamiltonian matrix with diagonal element is zero. best regards,Wei  Re: Overlap matrix between different group of atoms ( No.3 ) Date: 2022/03/16 12:04 Name: Naoya Yamaguchi Dear Wei,>not sure here why diagonal element is nonzero?The diagonal element of `global index=1 local index=0 (global=1, Rn=0)` should not be zero because `local index=0` means the original atom itself, that is, the element corresponds to the part between the atom and itself.>Also, it outputs the real and imaginary parts of the Hamiltonian elements separately? So this means the Kohn-Sham Hamiltonian elements should be a complex value? Or only real or imaginary part will be needed?The matrix elements of the Hamiltonian is complex only in the case of non-collinear cases, and the imaginary part is stored in `iHks`.>It seems the Hamiltonian and overlap matrix is also defined in terms of neighboring atoms and orbitals. But I just want to obtain the Hamiltonian matrix between different global atoms, could you please point me how to do that?Please use eq. 28 of http://www.openmx-square.org/tech_notes/tech1-1_2.pdf .Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.4 ) Date: 2022/03/16 19:06 Name: Wei Li  Hi Naoya,1) `global index=1 local index=0 (global=1, Rn=0)` local index=0 means the Hamiltonian element between the atom and itself. Could you please show which one corresponds to Ham element between different atoms (atom i and )j? we also have the outputs like the following:global index=1 local index=1 (global=2, Rn=0)-0.4353767 0.2334197 0.1650568 0.00000002) the diagonal element should be nonzero between the atom and itself, then this means that the Hamiltonian element for the same atoms can be nonzero? As I understand the off-diagonal elements are for Hamiltonians between different atoms and should be nonzero.3) "Please use eq. 28 of http://www.openmx-square.org/tech_notes/tech1-1_2.pdf.", > Could you please show which part of the code should I dig into?Sorry for asking many questions, I appreciate your helps.Wei  Re: Overlap matrix between different group of atoms ( No.5 ) Date: 2022/03/16 21:20 Name: Naoya Yamaguchi Dear Wei,A1)>Could you please show which one corresponds to Ham element between different atoms (atom i and )j?The elements between different atoms have nonzero local indices.A2) Yes.A3) See a function `Hamiltonian_Band` in `polB.c`, for example.Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.6 ) Date: 2022/03/20 06:45 Name: Wei Li  Hi Naoya,I have just played with analysis_example.c code:using the original analysis_example.c, for H2, I got the following outputs in HS.dat file:Kohn-Sham Hamiltonian spin=0global index=1 local index=0 (global=1, Rn=0)-0.3463745global index=1 local index=1 (global=2, Rn=0)-0.3914094global index=2 local index=0 (global=2, Rn=0)-0.3463745global index=2 local index=1 (global=1, Rn=0)-0.3914094As we previously confirmed that local index=0 means the original atom itself.However, I would like to output the Ham in global atom index, e.g., the Ham element between every two actual atoms. I edited the code a little: for (spin=0; spin<=SpinP_switch; spin++){ printf("\n\nKohn-Sham Hamiltonian spin=%i\n",spin); for (ct_AN=1; ct_AN<=atomnum; ct_AN++){ TNO1 = Total_NumOrbs[ct_AN]; for (h_AN=0; h_AN<=FNAN[ct_AN]; h_AN++){ Gh_AN = natn[ct_AN][h_AN]; Rn = ncn[ct_AN][h_AN]; TNO2 = Total_NumOrbs[Gh_AN]; printf("%i %i ", ct_AN, Gh_AN) ; for (i=0; ifor Hks[spin][ct_AN][Gh_AN][i][j]), both ct_AN and Gh_AN are in global index now.`Hks` doesn't have the matrix elements of such a global Hamiltonian. It stores only local components. Even though you put `Gh_AN` to `Hks`, you can't get what you want. You need to take the sum of the appropriate local components of `Hks` to get the global ones. As I mentioned, you can learn it from `Hamiltonian_Band` in `polB.c` and start your coding from that.Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.8 ) Date: 2022/03/24 07:28 Name: Wei Li  Dear Naoya,sorry for still asking questions. Now I am able to print the KS Ham and overlap in both AO and atom. thanks so much for your helps.But still has a question, is it possible to print the wave function (or coefficients?) of each AO orbitals? We may also need that. I still need to look into polB.c code, right?I think it would help a lot if you could give me some hint or point me which variable is for wave function coefficients of AO.thank you very much.Wei  Re: Overlap matrix between different group of atoms ( No.9 ) Date: 2022/03/24 12:31 Name: Naoya Yamaguchi Dear Wei,It's possible, but the eigenvector itself is not stored, and you need to solve the eigenvalue problem.For your information, you can refer to https://gist.github.com/Ncmexp2717/d6bd0eef9d331d759c66edef46386933#file-polb-c-L1298-L1341Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.10 ) Date: 2022/03/27 08:33 Name: Wei Li  Dear Naoya,could you please show more clearly which section of polB.c should I dig into? I am afraid it is difficult for me to locate correctly the right position. want to get the wave function of each AO orbitals. in addition, for periodic system the output of analysis_example script has case that the two global index is identical while local index and Rn are different. So to get the Ham matrix in AO basis, one needs to sum over the matrix with varying local index while the first and last global index are identical, right?for example, global index=1 local index=0 (global=1, Rn=0)-0.6672001 -0.0000363 0.0000209 -0.0000141-0.0000363 -0.4382435 -0.0000407 -0.0000000 0.0000209 -0.0000407 -0.4382905 0.0000000-0.0000141 -0.0000000 0.0000000 -0.2148317global index=1 local index=1 (global=1, Rn=185)-0.0000065 -0.0000102 -0.0000177 0.0000000 0.0000102 0.0000121 0.0000281 -0.0000000 0.0000177 0.0000278 0.0000444 -0.0000000 0.0000000 0.0000000 0.0000000 -0.0000034the two blocks are for same C atom, each block matrix is in AO basis, C has 4 AOs, s1p1. we want to get one Ham matrix in AO basis for C, then simply sum the two blocks to get just one matrix, right? and need to sum more if there are more blocks with the two global index equal to 1 while local index and Rn are different.thank you very much.Wei  Re: Overlap matrix between different group of atoms ( No.11 ) Date: 2022/03/27 14:23 Name: Naoya Yamaguchi Dear Wei,>could you please show more clearly which section of polB.c should I dig into?So, I gave the URL to highlight the lines to solve the eigenvalue problem. The highlighted lines are the minimum ones for the purpose that use simple functions to get the Hamiltonian and overlap matrix and the LAPACK. Of course, you need to trace functions and variables from the highlighted part.>So to get the Ham matrix in AO basis, one needs to sum over the matrix with varying local index while the first and last global index are identical, right?Such a process is done in https://gist.github.com/Ncmexp2717/d6bd0eef9d331d759c66edef46386933#file-polb-c-L1559-L1646>we want to get one Ham matrix in AO basis for C, then simply sum the two blocks to get just one matrix, right?Only for the Γ-point, yes, but otherwise no because of eq. 28 of http://www.openmx-square.org/tech_notes/tech1-1_2.pdf . eq. 28 is considered in https://gist.github.com/Ncmexp2717/d6bd0eef9d331d759c66edef46386933#file-polb-c-L1559-L1646 .Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.12 ) Date: 2022/03/27 18:18 Name: Wei Li  Dear Naoya,I just realized the code block was highlighted in the url you sent me. the answers help me a lot. thank you very much. Have a nice day.Wei  Re: Overlap matrix between different group of atoms ( No.13 ) Date: 2022/03/28 07:13 Name: Wei Li  Dear Naoya,I have just add the matrix element with 1st and 2nd global index are identical, but local index and Rn are varying. Only gamma point is used.There are some cases that matrix element is negative or positive. For example, global index=4 local index=44 (global=4, Rn=194 -2 -1 0) 0.0000001 0.0000002 0.0000001 -0.0000923-0.0000003 -0.0000005 -0.0000003 0.0002123-0.0000002 -0.0000003 -0.0000002 0.0001226 0.0000923 0.0002121 0.0001225 0.0000002global index=4 local index=49 (global=4, Rn=293 -1 1 0) 0.0000001 0.0000002 -0.0000001 -0.0000923-0.0000003 -0.0000005 0.0000003 0.0002123 0.0000002 0.0000003 -0.0000002 -0.0001226 0.0000923 0.0002121 -0.0001225 0.0000002The matrix element H43 is 0.0001225 and -0.0001225 for top and bottom matrix, should we keep the sign when add the element of H43, or just take the sum of absolute value of H43?I think we may need to keep the sigh because of Eq 28, not sure if this is correct.PS. When I keep the sign, the diagonal elements of final overlap matrix in AO basis are not 1. thank you very much for your helps.Wei  Re: Overlap matrix between different group of atoms ( No.14 ) Date: 2022/03/28 17:07 Name: Naoya Yamaguchi Dear Wei,>The matrix element H43 is 0.0001225 and -0.0001225 for top and bottom matrix, should we keep the sign when add the element of H43, or just take the sum of absolute value of H43?You have to keep the signs.>PS. When I keep the sign, the diagonal elements of final overlap matrix in AO basis are not 1.As explained in p. 11 of the technical note, cSc=I.Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.15 ) Date: 2022/03/28 20:44 Name: Wei Li  Dear Naoya,Sorry for asking again, so is it reasonable the diagonal elements of overlap matrix is not 1?for example, the overlap matrix, global index=1 local index=0 (global=1, Rn=0), 0.9999997 -0.0000000 0.0000000 0.0000000 0.0000000 0.9999992 -0.0000000 0.0000000-0.0000000 -0.0000000 0.9999992 -0.0000000-0.0000000 0.0000000 0.0000000 0.9999992 which is a 4x4 matrix between atom1 and atom1, then I print all H11 elements when first and second global index are both 1:1.0000000.0000010.0002910.0000010.0002910.0796520.0796520.0002910.0000010.0796520.0796520.0000010.0002910.0796520.0796520.0002910.0000010.0002910.000001Clearly the sum of H11 is not 1, is this right? The reason why I asked this is because when I try to use the overlap matrix S and KS Ham matrix in AO to solve the eigenvalues, it fails. The diagonal elements are not 1 for overlap matrix after adding the matrix elements (i.e., H11) when first and second global index is identical. However, if I look into some molecular systems, i.e., gas molecule in a big box, then there is only one Rn when first and second global index are identical, And the diagonal elements are 1 for overlap matrix in AO basis.I used the overlap and KS Ham matrix to solve the eigenvalues, it is successful.Thank you very much.Wei  Re: Overlap matrix between different group of atoms ( No.16 ) Date: 2022/03/28 22:52 Name: Naoya Yamaguchi Dear Wei,>Sorry for asking again, so is it reasonable the diagonal elements of overlap matrix is not 1?I think it is reasonable.>The reason why I asked this is because when I try to use the overlap matrix S and KS Ham matrix in AO to solve the eigenvalues, it fails.The generalized eigenvalue problems can be solved through `scfout` files, and basically, the post-process codes do so.>And the diagonal elements are 1 for overlap matrix in AO basis.This is natural for the molecule case.Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.17 ) Date: 2022/03/28 23:11 Name: Wei Li  Dear Naoya,Sorry for bothering you again and again. It turns out that I made something wrong when I try diagonalizing the KS Ham matrix. Now I have fixed it. The eigenvalues are same as the KS orbital energies outputted by openmx So diagonal elements of overlap matrix are not 1 is reasonable. thank you.In order to obtain the Ham or overlap matrix in AO basis, previously you have pointed out we can sum over different local indexes when first and second global atom index are identical, but this only works at Gamma point.Is there a way we do something similar at point other than Gamma? Taking CH4 for example, the basis set, H s1, C s1p1 , the total number of AO is 8we want to get a 8x8 matrix of KS Ham and overlap. If kpoint is Gamma, this is simple we can simply add the matrix elements (i.e., H11) when first and second global index are identical. But how about at other k?thank you very muchWei  Re: Overlap matrix between different group of atoms ( No.18 ) Date: 2022/03/29 03:15 Name: Naoya Yamaguchi Dear Wei,For general k-points, you need to multiply e^(ikRn) as shown in eq. 28.The factor is evaluated by using `ncn` and `atv_ijk` in addition to the fractional coordinate of a k-point.You can find the corresponding source code lines in the highlighted part.Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.19 ) Date: 2022/03/29 05:55 Name: Wei Li  Dear Naoya1. For the last question, I think I may have misunderstood your points. Perhaps you mean if we did many-k calculations (larger than 1), then I cannot simply add the matrix elements with same global index, right? I does single-k calculation, either Gamma or k-point other than Gamma. So if we use single-k point, sum of matrix elements maybe ok? But question still arises if many-k points were used in calculations.I have went through the main workflow of polB.c code. But still not clear on the following points:2. The code ask user to input NK values: do { if (myid==Host_ID){ printf(" (e.g 2 4 3) "); scanf("%d %d %d",&Nk,&Nk,&Nk); }So how should one decide what values of Nk, Nk, Nk to use?3. The code ask user to input direction of polarization. So this depends on what we direction we want to look, right? Not sure if direction of polarization would change wave function, but probably not. printf("\n Specify the direction of polarization as reciprocal a-, b-, and c-vectors\n"); printf(" (e.g 0 0 1 ) ");4. I found Wk1 and Wk2 are 2D matrix (fsize3xfsize3) store the wave functions of AO for each spin. I edited the code and add a line to print how it looks like: if (i1==0){ for (spin=0; spin Dear Naoya,Thank you.1. The code block highlighted in the url you sent me for polB.c code shown S and KS Ham matrix elements were multiplied by e^(ikRn), according to Eq 28. Not sure if the functions have been called in the main program of openmx or if other places have done similar things. If not, then S and H matrix in HS.out are not multiplied by e^(ikRn)? Or one needs to call these functions properly to output the quantity we need. 2. I plan to script to call Overlap_k1k2 function, and to print Wk1 of each AO. but still has issue with Nk, Nk, Nk, perhaps the three variables equal to the kgrid set in input files. 3. By the way, just to confirm with you, for scf calculation using single k (e.g., obtain the eigenvalues, overlap, KS Ham at this kpoint), how to specify the fractional coordinate of k-point?One needs to use the setting like the following, right?#Gammascf.EigenvalueSolver Clusterscf.Kgrid 1 1 1MO.Nkpoint 1 #Kscf.EigenvalueSolver bandscf.Kgrid 1 1 1MO.Nkpoint 1 I used the two settings for bilayer graphene, sounds them give identical eigenvalues. Maybe there are something wrong in my settings.All the best,Wei  Re: Overlap matrix between different group of atoms ( No.22 ) Date: 2022/03/30 12:48 Name: Naoya Yamaguchi Dear Wei,A1. >Not sure if the functions have been called in the main program of openmx or if other places have done similar things.There are the same processes in `openmx` itself. All processes to solve the eigen value problem follow section 2 of the technical note.A2. `Overlap_k1k2` is a special function for calculating the Berry phases. Instead, you can use the following as I explained in No. 9.https://gist.github.com/Ncmexp2717/d6bd0eef9d331d759c66edef46386933#file-polb-c-L1298-L1341A3. A SCF calculation with a single k-point is appropriate when the k-point is the Γ-point.If you want to get eigenvalues anyway, you can use a band dispersion function explained in http://www.openmx-square.org/openmx_man3.9/node68.html .Band.dispersion onBand.Nkpath 2If you want to get molecular orbitals, you can use the MO function, but you need to allocate a reasonably large number of k-points for `scf.Kgrid`.Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.23 ) Date: 2022/05/03 17:19 Name: Dongyu Liu Dear all,I have a similar question when I try to reproduce the eigenvalues of energy at various k-points in a periodic system. Using the H and S matrices generated by the analysis_example code, I'm able to get the same E values as openmx output at the gamma point. Then I considered the phase factor as cos(k*Rn) to calculate the H and S matrices (there is no spin polarization and SOC in my case) at another k-point. However, with the newly generated matrices, I got different E values compared with the openmx output at the same k-point. I'm wondering if I missed some steps here or if this method can lead to some errors on E?Thanks so much，Dongyu  Re: Overlap matrix between different group of atoms ( No.24 ) Date: 2022/05/03 23:41 Name: Naoya Yamaguchi Dear Dongyu,>Then I considered the phase factor as cos(k*Rn) to calculate the H and S matrices (there is no spin polarization and SOC in my case) at another k-point.You could obtain the correct eigenvalues only at the Γ-point, and it might be caused by the phase factor of exp(i*k*Rn).You might resolve this issue to consider exp(i*k*Rn) instead of cos(k*Rn).Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.25 ) Date: 2022/05/04 17:17 Name: Dongyu Liu Dear Naoya,Thanks for your helpful reply. Sorry I ignored the imaginary part before. Now I can get the same energy eigenvalues with the openmx generated H, S, and C matrices. Besides, I find the energy matrix also has some non-zero off-diagonal elements. May I ask if it is because of the computational accuracy or some other issues? Thanks.Best regards,Dongyu  Re: Overlap matrix between different group of atoms ( No.26 ) Date: 2022/05/05 14:30 Name: Naoya Yamaguchi Dear Dongyu,>Besides, I find the energy matrix also has some non-zero off-diagonal elements.Because it is too ambiguous to answer, can you explain what "the energy matrix" mean? Is it the Hamiltonian matrix H?Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.27 ) Date: 2022/05/05 17:35 Name: Dongyu Liu Dear Naoya,Sorry for this ambiguous description. I construct the H and S matrices at an arbitrary k-point and let openmx output the LCAO coefficient matrix (C) at the same k-point. Then I calculate the K-S energy eigenvalue matrix (E) following this equation HC=CES. I find the real part of the diagonal elements in E is close to the K-S eigenvalue in the .out file and the relevant image part is nearly zero. But I also notice that the E matrix has some non-zero off-diagonal elements and some of them are at the 1e-2 magnitude in my case. I'm wondering if it's reasonable since the decimal of the coefficients is limited. Many thanks,Dongyu  Re: Overlap matrix between different group of atoms ( No.28 ) Date: 2022/05/05 19:22 Name: Naoya Yamaguchi Dear Dongyu,> I construct the H and S matrices at an arbitrary k-point and let openmx output the LCAO coefficient matrix (C) at the same k-point.>Then I calculate the K-S energy eigenvalue matrix (E) following this equation HC=CES.How did you get the C? Is your way http://www.openmx-square.org/openmx_man3.9/node92.html ?In the case, the following may be true.>I'm wondering if it's reasonable since the decimal of the coefficients is limited.In eq. (27) of http://www.openmx-square.org/tech_notes/tech1-1_2.pdf , the eigenvalue matrix E and the C are obtained by solving the generalized eigenvalue problem, and therefore, a constraint that the E is diagonal and the matrix elements are real is automatically considered.Regards,Naoya Yamaguchi  Re: Overlap matrix between different group of atoms ( No.29 ) Date: 2022/05/05 21:10 Name: Dongyu Liu Dear Naoya,Thanks for your reply.>How did you get the C? Is your way http://www.openmx-square.org/openmx_man3.9/node92.html ?Yes, I turn 'ON' the 'MO.fileout' option and specify the 'MO.kpoint' as the k-point that I'm working on. Then I collect the coefficients from the .out file. I will study the note you shared as well.Bset,Dongyu Page: 

 Thread Title (must) Move the thread to the top Your Name (must) E-Mail (must) hidden display URL Password (used in modification of the submitted text) Comment (must) Save Cookie