2.1. qlinks.symmetry.gauss_law#

Classes

Flow(value[, names, module, qualname, type, ...])

GaussLaw(charge_distri[, flux_sector])

class qlinks.symmetry.gauss_law.Flow(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: IntEnum

outward = 1#
inward = -1#
class qlinks.symmetry.gauss_law.GaussLaw(charge_distri, flux_sector=None)[source]#

Bases: Node

Parameters:
  • charge_distri (ndarray[Any, dtype[int64]]) – The charge distribution on the lattice. The (N, M)-shaped input array is repositioned in the first quadrant, aligning the element at (N - 1, 0) to (0, 0), and the element at (0, M - 1) to (M - 1, N - 1).

  • flux_sector (Tuple[int, int] | None) – The flux sector of the lattice, optional.

charge_distri: ndarray[Any, dtype[int64]]#
flux_sector: Tuple[int, int] | None#
charge(site)[source]#
Parameters:

site (Site)

Return type:

int | float

property shape: Tuple[int, int]#
static possible_flows(charge)[source]#
Parameters:

charge (int)

Return type:

List[ndarray[Any, dtype[int64]]]

static possible_configs(charge)[source]#
Parameters:

charge (int)

Return type:

List[ndarray[Any, dtype[int64]]]

static random_charge_distri(length_x, length_y, seed=None, max_iter=1000)[source]#

Randomly sample static charges spread on 2d square lattice.

Charges are uniformly sampled from the interval \([-2, 2]\), with total charge being zero (this is always true under periodic boundary conditions). However, this does not guarantee to provide a valid configuration of links.

Internally, this function uses multinomial distribution to sample possible charge distributions. Iteration for the trial sampling will stop as soon as it produces a valid outcome with zero total charge. Normally this is at most \(\mathcal{O}(1)\) of lattice size, \(\text{length} \times \text{width}\).

Parameters:
  • length_x (int) – The length of the lattice.

  • length_y (int) – The width of the lattice.

  • seed (int | None) – If provided, used for random generator. Default None.

  • max_iter (int) – The maximum number of iterations for trial sampling. Default 1000.

Returns:

The drawn samples of shape (width \(\times\) length). Note that we have swapped rows and columns to match with the lattice shape.

Raises:

StopIteration – If no valid distribution can be sampled within max_iter iterations.

Return type:

ndarray[Any, dtype[int64]]

static staggered_charge_distri(length_x, length_y)[source]#

Generate a staggered charge distribution with +1 and -1 charges. The shape of the lattice must be even number, and the bottom-left corner is always +1. To make the bottom-left corner -1, simply multiply the output by -1.

Parameters:
  • length_x (int) – The length of the lattice.

  • length_y (int) – The width of the lattice.

Returns:

The staggered charge distribution.

Raises:

InvalidArgumentError – If the shape of the lattice is not even number.

Return type:

ndarray[Any, dtype[int64]]

Examples

>>> GaussLaw.staggered_charge_distri(2, 2)
array([[-1,  1],
       [ 1, -1]])
>>> GaussLaw.staggered_charge_distri(4, 4)
array([[-1,  1, -1,  1],
       [ 1, -1,  1, -1],
       [-1,  1, -1,  1],
       [ 1, -1,  1, -1]])
classmethod from_random_charge_distri(length_x, length_y, flux_sector=None)[source]#
Parameters:
  • length_x (int)

  • length_y (int)

  • flux_sector (Tuple[int, int] | None)

Return type:

Self

classmethod from_staggered_charge_distri(length_x, length_y, flux_sector=None)[source]#
Parameters:
  • length_x (int)

  • length_y (int)

  • flux_sector (Tuple[int, int] | None)

Return type:

Self

classmethod from_zero_charge_distri(length_x, length_y, flux_sector=None)[source]#
Parameters:
  • length_x (int)

  • length_y (int)

  • flux_sector (Tuple[int, int] | None)

Return type:

Self

extend_node()[source]#
Return type:

Set[Self]

is_the_solution()[source]#
Return type:

bool

solve(method='cp', **kwargs)[source]#
Parameters:

method (str)

Return type:

ComputationBasis

static to_basis(nodes)[source]#
Parameters:

nodes (List[GaussLaw])

Return type:

ComputationBasis

__init__(charge_distri, flux_sector=None)#
Parameters:
  • charge_distri (ndarray[Any, dtype[int64]])

  • flux_sector (Tuple[int, int] | None)

Return type:

None