graph2mat.core.data.matrices

Containers 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.

However, the user does not need to initialize these matrices explicitly, they are initialized appropiately when initializing a BasisConfiguration object using the OrbitalConfiguration.new method.

There are different matrix classes. This is something that is probably not needed and is reminiscent of the initial development stages.

Functions

get_matrix_cls(key)

class graph2mat.core.data.matrices.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.

class graph2mat.core.data.matrices.DensityMatrix(block_dict: 'Dict[Tuple[int, int, int], np.ndarray]', nsc: 'np.ndarray', orbital_count: 'OrbitalCount')[source]

Bases: OrbitalMatrix

__init__(block_dict: Dict[Tuple[int, int, int], np.ndarray], nsc: np.ndarray, orbital_count: OrbitalCount) None
get_atomic_matrices(z_table: AtomicTableWithEdges)[source]
class graph2mat.core.data.matrices.OrbitalMatrix(block_dict: Dict[Tuple[int, int, int], ndarray], nsc: ndarray, orbital_count: ndarray)[source]

Bases: BasisMatrix

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

This class just adds some extra aliases to the BasisMatrix class, to use orbital terminology.

__init__(block_dict: Dict[Tuple[int, int, int], ndarray], nsc: ndarray, orbital_count: ndarray) None
basis_count: ndarray

Array containing the number of basis functions for each point

block_dict: Dict[Tuple[int, int, int], ndarray]
get_atomic_matrices(z_table: AtomicTableWithEdges)[source]
get_point_matrices(basis_table: AtomicTableWithEdges) 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

Size of the auxiliary supercell. This is the number of cells required in each direction to account for all the interactions of the points in the unit cell. If the point distribution is not periodic, this will always be [1,1,1].

orbital_count: ndarray

Alias for basis_count. Array containing the number of basis functions for each point

graph2mat.core.data.matrices.get_matrix_cls(key: str | SparseOrbital | None) Type[OrbitalMatrix][source]

Modules

basis_matrix

physics