Beispiel #1
0
    def notestSaveReadWaveFunctionsTest(self):
        band = 21
        kn = 4
        ws = 2
        potential = Topographic(voltage=-2)
        rho, r, dh_cell = readCubeDensity(label=test_label)
        dh = np.array(map(vectorLength, dh_cell))
        rho = rho.sum(axis=0)
        c, variables, domain = surfaceIntegrator(rho=rho, variables=r, rho0=1e-3, DS=1)
        thick_surface = vectorLength(c, axis=0) > 1e-9
        take_z = thick_surface.sum(axis=0)
        take_z = take_z.sum(axis=0) > 0

        wf, r, dh_cell = readCubeWavefunction(label=test_label, band=band, kn=kn)
        EF, eigs= readEigenvalues(label=test_label)
        kpts = readKpoints(label=test_label)
        energy = eigs[kn-1, band-1, 0]
        we = STMWeighting(energies=[energy], potential=potential, EF=EF)
        we = we[0]

        kpt, wk = kpts[kn-1]
        kappa = getVacuumDecayRate(energy)
        eikr = phaseFactor(kpt, r)
        u = wf/eikr
        grad_u = np.array(np.gradient(u, *dh))
        A = (c*grad_u).sum(axis=0)
        B = u*c
        A=A[:,:,take_z]
        B=B[:,:,:,take_z]
        r=r[:,:,:,take_z]
        u, variables = propagateWaveFunction(
                A=A,
                B=B,
                kpt=kpt,
                r=r,
                kappa=kappa,
                height=10,
                )
        weight = we*ws*wk
        Itest = weight*abs(u)**2

        self.assertFalse(os.path.exists(testfile))
        saveWavefunctionsToPlane(filename=testfile, label=test_label)
        self.assertTrue(os.path.exists(testfile))
        f = netcdf.netcdf_file(testfile, 'r')
        self.assertTrue(len(f.variables.keys()) >0)
        f.close()
        I, r = STMFromFile(
                label=join(test_folder, 'test'),
                potentials=[potential],
                cells=None,
                )
        self.assertArraysEqual(np.log(Itest[0,0]), np.log(I[0,0,0]), 5)
Beispiel #2
0
def readInfoForSTMSimulation(label='./siesta'):
    kpts = readKpoints(label=label)
    EF, eigs = readEigenvalues(label=label)

    n_eigs = []
    sh = eigs.shape
    for kn, band, spin in itertools.product(range(sh[0]), range(sh[1]), range(sh[2])):
        n_eigs.append((eigs[kn, band, spin], kn, band, spin))

    n_eigs.sort()
    eigs = n_eigs

    return eigs, kpts, EF