Dear everyone:
When I used the script below, I found that it didn’t work at all.
………………………………………………………………………..
(n_u,n_d) = nlread('F:/ATK/graphene_nanoribbon/density.nc', ElectronDensity)
r = (n_u - n_d)/(n_u + n_d)
nlsave('F:/ATK/graphene_nanoribbon/diff.nc', r)
………………………………………………………………………..
the error message is:
Traceback (most recent call last):
File "c:\users\zhangsg\appdata\local\temp\2550619019667366.py", line 5, in <module>
r = (n_u - n_d)/(n_u + n_d)
TypeError: unsupported operand type(s) for /: 'ElectronDensity' and 'ElectronDensity'
NanoLanguageScript execution failure
Anyone can help me?
Another script also didn’t work:
………………………………………………………………………..
import numpy
import pylab
# Read coordinates and densities
coords = nlread('F:/ATK/graphene_nanoribbon/bandstructure.nc', BulkConfiguration)[0]
coords = coords.cartesianCoordinates().inUnitsOf(Angstrom)[:,1:3]
(n_u, n_d) = nlread('F:/ATK/graphene_nanoribbon/density.nc', ElectronDensity)
# Calculate the polarization density
n = (n_u - n_d)/(n_u + n_d)
n = n[:,:,:]
av = numpy.array(n.sum(axis=0))
# Set the 2D axis
y = numpy.array(range(av.shape[0]))/float(av.shape[0])*19.3063
z = numpy.array(range(av.shape[1]))/float(av.shape[1])*2.46100171044
# A 'spin-dependent colorbar'
cdict = {
'red': ((0.0, 0.0, 0.0),
(0.5, 0.0, 1.0),
(1.0, 1.0, 1.0)),
'green': ((0.0, 1.0, 1.0),
(0.5, 0.0, 0.0),
(1.0, 1.0, 1.0)),
'blue': ((0.0, 0.0, 0.0),
(0.5, 1.0, 0.0),
(1.0, 0.0, 0.0))
}
spin_cmap = pylab.matplotlib.colors.LinearSegmentedColormap('my_colormap',cdict,256)
# Build up the plot
pylab.clf()
pylab.figure(figsize=(5,y[-1]/z[-1]*5.))
pylab.xlabel('z / Angstrom')
pylab.ylabel('y / Angstrom')
pylab.contourf(z,y,av,40,colors='k')
pylab.contourf(z,y,av,40,cmap=spin_cmap)
pylab.plot(coords[:,1],coords[:,0],'ko',ms=15.0)
axis = pylab.axis('image')
v = [axis[0],axis[1],4.0,15.3]
pylab.axis(v)
pylab.colorbar()
pylab.savefig('av.png')
…………………………………………………………………………..
the error message is:
Traceback (most recent call last):
File "c:\users\zhangsg\appdata\local\temp\4538397047235477.py", line 12, in <module>
n = (n_u - n_d)/(n_u + n_d)
TypeError: unsupported operand type(s) for /: 'ElectronDensity' and 'ElectronDensity'
NanoLanguageScript execution failure
Almost the same error as the former script.
What should I do to carry out these scripts successfully? Can you help me? Thank you very much in advance, everyone.