Esempio n. 1
0
def test_neighbors():
    lat = lattice.honeycomb(1e-10)
    num_nth_nearest = [len(lat.neighbors(n)) for n in range(5)]
    assert num_nth_nearest == [2, 3, 6, 3, 6]
    lat = lattice.square(1e8)
    num_nth_nearest = [len(lat.neighbors(n)) for n in range(5)]
    assert num_nth_nearest == [1, 2, 2, 2, 4]
    lat = lattice.chain(1e-10)
    num_nth_nearest = [len(lat.neighbors(n)) for n in range(5)]
    assert num_nth_nearest == 5 * [1]
Esempio n. 2
0
def test_symmetry_act():
    lat = lattice.square(norbs=1)
    sym = lattice.TranslationalSymmetry((1, 0), (0, 1))
    site = lat(0, 0)
    hopping = (lat(0, 0), lat(1, 0))
    el = (1, 0)

    # Verify that the dtype of tags of sites returned by 'act' is 'int'
    for el in [el, ta.array(el, int)]:
        assert sym.act(el, site).tag.dtype is int
        assert all(s.tag.dtype is int for s in sym.act(el, *hopping))

    for el in [(1.0, 0), (1.5, 0)]:
        with raises(ValueError):
            sym.act(el, site)
        with raises(ValueError):
            sym.act(ta.array(el), site)
Esempio n. 3
0
def test_act_sites_array():
    lat = lattice.square(norbs=1)

    tags = [(i, j) for i in range(4) for j in range(5)]
    sites = [lat(*tag) for tag in tags]
    site_array = builder.SiteArray(lat, tags=tags)

    for vectors in ([(1, 0)], [(1, 0), (0, 1)]):
        symm = lattice.TranslationalSymmetry(*vectors)
        element = [np.random.randint(5, 10) for _ in range(len(vectors))]
        trans_sites = [symm.act(element, site) for site in sites]

        # these two sites array should be the equal
        trans_sites_array = builder._make_site_arrays(trans_sites)
        new_site_array = symm.act(element, site_array)

        trans_tags_dict = {sa.family.name: sa.tags for sa in trans_sites_array}
        new_tags_dict = {sa.family.name: sa.tags for sa in [new_site_array]}
        for name in trans_tags_dict:
            assert np.all(trans_tags_dict[name] == new_tags_dict[name])
Esempio n. 4
0
def test_monatomic_lattice():
    lat = lattice.square(norbs=1)
    lat2 = lattice.general(np.identity(2), norbs=1)
    lat3 = lattice.square(name='no', norbs=1)
    assert len(set([lat, lat2, lat3, lat(0, 0), lat2(0, 0), lat3(0, 0)])) == 4
Esempio n. 5
0
def test_monatomic_lattice():
    lat = lattice.square()
    lat2 = lattice.general(np.identity(2))
    lat3 = lattice.square(name="no")
    assert len(set([lat, lat2, lat3, lat(0, 0), lat2(0, 0), lat3(0, 0)])) == 4