I want to write a script that adds several LDOS, but I am having a lot of trouble
This is the script I wrote but I couldn't get anywhere with it.
t=0
energies=numpy.linspace(-0.40308,-0.34967,10)*electronVolt
for i in range(len(energies)):
lo = calculateLocalDensityOfStates(self_consistent_calculation = scf, energy = energies[i], quantum_number = (0.0,0.0))
lo=lo.toArray()
t=t+lo
export_cube_file(t,'file.cube')
if processIsMaster(): file.addToSample(t, 'ldosh', 'Local Density Of States Peak homo')
if processIsMaster(): file.addToSample(atomic_configuration,'ldosh')
You don't write the error message, so I have to guess a bit what goes wrong. Try removing the t=0 line; it makes t an integer, which you then try to add to an array.
I'd go with something like
t = None
energies = numpy.linspace(-0.40308,-0.34967,10)*electronVolt
for i in range(len(energies)):
ldos = calculateLocalDensityOfStates(scf, energy = energies[i], quantum_number = (0.0,0.0))
if t==None:
t = ldos.toArray()
else:
t = t+ldos.toArray()
Sorry for not writing an error message, I was a bit tired that morning.
This code seemed to be working, i just have to analyze the data now. :)
from ATK.TwoProbe import *
from ATK.MPI import processIsMaster
import numpy
# Fetch the calculations.
if processIsMaster(): file = VNLFile('ldosh.vnl')
# Read old atomic configuration
vnl_file = VNLFile("gap.vnl")
atomic_configuration = vnl_file.readAtomicConfigurations()["gap"]
scf = restoreSelfConsistentCalculation('CGsupergap.nc')
scf._attributeContainer().getAttributeContainer('SetupAttributes').setDouble(100.,'MeshCutoff')
t=None
energies=numpy.linspace(-0.40308,-0.34967,10)*electronVolt
for i in range(len(energies)):
ldos = calculateLocalDensityOfStates(scf, energy = energies[i], quantum_number = (0.0,0.0))
if t==None:
t = ldos.toArray()
else:
t = t+ldos.toArray()
ldos._LocalDensityOfStates__local_density_of_states_data =t
if processIsMaster(): file.addToSample(ldos, 'ldosh', 'Local Density Of States Peak homo')
if processIsMaster(): file.addToSample(atomic_configuration,'ldosh'
dE, you mean in your case the energy spacing/resolution? That's part of the statement
energies=numpy.linspace(-0.40308,-0.34967,10)*electronVol
10 means 10 points in the energy range indicated.