Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - wachr

Pages: [1]
1
Dear community,

as I have seen that the creation of a (zero-bias) transmission spectrum, e.g. for a nanotube, takes much longer than the calculation of the bandstructure, I have written a (simple) function that generates a transmission spectrum out of a given bandstructure. The calculation time of the transmission is in the range of seconds and almost not independent on the resolution given.

@ATK-developers / experienced users: What does the implemented ATK-feature do else to generate a transmission spectrum? May this approach used here generate errors for special systems?

Best regards!

Code
from NanoLanguange 
from numpy import * # sorry for this dirty import of numpy
from NanoLanguage import *

def create_transmission_atk(band, emin = -4, emax = 4, npoints = 1000):
    # create transmission function, band is an ATK-bandstructure object
    # [emin, emax] define the energy interval
    # npoints gives the resolution of the interval (+1 is added to this value, later on)
    energies = array(band.evaluate()) # all the energy points of the bandstructure in an array    
    return create_transmission(energies, emin = emin, emax = emax, npoints = npoints)

# the next function may be used also with other programs than ATK, no nano languange is needed

def create_transmission(energies, emin = -4, emax = 4, npoints = 1000):
    # create transmission function
    # energies = the energy points of the bandstructure in an array, each band separated
    epoints = linspace(emin, emax, npoints+1)
    transmission = zeros(npoints+1)
    nbands = size(energies[0,:])
    
    for i in range(nbands): # loop over bands
        tmp = energies[:,i] # band number i
        # print tmp
        l = size(tmp)
        nextreme = [0] # minima and maxima of the band
        de2 = 0; de = 0;
        for j in range(1,l-1):
            de2 = de
            de = tmp[j]-tmp[j-1]
            if (de2*de < 0):
                # does the sign of the energy difference change? (local extremum)
                nextreme.append(j-1)
        nextreme.append(l-1)
        
        for k in range(size(nextreme)-1):
            # all the minima and maxima
            istart = int((tmp[nextreme[k]]-emin) / (emax - emin) * npoints)
            iend = int((tmp[nextreme[k+1]]-emin) / (emax - emin) * npoints)
            if (istart < 0):
                istart = 0
            if (iend < 0):
                iend = 0
            if (istart > npoints ):
                istart = npoints
            if (iend > npoints ):
                iend = npoints
            if istart > iend:
                istart, iend = iend, istart
            transmission[istart:iend] = transmission[istart:iend] + ones(iend - istart)

    return array([epoints, transmission])

2
General Questions and Answers / script stucks on nlsave
« on: August 17, 2011, 12:18 »
Dear QuantumWise-Team,

I have got a question concerning an curious problem: I have written a script to evaluate the number of k-points needed to perform calculations for a nanotube as a first step towards my final simulation.

When I go through step script step by step via the console (also testet as an interactive, parallelized MPAVICH-job on a SMP machine), everything works fine, but when I start the job via the queuing system, ATK seems to hang up while saving the .nc-file, showing me 16 processors fully occupied, but I don't see any progress at all. The resulting .nc-file can be acessed witout any difficulties and doesn't show any error (it contains all the calculated Hamiltonians and my saved structure). The only difference between the script and the manual calculation is the for-loop around the instructions.

So here is the (minimal) script and the according output:

Code
# reading input and so on...

master = processIsMaster()

for k in arange(kstart,kend,kstep): # (1,52,5)
# Define nanotube
NT = NanoTube(n,m,element1,element2,bond_length*Units.Ang,vacuum*Units.Ang) # given parameters
NT = NT.center()
if master:
print "k-number: %d" % (k)

# Basis Set and basic calculator config
basis_set = LDABasis.DoubleZetaPolarized
numerical_accuracy_parameters = NumericalAccuracyParameters(
k_point_sampling = (1, 1, int(k)),
grid_mesh_cutoff = 40.0*Rydberg,
)
calculator = LCAOCalculator(
basis_set=basis_set,
numerical_accuracy_parameters=numerical_accuracy_parameters,
)
NT.setCalculator(calculator)

t1 = time()
force = Forces(NT)
t2 = time()

if master:
print "time for DFT + Forces: %fs" % (t2-t1)
desc = "Nanotube-%d-%d" % (n,m)
nlsave(filename + ".nc", NT, desc)
print "structure \"%s\" successfully written to %.nc" % (desc,filename)
# program stucks here! why?
print >> "%s epsilon %f" % ('%',epsilon)
f = open(filename + "_forces_NT.txt", 'w')
print >> f,"%s epsilon %f" % ('%',epsilon)
force.nlprint(f)
print >> f,""
f.close()

output:
Code
[...]
+------------------------------------------------------------------------------+
| Calculation Converged in 13 steps                                            |
|                                                                              |
| Fermi Level  = -0.131172 Ha                                                  |
+------------------------------------------------------------------------------+
+------------------------------------------------------------------------------+
|                                                                              |
| DFT Calculation  [Finished Wed Aug 17 11:50:15 2011]                         |
|                                                                              |
+------------------------------------------------------------------------------+

                            |--------------------------------------------------|
Calculating Eigenvalues    : ==================================================
Calculating Density Matrix : ==================================================

time for DFT + Forces: 92.478966s


Pages: [1]