symmray.symmetries

Definitions of various symmetries.

Classes

Symmetry

Helper class that provides a standard way to create an ABC using

ZN

Helper class that provides a standard way to create an ABC using

Z2

Helper class that provides a standard way to create an ABC using

U1

Helper class that provides a standard way to create an ABC using

Z2Z2

Helper class that provides a standard way to create an ABC using

U1U1

Helper class that provides a standard way to create an ABC using

Functions

sign_scalar(charge[, dual])

sign_tuple(charge[, dual])

get_zn_symmetry_cls(→ type)

Get a ZN symmetry class.

get_symmetry(→ Symmetry)

Get a symmetry instance by name.

calc_phase_permutation(→ int)

Given sequence of parities and a permutation, compute the phase of the

Module Contents

class symmray.symmetries.Symmetry[source]

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

__slots__ = ()
abstractmethod valid(*charges)[source]

Check if all charges are valid for the symmetry.

abstractmethod combine(*charges)[source]

Combine / add charges according to the symmetry.

abstractmethod sign(charge, dual=True)[source]

Negate a charge according to the symmetry and flag dual.

abstractmethod parity(charge)[source]

Return the parity, 0 or 1, of a charge according to the symmetry.

abstractmethod random_charge(seed=None)[source]

Return a random valid charge, for testing purposes.

__str__()[source]
__eq__(other)[source]
__hash__()[source]
__repr__()[source]
symmray.symmetries.sign_scalar(charge, dual=True)[source]
symmray.symmetries.sign_tuple(charge, dual=True)[source]
class symmray.symmetries.ZN[source]

Bases: Symmetry

Helper class that provides a standard way to create an ABC using inheritance.

__slots__ = ('N',)
valid(*charges: int) bool[source]

Check if all charges are valid for the symmetry.

combine(*charges: int) int[source]

Combine / add charges according to the symmetry.

sign(charge: int, dual=True) int[source]

Negate a charge according to the symmetry and flag dual.

parity(charge: int) int[source]

Return the parity, 0 or 1, of a charge according to the symmetry.

random_charge(seed=None) int[source]

Return a random valid charge, for testing purposes.

__reduce__()[source]
class symmray.symmetries.Z2[source]

Bases: ZN

Helper class that provides a standard way to create an ABC using inheritance.

N = 2
sign(charge: int, dual=True) int[source]

Negate a charge according to the symmetry and flag dual.

symmray.symmetries.get_zn_symmetry_cls(N: int) type[source]

Get a ZN symmetry class.

class symmray.symmetries.U1[source]

Bases: Symmetry

Helper class that provides a standard way to create an ABC using inheritance.

__slots__ = ()
valid(*charges: int) bool[source]

Check if all charges are valid for the symmetry.

combine(*charges: int) int[source]

Combine / add charges according to the symmetry.

sign(charge: int, dual=True) int[source]

Negate a charge according to the symmetry and flag dual.

parity(charge: int) int[source]

Return the parity, 0 or 1, of a charge according to the symmetry.

random_charge(seed=None) int[source]

Return a random valid charge, for testing purposes.

class symmray.symmetries.Z2Z2[source]

Bases: Symmetry

Helper class that provides a standard way to create an ABC using inheritance.

__slots__ = ()
valid(*charges: tuple[int, int]) bool[source]

Check if all charges are valid for the symmetry.

combine(*charges: tuple[int, int]) tuple[int, int][source]

Combine / add charges according to the symmetry.

sign(charge: tuple[int, int], dual=True) tuple[int, int][source]

Negate a charge according to the symmetry and flag dual.

parity(charge: tuple[int, int]) int[source]

Return the parity, 0 or 1, of a charge according to the symmetry.

random_charge(seed=None) tuple[int, int][source]

Return a random valid charge, for testing purposes.

class symmray.symmetries.U1U1[source]

Bases: Symmetry

Helper class that provides a standard way to create an ABC using inheritance.

__slots__ = ()
valid(*charges: tuple[int, int]) bool[source]

Check if all charges are valid for the symmetry.

combine(*charges: tuple[int, int]) tuple[int, int][source]

Combine / add charges according to the symmetry.

sign(charge: tuple[int, int], dual=True) tuple[int, int][source]

Negate a charge according to the symmetry and flag dual.

parity(charge: tuple[int, int]) int[source]

Return the parity, 0 or 1, of a charge according to the symmetry.

random_charge(seed=None) tuple[int, int][source]

Return a random valid charge, for testing purposes.

symmray.symmetries.get_symmetry(symmetry: str | Symmetry) Symmetry[source]

Get a symmetry instance by name.

Parameters:

symmetry (str or Symmetry) – The symmetry to get.

Returns:

The symmetry instance.

Return type:

Symmetry

symmray.symmetries.calc_phase_permutation(parities: tuple[int, Ellipsis], perm: tuple[int, Ellipsis] = None) int[source]

Given sequence of parities and a permutation, compute the phase of the permutation acting on the odd charges. I.e. whether the number of swaps of odd sectors is even or odd.

Parameters:
  • parities (tuple of int) – The parities of the sectors.

  • perm (tuple of int, optional) – The permutation of axes, by default None, which flips all axes.

Returns:

The phase of the permutation, either 1 or -1.

Return type:

int