Optical matrix elements
Moderators: myrta gruning, andrea marini, Daniele Varsano, Conor Hogan
-
- Posts: 72
- Joined: Tue Dec 08, 2020 11:16 am
Optical matrix elements
Hello!
I'm interested on the optical matrix elements and I've read here on the forum that is possible to extract this info from the dipoles database. I'm trying to do that using a script provided by Claudio in another post here on the forum but so far its not working(script1.py) so I suppose I must be using it wrong, just executing it as "python3 script1.py" is giving me the following error:
print "Dipole element <n{0:}|{3:}|n{1:}> at k{2:}: {4:}, module: {5:}".format(args.B1,args.B2,args.K,args.xyz,Dipole,abs(Dipole))
^
SyntaxError: invalid syntax
Also I tried using another script provided by Daniele and also no luck(script2.py), for this one I changed the "path" as instructed by I'm receiving the following error:
Traceback (most recent call last):
File "script.py", line 20, in <module>
dip_file = Dataset(path+"ndb.dipoles_fragment_1","r")
File "netCDF4/_netCDF4.pyx", line 2015, in netCDF4._netCDF4.Dataset.__init__
File "netCDF4/_netCDF4.pyx", line 1636, in netCDF4._netCDF4._ensure_nc_success
FileNotFoundError: [Errno 2] No such file or directory: b'/ccc/scratch/cont003/gen7682/cuccobru/final/SAVE/ndb.dipoles_fragment_1'
And in fact I don't have fragments of the nbd.dipoles on the Save folder, just the ndb.dipoles file. Any solutions for any of the scripts are very welcome! Thank you. (I'm using the Yambo 5.0.0)
Regards,
I'm interested on the optical matrix elements and I've read here on the forum that is possible to extract this info from the dipoles database. I'm trying to do that using a script provided by Claudio in another post here on the forum but so far its not working(script1.py) so I suppose I must be using it wrong, just executing it as "python3 script1.py" is giving me the following error:
print "Dipole element <n{0:}|{3:}|n{1:}> at k{2:}: {4:}, module: {5:}".format(args.B1,args.B2,args.K,args.xyz,Dipole,abs(Dipole))
^
SyntaxError: invalid syntax
Also I tried using another script provided by Daniele and also no luck(script2.py), for this one I changed the "path" as instructed by I'm receiving the following error:
Traceback (most recent call last):
File "script.py", line 20, in <module>
dip_file = Dataset(path+"ndb.dipoles_fragment_1","r")
File "netCDF4/_netCDF4.pyx", line 2015, in netCDF4._netCDF4.Dataset.__init__
File "netCDF4/_netCDF4.pyx", line 1636, in netCDF4._netCDF4._ensure_nc_success
FileNotFoundError: [Errno 2] No such file or directory: b'/ccc/scratch/cont003/gen7682/cuccobru/final/SAVE/ndb.dipoles_fragment_1'
And in fact I don't have fragments of the nbd.dipoles on the Save folder, just the ndb.dipoles file. Any solutions for any of the scripts are very welcome! Thank you. (I'm using the Yambo 5.0.0)
Regards,
You do not have the required permissions to view the files attached to this post.
MSc. Bruno Cucco
PhD Candidate
CNRS Institut des Sciences Chimiques de Rennes, France
Université de Rennes 1
https://iscr.univ-rennes1.fr
PhD Candidate
CNRS Institut des Sciences Chimiques de Rennes, France
Université de Rennes 1
https://iscr.univ-rennes1.fr
- palful
- Posts: 93
- Joined: Tue Jan 26, 2016 11:23 am
- Location: Modena and Milan
Re: Optical matrix elements
Ciao Bruno,
You can actually read the optical matrix elements ("dipoles") using yambopy, the python suite to manage advanced pre/postprocessing of yambo.
Below an example (also attached), followed by some explanation.
In order to read the dipoles your python script will be like (commented version attached):
First we import yambopy, then read the general lattice information (such as kpoint coordinates and symmetries) with YamboLatticeDB, for which you only need the ns.db1 file inside the yambo SAVE folder.
After that, we instance the class YamboDipolesDB where the argument 'save' is the path to the databases and 'filename' the database name.
Now, the numpy array contains the dipole values. Its axes are as follows: [ kpoint in full Brillouin zone, cartesian direction, band 1, band 2 ]. Keep in mind that since the indexing starts from 0, ydip.dipoles[0,2,4,3] in the example contains the values at Gamma, with component along the z-axis, between the third and second bands of the system.
Using yambopy
- Follow the installation instructions here: http://www.yambo-code.org/wiki/index.ph ... in_Yambopy.
- If you have questions or run into problems, you can post about it in this subtopic on the yambo forum: viewforum.php?f=35
Let us know if it worked!
Hope this helps,
Fulvio
You can actually read the optical matrix elements ("dipoles") using yambopy, the python suite to manage advanced pre/postprocessing of yambo.
Below an example (also attached), followed by some explanation.
In order to read the dipoles your python script will be like (commented version attached):
Code: Select all
from yambopy import *
ylat = YamboLatticeDB.from_db(filename='./SAVE/ns.db1')
ydip = YamboDipolesDB(ylat,save='./dbs',filename='./ndb.dipoles')
print(ydip.dipoles[0,2,4,3])
print(ydip.dipoles[0,2,3,4])
After that, we instance the class YamboDipolesDB where the argument 'save' is the path to the databases and 'filename' the database name.
Now, the numpy array
Code: Select all
ydip.dipoles
Using yambopy
- Follow the installation instructions here: http://www.yambo-code.org/wiki/index.ph ... in_Yambopy.
- If you have questions or run into problems, you can post about it in this subtopic on the yambo forum: viewforum.php?f=35
Let us know if it worked!
Hope this helps,
Fulvio
You do not have the required permissions to view the files attached to this post.
Dr. Fulvio Paleari
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy
-
- Posts: 72
- Joined: Tue Dec 08, 2020 11:16 am
Re: Optical matrix elements
Hello!
I think thats indeed what I'm looking for! Can you tell me what are the output units?
Regards,
I think thats indeed what I'm looking for! Can you tell me what are the output units?
Regards,
MSc. Bruno Cucco
PhD Candidate
CNRS Institut des Sciences Chimiques de Rennes, France
Université de Rennes 1
https://iscr.univ-rennes1.fr
PhD Candidate
CNRS Institut des Sciences Chimiques de Rennes, France
Université de Rennes 1
https://iscr.univ-rennes1.fr
- palful
- Posts: 93
- Joined: Tue Jan 26, 2016 11:23 am
- Location: Modena and Milan
Re: Optical matrix elements
Hi,
The quantity saved in ndb.dipoles should be: i*R_nmk = i*<n k| r | m k> , with R_nmk in atomic units of length (bohr).
Fulvio
The quantity saved in ndb.dipoles should be: i*R_nmk = i*<n k| r | m k> , with R_nmk in atomic units of length (bohr).
Fulvio
Dr. Fulvio Paleari
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy
-
- Posts: 67
- Joined: Fri Dec 18, 2020 7:14 am
Re: Optical matrix elements
Hi,
Is the yambopy updated in alignment with the newest yambo version? For Yambo-5.0.3, DIP_iR in ndb.dipoles has six indexes. Is it spin, kpts, vb, cb, catesian direction, imag or real?
Best,
Xiaoming
Is the yambopy updated in alignment with the newest yambo version? For Yambo-5.0.3, DIP_iR in ndb.dipoles has six indexes. Is it spin, kpts, vb, cb, catesian direction, imag or real?
Best,
Xiaoming
Xiaoming Wang
The University of Toledo
The University of Toledo
- palful
- Posts: 93
- Joined: Tue Jan 26, 2016 11:23 am
- Location: Modena and Milan
Re: Optical matrix elements
Dear Xiaoming,
Are you doing a spin-polarised calculation? Can you attach an example ndb.dipoles file?
Thanks,
Fulvio
Are you doing a spin-polarised calculation? Can you attach an example ndb.dipoles file?
Thanks,
Fulvio
Dr. Fulvio Paleari
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy
-
- Posts: 67
- Joined: Fri Dec 18, 2020 7:14 am
Re: Optical matrix elements
Dear Fulvio,
No, I'm not doing a spin-polarized calculation. The database is too large to be uploaded. Here I attach some information from ncdump.
You can see the shape of DIP_iR from above.
Best,
Xiaoming
No, I'm not doing a spin-polarized calculation. The database is too large to be uploaded. Here I attach some information from ncdump.
Code: Select all
netcdf ndb {
dimensions:
D_0000000003 = 3 ;
D_0000000001 = 1 ;
D_0000000002 = 2 ;
D_0000000004 = 4 ;
D_0000000011 = 11 ;
D_0000000100 = 100 ;
D_0000000032 = 32 ;
D_0000000008 = 8 ;
D_0000000576 = 576 ;
variables:
float HEAD_VERSION(D_0000000003) ;
float HEAD_REVISION(D_0000000001) ;
float SERIAL_NUMBER(D_0000000001) ;
float SPIN_VARS(D_0000000002) ;
float HEAD_R_LATT(D_0000000004) ;
float HEAD_WF(D_0000000001) ;
float FRAGMENTED(D_0000000001) ;
float TEMPERATURES(D_0000000002) ;
float PARS(D_0000000011) ;
char APPROACH(D_0000000001, D_0000000100) ;
char KINDS(D_0000000001, D_0000000100) ;
char WAVE_FUNC_XC(D_0000000001, D_0000000100) ;
float DIP_iR(D_0000000001, D_0000000576, D_0000000008, D_0000000032, D_0000000003, D_0000000002) ;
float DIP_P(D_0000000001, D_0000000576, D_0000000008, D_0000000032, D_0000000003, D_0000000002) ;
float DIP_v(D_0000000001, D_0000000576, D_0000000008, D_0000000032, D_0000000003, D_0000000002) ;
data:
HEAD_VERSION = 5, 0, 3 ;
HEAD_REVISION = 19584 ;
SERIAL_NUMBER = 2115 ;
SPIN_VARS = 1, 1 ;
HEAD_R_LATT = 576, 576, 576, 576 ;
HEAD_WF = 4077 ;
FRAGMENTED = 1 ;
TEMPERATURES = 0, 0 ;
PARS = 1, 40, 8, 9, -0.03674933, -0.03674933, 4077, 1, 1, 0, _ ;
APPROACH =
"G-space v " ;
KINDS =
"R V P " ;
WAVE_FUNC_XC =
"Perdew, Burke & Ernzerhof(X)+Perdew, Burke & Ernzerhof(C) " ;
DIP_iR =
-3.661782e-08, -3.201844e-08,
3.6709e-10, 1.779211e-08,
2.095814e-10, 8.769372e-09,
-7.588392e-10, 2.204259e-10,
-7.021913e-11, -3.309342e-10,
7.4839e-09, 1.125398e-09,
-0.01041611, 0.0005428896,
.....
Best,
Xiaoming
Xiaoming Wang
The University of Toledo
The University of Toledo
- palful
- Posts: 93
- Joined: Tue Jan 26, 2016 11:23 am
- Location: Modena and Milan
Re: Optical matrix elements
Dear Xiaoming,
My deepest apologies for never coming back to this. I just missed the post somehow.
The problem you had should be related to a new format for the dipoles database that was introduced in a recent version of yambo.
Yambopy was not supporting this new format, however now it is patched and it does (to be tested in the spin-polarised case).
This is a simple testing script for the new version (to be downloaded from the yambo page). In case you find additional issues, don't hesitate to reply.
Cheers,
Fulvio
My deepest apologies for never coming back to this. I just missed the post somehow.
The problem you had should be related to a new format for the dipoles database that was introduced in a recent version of yambo.
Yambopy was not supporting this new format, however now it is patched and it does (to be tested in the spin-polarised case).
This is a simple testing script for the new version (to be downloaded from the yambo page). In case you find additional issues, don't hesitate to reply.
Code: Select all
from yambopy import *
# Generic indices for testing
ik,ir,ic,iv = [3,1,6,2]
# Read lattice info
ylat = YamboLatticeDB.from_db(filename='ns.db1')
# Read dipole matrix element
ydip = YamboDipolesDB(ylat,save='dbs',filename='ndb.dipoles')
print(ydip.dipoles.shape)
print(ydip.dipoles[ik,ir,ic,iv])
Fulvio
Dr. Fulvio Paleari
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy
-
- Posts: 38
- Joined: Tue Jun 06, 2023 2:55 am
Re: Optical matrix elements
Dear Fulvio:
Thank you for your explanation. We are very interested in this topic too.
Based on your advice, I have obtained the dipole from VBM to CBM.
(1) I think this complex number should be the '<e|D|h>' in this expression:

is that correct?
(2) Can we also obtain the “Aeh” in this expression through yambopy? For example, in the form of complex number along each direction similar to a dipole?
In https://www.yambo-code.eu/wiki/index.ph ... e_excitons, I only found the square of Aeh.
Thank you for your explanation. We are very interested in this topic too.
Based on your advice, I have obtained the dipole from VBM to CBM.
(1) I think this complex number should be the '<e|D|h>' in this expression:

is that correct?
(2) Can we also obtain the “Aeh” in this expression through yambopy? For example, in the form of complex number along each direction similar to a dipole?
In https://www.yambo-code.eu/wiki/index.ph ... e_excitons, I only found the square of Aeh.
Jingda Guo
Beijing Institute of Technology
Beijing Institute of Technology
- Daniele Varsano
- Posts: 4198
- Joined: Tue Mar 17, 2009 2:23 pm
- Contact:
Re: Optical matrix elements
Dear Jingda,
Aeh are coefficients, so they do not have "directions". In a previous post (viewtopic.php?p=13877#p13877), I explained how to obtain dipoles mediated by exciton coefficients, is there any problem in your results, or you just need the Aeh for other reason?
Best,
Daniele
Aeh are coefficients, so they do not have "directions". In a previous post (viewtopic.php?p=13877#p13877), I explained how to obtain dipoles mediated by exciton coefficients, is there any problem in your results, or you just need the Aeh for other reason?
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/
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/