def test_structure_map_plot(compare_figure): model = pb.Model(graphene.monolayer(), pb.rectangle(0.8)) structure_map = model.structure_map(model.system.x * model.system.y) with compare_figure() as chk: structure_map.plot(site_radius=(0.03, 0.05)) assert chk.passed
def test_warnings(): """Extra arguments and ignored by pybinding -- warn users""" kwant_sys = pb.Model(graphene.monolayer(), pb.rectangle(1, 1)).tokwant() with pytest.warns(UserWarning): kwant_sys.hamiltonian_submatrix(sparse=True, args=(1, )) with pytest.warns(UserWarning): kwant_sys.hamiltonian_submatrix(sparse=True, params=dict(v=1))
def test_hamiltonian_submatrix_sites(): """The `to_sites` and `from_sites` arguments are not supported""" kwant_sys = pb.Model(graphene.monolayer(), pb.rectangle(1, 1)).tokwant() with pytest.raises(RuntimeError) as excinfo: kwant_sys.hamiltonian_submatrix(to_sites=1, from_sites=1) assert "not supported" in str(excinfo.value)
def test_structure_map_plot(compare_figure): model = pb.Model(graphene.monolayer(), pb.rectangle(0.8)) system = model.system data = np.arange(system.num_sites) structure_map = pb.results.StructureMap.from_system(data, system) with compare_figure() as chk: structure_map.plot_structure(site_radius=(0.03, 0.05), cbar_props=False) assert chk.passed
def pb_model(v=0, length=2, width=10): model = pb.Model( square_lattice(d=1, t=1), pb.rectangle(x=length, y=width), potential_well(v) ) model.attach_lead(-1, [0, -width / 2 - 0.1], [0, width / 2]) model.attach_lead(+1, [0, -width / 2 - 0.1], [0, width / 2]) return model
def test_structure_map_plot(compare_figure): model = pb.Model(graphene.monolayer(), pb.rectangle(0.8)) data = [3, 11, 19, 26, 5, 13, 21, 0, 7, 15, 23, 2, 9, 17, 10, 18, 25, 4, 12, 20, 27, 6, 14, 22, 1, 8, 16, 24] structure_map = model.structure_map(data) with compare_figure() as chk: structure_map.plot(site_radius=(0.03, 0.05)) assert chk.passed
def square_model(width=2, height=3): def square_lattice(d=1, t=1): lat = pb.Lattice(a1=[d, 0], a2=[0, d]) lat.add_sublattices(('A', [0, 0])) lat.add_hoppings( ([0, 1], 'A', 'A', -t), ([1, 0], 'A', 'A', -t), ) return lat return pb.Model(square_lattice(), pb.rectangle(width, height))
def test_structure_map_plot(compare_figure): import matplotlib.pyplot as plt model = pb.Model(graphene.monolayer(), pb.rectangle(0.8)) structure_map = model.structure_map(model.system.x * model.system.y) with compare_figure() as chk: structure_map.plot(site_radius=(0.03, 0.05)) plt.gca().set_aspect("equal", "datalim") assert chk.passed
def make_model(v0=0): model = pb.Model( graphene.monolayer().with_min_neighbors(1), pb.rectangle(length, width), potential_barrier(v0), ) model.attach_lead( -1, pb.line([-length / 2, -width / 2], [-length / 2, width / 2])) model.attach_lead( +1, pb.line([length / 2, -width / 2], [length / 2, width / 2])) return model
def test_hamiltonian_submatrix_orbitals(lattice, norb): """Return the number of orbitals at each site in addition to the Hamiltonian""" model = pb.Model(lattice, pb.rectangle(1, 1)) kwant_sys = model.tokwant() matrix, to_norb, from_norb = kwant_sys.hamiltonian_submatrix( sparse=True, return_norb=True) assert matrix.shape == model.hamiltonian.shape assert to_norb.size == model.system.num_sites assert from_norb.size == model.system.num_sites assert np.all(to_norb == norb) assert np.all(from_norb == norb)
def test_multiorbital_onsite(): def multi_orbital_lattice(): lat = pb.Lattice([1, 0], [0, 1]) tau_z = np.array([[1, 0], [0, -1]]) tau_x = np.array([[0, 1], [1, 0]]) lat.add_sublattices(("A", [0, 0], tau_z + 2 * tau_x), ("B", [0, 0.1], 0.5), ("C", [0, 0.2], [1, 2, 3])) lat.add_hoppings(([0, -1], "A", "A", 3 * tau_z), ([1, 0], "A", "A", 3 * tau_z), ([0, 0], "B", "C", [[2, 3, 4]])) return lat capture = {} @pb.onsite_energy_modifier def onsite(energy, x, y, z, sub_id): capture[sub_id] = [v.copy() for v in (energy, x, y, z)] return energy def assert_onsite(name, **expected): energy, x, y, z = capture[name] assert energy.shape == expected["shape"] expected_energy = np.array(expected["energy"]) for index in np.ndindex(*expected_energy.shape): expected_slice = np.full(energy.shape[-1], expected_energy[index]) assert pytest.fuzzy_equal(energy[index], expected_slice) assert pytest.fuzzy_equal(x, expected["x"]) assert pytest.fuzzy_equal(y, expected["y"]) assert pytest.fuzzy_equal(z, expected["z"]) model = pb.Model(multi_orbital_lattice(), pb.rectangle(2, 1), onsite) assert model.system.num_sites == 6 assert model.hamiltonian.shape[0] == 12 assert_onsite("A", shape=(2, 2, 2), energy=[[1, 2], [2, -1]], x=[0, 1], y=[0, 0], z=[0, 0]) assert_onsite("B", shape=(2,), energy=[0.5], x=[0, 1], y=[0.1, 0.1], z=[0, 0]) assert_onsite("C", shape=(3, 3, 2), energy=[[1, 0, 0], [0, 2, 0], [0, 0, 3]], x=[0, 1], y=[0.2, 0.2], z=[0, 0])
def test_api(): lattice = graphene.monolayer() shape = pb.rectangle(1) model = pb.Model(lattice, shape) assert model.lattice is lattice assert model.shape is shape # empty sequences are no-ops model.add(()) model.add([]) with pytest.raises(RuntimeError) as excinfo: model.add(None) assert "None" in str(excinfo.value)
def pb_model(v=0, length=2, width=10): def square_lattice(d, t): lat = pb.Lattice(a1=[d, 0], a2=[0, d]) lat.add_sublattices(("A", [0, 0], 4 * t)) lat.add_hoppings(([0, 1], "A", "A", -t), ([1, 0], "A", "A", -t)) return lat @pb.onsite_energy_modifier def potential_well(energy, x): energy[np.logical_and(x >= 0, x <= 1)] -= v return energy model = pb.Model(square_lattice(d=1, t=1), pb.rectangle(length, width), potential_well) model.attach_lead(-1, pb.line([0, -width / 2 - 0.1], [0, width / 2])) model.attach_lead(+1, pb.line([0, -width / 2 - 0.1], [0, width / 2])) return model
def model_ssh(t1=1, t2=1, m=0, n=26, m1=0): """returns SSH model Args: t1 (int, optional): incell interaction t2 (int, optional): inter cell interaction m (int, optional): mass gap n (int, optional): number of cells m1 (int, optional): alternate mass gap difference Returns: TYPE: Description """ def mass_term(delta): """Break sublattice symmetry with opposite A and B onsite energy""" @pb.onsite_energy_modifier def potential(energy, x, y, z, sub_id): pot = [] for i in range(len(x)): if x[i] < 0: if sub_id in ['A']: pot.append(-delta) if sub_id in ['B']: pot.append(delta) else: #if ang<=0 and ang>-180: if sub_id in ['A']: pot.append(delta) if sub_id in ['B']: pot.append(-delta) return np.array(pot) return potential d = 1 t1 = t1 t2 = t2 m = m m1 = m1 lattice = pb.Lattice(a1=[d]) lattice.add_sublattices(('A', [0], 0), ('B', [.5], 0)) lattice.add_hoppings(([0, 0], 'A', 'B', t1), ([1, 0], 'B', 'A', t2)) model = pb.Model(lattice, pb.rectangle(n), mass_term(m), pb.translational_symmetry(a1=False)) return model
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene models = { 'graphene-pristine': [graphene.monolayer(), pb.rectangle(15)], 'graphene-pristine-oversized': [graphene.monolayer(), pb.rectangle(20)], 'graphene-const_potential': [graphene.monolayer(), pb.rectangle(15), pb.constant_potential(0.5)], 'graphene-magnetic_field': [graphene.monolayer(), pb.rectangle(15), graphene.constant_magnetic_field(1e3)], } @pytest.fixture(scope='module', ids=list(models.keys()), params=models.values()) def model(request): return pb.Model(*request.param) @pytest.fixture(scope='module') def kpm(model): return [pb.greens.kpm(model, optimization_level=i) for i in range(4)] def test_ldos(kpm, baseline, plot_if_fails): energy = np.linspace(0, 2, 25) results = [k.calc_ldos(energy, broadening=0.15, position=(0, 0)) for k in kpm] expected = pb.results.LDOS(energy, baseline(results[0].ldos.astype(np.float32)))
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': [
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene models = { 'graphene-pristine': [graphene.monolayer(), pb.rectangle(15)], 'graphene-pristine-oversized': [graphene.monolayer(), pb.rectangle(20)], 'graphene-const_potential': [graphene.monolayer(), pb.rectangle(15), pb.constant_potential(0.5)], 'graphene-magnetic_field': [ graphene.monolayer(), pb.rectangle(15), graphene.constant_magnetic_field(1e3) ], } @pytest.fixture(scope='module', ids=list(models.keys()), params=models.values()) def model(request): return pb.Model(*request.param) @pytest.fixture(scope='module')
def test_multiorbital_onsite(): def multi_orbital_lattice(): lat = pb.Lattice([1, 0], [0, 1]) tau_z = np.array([[1, 0], [0, -1]]) tau_x = np.array([[0, 1], [1, 0]]) lat.add_sublattices(("A", [0, 0], tau_z + 2 * tau_x), ("B", [0, 0.1], 0.5), ("C", [0, 0.2], [1, 2, 3])) lat.add_hoppings(([0, -1], "A", "A", 3 * tau_z), ([1, 0], "A", "A", 3 * tau_z), ([0, 0], "B", "C", [[2, 3, 4]])) return lat capture = {} @pb.onsite_energy_modifier def onsite(energy, x, y, z, sub_id): capture[sub_id] = [v.copy() for v in (energy, x, y, z)] return energy def assert_positions(name, **expected): _, x, y, z = capture[name] assert pytest.fuzzy_equal(x.squeeze(), expected["x"]) assert pytest.fuzzy_equal(y.squeeze(), expected["y"]) assert pytest.fuzzy_equal(z.squeeze(), expected["z"]) def assert_onsite(name, **expected): energy, *_ = capture[name] assert energy.shape == expected["shape"] for i in range(energy.shape[0]): assert pytest.fuzzy_equal(energy[i], expected["energy"]) model = pb.Model(multi_orbital_lattice(), pb.rectangle(2, 1), onsite) assert model.system.num_sites == 6 assert model.hamiltonian.shape[0] == 12 assert_positions("A", x=[0, 1], y=[0, 0], z=[0, 0]) assert_positions("B", x=[0, 1], y=[0.1, 0.1], z=[0, 0]) assert_positions("C", x=[0, 1], y=[0.2, 0.2], z=[0, 0]) assert_onsite("A", shape=(2, 2, 2), energy=[[1, 2], [2, -1]]) assert_onsite("B", shape=(2, ), energy=[0.5]) assert_onsite("C", shape=(2, 3, 3), energy=[[1, 0, 0], [0, 2, 0], [0, 0, 3]]) @pb.onsite_energy_modifier def onsite_mod(energy, x, y, z, sub_id): if sub_id == "A": energy += sub_id.eye * (x > -1) elif sub_id == "B": energy *= 2 elif sub_id == "C": energy += [[0, 1, 0]] capture[sub_id] = [v.copy() for v in (energy, x, y, z)] return energy model = pb.Model(multi_orbital_lattice(), pb.rectangle(2, 1), onsite_mod) assert model.system.num_sites == 6 assert model.hamiltonian.shape[0] == 12 assert_onsite("A", shape=(2, 2, 2), energy=[[2, 2], [2, 0]]) assert_onsite("B", shape=(2, ), energy=[1]) assert_onsite("C", shape=(2, 3, 3), energy=[[1, 1, 0], [0, 3, 0], [0, 1, 3]])
def model(): return pb.Model(graphene.monolayer(), pb.rectangle(1))
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
def pb_model(v=0, length=2, width=10): model = pb.Model(square_lattice(d=1, t=1), pb.rectangle(x=length, y=width), potential_well(v)) model.attach_lead(-1, pb.line([0, -width / 2 - 0.1], [0, width / 2])) model.attach_lead(+1, pb.line([0, -width / 2 - 0.1], [0, width / 2])) return model
return pb.FreeformShape(contains, width=[2 * radius, 2 * radius]) 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()
"""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 = 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()
('B2', [0, 3*graphene.a_cc/2, -c0])) lat.register_hopping_energies({'t': graphene.t, 't_layer': -0.4}) lat.add_hoppings( # layer 1 ([ 0, 0], 'A1', 'B1', 't'), ([ 1, -1], 'A1', 'B1', 't'), ([ 0, -1], 'A1', 'B1', 't'), # layer 2 ([ 0, 0], 'A2', 'B2', 't'), ([ 1, -1], 'A2', 'B2', 't'), ([ 0, -1], 'A2', 'B2', 't'), # interlayer ([ 0, 0], 'B1', 'A2', 't_layer') ) lat.min_neighbors = 2 return lat model = pb.Model( bilayer_graphene(), pb.rectangle(1.3), # nm pb.translational_symmetry(a1=True, a2=False) ) model.plot() model.lattice.plot_vectors(position=[-0.6, 0.3]) # nm plt.show() solver = pb.solver.lapack(model) bands = solver.calc_bands(-pi/graphene.a, pi/graphene.a) bands.plot(point_labels=['$-\pi / a$', '$\pi / a$']) plt.show()
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene solvers = ['arpack'] if hasattr(pb._cpp, 'FEAST'): solvers.append('feast') models = { 'graphene-magnetic_field': {'model': [graphene.monolayer(), pb.rectangle(6), graphene.constant_magnetic_field(10)], 'arpack': [30], 'feast': [(-0.1, 0.1), 18]}, } @pytest.fixture(scope='module', ids=list(models.keys()), params=models.values()) def model_ex(request): return pb.Model(*request.param['model']), request.param @pytest.fixture(scope='module', params=solvers) def solver(request, model_ex): model, solver_cfg = model_ex make_solver = getattr(pb.solver, request.param) solver = make_solver(model, *solver_cfg[request.param]) solver.solve() return solver
# - scaling, if None it's automatic, if present select spectrum_bound=[e_min, e_max] configuration = kite.Configuration(divisions=[nx, ny], length=[l1, l2], boundaries=[True, True], is_complex=False, precision=1, spectrum_range=[-10, 10]) # require the calculation of DOS num_moments = 1000 calculation = kite.Calculation(configuration) calculation.dos(num_moments=num_moments, num_random=1, num_disorder=1, num_points=1000) # make modification object which caries info about # for a quick check, let's make a Pybinding model and check the DOS model = pb.Model(lattice, pb.rectangle(100, 100), pb.translational_symmetry(a1=50, a2=50)) # if you would like to specify Disorder, use other function that takes of converting KITE to Pybinding disorder objects # model = kite.make_pybinding_model(lattice) # dos = pb.kpm(model).calc_dos(np.linspace(-4, 4, 2000), broadening=1e-2, num_random=1) # dos.plot() # plt.show() # configure the *.h5 file kite.config_system(lattice, configuration, calculation, filename='tblg_{:.3f}.h5'.format(angle))
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene models = { 'graphene-pristine': [graphene.monolayer(), pb.rectangle(15)], 'graphene-pristine-oversized': [graphene.monolayer(), pb.rectangle(20)], 'graphene-const_potential': [graphene.monolayer(), pb.rectangle(15), pb.constant_potential(0.5)], 'graphene-magnetic_field': [graphene.monolayer(), pb.rectangle(15), graphene.constant_magnetic_field(1e3)], } configurations = [ {'matrix_format': "CSR", 'optimal_size': False, 'interleaved': False}, {'matrix_format': "CSR", 'optimal_size': True, 'interleaved': False}, {'matrix_format': "CSR", 'optimal_size': False, 'interleaved': True}, {'matrix_format': "ELL", 'optimal_size': True, 'interleaved': True}, ] @pytest.fixture(scope='module', ids=list(models.keys()), params=models.values()) def model(request): return pb.Model(*request.param) @pytest.fixture(scope='module') def kpm(model): strategies = [pb.chebyshev.kpm(model, **c) for c in configurations]
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene, group6_tmd models = { 'graphene-pristine': [graphene.monolayer(), pb.rectangle(15)], 'graphene-pristine-oversized': [graphene.monolayer(), pb.rectangle(20)], 'graphene-const_potential': [graphene.monolayer(), pb.rectangle(15), pb.constant_potential(0.5)], 'graphene-magnetic_field': [ graphene.monolayer(), pb.rectangle(15), graphene.constant_magnetic_field(1e3) ], } @pytest.fixture(scope='module', ids=list(models.keys()), params=models.values()) def model(request): return pb.Model(*request.param) ldos_models = {
The `y0` argument is the position of the junction, while `v1` and `v2` are the values of the potential (in eV) before and after the junction. """ @pb.onsite_energy_modifier def potential(energy, y): energy[y < y0] += v1 energy[y >= y0] += v2 return energy return potential model = pb.Model( graphene.monolayer(), pb.rectangle(1.2), # width in nanometers pb.translational_symmetry(a1=True, a2=False), mass_term(delta=2.5), # eV pn_juction(y0=0, v1=-2.5, v2=2.5) # y0 in [nm] and v1, v2 in [eV] ) model.system.plot() plt.show() # plot the potential: note that pn_junction cancels out delta on some sites model.onsite_map.plot_structure(cmap="coolwarm", site_radius=0.04) plt.show() # compute the bands solver = pb.solver.lapack(model) a = graphene.a_cc * sqrt(3) # nanoribbon unit cell length
The `y0` argument is the position of the junction, while `v1` and `v2` are the values of the potential (in eV) before and after the junction. """ @pb.onsite_energy_modifier def potential(energy, y): energy[y < y0] += v1 energy[y >= y0] += v2 return energy return potential model = pb.Model( graphene.monolayer(), pb.rectangle(1.2), # width in nanometers pb.translational_symmetry(a1=True, a2=False), mass_term(delta=2.5), # eV pn_juction(y0=0, v1=-2.5, v2=2.5) # y0 in [nm] and v1, v2 in [eV] ) model.system.plot() plt.show() # plot the potential: note that pn_junction cancels out delta on some sites model.onsite_map.plot_structure(cmap="coolwarm", site_radius=0.04) pb.pltutils.colorbar(label="U (eV)") plt.show() # compute the bands solver = pb.solver.lapack(model)
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene solvers = ['arpack'] if hasattr(pb._cpp, 'FEAST'): solvers.append('feast') models = { 'graphene-magnetic_field': { 'model': [ graphene.monolayer(), pb.rectangle(6), graphene.constant_magnetic_field(10) ], 'arpack': [30], 'feast': [(-0.1, 0.1), 18] }, } @pytest.fixture(scope='module', ids=list(models.keys()), params=models.values()) def model_ex(request): return pb.Model(*request.param['model']), request.param @pytest.fixture(scope='module', params=solvers)