Exemple #1
0
import pybinding as pb
from pybinding.repository import graphene
import matplotlib.pyplot as plt
from math import pi

pb.pltutils.use_style()

model = pb.Model(
    graphene.monolayer(),
    pb.rectangle(x=2, y=1.2)
)
model.plot()
plt.show()


model = pb.Model(
    graphene.monolayer(),
    pb.regular_polygon(num_sides=6, radius=1.4, angle=pi/6)
)
model.plot()
plt.show()


# A graphene-specific shape which guaranties armchair edges on all sides
model = pb.Model(
    graphene.bilayer(),
    graphene.hexagon_ac(side_width=1)
)
model.plot()
plt.show()
Exemple #2
0
        ux = 2*c * x*y
        uy = c * (x**2 - y**2)
        return x + ux, y + uy, z

    @pb.hopping_energy_modifier
    def strained_hopping(energy, x1, y1, z1, x2, y2, z2):
        l = np.sqrt((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)
        w = l / graphene.a_cc - 1
        return energy * np.exp(-3.37 * w)

    return displacement, strained_hopping


model = pb.Model(
    graphene.monolayer(),
    pb.regular_polygon(num_sides=3, radius=2, angle=pi),
    triaxial_strain(c=0.1)
)
model.system.plot()
plt.show()


plt.figure(figsize=(7, 2.5))
grid = plt.GridSpec(nrows=1, ncols=2)
for block, energy in zip(grid, [0, 0.25]):
    plt.subplot(block)
    plt.title("E = {} eV".format(energy))

    solver = pb.solver.arpack(model, k=30, sigma=energy)
    ldos_map = solver.calc_spatial_ldos(energy=energy, broadening=0.03)
    ldos_map.plot_structure()
Exemple #3
0
import pytest

import numpy as np
import pybinding as pb
from pybinding.repository import graphene, group6_tmd

models = {
    'graphene-monolayer': [graphene.monolayer(), graphene.hexagon_ac(1)],
    'graphene-monolayer-alt': [graphene.monolayer_alt(), pb.rectangle(1.6, 1.4)],
    'graphene-monolayer-4atom': [graphene.monolayer_4atom()],
    'graphene-monolayer-nn': [graphene.monolayer(2), pb.regular_polygon(6, 0.9)],
    'graphene-monolayer-periodic-1d': [graphene.monolayer(), pb.primitive(5, 5),
                                       pb.translational_symmetry(a1=True, a2=False)],
    'graphene-monolayer-periodic-1d-alt': [graphene.monolayer_4atom(), pb.rectangle(1),
                                           pb.translational_symmetry(a1=False, a2=0.6)],
    'graphene-monolayer-periodic-2d': [graphene.monolayer(), pb.primitive(a1=5, a2=5),
                                       pb.translational_symmetry(a1=1, a2=1)],
    'graphene-monolayer-4atom-periodic-2d': [graphene.monolayer_4atom(), pb.rectangle(1),
                                             pb.translational_symmetry(a1=0.6, a2=0.6)],
    'graphene-bilayer': [graphene.bilayer(), graphene.hexagon_ac(0.6)],
}


@pytest.fixture(scope='module', ids=list(models.keys()), params=models.values())
def model(request):
    return pb.Model(*request.param)


def test_pickle_round_trip(model):
    import pickle
    unpickled = pickle.loads(pickle.dumps(model.system))
Exemple #4
0
import pytest

import math
import numpy as np
import pybinding as pb
from pybinding.repository import graphene, examples

polygons = {
    'triangle': pb.regular_polygon(3, radius=1.1),
    'triangle90': pb.regular_polygon(3, radius=1.1, angle=math.pi / 2),
    'diamond': pb.regular_polygon(4, radius=1),
    'square': pb.regular_polygon(4, radius=1, angle=math.pi / 4),
    'pentagon': pb.regular_polygon(5, radius=1),
}


@pytest.fixture(scope='module',
                ids=list(polygons.keys()),
                params=polygons.values())
def polygon(request):
    return request.param


def test_polygon_expected(polygon, baseline, plot_if_fails):
    model = pb.Model(graphene.monolayer(), polygon)
    expected = baseline(model.system)
    plot_if_fails(model.system, expected, "plot")
    plot_if_fails(polygon, polygon, "plot")
    assert pytest.fuzzy_equal(model.system, expected, 1.e-4, 1.e-6)

#!/usr/bin python
# -*- encoding: utf-8 -*-
'''
@Author  :   Celeste Young
@File    :   石墨烯单层.py    
@Time    :   2021/9/18 16:25  
@E-mail  :   [email protected]
@Tips    :   
'''
"""Several finite-sized systems created using builtin lattices and shapes"""
import pybinding as pb
from pybinding.repository import graphene
import matplotlib.pyplot as plt
from math import pi

pb.pltutils.use_style()

model_1 = pb.Model(
    graphene.monolayer(),
    # pb.rectangle(x=2, y=1.2)
    pb.regular_polygon(num_sides=6, radius=1.4))
model_2 = pb.Model(graphene.bilayer(), graphene.hexagon_ac(side_width=1))

model_3 = pb.Model(
    graphene.monolayer(),
    # pb.rectangle(x=2, y=1.2)
    pb.regular_polygon(num_sides=6, radius=1.4, angle=0))
model_2.plot()
# model_2.plot()
plt.show()
Exemple #6
0
import pytest

import pybinding as pb
from pybinding.repository import graphene

models = {
    'graphene-monolayer': [graphene.monolayer(), graphene.hexagon_ac(1)],
    'graphene-monolayer-alt': [graphene.monolayer_alt(), pb.rectangle(1.6, 1.4)],
    'graphene-monolayer-4atom': [graphene.monolayer_4atom()],
    'graphene-monolayer-nn': [graphene.monolayer(2), pb.regular_polygon(6, 0.9)],
    'graphene-monolayer-periodic-1d': [graphene.monolayer(), pb.primitive(5, 5),
                                       pb.translational_symmetry(a1=True, a2=False)],
    'graphene-monolayer-periodic-1d-alt': [graphene.monolayer_4atom(), pb.rectangle(1),
                                           pb.translational_symmetry(a1=False, a2=0.6)],
    'graphene-monolayer-periodic-2d': [graphene.monolayer(), pb.primitive(a1=5, a2=5),
                                       pb.translational_symmetry(a1=1, a2=1)],
    'graphene-monolayer-4atom-periodic-2d': [graphene.monolayer_4atom(), pb.rectangle(1),
                                             pb.translational_symmetry(a1=0.6, a2=0.6)],
    'graphene-bilayer': [graphene.bilayer(), graphene.hexagon_ac(0.6)],
}


@pytest.fixture(scope='module', ids=list(models.keys()), params=models.values())
def model(request):
    return pb.Model(*request.param)


def test_api():
    model = pb.Model(graphene.monolayer(), pb.primitive(2, 2))
    system = model.system
Exemple #7
0
import pytest

import math
import numpy as np
import pybinding as pb
from pybinding.repository import graphene


polygons = {
    'triangle': pb.regular_polygon(3, radius=1.1),
    'triangle90': pb.regular_polygon(3, radius=1.1, angle=math.pi/2),
    'diamond': pb.regular_polygon(4, radius=1),
    'square': pb.regular_polygon(4, radius=1, angle=math.pi/4),
    'pentagon': pb.regular_polygon(5, radius=1),
}


@pytest.fixture(scope='module', ids=list(polygons.keys()), params=polygons.values())
def polygon(request):
    return request.param


def test_polygon_api():
    with pytest.raises(RuntimeError) as excinfo:
        pb.Polygon([0, 0], [0, 1])
    assert "at least 3 sides" in str(excinfo.value)


def test_polygon(polygon, baseline, plot_if_fails):
    model = pb.Model(graphene.monolayer(), polygon)
    expected = baseline(model.system)

def ring(inner_radius, outer_radius):
    def contains(x, y, z):
        r = np.sqrt(x**2 + y**2)
        return np.logical_and(inner_radius < r, r < outer_radius)

    return pb.FreeformShape(contains,
                            width=[2 * outer_radius, 2 * outer_radius])


#
# shape = ring(inner_radius=1.4, outer_radius=2)
# shape.plot()
rec = pb.rectangle(x=6, y=1)
hexa = pb.regular_polygon(num_sides=6, radius=1.92, angle=np.pi / 6)
cir = pb.circle(radius=0.6)
shape = rec + hexa - cir
model = pb.Model(
    graphene.monolayer(),
    # trapezoid(a=3.2, b=1.4, h=1.5)
    # circle(radius=2.5)
    shape)
model.plot()
# model.shape.plot()
# model = pb.Model(
#     graphene.monolayer(),
#     pb.primitive(a1=6, a2=6)  # 在a1 a2方向上扩胞
# )
# model.plot()
plt.show()