Commit 383f8435 authored by Joseph Weston's avatar Joseph Weston
Browse files

set discrete symmetries and conservation law when attaching lead

Previously when 'attach_lead' would expand a lead unit cell to deal
with greater than nearest-neighbor hoppings it would unset the
conservation law and discrete symmetries of the lead.

Closes #303.
parent b1fa479f
......@@ -1681,7 +1681,13 @@ class Builder:
if hop_range > 1:
# Automatically increase the period, potentially warn the user.
new_lead = Builder(sym.subgroup((hop_range,)))
new_lead = Builder(
sym.subgroup((hop_range,)),
conservation_law=lead_builder.conservation_law,
time_reversal=lead_builder.time_reversal,
particle_hole=lead_builder.particle_hole,
chiral=lead_builder.chiral,
)
with reraise_warnings():
new_lead.fill(lead_builder, lambda site: True,
lead_builder.sites(), max_sites=float('inf'))
......
......@@ -843,7 +843,7 @@ def test_fill_sticky():
def test_attach_lead():
fam = builder.SimpleSiteFamily()
fam = builder.SimpleSiteFamily(norbs=1)
fam_noncommensurate = builder.SimpleSiteFamily(name='other')
syst = builder.Builder()
......@@ -878,7 +878,12 @@ def test_attach_lead():
# add some further-than-nearest-neighbor hoppings
hop_range = 3
lead = builder.Builder(VerySimpleSymmetry(1))
lead = builder.Builder(
VerySimpleSymmetry(1),
conservation_law=np.eye(1),
time_reversal=np.eye(1),
particle_hole=np.eye(1),
chiral=np.eye(1))
lead[fam(0)] = 1
for i in range(1, hop_range + 1):
lead[fam(0), fam(i)] = 1
......@@ -886,6 +891,10 @@ def test_attach_lead():
expanded_lead = syst.leads[-1].builder
assert expanded_lead.symmetry.period == hop_range
assert len(list(expanded_lead.sites())) == hop_range
assert expanded_lead.conservation_law is lead.conservation_law
assert expanded_lead.time_reversal is lead.time_reversal
assert expanded_lead.particle_hole is lead.particle_hole
assert expanded_lead.chiral is lead.chiral
# check that we can actually finalize the system
syst.finalized()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment