Example #1
1
File: stm.py Project: lqcata/ase
from ase.calculators.test import make_test_dft_calculation
from ase.dft.stm import STM

atoms = make_test_dft_calculation()
stm = STM(atoms, [0, 1, 2])
c = stm.get_averaged_current(4.5)
h = stm.scan(c)
Example #2
0
    def __init__(self, atoms):

        self.file = None
        self.is_wf = False
        self.bias = None
        self.ldos = None
        self.heights = None

        if isinstance(atoms, str):
            self.read_3D(atoms)
            self.calc = None
            self.atoms = None
        else:
            if isinstance(atoms, Atoms):
                self.atoms = atoms
                self.calc = atoms.get_calculator()
            else:
                self.calc = atoms
                self.atoms = self.calc.get_atoms()
            self.calc.converge_wave_functions()

            self.gd = self.calc.wfs.gd
            self.offset_c = [int(not a) for a in self.gd.pbc_c]

            STM.__init__(self, self.atoms)
Example #3
0
def plot_stm(ground_state_file, bias, z):
    calc = GPAW(ground_state_file, txt="graphene_stm.txt")
    stm = STM(calc.get_atoms())
    # Get the average constant-height (height = z) current for a reasonable value
    # of the current to use when scanning.
    c = stm.get_averaged_current(bias, z)
    # Scan over the unit cell at constant current.
    # repeat=(3, 5) --> repeat over 3 copies of unit cell in one direction, 5 in another
    x, y, h = stm.scan(bias, c, repeat=(3, 5))

    plt.gca(aspect='equal')
    plt.contourf(x, y, h, 80)  # 80 contour levels
    plt.hot()
    plt.colorbar()
    plt.savefig("graphene_stm_bias_{:.2f}_z_{:.2f}.png".format(bias, z),
                bbox_inches='tight',
                dpi=500)
    plt.clf()
Example #4
0
File: stm.py Project: fuulish/fuase
from ase.calculators.test import make_test_dft_calculation
from ase.dft.stm import STM

atoms = make_test_dft_calculation()
stm = STM(atoms, [0, 1, 2])
c = stm.get_averaged_current(-1.0, 4.5)
x, y, h = stm.scan(-1.0, c)
stm.write('stm.pckl')
x, y, h2 = STM('stm.pckl').scan(-1, c)
assert abs(h - h2).max() == 0
Example #5
0
def test_stm():
    atoms = make_test_dft_calculation()
    stm = STM(atoms, [0, 1, 2])
    c = stm.get_averaged_current(-1.0, 4.5)
    x, y, h = stm.scan(-1.0, c)
    stm.write('stm.pckl')
    x, y, h2 = STM('stm.pckl').scan(-1, c)
    assert abs(h - h2).max() == 0

    stm = STM(atoms, use_density=True)
    c = stm.get_averaged_current(-1, 4.5)
    x, y, I = stm.scan2(-1.0, 1.0)
    stm.write('stm2.pckl')
    x, y, I2 = STM('stm2.pckl').scan2(-1, 1)
    assert abs(I - I2).max() == 0

    stm = STM(atoms, use_density=True)
    c = stm.get_averaged_current(42, 4.5)
    x, y = stm.linescan(42, c, [0, 0], [2, 2])
    assert abs(x[-1] - 2 * 2**0.5) < 1e-13
    assert abs(y[-1] - y[0]) < 1e-13
Example #6
0
calc.read_results()
e = calc.results['energy']
fermi = calc.get_fermi_level()
print('Energy: {0:1.3f}'.format(e))
#===============================================================
# post calculation
calc.post(package='pp',
          plot_num=5,
          sample_bias=0.0735,
          iflag=3,
          output_format=6,
          fileout='stm1_1eV.cube')
# ========================
# Creates: 2d.png, 2d_I.png, line.png, dIdV.png
from ase.dft.stm import STM
from ase.io.cube import read_cube_data
import pickle
ldos, atoms = read_cube_data('scf/al/stm1_1eV.cube')
with open('scf/al/datas.pickle', 'wb') as f:
    pickle.dump([ldos, 1.0, atoms.cell], f)
stm = STM('scf/al/datas.pickle')
z = 8.0
bias = 1.0
c = stm.get_averaged_current(bias, z)
x, y, h = stm.scan(bias, c, repeat=(3, 5))
# print(x, y, h)
import matplotlib.pyplot as plt
plt.gca(aspect='equal')
plt.contourf(x, y, h, 40)
plt.colorbar()
plt.savefig('2d.png')
Example #7
0
 def linescan(self, bias, current, p1, p2, npoints=50, z0=None):
     """Line scan for a given current [nA]"""
     return STM.linescan(self, bias, self.current_to_density(current), p1,
                         p2, npoints, z0)
Example #8
0
# Creates: 2d.png, 2d_I.png, line.png, dIdV.png
from ase.dft.stm import STM
from gpaw import GPAW
calc = GPAW('al111.gpw')
atoms = calc.get_atoms()
stm = STM(atoms)
z = 8.0
bias = 1.0
c = stm.get_averaged_current(bias, z)
x, y, h = stm.scan(bias, c, repeat=(3, 5))
# plot1
import matplotlib.pyplot as plt
plt.gca(aspect='equal')
plt.contourf(x, y, h, 40)
plt.colorbar()
plt.savefig('2d.png')
# plot2
plt.figure()
plt.gca(aspect='equal')
x, y, I = stm.scan2(bias, z, repeat=(3, 5))
plt.contourf(x, y, I, 40)
plt.colorbar()
plt.savefig('2d_I.png')
# plot3
plt.figure()
a = atoms.cell[0, 0]
x, y = stm.linescan(bias, c, [0, 0], [2 * a, 0])
plt.plot(x, y)
plt.savefig('line.png')
# plot4
plt.figure()
Example #9
0
from ase.dft.stm import STM
from gpaw import GPAW
calc = GPAW('al111.gpw')
atoms = calc.get_atoms()
stm = STM(atoms)
z = 8.0
bias = 1.0
c = stm.get_averaged_current(bias, z)
x, y, h = stm.scan(bias, c, repeat=(3, 5))
import matplotlib.pyplot as plt
import numpy as np
plt.gca(aspect='equal')
plt.contourf(x, y, h, 40)
plt.hot()
plt.colorbar()
plt.savefig('2d.png')
plt.figure()
a = atoms.cell[0, 0]
x, y = stm.linescan(bias, c, [0, 0], [2 * a, 0])
plt.plot(x, y)
plt.savefig('line.png')
Example #10
0
from ase.calculators.test import make_test_dft_calculation
from ase.dft.stm import STM

atoms = make_test_dft_calculation()
stm = STM(atoms, [0, 1, 2])
c = stm.get_averaged_current(-1.0, 4.5)
x, y, h = stm.scan(-1.0, c)
stm.write('stm.pckl')
x, y, h2 = STM('stm.pckl').scan(-1, c)
assert abs(h - h2).max() == 0

stm = STM(atoms, use_density=True)
c = stm.get_averaged_current(42, 4.5)
x, y = stm.linescan(42, c, [0, 0], [2, 2])
assert abs(x[-1] - 2 * 2**0.5) < 1e-13
assert abs(y[-1] - y[0]) < 1e-13
Example #11
0
from ase.calculators.test import make_test_dft_calculation
from ase.dft.stm import STM

atoms = make_test_dft_calculation()
stm = STM(atoms, [0, 1, 2])
c = stm.get_averaged_current(-1.0, 4.5)
x, y, h = stm.scan(-1.0, c)
stm.write('stm.pckl')
x, y, h2 = STM('stm.pckl').scan(-1, c)
assert abs(h - h2).max() == 0

stm = STM(atoms, use_density=True)
c = stm.get_averaged_current(-1, 4.5)
x, y, I = stm.scan2(-1.0, 1.0)
stm.write('stm2.pckl')
x, y, I2 = STM('stm2.pckl').scan2(-1, 1)
assert abs(I - I2).max() == 0

stm = STM(atoms, use_density=True)
c = stm.get_averaged_current(42, 4.5)
x, y = stm.linescan(42, c, [0, 0], [2, 2])
assert abs(x[-1] - 2 * 2**0.5) < 1e-13
assert abs(y[-1] - y[0]) < 1e-13