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
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))
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': [
twist_layers(theta=21.798)) plt.figure(figsize=(6.5, 6.5)) model.plot() plt.title(r"$\theta$ = 21.798 $\degree$") plt.show() model = pb.Model(two_graphene_monolayers(), pb.circle(radius=1.5), twist_layers(theta=12.95)) plt.figure(figsize=(6.5, 6.5)) model.plot() plt.title(r"$\theta$ = 12.95 $\degree$") plt.show() shape = pb.circle(radius=2), model = pb.Model( graphene.monolayer_alt(), # reference stacking is AB (theta=0) shape, hbn_layer(shape=shape), twist_layers(21.787), ) plt.figure(figsize=(6.8, 7.5)) s = model.system plt.subplot(2, 2, 1, title="graphene") s[s.z == 0].plot() plt.subplot(2, 2, 2, title="hBN") s[s.z < 0].plot() plt.subplot(2, 2, (3, 4), title="graphene/hBN") s.plot() plt.show()
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
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]