questions on the using of plot-excitondb.py
Posted: Wed Apr 17, 2024 2:13 am
Dear Developers,
I tried yambopy and found it is very strong and versatile. I have a question about the using, that is when I input: python plot-excitondb.py
it shows:
19 kpoints expanded to 144
Ground state energy: 1.765612
Intensity: 0.360372
1st-excited state energy: 1.769712
Intensity: 0.000000
This interpolation is provided by the SKW interpolator implemented in Abipy
19 kpoints expanded to 144
Found 24 symmetries in point group
rmax [13 13 13] msize: 19683
gen points 0.24698424339294434
nshells 1386
shells 0.011551618576049805
stars 1.1475365161895752
r2max [ 9 -8 2]
end 0.0024149417877197266
Using: 190 star-functions. nstars/nk: 10.0
FIT vs input data: Mean Absolute Error= 4.885e-11 (meV)
Interpolation completed in 0.072 (s)
Found 24 symmetries in point group
rmax [13 13 13] msize: 19683
gen points 0.24494242668151855
nshells 1386
shells 0.011464834213256836
stars 1.1547348499298096
r2max [ 9 -8 2]
end 0.0022423267364501953
Using: 190 star-functions. nstars/nk: 10.0
FIT vs input data: Mean Absolute Error= 2.195e-12 (meV)
Interpolation completed in 0.071 (s)
Traceback (most recent call last):
File "plot-excitondb.py", line 66, in <module>
yexc.plot_exciton_2D_ax(ax,states,mode='hexagon',limfactor=0.8,scale= 600)
File "/home/may0d/Codes/Miniconda3/envs/deepmd/lib/python3.8/site-packages/yambopy/dbs/excitondb.py", line 822, in plot_exciton_2D_ax
ax.add_patch(BZ_Wigner_Seitz(self.lattice))
File "/home/may0d/Codes/Miniconda3/envs/deepmd/lib/python3.8/site-packages/yambopy/plot/plotting.py", line 52, in BZ_Wigner_Seitz
if lat_type[:3]=='Hex': return BZ_hexagon(lattice.rlat,center=center,orientation=orientation,color=color,linewidth=linewidth)
TypeError: 'NoneType' object is not subscriptable
could you please tell me how can I resolve this issue? It seems like nothing generated.
This is the content of my script:
#from __future__ import print_function, division
from qepy import *
from yambopy import *
import matplotlib.pyplot as plt
import os
npoints = 20
fig = plt.figure(figsize=(4,6))
ax = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])
# Define path in reduced coordinates using Class Path
path = Path([ [[ 0.0, 0.0, 0.0],'$\Gamma$'],
[[ 0.5, 0.0, 0.0],'M'],
[[2./3.,1./3., 0.0],'K'],
[[ 0.0, 0.0, 0.0],'$\Gamma$']], [int(npoints*2),int(npoints),int(sqrt(5)*npoints)] )
# Load databases
# SAVE database
save = YamboSaveDB.from_db_file(folder='/lustre/scratch/sun/Exciton/SAVE/')
# Lattice information
lat = YamboLatticeDB.from_db_file(filename='/lustre/scratch/sun/Exciton/SAVE/ns.db1')
# Exciton database read from db file
if os.path.isfile('/lustre/scratch/sun/Exciton/all_Bz-BSE-Diagonalization-3-16/ndb.BS_diago_Q01'):
yexc = YamboExcitonDB.from_db_file(lat,filename='ndb.BS_diago_Q01',folder='/lustre/scratch/sun/Exciton/all_Bz-BSE-Diagonalization-3-16/')
if os.path.isfile('/lustre/scratch/sun/Exciton/all_Bz-BSE-Diagonalization-3-16/ndb.BS_diago_Q1'):
yexc = YamboExcitonDB.from_db_file(lat,filename='ndb.BS_diago_Q1',folder='/lustre/scratch/sun/Exciton/all_Bz-BSE-Diagonalization-3-16/')
print("Ground state energy: %lf" % yexc.eigenvalues[0].real )
print("Intensity: %lf" % (yexc.get_intensities()[0].real+yexc.get_intensities()[1].real) )
print("1st-excited state energy: %lf" % yexc.eigenvalues[2].real )
print("Intensity: %lf" % (yexc.get_intensities()[2].real+yexc.get_intensities()[3].real) )
# List of states to be merged
states = [1,2]
# 1. Plot exciton weights in band structure NOT interpolated
exc_bands = yexc.get_exciton_bs(save,path,states,size=1.0)
exc_bands.plot_ax(ax,color_bands='grey',c_weights='red')
plt.show()
# 2. Plot exciton weights in band structure INTERPOLATED
fig = plt.figure(figsize=(4,6))
ax = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])
# In case of problems with the interpolation, try to increase lpratio
exc_bands_inter = yexc.interpolate(save,path,states,lpratio=10,f=None,size=0.5,verbose=True)
exc_bands_inter.plot_ax(ax,color_bands='grey',c_weights='red',alpha_weights=0.5,c_label='$X_1$')
plt.show()
# 3. Plot exciton weights in a 2D map of the BZ
fig = plt.figure(figsize=(4,4))
ax = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])
yexc.plot_exciton_2D_ax(ax,states,mode='hexagon',limfactor=0.8,scale= 600)
plt.show()
In addition, I only find ndb.BS_diago_Q1 in my folder and didn't find ndb.BS_diago_Q01.
Thank you.
Best,
Sun
I tried yambopy and found it is very strong and versatile. I have a question about the using, that is when I input: python plot-excitondb.py
it shows:
19 kpoints expanded to 144
Ground state energy: 1.765612
Intensity: 0.360372
1st-excited state energy: 1.769712
Intensity: 0.000000
This interpolation is provided by the SKW interpolator implemented in Abipy
19 kpoints expanded to 144
Found 24 symmetries in point group
rmax [13 13 13] msize: 19683
gen points 0.24698424339294434
nshells 1386
shells 0.011551618576049805
stars 1.1475365161895752
r2max [ 9 -8 2]
end 0.0024149417877197266
Using: 190 star-functions. nstars/nk: 10.0
FIT vs input data: Mean Absolute Error= 4.885e-11 (meV)
Interpolation completed in 0.072 (s)
Found 24 symmetries in point group
rmax [13 13 13] msize: 19683
gen points 0.24494242668151855
nshells 1386
shells 0.011464834213256836
stars 1.1547348499298096
r2max [ 9 -8 2]
end 0.0022423267364501953
Using: 190 star-functions. nstars/nk: 10.0
FIT vs input data: Mean Absolute Error= 2.195e-12 (meV)
Interpolation completed in 0.071 (s)
Traceback (most recent call last):
File "plot-excitondb.py", line 66, in <module>
yexc.plot_exciton_2D_ax(ax,states,mode='hexagon',limfactor=0.8,scale= 600)
File "/home/may0d/Codes/Miniconda3/envs/deepmd/lib/python3.8/site-packages/yambopy/dbs/excitondb.py", line 822, in plot_exciton_2D_ax
ax.add_patch(BZ_Wigner_Seitz(self.lattice))
File "/home/may0d/Codes/Miniconda3/envs/deepmd/lib/python3.8/site-packages/yambopy/plot/plotting.py", line 52, in BZ_Wigner_Seitz
if lat_type[:3]=='Hex': return BZ_hexagon(lattice.rlat,center=center,orientation=orientation,color=color,linewidth=linewidth)
TypeError: 'NoneType' object is not subscriptable
could you please tell me how can I resolve this issue? It seems like nothing generated.
This is the content of my script:
#from __future__ import print_function, division
from qepy import *
from yambopy import *
import matplotlib.pyplot as plt
import os
npoints = 20
fig = plt.figure(figsize=(4,6))
ax = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])
# Define path in reduced coordinates using Class Path
path = Path([ [[ 0.0, 0.0, 0.0],'$\Gamma$'],
[[ 0.5, 0.0, 0.0],'M'],
[[2./3.,1./3., 0.0],'K'],
[[ 0.0, 0.0, 0.0],'$\Gamma$']], [int(npoints*2),int(npoints),int(sqrt(5)*npoints)] )
# Load databases
# SAVE database
save = YamboSaveDB.from_db_file(folder='/lustre/scratch/sun/Exciton/SAVE/')
# Lattice information
lat = YamboLatticeDB.from_db_file(filename='/lustre/scratch/sun/Exciton/SAVE/ns.db1')
# Exciton database read from db file
if os.path.isfile('/lustre/scratch/sun/Exciton/all_Bz-BSE-Diagonalization-3-16/ndb.BS_diago_Q01'):
yexc = YamboExcitonDB.from_db_file(lat,filename='ndb.BS_diago_Q01',folder='/lustre/scratch/sun/Exciton/all_Bz-BSE-Diagonalization-3-16/')
if os.path.isfile('/lustre/scratch/sun/Exciton/all_Bz-BSE-Diagonalization-3-16/ndb.BS_diago_Q1'):
yexc = YamboExcitonDB.from_db_file(lat,filename='ndb.BS_diago_Q1',folder='/lustre/scratch/sun/Exciton/all_Bz-BSE-Diagonalization-3-16/')
print("Ground state energy: %lf" % yexc.eigenvalues[0].real )
print("Intensity: %lf" % (yexc.get_intensities()[0].real+yexc.get_intensities()[1].real) )
print("1st-excited state energy: %lf" % yexc.eigenvalues[2].real )
print("Intensity: %lf" % (yexc.get_intensities()[2].real+yexc.get_intensities()[3].real) )
# List of states to be merged
states = [1,2]
# 1. Plot exciton weights in band structure NOT interpolated
exc_bands = yexc.get_exciton_bs(save,path,states,size=1.0)
exc_bands.plot_ax(ax,color_bands='grey',c_weights='red')
plt.show()
# 2. Plot exciton weights in band structure INTERPOLATED
fig = plt.figure(figsize=(4,6))
ax = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])
# In case of problems with the interpolation, try to increase lpratio
exc_bands_inter = yexc.interpolate(save,path,states,lpratio=10,f=None,size=0.5,verbose=True)
exc_bands_inter.plot_ax(ax,color_bands='grey',c_weights='red',alpha_weights=0.5,c_label='$X_1$')
plt.show()
# 3. Plot exciton weights in a 2D map of the BZ
fig = plt.figure(figsize=(4,4))
ax = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])
yexc.plot_exciton_2D_ax(ax,states,mode='hexagon',limfactor=0.8,scale= 600)
plt.show()
In addition, I only find ndb.BS_diago_Q1 in my folder and didn't find ndb.BS_diago_Q01.
Thank you.
Best,
Sun