Skip to content

utils#

Includes utility methods. TODO will be refactored

Functions:

compute_sparsity_pattern #

compute_sparsity_pattern(positions: NDArray, cutoff_distance: float, transport_direction: str = 'a', strategy: str = 'box', start_idx: int = 0, end_idx: int = None, batch_size: int = 1000) -> coo_matrix

Computes the sparsity pattern for the interaction matrix.

Parameters:

  • positions (NDArray) –

    The grid points.

  • cutoff_distance (float) –

    The interaction cutoff.

  • transport_direction (str, default: 'a' ) –

    The transport direction, by default "a".

  • strategy (str, default: 'box' ) –

    The strategy to use, by default "box", where only the distance along the transport direction is considered. The other option is "sphere", where the usual Euclidean distance between points matters.

  • start_idx (int, default: 0 ) –

    The start index for which to compute the sparsity pattern, by default 0.

  • end_idx (int, default: None ) –

    The end index for which to compute the sparsity pattern, by default None.

  • batch_size (int, default: 1000 ) –

    The batch size for distance computations, by default 1000.

Returns:

  • coo_matrix –

    The sparsity pattern.

compute_num_connected_blocks #

compute_num_connected_blocks(sparsity_pattern: coo_matrix, block_sizes: NDArray) -> int

Computes the number of "connected" blocks in the sparsity pattern.

This number of "connected" blocks is the number of blocks that need to be merged together to arrive at a block-tridiagonal matrix after multiplying the sparsity pattern with itself twice (s @ s @ s).

This is a heuristic used to determine the block size for the screened Coulomb interaction.

Parameters:

  • sparsity_pattern (coo_matrix) –

    The sparsity pattern.

  • block_sizes (NDArray) –

    The block sizes.

Returns:

  • int –

    The number of connected blocks.