Skip to content
Snippets Groups Projects
Commit 09875794 authored by Anton Akhmerov's avatar Anton Akhmerov Committed by Christoph Groth
Browse files

fix a bug in TranslationalSymmetry.act and add a test case for it

parent 9c067105
No related branches found
No related tags found
No related merge requests found
......@@ -340,9 +340,19 @@ class TranslationalSymmetry(builder.Symmetry):
raise ValueError(msg.format(self.num_directions, element))
if b is None:
return builder.Site(a.group, a.tag + delta, True)
else:
elif b.group is a.group:
return builder.Site(a.group, a.tag + delta, True), \
builder.Site(b.group, b.tag + delta, True)
else:
m_part = self._get_site_group_data(b.group)[0]
try:
delta2 = ta.dot(m_part, element)
except ValueError:
msg = 'Expecting a {0}-tuple group element, ' + \
'but got `{1}` instead.'
raise ValueError(msg.format(self.num_directions, element))
return builder.Site(a.group, a.tag + delta, True), \
builder.Site(b.group, b.tag + delta2, True)
def to_fd(self, a, b=None):
return self.act(-self.which(a), a, b)
......
......@@ -57,7 +57,6 @@ def test_translational_symmetry():
assert_raises(ValueError, sym.add_site_group, g2)
# Test lattices with dimension smaller than dimension of space.
g2in3 = lattice.make_lattice([[4, 4, 0], [4, -4, 0]])
sym = ts((8, 0, 0))
sym.add_site_group(g2in3)
......@@ -95,6 +94,12 @@ def test_translational_symmetry():
assert_equal(sym.to_fd(site2, shifted(site2, hop)),
(site, shifted(site, hop)))
# Test act for hoppings belonging to different lattices.
g2p = lattice.make_lattice(2 * np.identity(2))
sym = ts(*(2 * np.identity(2)))
assert sym.act((1, 1), g2(0, 0), g2p(0, 0)) == (g2(2, 2), g2p(1, 1))
assert sym.act((1, 1), g2p(0, 0), g2(0, 0)) == (g2p(1, 1), g2(2, 2))
def test_translational_symmetry_reversed():
def assert_equal_symmetry(a, b):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment