SCDM-k bug with different pseudopotentials?

Hello!

I was very interested in getting SCDM-k working while using EPW. However, there seems to be an issue that pops up with using different kinds of pseudopotentials that I wasn’t able to find documented anywhere.

If I run the test-suite epw_scdm case (on Silicon) without changing anything, it all works, epw1-epw3. Good so far.

However, performing a minimal change of the pseudopotential (for the SCF and NSCF calculations)
from the ‘q-e/pseudo/Si_r.upf’ to either Si.pbe-nl-kjpaw_psl.1.0.0.UPF or Si.pbe-n-rrkjus_psl.1.0.0.UPF pseudopotentials

seems to produce a crash when running epw2.in and epw3.in (both of the SCDM examples) with the following output:
from allocate_bec_type : error # 5014
cannot allocate bec%k

Now, the test-suite example only has a 3x3x3 k-point mesh with 12 bands, so I don’t expect that bec%k is too large to be allocated. To be clear, when I used a different pseudopotential, I made sure to redo the scf, nscf, and phonon calculations with the new pseudopotential.

So does the SCDM-k method work only with certain pseudopotentials? The above other pseudopotentials I tried are from the PSLibrary, both a PAW and USPP failed. If so, what pseudopotentials are usable with EPW? I ask because I’m working with lanthanide compounds, and so have a limited set of pseudopotentials that are both accurate and converge well.

Dear adenchfi:

Personally, I would suggest you to use norm-conserving pseudopotentials (PPs) for the SCDM method even though officially the paper (https://arxiv.org/abs/1909.00433) mentions no restriction in choice of PPs (See Appendix A in this paper).

Well, could you confirm that you are using the most-recent version of EPW downloaded at https://gitlab.com/QEF/q-e so that I can reproduce your problem and check the code?

Meanwhile, I would suggest you to try to get Wannier functions using Wannier90 (W90) >=v3.0. Now you need to check whether the SCDM method works in your case by changing a few parameters and rerunning the Wannierization, and for this purpose, it is more convenient to start with W90.
If it works, you can just use the same relevant inputs in the input of EPW.

PS) As I already mentioned it my previous post, you had better get Wannier functions using the SCDM method for the smallest “isolated” band manifold including your reduced one. Otherwise, you might encounter problems with the Fermi energy since it is possible that nbndskip is not constant.

Sincerely,

H. Lee

Dear adenchfi:

I reproduced your problem and found a minor bug in the subroutine of compute_mmn_para() in EPW/src/pw2wan2epw.f90 ; this error is due to the double allocation of bec%k.

The temporary fix is as follows:

(1) Find the part below in the subroutine of compute_mmn_para()

    !                                                                                                                                                                                                       
    !   USPP                                                                                                                                                                                                
    !                                                                                                                                                                                                       
    IF (any_uspp) THEN
      CALL allocate_bec_type(nkb, nbnd, becp)
      IF (noncolin) THEN
        ALLOCATE(becp2_nc(nkb, 2, nbnd), STAT = ierr)
        IF (ierr /= 0) CALL errore('compute_mmn_para', 'Error allocating becp2_nc', 1)
      ELSE
        ALLOCATE(becp2(nkb, nbnd), STAT = ierr)
        IF (ierr /= 0) CALL errore('compute_mmn_para', 'Error allocating becp2', 1)
      ENDIF

(2) Before the line including

CALL allocate_bec_type(nkb, nbnd, becp)

, insert the following line:

CALL deallocate_bec_type(becp)

PS) You should consider some cautions in use of the SCDM method I mentioned in my post above.

Sincerely,

H. Lee

Hello H. Lee,

Thank you for your reply! I would have replied sooner, but the “Notify me when a reply is posted” feature seemed to not send me an email. I’ll have to double-check my information.

I have been working on finding or generating norm-conserving (NC) pseudopotentials the past couple days using atomic/ld1.x exactly because of your recommendation, and let me tell you, for some rare-earth elements (in my case La, Ce, through Dy) it is very difficult and doesn’t seem to be very transferable! Regardless, I will be trying to do that.

I had just cloned q-e from the GitHub (not GitLab, but I assumed they were synced), so I assumed I was using the latest. However, I see the GitLab version is more up-to-date; I will compile that version now!

And yes, I will try it with the smallest isolated band subspace for my particular problem. Thanks for your help!

Dear adenchfi:

I have been working on finding or generating norm-conserving (NC) pseudopotentials the past couple days using atomic/ld1.x exactly because of your recommendation, and let me tell you, for some rare-earth elements (in my case La, Ce, through Dy) it is very difficult and doesn’t seem to be very transferable! Regardless, I will be trying to do that.

You are right. La is ok, but regarding Ce through Dy it is VERY difficult to construct a transferrable norm-conserving pseudopotentials (NCPPs). If you succeed in it, you should provide in the supplementary section of your future paper your inputs to ld1.x so that you can get credit for your rare-earth NCPPs.
To the best of my knowledge, there is no PPs for Ce through Dy in pseudo-dojo (http://www.pseudo-dojo.org/), pslibrary (https://dalcorso.github.io/pslibrary/), and gbrv (https://www.physics.rutgers.edu/gbrv/).

Even if you succeed in constructing PPs, you might need the Hubbard U correction. In this case, there is no problem with scf, phonon, and Wannier90 (W90), but EPW is currently incompatible with DFT+U (you need some modification).

In any case, you need good reference PPs; although I didn’t check, you can try “Rare Earth PAW datasets” (http://www.mineralscloud.com/resources/repaw/index.shtml I don’t know the reason, but this page is currently inaccessible)

I had just cloned q-e from the GitHub (not GitLab, but I assumed they were synced), so I assumed I was using the latest. However, I see the GitLab version is more up-to-date; I will compile that version now!

The most-recent development version of EPW is available in GitLab (https://gitlab.com/QEF/q-e).
However, before using EPW I would suggest you to check whether phonon calculation and Wannierization with the SCDM method work with PAWs mentioned above.
EPW heavily relies on the results from phonon (ph.x) and W90. Therefore, if you can’t obtain the reasonable results from ph.x and W90, it makes no sense to use EPW.

Sincerely,

H. Lee

Hello H. Lee,

In particular I’m studying the RTe_3 compounds, where R is a lanthanide. Chemical intuition tells me Te likes to fill its valence, and so the R will contribute some electrons, and act as if it’s ionized. Therefore, I’m trying the R_3+ pseudopotentials on pseudo_dojo (designed for when the lanthanide is highly ionized) right now. My inputs with ld1.x so far have produced pseudopotentials that aren’t quite right, but I may keep experimenting!

The PAW pseudopotentials for my system correctly work for the relax/scf/phonon/EPW calculations (this is what I’ve been doing the past few months), and after adding your bug fix, I tested the SCDM-k Silicon example with PAW pseudopotentials, which works now!

So I expect either way that I’ll be good (either with the above NC_pseudos or using the bugfix which now allows US/PAWs with the SCDM-k).

Thanks again!

Dear adenchfi:

Good to know that your calculations work. Well, currently the QR factorization with column pivoting, an essential part of the SCDM method, is not parallelized both in Wannier90 and EPW; thus, for large configurations, this step could be slow.

Lastly, as you probably know, the bug in the SCDM method with PAW or USPP was fixed in the most-recent development version of EPW:
https://gitlab.com/QEF/q-e/-/merge_requests/928

I fixed the bug slightly different from the temporal fix I mentioned in this thread.

Sincerely,

H. Lee

Hi H. Lee,

Is the slow part you mentioned in this part of pw2wan2epw.f90?

! vv: Compute unk’s on a real grid (the fft grid)
!
psic(:slight_smile: = czero
psic(dffts%nl(igk_k(1:npw, ik))) = evc(1:npw, ibnd)
CALL invfft(‘Wave’, psic, dffts)
!
! vv: Build Psi_k = Unk * focc at G-point only
pnorm = REAL(SUM(psic(1:nrtot) * CONJG(psic(1:nrtot))), KIND = DP)
norm_psi = DSQRT(pnorm)
psi_gamma(1:nrtot, ibnd1) = (psic(1:nrtot) / norm_psi) * f_gamma

because that’s where my system seems to be taking awhile (in fact it hasn’t gotten past it yet). I’ve tried excluding bands by telling Wannier to exclude bands (since specifying the energy window doesn’t seem to modify the excluded_bands boolean which SCDM-k checks), but I’m not sure it’s working. I have 71 bands and am excluding the first 50, so I’d figure it could handle 21 bands.

Yes, I saw you had merged your changes in there, so I seem to have added your temporary fix in addition to your merged changes. I’ll have to undo that!

Dear adenchfi:

Is the slow part you mentioned in this part of pw2wan2epw.f90?

The part you mentioned could be slow, but the main bottleneck is below:

      IF (noncolin) THEN
        CALL ZGEQP3(numbands, 2 * nrtot, TRANSPOSE(CONJG(psi_gamma)), numbands, &
                    piv, qr_tau, cwork, lcwork, rwork, info)
      ELSE
        CALL ZGEQP3(numbands, nrtot, TRANSPOSE(CONJG(psi_gamma)), numbands, &
                    piv, qr_tau, cwork, lcwork, rwork, info)
      ENDIF

psi_gamma is a matrix with the dimension of numbands by 2 * nrtot, where nrtot is the number of grids in the soft FFT grid.
This matrix operation is done only on the meta_ionode (=0).

If I remember correctly, numbands is the number of Wannier functions when scdm_entanglement = ‘isolated’; otherwise, it is the total number of bands minus the excluded bands.

I have 71 bands and am excluding the first 50, so I’d figure it could handle 21 bands.

If you want to exclude the bands from 1 to 50 in the development version of EPW, you should add to the input of EPW the following:

bands_skipped = 'exclude_bands = 1-50'

You had better check the *.wout file in your working directory so that all parameters related to Wannierization is fine.

PS) I would like to mention again the following:

Meanwhile, I would suggest you to try to get Wannier functions using Wannier90 (W90) >=v3.0. Now you need to check whether the SCDM method works in your case by changing a few parameters and rerunning the Wannierization, and for this purpose, it is more convenient to start with W90.
If it works, you can just use the same relevant inputs in the input of EPW.

Sincerely,

H. Lee

Hi H. Lee,

If you want to exclude the bands from 1 to 50 in the development version of EPW, you should add to the input of EPW the following:

Yes, I figured that out by looking in the code. It’s good to get confirmation!

PS) I would like to mention again the following:

I assume this is because the SCDM-k is working and parallelized in Wannier90 already. I’ll likely take this suggestion next, despite the extra steps in getting WFs via W90 first via manually.

The part you mentioned could be slow, but the main bottleneck is below:

They both involve nrtot, so I suppose with the default FFT grid (160x160x54, according to my epw.out) it must really be bottlenecking at those spots. What must be happening is that the one node’s worth of memory isn’t handling it, because it’s been a couple hours and it hasn’t even looped through the first band when performing the

         
         psic(:) = czero
          psic(dffts%nl(igk_k(1:npw, ik))) = evc(1:npw, ibnd)
          CALL invfft('Wave', psic, dffts)

lines, e.g. the above hasn’t completed once, since my print statement before the above line executes, but not the one after.

Anyway, it sounds like the SCDM-k implementation is more complete on the purely W90 side, so I’ll work on generating the WFs via W90 before using them in EPW. Is there documentation for having EPW use WFs generated by W90 first, as you are suggesting?

Dear adenchfi:

I assume this is because the SCDM-k is working and parallelized in Wannier90 already. I’ll likely take this suggestion next, despite the extra steps in getting WFs via W90 first via manually.

No, the essential part of the SCDM method is not parallelized even in Wannier90 (W90).
The generation of Amn matrix using the SCDM is done in pw2wannier90.f90 in PP/src.
Below is the excerpt from pw2wannier.f90.

      CALL invfft ('Wave', psic, dffts)
#if defined(__MPI)
      CALL gather_grid(dffts,psic,psic_all)
      ! vv: Gamma only
      ! vv: Build Psi_k = Unk * focc
      norm_psi = sqrt(real(sum(psic_all(1:nrtot)*conjg(psic_all(1:nrtot))),kind=DP))
      psic_all(1:nrtot) = psic_all(1:nrtot)/ norm_psi
      psi_gamma(1:nrtot,locibnd) = psic_all(1:nrtot)
      psi_gamma(1:nrtot,locibnd) = psi_gamma(1:nrtot,locibnd) * f_gamma
#else
      norm_psi = sqrt(real(sum(psic(1:nrtot)*conjg(psic(1:nrtot))),kind=DP))
      psic(1:nrtot) = psic(1:nrtot)/ norm_psi
      psi_gamma(1:nrtot,locibnd) = psic(1:nrtot)
      psi_gamma(1:nrtot,locibnd) = psi_gamma(1:nrtot,locibnd) * f_gamma
#endif
...
#if defined(__MPI)
   IF(ionode) THEN
      CALL ZGEQP3(numbands,nrtot,TRANSPOSE(CONJG(psi_gamma)),numbands,piv,qr_tau,cwork,lcwork,rwork,info)
      IF(info/=0) call errore('compute_amn','Error in computing the QR factorization',1)
   ENDIF
   CALL mp_bcast(piv,ionode_id,world_comm)
#else
   ! vv: Perform QR factorization with pivoting on Psi_Gamma
   CALL ZGEQP3(numbands,nrtot,TRANSPOSE(CONJG(psi_gamma)),numbands,piv,qr_tau,cwork,lcwork,rwork,info)
   IF(info/=0) call errore('compute_amn','Error in computing the QR factorization',1)
#endif

As you can see, the main difference between pw2wannier90 and EPW is that in pw2wannier90 plane waves (FFT grids) are distributed, leading to the parallelization of the inverse Fourier transfrom (invFFT), but in EPW invFFT is not parallelized since plane waves (FFT grids) are not distributed.

Regarding other parts, both pw2wannier90 and EPW are the same; that is, the QR factorization is only done on the ionode and after gather_grid, the operation on psi_gamma is done only on the first processor of the FFT communicator, dfft%root.

The reason why I suggest you to start with W90 is that construction of Wannier functions is basically done by a trial-and-error approach; you need to vary some parameters and rerun Wannierization until you get good Wannier functions. For this purpose, (in my opinion) I think that it is more convenient to use W90.

After finding the good parameters and getting good Wannier functions, you have to return to EPW and construct Wannier functions in EPW using the same parameters you found in the test run of W90.

Anyway, it sounds like the SCDM-k implementation is more complete on the purely W90 side, so I’ll work on generating the WFs via W90 before using them in EPW. Is there documentation for having EPW use WFs generated by W90 first, as you are suggesting?

I didn’t implement the part of SCDM-k in EPW, but I don’t think that the SCDM-k implementation is more complete on the purely W90 side; I think that they are the same. More importantly, currently there is no way to use Wannier functions obtained from W90 in EPW. As I mentioned above, with the parameters you found in the test run of W90, you have to rerun Wannierization in EPW.

Sincerely,

H. Lee

Hi,

Just to add to Hyungjun email. SCDM-k implementation in EPW and pw2wannier.f90 subroutines should be the same unless some modifications were done in the pw2wannier.f90 implementation sometime after the release of QE 6.5 in November 2019.

Best,
Roxana

Alright, thanks! I’ll be tinkering.

Hello,

As a comment, the SCDM-k using pw2wannier90 seems to be working just fine for me with my larger RTe3 system; when I tried doing it with purely EPW, constructing Amn never seemed to complete. (Doing it through EPW with smaller systems like Si still works fine though)

It could be what you said H. Lee about the distribution of the FFT grids, but I tried decreasing the size of the FFT grid for my system by lowering scf/nscf cutoff energies, and it didn’t seem to help. Maybe I didn’t decrease it enough.

Still, your advice about switching over to directly using pw2wannier90 and wannier90 was good, so thank you! Now I just need to develop my Wannier90 skills, haha.

Dear adenchfi:

Thank you for the feedback. It might be helpful for me to give the more clear suggestion if you provide more information on the running status of your runs.

They both involve nrtot, so I suppose with the default FFT grid (160x160x54, according to my epw.out) it must really be bottlenecking at those spots.

If the FFT grid of 160x160x54 represents the soft FFT grid, in EPW this is not distributed. In pw2wannier90, if you are using 10 cores, this is distributed over 10 cores since in pw2wannier90, the parallelization over k points (-nk) is not supported and only G-vector parallization is supported.

As I said several times, the QR factorization is only done on the ionode both in epw and pw2wannier90.

In any case, if you succeed in getting good Wannier functions using the SCDM method in the route using pw2wannier90+Wannier90, but still have difficulty with it in EPW, please let me know it. I will guide you about the way to import the relevant data from W90 in EPW.

Sincerely,

H. Lee

Hello H. Lee,

Thanks again for your assistance!

I have tinkered with the SCDM-k method a lot for my systems in the past few days. There are only 4 bands crossing the Fermi level, but they’re entangled with other bands over a huge (> 30 eV) energy window.

Using 18 Wannier functions and the SCDM-k method through w90 directly worked quite well, I got great localization for my system, but the Fermi level properties weren’t represented well. Introducing a small frozen window around E_fermi made me have to use a lot of disentanglement steps (a few thousand) before the localization was good again. Doing the SCDM-k via EPW didn’t seem to work with my system, getting stuck on the part I mentioned above. But using w90 and pw2wan works fine.

I would appreciate it if you guided me in using Wannier90 output to then run EPW, as doing the above took many computing hours already (it turns out I needed a tight nscf k-mesh for my system, which meant the wannier90 disentanglement took a long time). I don’t have the ‘filukk’.

Dear adenchfi:

Basically, it is not difficult for EPW to import the relevant data from W90.
However, you should be VERY careful at the fact that you should use the SAME wavefunctions in constructing Wannier functions and evaluating the electron-phonon matrix elements. Otherwise, your results are totally meaningless due to the gauge inconsistency.
This is why EPW constructs Wannier functions AND evaluates electron-phonon matrix elements internally.

In order for EPW to import the relevant data from W90, you just need to modify the subroutine of plot_u_matrices in W90 so that it writes the relevant informations in the format compatible with EPW.
Please compare the subroutine of plot_u_matrices in src/plot.F90 in W90 and the subroutine of loadumat.f90 in EPW/src .

To do this, you need to understand how variables in W90 and EPW match and modify plot_u_matrices so as to write additional data, for instance, exdata and w_centers which are stored in .ukk file.

Sincerely,

H. Lee

Hello H. Lee,

Thank you! I will work on your suggestions.