Dear professor Anders, i got a problem with the script.
***************************************
from NanoLanguage import *
import NLEngine
def makeGridValues(datagrid, cell, origin, unit):
n0, n1, n2 = datagrid.shape
gA, gB, gC = cell
u0 = NLEngine.Cartesian3D(gA[0],gA[1],gA[2])
u1 = NLEngine.Cartesian3D(gB[0],gB[1],gB[2])
u2 = NLEngine.Cartesian3D(gC[0],gC[1],gC[2])
cell_origin = NLEngine.Cartesian3D(origin[0],origin[1],origin[2])
grid_descriptor = NLEngine.GridDescriptor(n0,n1,n2,
NLEngine.UnitCell(u0,u1,u2,cell_origin))
grid3d = NLEngine.RealGrid3D(grid_descriptor,
NLEngine.doubleSequenceToRealVector(datagrid.flatten()),True)
return GridValues(grid3d,unit)
bulk_configuration = nlread("D:/DATA/ATK/band/zig8-1.nc", BulkConfiguration)[0]
conf = nlread("D:/DATA/ATK/band/zig8-1.nc", BulkConfiguration, read_state=False)[0]
dm = bulk_configuration.calculator()._densityMatrixCalculator()
number_of_electrons = int(dm.fermiDistribution().numberOfElectrons())
LUMO = number_of_electrons/2
HOMO = LUMO-1
# Which state to compute?
spin = Spin.Up
state = HOMO
filename = "bloch_z8_HOMO_up.nc"
# Number of points to sample from G to Z
Nk = 20
density = None
for kz in numpy.linspace(0.42,0.5,Nk):
b = BlochState(bulk_configuration, quantum_number=state, k_point=[0,0,kz], spin=spin)
psi = b.toArray()
if density == None:
density = (psi*psi.conj()).real
else:
density += (psi*psi.conj()).real
cell = conf.bravaisLattice().primitiveVectors().inUnitsOf(Bohr)
origin = conf.bravaisLattice().origin().inUnitsOf(Bohr)
grid = makeGridValues(density,cell,origin,unit = eV/eV)
nlsave(filename, grid)
nlsave(filename, conf)
*****************************
the wrong message shows as follows:
Traceback (most recent call last):
File "c:\users\kaypu\appdata\local\temp\0851755004935871.py", line 50, in <module>
grid = makeGridValues(density,cell,origin,unit = eV/eV)
File "c:\users\kaypu\appdata\local\temp\0851755004935871.py", line 20, in makeGridValues
return GridValues(grid3d,unit)
NameError: global name 'GridValues' is not defined
what's wrong with it? i use atk 11.8.2