 ### allow computations even if a discrete symmetry is broken

parent f10f3de2
 ... @@ -11,6 +11,7 @@ ... @@ -11,6 +11,7 @@ __all__ = ['System', 'FiniteSystem', 'InfiniteSystem'] __all__ = ['System', 'FiniteSystem', 'InfiniteSystem'] import abc import abc import warnings from copy import copy from copy import copy from . import _system from . import _system ... @@ -235,12 +236,26 @@ class InfiniteSystem(System, metaclass=abc.ABCMeta): ... @@ -235,12 +236,26 @@ class InfiniteSystem(System, metaclass=abc.ABCMeta): ham = self.cell_hamiltonian(args, params=params) ham = self.cell_hamiltonian(args, params=params) hop = self.inter_cell_hopping(args, params=params) hop = self.inter_cell_hopping(args, params=params) symmetries = self.discrete_symmetry(args, params=params) symmetries = self.discrete_symmetry(args, params=params) broken = symmetries.validate(ham) # Check whether each symmetry is broken. if broken is not None: # If a symmetry is broken, it is ignored in the computation. raise ValueError("Cell Hamiltonian breaks " + broken.lower()) symmetry_names = ['Conservation law'] + physics.symmetry._names broken = symmetries.validate(hop) broken = (symmetries.validate(ham), if broken is not None: symmetries.validate(hop)) raise ValueError("Inter-cell hopping breaks " + broken.lower()) for name in symmetry_names: if name in broken: warnings.warn("Hamiltonian breaks " + name + ", ignoring the symmetry in the computation.") if name == symmetry_names: symmetries.projectors = None elif name == symmetry_names: symmetries.time_reversal = None elif name == symmetry_names: symmetries.particle_hole = None elif name == symmetry_names: symmetries.chiral = None else: warnings.warn("Misidentified a broken symmetry" +" in the lead.") shape = ham.shape shape = ham.shape assert len(shape) == 2 assert len(shape) == 2 assert shape == shape assert shape == shape ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!