Esempio n. 1
0
 def test_bands(self):
     c = Basis(
         numpy.array(((1.000000, -0.577350, 0.000000),
                      (0.000000, 1.154701, 0.000000),
                      (0.000000, 0.000000, 0.158745))) * 2 * math.pi /
         5.999694 / numericalunits.aBohr)
     c = self.parser.bands(c)
     assert_standard_bands_path(c)
     assert c.values.shape == (400, 34)
     assert c.coordinates.shape == (400, 3)
     testing.assert_allclose(c.coordinates[0, :],
                             (0.500000, -0.288675, 0.000000))
     testing.assert_allclose(
         c.values[0, :],
         numpy.array(
             (0.500, -0.500, 0.185, -0.185, 0.248, -0.248, 0.067, -0.067,
              -0.498, 0.498, -0.498, 0.498, -0.500, 0.500, -0.499, 0.499,
              0.500, -0.500, 0.499, -0.499, -0.498, 0.498, -0.498, 0.498,
              0.499, -0.499, 0.499, -0.499, 0.496, -0.496, 0.496, -0.496,
              0.499, -0.499)) * numericalunits.eV)
     testing.assert_allclose(c.coordinates[-1, :],
                             (-0.503333, -0.282902, 0.000000))
     testing.assert_allclose(
         c.values[-1, :],
         numpy.array(
             (0.500, -0.500, 0.185, -0.185, -0.250, 0.247, -0.065, 0.069,
              0.497, -0.498, 0.498, -0.497, -0.500, 0.500, 0.499, -0.499,
              0.500, -0.500, -0.499, 0.499, -0.498, 0.498, -0.497, 0.498,
              0.499, -0.499, 0.499, -0.499, -0.496, 0.496, 0.496, -0.496,
              -0.499, 0.499)) * numericalunits.eV)
Esempio n. 2
0
 def setUp(self):
     self.cell = Cell(
         Basis((3.19 * angstrom, 3.19 * angstrom, 10 * angstrom, 0, 0, .5),
               kind='triclinic'),
         (
             (1. / 3, 1. / 3, .5),
             (2. / 3, 2. / 3, .6),
             (2. / 3, 2. / 3, .4),
         ),
         ('Mo', 'S', 'S'),
     ).repeated(10, 10)
Esempio n. 3
0
from dfttools.types import Basis, Cell
from dfttools.presentation import svgwrite_unit_cell

from numericalunits import angstrom as a

mos2_basis = Basis(
    (3.19*a, 3.19*a, 20*a, 0,0,.5),
    kind = 'triclinic'
)
d = 1.57722483162840/20

# Unit cell with 3 atoms
mos2_cell = Cell(mos2_basis, (
    (1./3,1./3,.5),
    (2./3,2./3,0.5+d),
    (2./3,2./3,0.5-d),
), ('Mo','S','S'))

# Rectangular supercell with 6 atoms
mos2_rectangular = mos2_cell.supercell(
    (1,0,0),
    (-1,2,0),
    (0,0,1)
)

# Rectangular sheet with a defect
mos2_defect = mos2_rectangular.normalized()
mos2_defect.discard((mos2_defect.values == "S") * (mos2_defect.coordinates[:,1] < .5) * (mos2_defect.coordinates[:,2] < .5))

# Prepare a sheet
mos2_sheet = Cell.stack(*((mos2_rectangular,)*3 + (mos2_defect,) + (mos2_rectangular,)*3), vector = 'y')
Esempio n. 4
0
from dfttools.types import Basis, Cell
from dfttools.presentation import svgwrite_unit_cell

from numericalunits import angstrom as a

si_basis = Basis((3.9 * a / 2, 3.9 * a / 2, 3.9 * a / 2, .5, .5, .5),
                 kind='triclinic')
si_cell = Cell(si_basis, (.5, .5, .5), 'Si')
svgwrite_unit_cell(si_cell, 'output.svg', size=(440, 360), show_cell=True)
Esempio n. 5
0
from dfttools.types import Basis, Cell
from dfttools import presentation

from matplotlib import pyplot
from numericalunits import eV
import numpy

# A reciprocal basis
basis = Basis((1, 1, 1, 0, 0, -0.5), kind='triclinic', meta={"Fermi": 0})

# G-K path
kp = numpy.linspace(0, 1, 100)[:, numpy.newaxis] * numpy.array(
    ((1. / 3, 2. / 3, 0), ))

# A dummy grid Cell with correct kp-path
bands = Cell(
    basis,
    kp,
    numpy.zeros((100, 2), dtype=numpy.float64),
)

# Calculate graphene band
k = bands.cartesian() * numpy.pi / 3.**.5 * 2
e = (1 + 4 * numpy.cos(k[..., 1])**2 +
     4 * numpy.cos(k[..., 1]) * numpy.cos(k[..., 0] * 3.**.5))**.5 * eV

# Set the band values
bands.values[..., 0] = -e
bands.values[..., 1] = e

# Assign some weights
Esempio n. 6
0
from dfttools.types import Basis, Cell
from dfttools.presentation import svgwrite_unit_cell

from numericalunits import angstrom as a

graphene_basis = Basis(
    (2.46*a, 2.46*a, 6.7*a, 0,0,.5),
    kind = 'triclinic'
)

# Unit cell
graphene_cell = Cell(graphene_basis, (
    (1./3,1./3,.5),
    (2./3,2./3,.5),
), ('C','C'))

# Moire matching vectors
moire = [1, 26, 6, 23]

# A top layer
l1 = graphene_cell.supercell(
    (moire[0],moire[1],0),
    (-moire[1],moire[0]+moire[1],0),
    (0,0,1)
)

# A bottom layer
l2 = graphene_cell.supercell(
    (moire[2],moire[3],0),
    (-moire[3],moire[2]+moire[3],0),
    (0,0,1)
Esempio n. 7
0
from dfttools.types import Basis, Grid
from dfttools import presentation

from numericalunits import angstrom
from matplotlib import pyplot
import numpy

grid = Grid(
    Basis((1 * angstrom, 1 * angstrom, 1 * angstrom, 0, 0, -0.5),
          kind='triclinic'),
    (
        numpy.linspace(0, 1, 30, endpoint=False),
        numpy.linspace(0, 1, 30, endpoint=False),
        numpy.linspace(0, 1, 30, endpoint=False),
    ),
    numpy.zeros((30, 30, 30)),
)
grid.values = numpy.prod(numpy.sin(grid.explicit_coordinates() * 2 * numpy.pi),
                         axis=-1)

presentation.matplotlib_scalar(grid,
                               pyplot.gca(), (0.1, 0.1, 0.1),
                               'z',
                               show_cell=True)
pyplot.show()