graph2mat.core.data.matrices.basis_matrix

Classes

BasisMatrix(block_dict, nsc, basis_count)

Container to store the raw matrices as a dictionary of blocks.

class graph2mat.core.data.matrices.basis_matrix.BasisMatrix(block_dict: Dict[Tuple[int, int, int], ndarray], nsc: ndarray, basis_count: ndarray)[source]

Bases: object

Container to store the raw matrices as a dictionary of blocks.

The matrices are stored in this format in BasisConfiguration, until they are converted to flat arrays for training in BasisMatrixData.

As a user you probably don’t need to initialize these matrices explicitly, they are initialized appropiately when initializing a BasisConfiguration object using the OrbitalConfiguration.new method.

__init__(block_dict: Dict[Tuple[int, int, int], ndarray], nsc: ndarray, basis_count: ndarray) None
basis_count: ndarray
block_dict: Dict[Tuple[int, int, int], ndarray]
get_point_matrices(basis_table: BasisTableWithEdges) Dict[int, ndarray][source]

This method should implement a way of retreiving the sub-matrices of each individual point.

This is, the matrix that the point would have if it was the only point in the system. This matrix will depend on the type of the point, so the basis_table needs to be provided.

The user might choose to subtract this matrix from the block_dict matrix during training, so that the model only learns the interactions between points.

nsc: ndarray
to_flat_nodes_and_edges(edge_index: ndarray, edge_sc_shifts: ndarray, points_order: ndarray | None = None, basis_table: BasisTableWithEdges | None = None, point_types: ndarray | None = None, sub_point_matrix: bool = False) Tuple[ndarray, ndarray][source]

Converts the matrix to a flat representation of the nodes and edges values.

This representation might be useful for training a neural network, where you will want to compare the output array to the target array. If you have flat arrays instead of block dicts you can easily compare the whole matrix at once.

Parameters:
  • edge_index (np.ndarray) – Array of shape [2, n_edges] containing the indices of the points that form each edge.

  • edge_sc_shifts (np.ndarray) – Array of shape [n_edges, 3] containing the supercell shifts of each edge. That is, if an edge is from point i to a periodic image of point j in the [1,0,0] cell, edge_sc_shifts for this edge should be [1,0,0]. Note that for the reverse edge (if there is one), the shift will be [-1,0,0].

  • points_order (Union[np.ndarray, None], optional) – Array of shape [n_points] containing the order in which the points should be flattened. If None, the order will simply be determined by their index.

  • basis_table (Union[BasisTableWithEdges, None], optional) – Table containing the types of the points. Only needed if sub_point_matrix is True.