Author Topic: LDDOS plot  (Read 2584 times)

0 Members and 1 Guest are viewing this topic.

Offline ruyam

  • Heavy QuantumATK user
  • ***
  • Posts: 60
  • Country: in
  • Reputation: 0
    • View Profile
LDDOS plot
« on: February 25, 2015, 14:03 »
Dear QW staff, Can you let me know what all changes should be done in the following script to plot the LDDOS
Code
# import list with lddos
lddos_list = nlread('lddos.nc', LocalDeviceDensityOfStates)

#Find the z-spacing
dX, dY, dZ = lddos_list[0].volumeElement().convertTo(Ang)
dz = dZ.norm()
shape = lddos_list[0].shape()
z = dz * numpy.arange(shape[2])

# calculate average lddos along z for each spectrum
energies = []
lddos_z = []
for lddos in lddos_list:
    energies = energies + [lddos.energy().inUnitsOf(eV)]
    avg_z = numpy.apply_over_axes(numpy.mean,lddos[:,:,:],[0,1]).flatten()
    lddos_z = lddos_z + [avg_z]

# plot as contour plot
# make variables
energies = numpy.array(energies)
X, Y = numpy.meshgrid(z, energies)
Z = numpy.array(lddos_z).reshape(numpy.shape(X))


import pylab
#plot the LDDOS(E, z)
pylab.xlabel('z (Angstrom)',fontsize=12,family='sans-serif')
pylab.ylabel('Energy (eV)',fontsize=12,family='sans-serif')
contour_values = numpy.linspace(0,0.02,21)
pylab.contourf(X, Y, Z, contour_values)
pylab.colorbar()
pylab.axis([6,16,-3, 3])

pylab.title('Au-DTB-Au : LDDOS(E, z)')
pylab.savefig('lddos.png',dpi=100)


pylab.show()
Actually I got the following error: Traceback (most recent call last):   File "/tmp/0747130924409530.py", line 25, in <module>     X, Y = numpy.meshgrid(z, energies)   File "./build/lib/python2.7/site-packages/numpy/lib/function_base.py", line 3379, in meshgrid   File "./zipdir/NL/CommonConcepts/PhysicalQuantity.py", line 456, in __mul__   File "./zipdir/NL/CommonConcepts/PhysicalQuantity.py", line 249, in unit AttributeError: 'PhysicalQuantity' object has no attribute '_PhysicalQuantity__unit'

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5565
  • Country: dk
  • Reputation: 93
    • View Profile
    • QuantumATK at Synopsys
Re: LDDOS plot
« Reply #1 on: February 25, 2015, 15:29 »
Asked many times already :)

Change to

dz = dZ.norm().inUnitsOf(Angstrom)