1
Scripts, Tutorials and Applications / Ask for the setting of the file.py
« on: April 15, 2020, 05:22 »
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
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