Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Aaron Shen

Pages: [1]
1
In the tutorial named Silicon p-n junction, how to set  'fname' and 'data_index'  for the file named ddos_edp.py :

device_configuration = nlread(fname, DeviceConfiguration)[data_index]

potentials=nlread(fname, ElectrostaticDifferencePotential)[data_index]

ddos = nlread(fname, DeviceDensityOfStates)[data_index]
 
And the file is shown as follow:

from QuantumATK import *
import pylab
import sys

# Define the number of the index of the data in the file
data_index = 0

########################
# Define the filename containing the DeviceConfiguration, ElectrostaticDifferencePotential and
# DeviceDensityOfStates and load them
########################

fname = sys.argv[1]

device_configuration = nlread(IV_2e19_SK.hdf5, DeviceConfiguration)[0]

potentials=nlread(IV_2e19_SK.hdf5, ElectrostaticDifferencePotential)[0]

ddos = nlread(IV_2e19_SK.hdf5, DeviceDensityOfStates)[0]

########################
# Calculate and plot the spatial resolved DeviceDenstyOfStates
########################

# Determine layer structure
z_coordinates = device_configuration.cartesianCoordinates().inUnitsOf(Ang)[:,2]
for ix,z in enumerate(z_coordinates):
    if ix==0:
        indices_by_layer = []
        tmp =

    elif abs(z-z0) <= 0.1:
        tmp.append(ix)
    else:
        indices_by_layer.append(tmp)
        tmp = [ix]
    z0 = z

# Calculate the average z coordinate of the index atoms
z_average =  numpy.array([sum(z_coordinates[ind])/len(ind) for ind in indices_by_layer])


energies = ddos.energies().inUnitsOf(eV)
ddos_average = [ddos.evaluate(Spin.Sum, ProjectionList(ind)) for ind in indices_by_layer]

X, Y = numpy.meshgrid(z_average,energies)
Z = numpy.array(numpy.array(ddos_average).transpose()).reshape(numpy.shape(X))


# Get electrodes voltages and V_bias
V_L = device_configuration.calculator().electrodeVoltages()[0].inUnitsOf(Volt)
V_R = device_configuration.calculator().electrodeVoltages()[1].inUnitsOf(Volt)
Vbias = V_L - V_R

# Left and right Fermi levels are defined with repsect to the left and right applied biases, respectively.
EF_L = - V_L / 2.

# Contour levels and colors
levels=[0.,
       0.001, 0.002,
       0.003,0.005, 0.01,
       0.02,0.03, 0.05, 0.07, 0.1, 0.15,
       0.2, 0.25,0.3, 0.35, 0.4, 0.5,
       0.6, 0.7, 0.8,0.9,1.0]

colors=[[0,0,0],
       [0, 25*0.001,0.2],[0, 25*0.002,0.4],
       [0, 25*0.003,0.5], [0, 25*0.005,0.5], [0, 20* 0.01,0.5],
       [0.02*4, 0.22,0.5], [0.03*4, 0.25,0.5], [ 0.05*4, 0.25,0.5], [ 0.07*4, 0.25,0.5], [ 0.1*4, 0.25,0.5], [ 0.15*3, 0.25,0.5],
       [ 0.4+0.6*0.2, 0.25, 0.5], [ 0.4+0.6* 0.25, 0.25, 0.5], [ 0.4+0.6*0.3, 0.25, 0.5], [ 0.4+0.6* 0.35, 0.25, 0.5], [ 0.4+0.6* 0.4, 0.25, 0.5], [ 0.4+0.6* 0.5, 0.25, 0.5],
       [ 0.4+0.6* 0.6, 0.25, 0.5], [ 0.4+0.6* 0.7, 0.25, 0.5], [ 0.4+0.6* 0.8, 0.25, 0.5], [ 0.4+0.6*0.9, 0.25, 0.5], [ 0.4+0.6*1.0, 0.25,0.5] ]

# Plot device density of states
pylab.contourf(X,Y,Z, levels=levels, colors=colors, extend='both')


# Plot Fermi energy labels
if Vbias == 0.:
    pylab.text (X[0][0]+2, 0.1,"E$_F$",color='w' )
    pylab.plot([X[0][0], X[0][-1]],[0., 0.], linewidth=1.0, linestyle='--', color='w')
else:
    pylab.text (X[0][-1]-15, Vbias/2-0.2,"E$_F$(R)",color='w' )
    pylab.text (X[0][0]+2, -Vbias/2+0.1,"E$_F$(L)",color='w' )
    # Plot fermi levels
    pylab.plot([X[0][0], X[0][-1]],[Vbias/2., Vbias/2.], linewidth=0.5, linestyle='--', color='w')
    pylab.plot([X[0][0], X[0][-1]],[-Vbias/2., -Vbias/2.], linewidth=0.5, linestyle='--', color='w')

    pylab.plot([X[0][-1], X[0][-1]-10],[Vbias/2., Vbias/2.], linewidth=2.0, linestyle='-', color='w')
    pylab.plot([X[0][0]+10, X[0][0]],[-Vbias/2., -Vbias/2.], linewidth=2.0, linestyle='-', color='w')

########################
# Locate and print band edges from DeviceDensityOfStates.
# Note that the resolution is dictated by the number of energy points used
# in the DeviceDensityOfStates calculation
########################

dos0 = ddos.evaluate(Spin.Sum, ProjectionList(atoms=[0]))
zeros = numpy.where(dos0.inUnitsOf(eV**-1)<0.01)

gap_list = []
for c in zeros:
    gap_list = [dos0.inUnitsOf(eV**-1)[c], energies[c]]

VB_edge=gap_list[1][0]
CB_edge=gap_list[1][-1]
# Calculate the band gap from band edges
#Band_gap = CB_edge - VB_edge
# or enter the band gap manually
Band_gap = 1.18

2
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()

Pages: [1]