TypeError: 'NoneType' object is not subscriptable

Dear all,

I am trying to calculate the electronic band structures of few-layer materials. However, I have encountered an error like this for several times:

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pymatgen/symmetry/kpath.py:179: UserWarning: The input structure does not match the expected standard primitive! The path can be incorrect. Use at your own risk.
  warn(
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/abiopen.py", line 347, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/monty/functools.py", line 405, in wrapper
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/abiopen.py", line 219, in main
    abifile = abilab.abiopen(options.filepath)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/abipy/abilab.py", line 288, in abiopen
    return cls.from_file(filepath)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/abipy/electrons/gsr.py", line 50, in from_file
    return cls(filepath)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/abipy/electrons/gsr.py", line 57, in __init__
    self._ebands = r.read_ebands()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/abipy/electrons/ebands.py", line 3566, in read_ebands
    kpoints=self.read_kpoints(),
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/abipy/core/kpoints.py", line 1732, in read_kpoints
    kpoint.set_name(structure.findname_in_hsym_stars(kpoint))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/abipy/core/structure.py", line 1185, in findname_in_hsym_stars
    for star in self.hsym_stars:
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/monty/functools.py", line 238, in __get__
    value = self.__func(inst)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/abipy/core/structure.py", line 1152, in hsym_stars
    return [kpoint.compute_star(self.abi_spacegroup.fm_symmops) for kpoint in self.hsym_kpoints]
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/monty/functools.py", line 238, in __get__
    value = self.__func(inst)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/abipy/core/structure.py", line 1105, in hsym_kpoints
    name2frac_coords = self.hsym_kpath.kpath["kpoints"]
TypeError: 'NoneType' object is not subscriptable

Sometimes, this error didn’t show up (1,3,6,9…layers) and it gave me nice band structures. Other times, this error showed up (2,4,5,7,8…layers) and I have no clue how to solve it since I only changed the number of atoms in the unit cell and the thickness of vacuum. How can I solve this problem? Thank you.

I couldn’t find the way to attach my input file. So I copy paste it here. Some of variables are set to lower value to quickly check whether the error occurs again.

ndtset 2

#Dataset 1 : GS calculation
kptopt1  1              # Use symmetry and treat only inequivalent points
ngkpt1   5 5 1 #5 5 1
nshiftk1 1
shiftk1
  0.5 0.5 0.5
occopt1  4              # Marzari smearing
tsmear1  0.05
prtden1  1
tolvrs1  1.0d-10

#Dataset 2: Band structure calculation from Dataset 1.

iscf2  -2
getden2 1
kptopt2 -4
tolwfr2  1.0d-8
ndivsm2  16 #16
kptbounds2     # Extrema of the k-path.
0.5 0.0 0.0  #X
0.0 0.0 0.0  #Gamma
0.0 0.5 0.0  #Y
0.5 0.5 0.0  #M
0.5 0.0 0.0  #X


#Definition of the planewave basis set
ecut    15.0  #Definition of the plane wave basis set
#pawecutg 10.0
##Definition of the SCF procedure
nband   30
nstep   50

#Te lattice structure
ntypat   1
znucl   52
natom   3
typat   12*1

acell  5.93 4.45 7.9394   Angstrom #3.854

rprim   1.0   0.0  0.0  #x
        0.0   1.0  0.0  #y
        0.0   0.0  1.0  #z
#Atomic positions
xcart  #0.53
#0.0      0.3686    0.23728
#1/3      0.76272   0.5
#2/3      0.3686    0.76271

#0.0      1.6402    0.9144
#1.9766   3.3941    1.927
#3.9533   1.6402    2.9394
#0.0      3.8652    4.7684
#1.9766   1.1691    5.781
#3.9533   3.8652    6.7934
#0.0      1.6402    8.6224
#1.9766   3.3941    9.635
#3.9533   1.6402    10.6474
#0.0      3.8652    12.4764
#1.9766   1.1691    13.489
#3.9533   3.8652    14.5014
0.0      3.0947    1.7252
3.7294   6.4039    3.6358
7.459    3.0947    5.546
0.0      7.2928    8.9969
3.7294   2.2058    10.9075
7.459    7.2928    12.8177
0.0      3.0947    16.2686
3.7294   6.4039    18.1792
7.459    3.0947    20.0894
0.0      7.2928    23.5403
3.7294   2.2058    25.4509
7.459    7.2928    27.3611
chksymtnons 0
#Pseudo potentials
 pp_dirpath "$ABI_PSPDIR"
 pseudos "PseudosHGH_pwteter/52te.6.hgh"

There’s a problem in the pymatgen module that returns the list of high-symmetry k-points.
Your lattice is orthorhombic but spglib classifies it as triclinic.
To fix the problem, you need to change your /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pymatgen/symmetry/kpath.py file by applying this patch:

diff --git a/pymatgen/symmetry/kpath.py b/pymatgen/symmetry/kpath.py
index b58810571..aef8c4a13 100644
--- a/pymatgen/symmetry/kpath.py
+++ b/pymatgen/symmetry/kpath.py
@@ -277,6 +277,8 @@ class KPathSetyawanCurtarolo(KPathBase):
                 self._kpath = self.tria()
             if kalpha < 90 and kbeta < 90 and kgamma == 90:
                 self._kpath = self.trib()
+            # Handle orthorhombic lattice detected as triclinic
+            if np.allclose(self._rec_lattice.parameters[3:6], 90):
+                self._kpath = self.orc()

         else:
             warn("Unknown lattice type %s" % lattice_type)
1 Like

Dear gmatteo,

It solved my problem. Thank you so much!

Best regards,
WH Peng

Hi gmatteo,

Sorry for bothering you again. I encountered the similar problem that I tried to express a rhombohedral structure by hexagonal structure since I aimed to see the band structures of Gamma-K and Gamma-M. However, Abinit gave me the same error: ‘NoneType’ object is not subscriptable. I tried to modify my kpath.py file by following your solution to my previous problem, but it didn’t work:

elif lattice_type == “rhombohedral”:
alpha = self._prim.lattice.parameters[3]
if alpha < 90 and alpha != 60: # if alpha <90:
self._kpath = self.rhl1(alpha * pi / 180)
elif alpha >= 90: # else:
self._kpath = self.rhl2(alpha * pi / 180)
# Handle hexagonal lattice detected as rhombohedral
elif np.allclose(self._prim_lattice.parameters[3:5], 60):
self._kpath = self.hex()

Do you have other suggestions about this issue? I am grateful for your help.

Here is my file for the rhombohedral structure of Sb. Some variables were set to lower values to quickly check whether the issue was resolved.

ndtset 2

#Dataset 1 : GS calculation
kptopt1 4 # initially 1
ngkpt1 2 2 1 #6 6 1
nshiftk1 1
shiftk1 0.0 0.0 0.5 # This choice preserves the hexagonal symmetry of the grid,
occopt1 4 # Marzari smearing
tsmear1 0.05
prtden1 1
tolvrs1 1.0d-10
pawspnorb 1 #SOC
nspinor 2 #SOC

#Dataset 2: Band structure calculation from Dataset 1.

iscf2 -2
getden2 1
kptopt2 -2
tolwfr2 1.0d-8
ndivsm2 4
kptbounds2 # Extrema of the k-path.
0.5 0.0 0.0 #M
0.0 0.0 0.0 #Gamma
1/3 1/3 0.0 #K

#Definition of the planewave basis set
ecut 5.0 #20.0
#pawecutdg 35.0
##Definition of the SCF procedure
nband 30
nstep 50
#Sb lattice structure
ntypat 1
znucl 51
natom 4
typat 10*1

cell 4.3 4.3 27.48 Angstrom
rprim
0.866025403784439 0.5 0.0
-0.866025403784439 0.5 0.0
0.0 0.0 1.0

#Atomic positions
#xred
#0.0 0.0 0.0
#2/3 1/3 1.5/3.74
#1/3 2/3 1.0
#0.0 0.0 1.0+1.5/3.74
xcart #0.529177 (angstrom–>Bohr)
#0.0 0.0 0.0
#1.2412 2.15 1.5
#2.15 1.2412 3.74
#0.0 0.0 5.24 #angstrom

0.0 0.0 0.0
2.34553 4.06291 2.83459
4.06291 2.34553 7.06757
1.88972 1.88972 9.90216 #Bohr
chksymtnons 0
#Pseudo potentials
pp_dirpath “$ABI_PSPDIR”
pseudos “PseudosHGH_pwteter/51sb.5.hgh”
#Pseudodojo_paw_pbe_standard/Sb.xml"