Yambo 4.1.4 Edit Quasiparticle with Spin

Anything regarding the post-processing utility (e.g. excitonic wavefunction analysis) is dealt with in this forum.

Moderators: Davide Sangalli, andrea marini, Daniele Varsano

Post Reply
Shimin
Posts: 7
Joined: Fri Dec 18, 2020 6:03 am

Yambo 4.1.4 Edit Quasiparticle with Spin

Post by Shimin » Tue Mar 08, 2022 8:40 am

Dear YAMBO team,
I'm using ypp -q g to Combine all the Quasiparticle corrections i calculated separately before.
(I tested the merging method for this version, somehow it does not work)
However the editing format does not have spin parameter

Code: Select all

%QPkrange            # [QPDB] QP correctionQPDB energy correction( kp1| kp2| bnd1| bnd2| E-Eo[eV]| Img(E)[eV]| Re[Z] |)
   1|  1|139|139|   -0.698305|    0.012206|    0.817785|
  1|  1|139|139|   -0.694332|    0.012167|    0.817689|
...
 
i think it suppose to have the spin parameter like Spin_Pol in output o.qp file

Code: Select all

#  K-point    Band       Eo         E-Eo       Sc|Eo      Spin_Pol
    1.0000   139.0000    -3.1706    -0.6983     2.5615     1.0000
    1.0000   139.0000    -3.1654    -0.6943     2.5522    -1.0000
when i try to generate the new database the ERROR message appeared
Duplicate quasi-particle indexes!
I found the Error message are from ypp/qp/QP_DBs_setup.F.
My Question is:
1. If i comment out this Duplicate check in ypp/qp/QP_DBs_setup.F would the new database actually contain the spin information?
2. If i want to add the spin information how should i modify the code?
3. I would need to finish current calculation on this version, if a newer version ypp have fixed this problem would i be able to use the newer version ypp QP Edit function to modify database of Yambo 4.1.4?
Shimin Zhang
PhD student in Material Science& Engineering
University of Wisconsin, Madison

User avatar
Daniele Varsano
Posts: 3808
Joined: Tue Mar 17, 2009 2:23 pm
Contact:

Re: Yambo 4.1.4 Edit Quasiparticle with Spin

Post by Daniele Varsano » Tue Mar 08, 2022 2:16 pm

Dear Shimin,

The spin polarization is handled within the database.
Yambo version 4.1.4 is very old and it is not supported anymore.
I suggest you update to a newer version of the code, you can have a try if the ypp merging procedure works also for old databases but this is not guaranteed.

About the editing procedure we need to have a look.

Best,
Daniele
Dr. Daniele Varsano
S3-CNR Institute of Nanoscience and MaX Center, Italy
MaX - Materials design at the Exascale
http://www.nano.cnr.it
http://www.max-centre.eu/

Shimin
Posts: 7
Joined: Fri Dec 18, 2020 6:03 am

Re: Yambo 4.1.4 Edit Quasiparticle with Spin

Post by Shimin » Tue Mar 08, 2022 6:52 pm

I still wonder if i can add spin parameter in Editing process, which part of the code is related to the editing part?

Best,
Shimin
Shimin Zhang
PhD student in Material Science& Engineering
University of Wisconsin, Madison

User avatar
Davide Sangalli
Posts: 614
Joined: Tue May 29, 2012 4:49 pm
Location: Via Salaria Km 29.3, CP 10, 00016, Monterotondo Stazione, Italy
Contact:

Re: Yambo 4.1.4 Edit Quasiparticle with Spin

Post by Davide Sangalli » Thu Mar 10, 2022 10:44 am

Dear Shimin,
at present it is not possible to add a spin parameter.

However it would be indeed a very useful option.
The coding is not trivial. The subroutines to look into are

Code: Select all

ypp/interface/QP_DBs_initialize.F
ypp/qp/QP_DBs_create_and_modify.F
Anyway I'll put that in the yambo wish-list.
Hopefully it will be ready in some future release.

Best,
D.
Davide Sangalli, PhD
CNR-ISM, Division of Ultrafast Processes in Materials (FLASHit) and MaX Centre
https://sites.google.com/view/davidesangalli
http://www.max-centre.eu/

User avatar
Davide Sangalli
Posts: 614
Joined: Tue May 29, 2012 4:49 pm
Location: Via Salaria Km 29.3, CP 10, 00016, Monterotondo Stazione, Italy
Contact:

Re: Yambo 4.1.4 Edit Quasiparticle with Spin

Post by Davide Sangalli » Thu Mar 10, 2022 6:30 pm

Ok. The coding was easy.
Can you try this patch on version 5.0:

(Please notice that I did update the patch on March 15)

Code: Select all

diff --git a/ypp/interface/QP_DBs_initialize.F b/ypp/interface/QP_DBs_initialize.F
index acf24f36e..575957ec3 100644
--- a/ypp/interface/QP_DBs_initialize.F
+++ b/ypp/interface/QP_DBs_initialize.F
@@ -26,6 +26,7 @@ subroutine QP_DBs_initialize()
  ! QPDB_states -> input file
  !
  use QP_m,      ONLY:QP_t,QP_reset
+ use electrons, ONLY:spin
  use parser_m,  ONLY:PARSER_array
  use IO_int,    ONLY:io_control
  use IO_m,      ONLY:OP_RD_CL,DUMP,NONE
@@ -38,7 +39,7 @@ subroutine QP_DBs_initialize()
  ! Work Space
  !
  type(QP_t) :: qp
- integer :: i_qp,io_QP_and_GF_err,ID,n_user_qp_corrections
+ integer :: i_qp,io_QP_and_GF_err,ID,n_user_qp_corrections,n_lines
  integer, external :: io_QP_and_GF
  !
  ! If there are already the DB lines or there's not the input file todo return
@@ -51,29 +52,31 @@ subroutine QP_DBs_initialize()
    !
    ! QP corrections
    ! 
-   call PARSER_array(mode="REAL dimensions",VAR="QP_user_corrections",N=n_user_qp_corrections,M=7)
+   n_lines=8
+   call PARSER_array(mode="REAL dimensions",VAR="QP_user_corrections",N=n_user_qp_corrections,M=n_lines)
    if (n_user_qp_corrections>0) then
-     YAMBO_ALLOC(QP_user_corrections,(n_user_qp_corrections,7))
-     call PARSER_array(mode="read",VAR="QP_user_corrections",N=n_user_qp_corrections,M=7,R_v=QP_user_corrections)
+     YAMBO_ALLOC(QP_user_corrections,(n_user_qp_corrections,n_lines))
+     call PARSER_array(mode="read",VAR="QP_user_corrections",N=n_user_qp_corrections,M=n_lines,R_v=QP_user_corrections)
    else if (io_QP_and_GF_err==0) then
      n_user_qp_corrections=qp%n_states
-     YAMBO_ALLOC(QP_user_corrections,(n_user_qp_corrections,7))
+     YAMBO_ALLOC(QP_user_corrections,(n_user_qp_corrections,n_lines))
      do i_qp=1,qp%n_states
-       QP_user_corrections(i_qp,1:2)=qp%table(i_qp,3)  
-       QP_user_corrections(i_qp,3:4)=qp%table(i_qp,1)  
-       QP_user_corrections(i_qp,5)  =real(qp%E(i_qp)-qp%E_bare(i_qp))*HA2EV
-       QP_user_corrections(i_qp,6)  =aimag(qp%E(i_qp))*HA2EV
-       QP_user_corrections(i_qp,7)  =real(qp%Z(i_qp))
+       QP_user_corrections(i_qp,1)  =spin(qp%table(i_qp,:))
+       QP_user_corrections(i_qp,2:3)=qp%table(i_qp,3)  
+       QP_user_corrections(i_qp,4:5)=qp%table(i_qp,1)  
+       QP_user_corrections(i_qp,6)  =real(qp%E(i_qp)-qp%E_bare(i_qp))*HA2EV
+       QP_user_corrections(i_qp,7)  =aimag(qp%E(i_qp))*HA2EV
+       QP_user_corrections(i_qp,8)  =real(qp%Z(i_qp))
      enddo
    else
      n_user_qp_corrections=1
-     YAMBO_ALLOC(QP_user_corrections,(n_user_qp_corrections,7))
-     QP_user_corrections(1,:)=(/-1,-1,-1,-1,0,0,0/)
+     YAMBO_ALLOC(QP_user_corrections,(n_user_qp_corrections,n_lines))
+     QP_user_corrections(1,:)=(/-1,-1,-1,-1,-1,0,0,0/)
    endif
    !
    call PARSER_array(mode="write",VAR="QP_user_corrections",&
-&                    DESC="[QPDB] Correction( kp1| kp2| bnd1| bnd2| E-Eo[eV]| Img(E)[eV]| Re[Z] |)",&
-&                    N=n_user_qp_corrections,M=7,R_v=QP_user_corrections,Kn=(/"i","i","i","i","r","r","r"/))
+&                    DESC="[QPDB] Correction( spin | kp1| kp2| bnd1| bnd2| E-Eo[eV]| Img(E)[eV]| Re[Z] |)",&
+&                    N=n_user_qp_corrections,M=n_lines,R_v=QP_user_corrections,Kn=(/"i","i","i","i","i","r","r","r"/))
    !
  else if (l_QP_DBs_manipulate) then
    !
diff --git a/ypp/qp/QP_DBs_create_and_modify.F b/ypp/qp/QP_DBs_create_and_modify.F
index 03c1fbd00..0238c49d6 100644
--- a/ypp/qp/QP_DBs_create_and_modify.F
+++ b/ypp/qp/QP_DBs_create_and_modify.F
@@ -39,7 +39,7 @@ subroutine QP_DBs_create_and_modify(en,k)
  !
  ! Work Space
  !
- integer  :: io_QP_and_GF_err,ID,i_u,ib,ik,ic,is
+ integer  :: io_QP_and_GF_err,ID,i_u,ib,ik,ic,is,ik_qp,nk_lim(2),nb_lim(2)
  integer, external    :: io_QP_and_GF
  logical, allocatable :: QP_done(:,:,:,:)
  type(QP_t) :: qp
@@ -47,6 +47,9 @@ subroutine QP_DBs_create_and_modify(en,k)
  call section("=",'QP databases creation')
  !========================================
  !
+ nk_lim=(/minval(QP_user_corrections(:,2)),maxval(QP_user_corrections(:,3))/)
+ nb_lim=(/minval(QP_user_corrections(:,4)),maxval(QP_user_corrections(:,5))/)
+ !
  ! ...resets
  !
  call QP_reset(qp)
@@ -59,28 +62,30 @@ subroutine QP_DBs_create_and_modify(en,k)
  ! ...mark the states to correct
  !
  do i_u=1,size(QP_user_corrections,1)
-   do is=1,n_sp_pol
-     do ik=int(QP_user_corrections(i_u,1)),int(QP_user_corrections(i_u,2))
-       do ib=int(QP_user_corrections(i_u,3)),int(QP_user_corrections(i_u,4))
-         QP_state(ib,ik)=.TRUE.
-         QP_nb=max(QP_nb,ib)
-         QP_nk=max(QP_nk,ib)
-       enddo
+   do ik=int(QP_user_corrections(i_u,2)),int(QP_user_corrections(i_u,3))
+     do ib=int(QP_user_corrections(i_u,4)),int(QP_user_corrections(i_u,5))
+       QP_state(ib,ik)=.TRUE.
      enddo
    enddo
  enddo
  !
- ! ... not turn QP_state into QP_table
+ QP_nk=nk_lim(2)
+ QP_nb=nb_lim(2)
+ !
+ ! ... now turn QP_state into QP_table
  !
  call QP_state_table_setup(en)
  !
+ QP_nk=nk_lim(2)-nk_lim(1)+1
+ QP_nb=nb_lim(2)-nb_lim(1)+1
+ !
  qp%n_states=QP_n_states
  qp%nb      =QP_nb
  qp%nk      =QP_nk
  ! 
  call QP_alloc(qp)
  !
- YAMBO_ALLOC(QP_done,(QP_nb,QP_nb,QP_nk,n_sp_pol))
+ YAMBO_ALLOC(QP_done,(nb_lim(1):nb_lim(2),nb_lim(1):nb_lim(2),nk_lim(1):nk_lim(2),n_sp_pol))
  QP_done=.FALSE.
  !
  ! ...let's fill now
@@ -88,20 +93,21 @@ subroutine QP_DBs_create_and_modify(en,k)
  ic=1
  do i_u=1,size(QP_user_corrections,1)
    !
-   if (QP_user_corrections(i_u,7)<epsilon(1._SP)) QP_user_corrections(i_u,7)=1.
+   if (QP_user_corrections(i_u,8)<epsilon(1._SP)) QP_user_corrections(i_u,8)=1._SP
    !
-   do is=1,n_sp_pol
-     do ik=int(QP_user_corrections(i_u,1)),int(QP_user_corrections(i_u,2))
-       do ib=int(QP_user_corrections(i_u,3)),int(QP_user_corrections(i_u,4))
+   do is=int(QP_user_corrections(i_u,1)),int(QP_user_corrections(i_u,1))
+     do ik=int(QP_user_corrections(i_u,2)),int(QP_user_corrections(i_u,3))
+       ik_qp=ik-QP_user_corrections(i_u,2)+1
+       do ib=int(QP_user_corrections(i_u,4)),int(QP_user_corrections(i_u,5))
          !
          qp%E_bare(ic) =en%E(ib,ik,is)
-         qp%E(ic)      =cmplx(QP_user_corrections(i_u,5)/HA2EV+en%E(ib,ik,is),QP_user_corrections(i_u,6)/HA2EV,kind=SP)
-         qp%Z(ic)      =cmplx(QP_user_corrections(i_u,7),0.,kind=SP)
+         qp%E(ic)      =cmplx(QP_user_corrections(i_u,6)/HA2EV+en%E(ib,ik,is),QP_user_corrections(i_u,7)/HA2EV,kind=SP)
+         qp%Z(ic)      =cmplx(QP_user_corrections(i_u,8),0._SP,kind=SP)
          qp%table(ic,1)=ib
          qp%table(ic,2)=ib
          qp%table(ic,3)=ik
          if(n_sp_pol==2) qp%table(ic,4)=is
-         qp%k(qp%table(ic,3),:)  =k%pt(qp%table(ic,3),:)
+         qp%k(ik_qp,:)  =k%pt(ik,:)
          !
          if(QP_done(ib,ib,ik,is)) call error("Duplicated quasi-particle index found")
          !
Please let me know if it works.
Best,
D.
Davide Sangalli, PhD
CNR-ISM, Division of Ultrafast Processes in Materials (FLASHit) and MaX Centre
https://sites.google.com/view/davidesangalli
http://www.max-centre.eu/

Post Reply