Skip to content
Snippets Groups Projects
Commit b3d2b7c5 authored by Joseph Weston's avatar Joseph Weston
Browse files

add support for conservation laws and discrete symmetries to wraparound

No extra logic is added to wraparound, we just transfer over extra
Builder attributes to the wrapped around system, being careful to
set TR and PH symmetry to None (for the k-space Hamiltonian these
are only satisfied at special points in the Brillouin zone, and
currently there is no way in Kwant to specify that symmetries only
appear for certain parameter values).
parent aa6c84b4
Branches
No related tags found
No related merge requests found
......@@ -166,3 +166,29 @@ def test_signatures():
params, takes_kwargs = get_parameters(wrapped_syst[hopping])
assert params[2:] == params_should_be
assert takes_kwargs == should_take_kwargs
def test_symmetry():
syst = _simple_syst(kwant.lattice.square())
matrices = [np.random.rand(2, 2) for i in range(4)]
laws = (matrices, [(lambda a: m) for m in matrices])
for cl, ch, ph, tr in laws:
syst.conservation_law = cl
syst.chiral = ch
syst.particle_hole = ph
syst.time_reversal = tr
wrapped = wraparound(syst)
assert wrapped.time_reversal is None
assert wrapped.particle_hole is None
for attr in ('conservation_law', 'chiral'):
new = getattr(wrapped, attr)
orig = getattr(syst, attr)
if callable(orig):
params, _ = get_parameters(new)
assert params[1:] == ['k_x', 'k_y']
assert np.all(orig(None) == new(None, None, None))
else:
assert np.all(orig == new)
......@@ -228,6 +228,18 @@ def wraparound(builder, keep=None, *, coordinate_names=('x', 'y', 'z')):
sym = TranslationalSymmetry(*periods)
momenta.pop(keep)
# Wrapped around system retains conservation law and chiral symmetry.
# We use 'bind_site' to add the momenta arguments if required.
cons = builder.conservation_law
ret.conservation_law = bind_site(cons) if callable(cons) else cons
chiral = builder.chiral
ret.chiral = bind_site(chiral) if callable(chiral) else chiral
# Set these to zero, as they can only hold @ k=0, and we currently
# have no mechanism for telling the system about the existence
# (or not) of a symmetry at different parameter values.
ret.particle_hole = None
ret.time_reversal = None
sites = {}
hops = collections.defaultdict(list)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment