How to get the element of transition dipole matrix with nspin=2

Deals with issues related to computation of optical spectra in reciprocal space: RPA, TDDFT, local field effects.

Moderators: Davide Sangalli, andrea.ferretti, myrta gruning, andrea marini, Daniele Varsano, Conor Hogan

Post Reply
ZHuang
Posts: 10
Joined: Sat Jul 08, 2023 3:32 pm

How to get the element of transition dipole matrix with nspin=2

Post by ZHuang » Thu Dec 14, 2023 2:34 pm

Dear developers,

Can you introduce that in case the linear optical absorption was calculated using "yambo -o c" with “nspin=2” in quantum espresso, how can I got the dipole matrix element corresponding to SPIN UP and SPIN DOWN transition?

My question comes from the error I met during running the following code

Code: Select all

ylat = YamboLatticeDB.from_db_file(filename='./SAVE/ns.db1')
ydip = YamboDipolesDB(ylat,save="./SAVE/",filename='ndb.dipoles')
yel = YamboElectronsDB(ylat,save='./SAVE/')
and the error information is
File ~/software/miniconda3/envs/pynotebook/lib/python3.12/site-packages/yambopy-1-py3.12.egg/yambopy/dbs/dipolesdb.py:193, in YamboDipolesDB.expandDipoles(self, dipoles, field_dir, field_dir3)
189 tra = np.dot(pro,sym)
191 for c,v in product(list(range(self.nbandsc)),list(range(self.nbandsv))):
192 #rotate dipoles
--> 193 self.dipoles[nk_fbz,:,indexc+c,indexv+v] = np.dot(tra,dip[:,c,v])
195 #make hermitian
196 for c,v in product(list(range(self.nbandsc)),list(range(self.nbandsv))):

ValueError: shapes (3,3) and (320,2) not aligned: 3 (dim 1) != 320 (dim 0)
320 is the value of nbnd I set in the quantum espresso.


In this post (viewtopic.php?t=1214) it is said that
in the new ndb.dipoles the matrix elements DIP(3)_cvk sigma are stored with the indexes running as follow
(first index run faster):
a) real, imaginary part
b) cartesian index (xyz)
c) conduction band index
d) valence band index
e) k-point index (if you fragment this index goes into the fragment index)
f) if n_sp_pol>1, spin index (if you fragment this index goes into the fragment index)
However, I found that the dipoledb.py in yambopy seems to have only 5 index, and the real and imaginary part was the last index:

Code: Select all

dip = (dip[:,:,:,:,0]+1j*dip[:,:,:,:,1]) # Read as nk,nv,nc,it
Thank you very for your help!
Huang
--------
Tongji University, PR China

User avatar
palful
Posts: 60
Joined: Tue Jan 26, 2016 11:23 am
Location: Modena and Milan

Re: How to get the element of transition dipole matrix with nspin=2

Post by palful » Fri Dec 15, 2023 12:38 pm

Dear Huang,

You are right, at the moment the yambopy class to read dipoles only supports the nspin=1 case. The fact that it exits without explanation is a bug. We will add spin-polarised support for the class as soon as possible. I will let you know in this thread when it's done.

Cheers,
Fulvio
Dr. Fulvio Paleari
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy

ZHuang
Posts: 10
Joined: Sat Jul 08, 2023 3:32 pm

Re: How to get the element of transition dipole matrix with nspin=2

Post by ZHuang » Fri Dec 15, 2023 3:24 pm

Dear Fulvio,

Thank you very much for the reply!

Following the dipolesdb.py in the yambopy, I try to assess the ndb.dipoles via reading dataset, i.e. dbDiPole.variables['DIP_iR'].
For nspin =2, I got an array with the shape [2,32,320,320,3,2], and I know that 32 is the number of kpoint, 320 is the nbnd, and 3 referes to the three directions.
Can you give some suggestions that the first index or the last index corresponds to the spin state?

Best regards,
Huang
-------------------
Tongji University

User avatar
palful
Posts: 60
Joined: Tue Jan 26, 2016 11:23 am
Location: Modena and Milan

Re: How to get the element of transition dipole matrix with nspin=2

Post by palful » Fri Feb 02, 2024 3:32 pm

Dear Huang,

This is just to inform you that spin-polarised support has been added in the dipolesdb class in the new version of yambopy.

To answer your question, the first index is the spin polarisation index, while the last refers to the real and imaginary parts of the dipoles.

Cheers,
Fulvio
Dr. Fulvio Paleari
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy

Post Reply