shifted grids method for dipoles
Moderators: Davide Sangalli, andrea marini, Daniele Varsano, andrea.ferretti, myrta gruning, Conor Hogan

 Posts: 67
 Joined: Fri Dec 18, 2020 7:14 am
Re: shifted grids method for dipoles
Hi Davide,
Thanks for your suggestions. I figured out that it is not the q shift magnitude that matters as you mentioned. The problem is that by using SVD, under which the overlap matrix elements are in parallel transport gauge as in David Vanderbilt's book, the diagonal matrix elements are supposed to be near 1 and the offdiagonal ones are supposed to be close to 0! The ypp renormalization issue can be solved by commenting out the if clause.
Indeed, I'm more interested in the diagonal dipole matrix elements difference (A_cc  A_vv in the following fig). So with the shifted grid method implemented in Yambo, if we expand the u_nk+q to second order, we have The alpha and gamma can be obtained from a shifted grid run, while beta is calculated by another q shift. Note that I comment out the symmetrization procedure of the matrix elements and set the loops over valence and conduction bands to all the bands while calculating the overlap matrix elements. The problem is that while the A_vc is quite robust, the A_cc  A_vv is however very sensitive to the q shift. Are these due to the numerical accuracy of the wave functions? Btw, I'm using the double precision version of yambo and the conv_thr for QE calculations is set to 1.d13. Any comment is appreciated.
Best,
Xiaoming
Thanks for your suggestions. I figured out that it is not the q shift magnitude that matters as you mentioned. The problem is that by using SVD, under which the overlap matrix elements are in parallel transport gauge as in David Vanderbilt's book, the diagonal matrix elements are supposed to be near 1 and the offdiagonal ones are supposed to be close to 0! The ypp renormalization issue can be solved by commenting out the if clause.
Indeed, I'm more interested in the diagonal dipole matrix elements difference (A_cc  A_vv in the following fig). So with the shifted grid method implemented in Yambo, if we expand the u_nk+q to second order, we have The alpha and gamma can be obtained from a shifted grid run, while beta is calculated by another q shift. Note that I comment out the symmetrization procedure of the matrix elements and set the loops over valence and conduction bands to all the bands while calculating the overlap matrix elements. The problem is that while the A_vc is quite robust, the A_cc  A_vv is however very sensitive to the q shift. Are these due to the numerical accuracy of the wave functions? Btw, I'm using the double precision version of yambo and the conv_thr for QE calculations is set to 1.d13. Any comment is appreciated.
Best,
Xiaoming
You do not have the required permissions to view the files attached to this post.
Xiaoming Wang
The University of Toledo
The University of Toledo

 Posts: 67
 Joined: Fri Dec 18, 2020 7:14 am
Re: shifted grids method for dipoles
Maybe the shift q is too small. So I tried to increase q to 0.01. But the dipole calculation stopped with the following error.
Any idea?
Code: Select all
[ERROR] STOP signal received while in[04] Dipoles
[ERROR] Reading File shiftx/SAVE//ns.wf_fragments_1_1; Variable WF_COMPONENTS_@_SP_POL1_K1_BAND_GRP_1; NetCDF: Start+count exceeds dimension bound
Xiaoming Wang
The University of Toledo
The University of Toledo
 Davide Sangalli
 Posts: 418
 Joined: Tue May 29, 2012 4:49 pm
 Location: Via Salaria Km 29.3, CP 10, 00016, Monterotondo Stazione, Italy
 Contact:
Re: shifted grids method for dipoles
Dear Xiaoming Wang
For the renormalization I guess you mean these lines in ypp/kpoints/k_grids.F
and you directly set q0 = U_q_shifts(i1,:)
I think it was there since
 for q<1.E6 single precision error starts to give issues in the offdiagonal dipoles
 for q>1.E4 the distance between k and k+q starts to be too big to get a good approximation for the Taylor expansion
I would expect this range to be optimal also for what you need
Can it be that the number of bands differs between the two databases (shifted and nonshifted)?
Try to do to check if the size are the same.
Best,
D.
All makes sense to me.Thanks for your suggestions. I figured out that it is not the q shift magnitude that matters as you mentioned. The problem is that by using SVD, under which the overlap matrix elements are in parallel transport gauge as in David Vanderbilt's book, the diagonal matrix elements are supposed to be near 1 and the offdiagonal ones are supposed to be close to 0! The ypp renormalization issue can be solved by commenting out the if clause.
For the renormalization I guess you mean these lines in ypp/kpoints/k_grids.F
Code: Select all
if (v_norm(U_q_shifts(i1,:))>1.E4.or.v_norm(U_q_shifts(i1,:))<1.E6) then
q0 = U_q_shifts(i1,:)*1.E4/v_norm(U_q_shifts(i1,:))
call msg("s","Renormalizing shift to :",v_norm(q0))
else
q0 = U_q_shifts(i1,:)
endif
I think it was there since
 for q<1.E6 single precision error starts to give issues in the offdiagonal dipoles
 for q>1.E4 the distance between k and k+q starts to be too big to get a good approximation for the Taylor expansion
I would expect this range to be optimal also for what you need
I do not have specific comments. Double precision and conv_thr look good to me.Indeed, I'm more interested in the diagonal dipole matrix elements difference (A_cc  A_vv in the following fig). So with the shifted grid method implemented in Yambo, if we expand the u_nk+q to second order, we have
..
The alpha and gamma can be obtained from a shifted grid run, while beta is calculated by another q shift. Note that I comment out the symmetrization procedure of the matrix elements and set the loops over valence and conduction bands to all the bands while calculating the overlap matrix elements. The problem is that while the A_vc is quite robust, the A_cc  A_vv is however very sensitive to the q shift. Are these due to the numerical accuracy of the wave functions? Btw, I'm using the double precision version of yambo and the conv_thr for QE calculations is set to 1.d13. Any comment is appreciated.
Before loading the database of the shifted grids, the code checks that it has the same number of components.Maybe the shift q is too small. So I tried to increase q to 0.01. But the dipole calculation stopped with the following error.Any idea?Code: Select all
[ERROR] STOP signal received while in[04] Dipoles [ERROR] Reading File shiftx/SAVE//ns.wf_fragments_1_1; Variable WF_COMPONENTS_@_SP_POL1_K1_BAND_GRP_1; NetCDF: Start+count exceeds dimension bound
Can it be that the number of bands differs between the two databases (shifted and nonshifted)?
Try to do
Code: Select all
ncdump h SAVE/ns.wf_fragments_1_1
Best,
D.
Davide Sangalli, PhD
CNRISM, Division of Ultrafast Processes in Materials (FLASHit) and MaX Centre
https://sites.google.com/view/davidesangalli
http://www.maxcentre.eu/
CNRISM, Division of Ultrafast Processes in Materials (FLASHit) and MaX Centre
https://sites.google.com/view/davidesangalli
http://www.maxcentre.eu/

 Posts: 67
 Joined: Fri Dec 18, 2020 7:14 am
Re: shifted grids method for dipoles
Dear Davide,
Thanks for your detailed reply. For the last point, the two wave functions did have different components but same bands. However, I have already commented out the checking procedure in the subroutine. Indeed, For smaller q shift of 0.001, the two components are also different, but it works. I don't know why for the q shift of 0.01 it doesn't.
Best,
Xiaoming
Thanks for your detailed reply. For the last point, the two wave functions did have different components but same bands. However, I have already commented out the checking procedure in the subroutine. Indeed, For smaller q shift of 0.001, the two components are also different, but it works. I don't know why for the q shift of 0.01 it doesn't.
Best,
Xiaoming
Xiaoming Wang
The University of Toledo
The University of Toledo

 Posts: 67
 Joined: Fri Dec 18, 2020 7:14 am
Re: shifted grids method for dipoles
Btw, does the difference of the components matter? I mean which grid has larger components?
Best,
Xiaoming
Best,
Xiaoming
Xiaoming Wang
The University of Toledo
The University of Toledo
 Davide Sangalli
 Posts: 418
 Joined: Tue May 29, 2012 4:49 pm
 Location: Via Salaria Km 29.3, CP 10, 00016, Monterotondo Stazione, Italy
 Contact:
Re: shifted grids method for dipoles
The number of components is defined by the DFT code to respect k+G^2<=E_wf_cutoff.
Now shifting the kpoints by delta, it may happen that for some k_i, G_j for which k_i+G_j^2>E_wf_cutoff, G_j becomes allowed, i.e. k_i+delta+G_j^2<=E_wf_cutoff (or viceversa)
I would say it does not really matter, but you can eventually check that by playing with the cutoff.
D.
Now shifting the kpoints by delta, it may happen that for some k_i, G_j for which k_i+G_j^2>E_wf_cutoff, G_j becomes allowed, i.e. k_i+delta+G_j^2<=E_wf_cutoff (or viceversa)
I would say it does not really matter, but you can eventually check that by playing with the cutoff.
D.
Davide Sangalli, PhD
CNRISM, Division of Ultrafast Processes in Materials (FLASHit) and MaX Centre
https://sites.google.com/view/davidesangalli
http://www.maxcentre.eu/
CNRISM, Division of Ultrafast Processes in Materials (FLASHit) and MaX Centre
https://sites.google.com/view/davidesangalli
http://www.maxcentre.eu/

 Posts: 67
 Joined: Fri Dec 18, 2020 7:14 am
Re: shifted grids method for dipoles
Thanks Davide. I would expect to have different components for larger shifts anyway. The problem is that sometimes it works, for example,
but sometimes it does not.
So the error seems to point out that the components for shifted grid are larger than the unshifted one? If it is smaller, the problem would disappear?
Best,
Xiaoming
Code: Select all
<> loading info from shiftx
<> [WARNING] Shifted grid in folder "shiftx":change in number of WFs components
<> Grid 1 has shift vector : 0.100000E2 0.00000 0.00000 [c.c.]
<> loading info from shifty
<> [WARNING] Shifted grid in folder "shifty":change in number of WFs components
<> Grid 2 has shift vector : 0.0000 0.10000E02 0.44452E17 [c.c.]
<> loading info from shiftz
<> [WARNING] Shifted grid in folder "shiftz":change in number of WFs components
<> Grid 3 has shift vector : 0.00000 0.00000 0.100000E2 [c.c.]
<09s> Dipoles shifted grids ######################################## [100%] 08s(E) 08s(X)
<45s> Dipoles: P (T) ######################################## [100%] 35s(E) 35s(X)
<45s> [DIP] Writing dipoles header
<45s> [05] Optics
<45s> [LA] SERIAL linear algebra
<45s> [DIP] Checking dipoles header
<45s> [XCG] R(p) Tot o/o(of R): 712 7104 100
<45s> [X] Upper matrix triangle filled
<46s> Xo@q[1] ######################################## [100%] (E) (X)
<46s> [06] Timing Overview
<46s> [07] Memory Overview
<46s> [08] Game Over & Game summary
Code: Select all
<> [04] Dipoles
<> [DIP] Checking dipoles header
<> [WARNING] DIPOLES database not correct or missing
<> loading info from shiftx
<> [WARNING] Shifted grid in folder "shiftx":change in number of WFs components
<> Grid 1 has shift vector : 0.10000E01 0.25237E16 0.18354E16 [c.c.]
<> loading info from shifty
<> [WARNING] Shifted grid in folder "shifty":change in number of WFs components
<> Grid 2 has shift vector : 0.0000 0.10000E01 0.26767E16 [c.c.]
<> loading info from shiftz
<> [WARNING] Shifted grid in folder "shiftz":change in number of WFs components
<> Grid 3 has shift vector : 0.000000 0.000000 0.010000 [c.c.]
<> Dipoles shifted grids   [000%] (E) (X)
[ERROR] STOP signal received while in[04] Dipoles
[ERROR] Reading File shiftx/SAVE//ns.wf_fragments_1_1; Variable WF_COMPONENTS_@_SP_POL1_K1_BAND_GRP_1; NetCDF: Start+count exceeds dimension bound
Best,
Xiaoming
Xiaoming Wang
The University of Toledo
The University of Toledo