示例#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()
示例#2
0
import pytest

import pybinding as pb
from pybinding.repository import graphene

lattices = {
    'graphene-monolayer': graphene.monolayer(),
    'graphene-monolayer-alt': graphene.monolayer_alt(),
    'graphene-monolayer-4atom': graphene.monolayer_4atom(),
    'graphene-monolayer-nn': graphene.monolayer(2),
    'graphene-bilayer': graphene.bilayer(),
}


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


@pytest.fixture
def mock_lattice():
    a_cc, a, t = 1, 1.73, 1
    lat = pb.Lattice([a, 0], [0.5 * a, 0.866 * a])
    lat.add_sublattices(['a', (0, -a_cc / 2)], ['b', (0, a_cc / 2)])
    lat.add_hoppings([(0, 0), 'a', 'b', t], [(1, -1), 'a', 'b', t],
                     [(0, -1), 'a', 'b', t])
    lat.min_neighbors = 2
    return lat
示例#3
0
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))
    assert pytest.fuzzy_equal(model.system, unpickled)


def test_expected(model, baseline, plot_if_fails):
示例#4
0
def test_system_plot(compare_figure):
    model = pb.Model(graphene.bilayer(), graphene.hexagon_ac(0.1))
    with compare_figure() as chk:
        model.system.plot()
    assert chk.passed
示例#5
0
#!/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()
示例#6
0
import pytest

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

lattices = {
    "graphene-monolayer": graphene.monolayer(),
    "graphene-monolayer-nn": graphene.monolayer(2),
    "graphene-monolayer-4atom": graphene.monolayer_4atom(),
    "graphene-bilayer": graphene.bilayer(),
}


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


def test_pickle_round_trip(lattice):
    import pickle
    unpickled = pickle.loads(pickle.dumps(lattice))
    assert pytest.fuzzy_equal(lattice, unpickled)


def test_expected(lattice, baseline, plot_if_fails):
    expected = baseline(lattice)
    plot_if_fails(lattice, expected, "plot")
    assert pytest.fuzzy_equal(lattice, expected)
示例#7
0
def test_system_plot(compare_figure):
    model = pb.Model(graphene.bilayer(), graphene.hexagon_ac(0.1))
    with compare_figure() as chk:
        model.system.plot()
    assert chk.passed
示例#8
0
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

    idx = system.num_sites // 2
    assert idx == system.find_nearest(system.xyz[idx])
    assert idx == system.find_nearest(system.xyz[idx], system.sublattices[idx])
示例#9
0
import pytest

import pybinding as pb
from pybinding.repository import graphene

lattices = {
    'graphene-monolayer': graphene.monolayer(),
    'graphene-monolayer-alt': graphene.monolayer_alt(),
    'graphene-monolayer-4atom': graphene.monolayer_4atom(),
    'graphene-monolayer-nn': graphene.monolayer(2),
    'graphene-bilayer': graphene.bilayer(),
}


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


@pytest.fixture
def mock_lattice():
    a_cc, a, t = 1, 1.73, 1
    lat = pb.Lattice([a, 0], [0.5 * a, 0.866 * a])
    lat.add_sublattices(
        ['a', (0, -a_cc/2)],
        ['b', (0,  a_cc/2)]
    )
    lat.add_hoppings(
        [(0,  0), 'a', 'b', t],
        [(1, -1), 'a', 'b', t],
        [(0, -1), 'a', 'b', t]