Author Topic: AttributeError: 'Bandstructure' object has no attribute 'indirectBandGap'  (Read 2564 times)

0 Members and 1 Guest are viewing this topic.

Offline Aaron Shen

  • New QuantumATK user
  • *
  • Posts: 2
  • Country: cn
  • Reputation: 0
    • View Profile
In the tutorial named Silicon p-n junction, the error occured when the bandstructure_fit.py run. The error information is shown as follow:
+------------------------------------------------------------------------------+
|                                                                              |
| QuantumATK 2018.06-SP1-1[Build 3f8f0aa75d]                                   |
|                                                                              |
+------------------------------------------------------------------------------+
Traceback (most recent call last):
  File "bandstructure_fit.py", line 14, in <module>
    ind_gap.append(bandstructure.indirectBandGap().inUnitsOf(eV))
AttributeError: 'Bandstructure' object has no attribute 'indirectBandGap'

Timing:                          Total     Per Step        %

--------------------------------------------------------------------------------

Loading Modules + MPI   :       2.87 s       2.87 s      68.00% |=============|
--------------------------------------------------------------------------------
Total                   :       4.22 s
And the bandstructure_fit.py is:
from QuantumATK import *
import pylab
import numpy as np
from pylab import *

# List of c(tb09) parameters used in the MGGA bandstructure calculations
tb09=[0.9,1.0,1.1,1.2]

# Read the bandstructures objects calculated at different tb09 parameters and calculate the
# indirect band gap.
ind_gap=[]
for n in range(0,4):
    bandstructure=nlread("MGGA_bulk.hdf5", Bandstructure)[n]
    ind_gap.append(bandstructure.indirectBandGap().inUnitsOf(eV))

# Calculate the Slater-Koster bindirect band gap
bandstructure_SK=nlread("bulk_SK.hdf5", Bandstructure)[-1]
SK = bandstructure_SK.indirectBandGap().inUnitsOf(eV)

# Perform a linear fit of the calculated MGGA band gap vs tb09 parameter and
# calculate the c parameters which will give the SK band gap.
(m,b)=polyfit(tb09,ind_gap,1)
fitted_c = (SK - b) / m

print "Fitted c parameter: ",  fitted_c

#  Make the plot
pylab.plot([min(tb09),max(tb09)],[SK,SK] , linewidth=1.0, linestyle='-', color='black', label="SK band gap" )
pylab.plot([fitted_c, fitted_c],[min(ind_gap),max(ind_gap)] , linewidth=1.0, linestyle='-', color='b', label="fitted c" )

pylab.plot(tb09,ind_gap,'*b',label='MGGA gap')

yp=polyval([m,b],tb09)
pylab.plot(tb09,yp, '--')

pylab.xlabel("TB09 - c")
pylab.ylabel("Band Gap (eV)")
pylab.grid(True)
pylab.legend(loc="lower right")
pylab.show()

Offline Daniele Stradi

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 286
  • Country: dk
  • Reputation: 3
    • View Profile
Hello,

the program fails because the function indirectBandGap() is a not a public function in 2018.06-SP1.

In order to make the script work, you should change:
bandstructure.indirectBandGap().inUnitsOf(eV))
to:
bandstructure._indirectBandGap().inUnitsOf(eV))

We have filed an bug for this.

Best regards,
Daniele