Format conversions
When graph2mat
is initialized, a global graph2mat.ConversionManager
is created and made available
at graph2mat.conversions
. It can be imported like:
import graph2mat
# Use it like
graph2mat.conversions
# Or alternatively
from graph2mat import conversions
This conversion manager contains all the conversions between formats implemented in graph2mat
.
Note
See the documentation of graph2mat.ConversionManager
for some remarks on how to
access/use the existing converters, as well as how to add new ones.
Summary of available conversions
The following table summarizes all the available conversions. Each row contains:
Source: The format to convert from.
Target: The format to convert to.
Function: The function that performs the conversion, click on it to go to its documentation.
See graph2mat.Formats
for a list of all available formats, together with
a description of what each format is.
Source |
Target |
Function |
---|---|---|
basisconfiguration |
basismatrixdata |
|
basisconfiguration |
orbitalconfiguration |
|
basisconfiguration |
sisl_geometry |
|
basisconfiguration |
torch_basismatrixdata |
|
basismatrixdata |
basismatrixdata |
|
basismatrixdata |
numpy |
|
basismatrixdata |
scipy_coo |
|
basismatrixdata |
scipy_csr |
|
basismatrixdata |
sisl |
|
basismatrixdata |
sisl_DM |
|
basismatrixdata |
sisl_EDM |
|
basismatrixdata |
sisl_H |
|
basismatrixdata |
torch |
|
block_dict |
numpy |
|
block_dict |
scipy_coo |
|
block_dict |
scipy_csr |
|
block_dict |
torch |
|
nodesedges |
numpy |
|
nodesedges |
scipy_coo |
|
nodesedges |
scipy_csr |
|
nodesedges |
sisl |
|
nodesedges |
sisl_DM |
|
nodesedges |
sisl_EDM |
|
nodesedges |
sisl_H |
|
nodesedges |
torch |
|
numpy |
torch |
|
orbitalconfiguration |
basismatrixdata |
|
orbitalconfiguration |
torch_basismatrixdata |
|
scipy_coo |
basismatrix |
|
scipy_coo |
numpy |
|
scipy_coo |
scipy_csr |
|
scipy_coo |
sisl |
|
scipy_coo |
sisl_DM |
|
scipy_coo |
sisl_EDM |
|
scipy_coo |
sisl_H |
|
scipy_coo |
torch |
|
scipy_csr |
basismatrix |
|
scipy_csr |
numpy |
|
scipy_csr |
scipy_coo |
|
scipy_csr |
sisl |
|
scipy_csr |
sisl_DM |
|
scipy_csr |
sisl_EDM |
|
scipy_csr |
sisl_H |
|
scipy_csr |
torch |
|
sisl |
basismatrixdata |
|
sisl |
orbitalconfiguration |
|
sisl |
torch_basismatrixdata |
|
sisl_geometry |
basismatrixdata |
|
sisl_geometry |
orbitalconfiguration |
|
sisl_geometry |
torch_basismatrixdata |
|
sisl_sile |
basismatrixdata |
|
sisl_sile |
orbitalconfiguration |
|
sisl_sile |
torch_basismatrixdata |
|
torch |
numpy |
|
torch_basismatrixdata |
basismatrixdata |
|
torch_basismatrixdata |
numpy |
|
torch_basismatrixdata |
scipy_coo |
|
torch_basismatrixdata |
scipy_csr |
|
torch_basismatrixdata |
sisl |
|
torch_basismatrixdata |
sisl_DM |
|
torch_basismatrixdata |
sisl_EDM |
|
torch_basismatrixdata |
sisl_H |
|
torch_basismatrixdata |
torch |
|
torch_basismatrixdata |
torch_coo |
|
torch_basismatrixdata |
torch_csr |
|
torch_coo |
numpy |
|
torch_coo |
torch |
|
torch_coo |
torch_csr |
|
torch_csr |
numpy |
|
torch_csr |
torch |
|
torch_csr |
torch_coo |
|
torch_nodesedges |
torch |
|
torch_nodesedges |
torch_coo |
|
torch_nodesedges |
torch_csr |
Documentation of conversion functions
Formats.BASISCONFIGURATION
-> Formats.BASISMATRIXDATA
- graph2mat.conversions.basisconfiguration_to_basismatrixdata(config: BasisConfiguration, data_processor: MatrixDataProcessor, nsc=None) BasisMatrixData
Creates a basis matrix data object from a configuration.
- Parameters:
config – The configuration from which to create the basis matrix data object.
data_processor – The data processor that contains all the information needed to convert the configuration into the basis matrix data object. E.g. it contains the basis table.
Formats.BASISCONFIGURATION
-> Formats.ORBITALCONFIGURATION
- graph2mat.conversions.basisconfiguration_to_orbitalconfiguration(config: BasisConfiguration, cls: type[OrbitalConfiguration] = graph2mat.core.data.configuration.OrbitalConfiguration, **kwargs) OrbitalConfiguration
Conversion from ‘basisconfiguration’ to ‘orbitalconfiguration’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
basisconfiguration
-> [sisl_geometry
->orbitalconfiguration
]- Parameters:
cls – Class to initialize, should be a subclass of
OrbitalConfiguration
.**kwargs – Additional arguments to be passed to the OrbitalConfiguration constructor.
See also
sisl_geometry_to_orbitalconfiguration
The original converter that has been expanded to create this one.
Formats.BASISCONFIGURATION
-> Formats.SISL_GEOMETRY
- graph2mat.conversions.basisconfiguration_to_sisl_geometry(config: BasisConfiguration) Geometry
Formats.BASISCONFIGURATION
-> Formats.TORCH_BASISMATRIXDATA
- graph2mat.conversions.basisconfiguration_to_torch_basismatrixdata(config: BasisConfiguration, data_processor: MatrixDataProcessor, nsc=None) BasisMatrixData
Creates a basis matrix data object from a configuration.
- Parameters:
config – The configuration from which to create the basis matrix data object.
data_processor – The data processor that contains all the information needed to convert the configuration into the basis matrix data object. E.g. it contains the basis table.
Formats.BASISMATRIXDATA
-> Formats.BASISMATRIXDATA
- graph2mat.conversions.basismatrixdata_to_basismatrixdata(data) BasisMatrixData
Formats.BASISMATRIXDATA
-> Formats.NUMPY
- graph2mat.conversions.basismatrixdata_to_numpy(data, threshold: float | None = None, **kwargs) ndarray
Conversion from ‘basismatrixdata’ to ‘numpy’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
basismatrixdata
->scipy_csr
] ->numpy
See also
basismatrixdata_to_scipy_csr
The original converter that has been expanded to create this one.
Formats.BASISMATRIXDATA
-> Formats.SCIPY_COO
- graph2mat.conversions.basismatrixdata_to_scipy_coo(data, threshold: float | None = None, **kwargs) coo_array
Conversion from ‘basismatrixdata’ to ‘scipy_coo’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
basismatrixdata
->scipy_csr
] ->scipy_coo
See also
basismatrixdata_to_scipy_csr
The original converter that has been expanded to create this one.
Formats.BASISMATRIXDATA
-> Formats.SCIPY_CSR
Formats.BASISMATRIXDATA
-> Formats.SISL
Formats.BASISMATRIXDATA
-> Formats.SISL_DM
Formats.BASISMATRIXDATA
-> Formats.SISL_EDM
Formats.BASISMATRIXDATA
-> Formats.SISL_H
Formats.BASISMATRIXDATA
-> Formats.TORCH
- graph2mat.conversions.basismatrixdata_to_torch(data, threshold: float | None = None, **kwargs) Tensor
Conversion from ‘basismatrixdata’ to ‘torch’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
basismatrixdata
->scipy_csr
] ->torch
See also
basismatrixdata_to_scipy_csr
The original converter that has been expanded to create this one.
Formats.BLOCK_DICT
-> Formats.NUMPY
- graph2mat.conversions.block_dict_to_numpy(block_dict: Dict[Tuple[int, int, int], ndarray], first_orb: ndarray, n_supercells: int = 1, threshold: float = 1e-08) ndarray
Conversion from ‘block_dict’ to ‘numpy’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
block_dict
->scipy_coo
] ->numpy
See also
block_dict_to_scipy_coo
The original converter that has been expanded to create this one.
Formats.BLOCK_DICT
-> Formats.SCIPY_COO
- graph2mat.conversions.block_dict_to_scipy_coo(block_dict: Dict[Tuple[int, int, int], ndarray], first_orb: ndarray, n_supercells: int = 1, threshold: float = 1e-08) coo_array
Converts a block dictionary into a coo array.
Conversions to any other sparse structure can be done once we’ve got the coo array.
Formats.BLOCK_DICT
-> Formats.SCIPY_CSR
- graph2mat.conversions.block_dict_to_scipy_csr(block_dict: Dict[Tuple[int, int, int], ndarray], first_orb: ndarray, n_supercells: int = 1, threshold: float = 1e-08) csr_array
Conversion from ‘block_dict’ to ‘scipy_csr’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
block_dict
->scipy_coo
] ->scipy_csr
See also
block_dict_to_scipy_coo
The original converter that has been expanded to create this one.
Formats.BLOCK_DICT
-> Formats.TORCH
- graph2mat.conversions.block_dict_to_torch(block_dict: Dict[Tuple[int, int, int], ndarray], first_orb: ndarray, n_supercells: int = 1, threshold: float = 1e-08) Tensor
Conversion from ‘block_dict’ to ‘torch’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
block_dict
->scipy_coo
] ->torch
See also
block_dict_to_scipy_coo
The original converter that has been expanded to create this one.
Formats.NODESEDGES
-> Formats.NUMPY
- graph2mat.conversions.nodesedges_to_numpy(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, orbitals: ndarray, n_supercells: int = 1, edge_neigh_isc: ndarray | None = None, threshold: float | None = None, symmetrize_edges: bool = False) ndarray
Conversion from ‘nodesedges’ to ‘numpy’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
nodesedges
->scipy_coo
] ->numpy
- Parameters:
node_vals – Flat array containing the values of the node blocks. The order of the values is first by node index, then row then column.
edge_vals – Flat array containing the values of the edge blocks. The order of the values is first by edge index, then row then column.
edge_index – Array of shape (2, n_edges) containing the indices of the atoms that participate in each edge.
orbitals – Array of shape (n_nodes, ) containing the number of orbitals for each atom.
n_supercells – Number of auxiliary supercells.
edge_neigh_isc – Array of shape (n_edges, ) containing the supercell index of the second atom in each edge with respect to the first atom. If not provided, all interactions are assumed to be in the unit cell.
threshold – Matrix elements with a value below this number are set to 0.
symmetrize_edges – whether for each edge only one direction is provided. The edge block for the opposite direction is then created as the transpose.
See also
nodesedges_to_scipy_coo
The original converter that has been expanded to create this one.
Formats.NODESEDGES
-> Formats.SCIPY_COO
- graph2mat.conversions.nodesedges_to_scipy_coo(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, orbitals: ndarray, n_supercells: int = 1, edge_neigh_isc: ndarray | None = None, threshold: float | None = None, symmetrize_edges: bool = False) coo_array
Converts an orbital matrix from node and edges array to scipy coo.
Conversions to any other sparse structure can be done once we’ve got the coo array.
- Parameters:
node_vals – Flat array containing the values of the node blocks. The order of the values is first by node index, then row then column.
edge_vals – Flat array containing the values of the edge blocks. The order of the values is first by edge index, then row then column.
edge_index – Array of shape (2, n_edges) containing the indices of the atoms that participate in each edge.
orbitals – Array of shape (n_nodes, ) containing the number of orbitals for each atom.
n_supercells – Number of auxiliary supercells.
edge_neigh_isc – Array of shape (n_edges, ) containing the supercell index of the second atom in each edge with respect to the first atom. If not provided, all interactions are assumed to be in the unit cell.
threshold – Matrix elements with a value below this number are set to 0.
symmetrize_edges – whether for each edge only one direction is provided. The edge block for the opposite direction is then created as the transpose.
Formats.NODESEDGES
-> Formats.SCIPY_CSR
- graph2mat.conversions.nodesedges_to_scipy_csr(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, orbitals: ndarray, n_supercells: int = 1, edge_neigh_isc: ndarray | None = None, threshold: float | None = None, symmetrize_edges: bool = False) csr_array
Conversion from ‘nodesedges’ to ‘scipy_csr’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
nodesedges
->scipy_coo
] ->scipy_csr
- Parameters:
node_vals – Flat array containing the values of the node blocks. The order of the values is first by node index, then row then column.
edge_vals – Flat array containing the values of the edge blocks. The order of the values is first by edge index, then row then column.
edge_index – Array of shape (2, n_edges) containing the indices of the atoms that participate in each edge.
orbitals – Array of shape (n_nodes, ) containing the number of orbitals for each atom.
n_supercells – Number of auxiliary supercells.
edge_neigh_isc – Array of shape (n_edges, ) containing the supercell index of the second atom in each edge with respect to the first atom. If not provided, all interactions are assumed to be in the unit cell.
threshold – Matrix elements with a value below this number are set to 0.
symmetrize_edges – whether for each edge only one direction is provided. The edge block for the opposite direction is then created as the transpose.
See also
nodesedges_to_scipy_coo
The original converter that has been expanded to create this one.
Formats.NODESEDGES
-> Formats.SISL
- graph2mat.conversions.nodesedges_to_sisl(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, geometry: Geometry, sp_class: Type[SparseOrbital] = sisl.SparseOrbital, edge_neigh_isc: ndarray | None = None, threshold: float = 1e-08, symmetrize_edges: bool = False) SparseOrbital
Formats.NODESEDGES
-> Formats.SISL_DM
- graph2mat.conversions.nodesedges_to_sisl_DM(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.DensityMatrix, edge_neigh_isc: ndarray | None = None, threshold: float = 1e-08, symmetrize_edges: bool = False) SparseOrbital
Formats.NODESEDGES
-> Formats.SISL_EDM
- graph2mat.conversions.nodesedges_to_sisl_EDM(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.EnergyDensityMatrix, edge_neigh_isc: ndarray | None = None, threshold: float = 1e-08, symmetrize_edges: bool = False) SparseOrbital
Formats.NODESEDGES
-> Formats.SISL_H
- graph2mat.conversions.nodesedges_to_sisl_H(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.Hamiltonian, edge_neigh_isc: ndarray | None = None, threshold: float = 1e-08, symmetrize_edges: bool = False) SparseOrbital
Formats.NODESEDGES
-> Formats.TORCH
- graph2mat.conversions.nodesedges_to_torch(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, orbitals: ndarray, n_supercells: int = 1, edge_neigh_isc: ndarray | None = None, threshold: float | None = None, symmetrize_edges: bool = False) Tensor
Conversion from ‘nodesedges’ to ‘torch’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
nodesedges
->scipy_coo
] ->torch
- Parameters:
node_vals – Flat array containing the values of the node blocks. The order of the values is first by node index, then row then column.
edge_vals – Flat array containing the values of the edge blocks. The order of the values is first by edge index, then row then column.
edge_index – Array of shape (2, n_edges) containing the indices of the atoms that participate in each edge.
orbitals – Array of shape (n_nodes, ) containing the number of orbitals for each atom.
n_supercells – Number of auxiliary supercells.
edge_neigh_isc – Array of shape (n_edges, ) containing the supercell index of the second atom in each edge with respect to the first atom. If not provided, all interactions are assumed to be in the unit cell.
threshold – Matrix elements with a value below this number are set to 0.
symmetrize_edges – whether for each edge only one direction is provided. The edge block for the opposite direction is then created as the transpose.
See also
nodesedges_to_scipy_coo
The original converter that has been expanded to create this one.
Formats.NUMPY
-> Formats.TORCH
Formats.ORBITALCONFIGURATION
-> Formats.BASISMATRIXDATA
- graph2mat.conversions.orbitalconfiguration_to_basismatrixdata(config: BasisConfiguration, data_processor: MatrixDataProcessor, nsc=None) BasisMatrixData
Creates a basis matrix data object from a configuration.
- Parameters:
config – The configuration from which to create the basis matrix data object.
data_processor – The data processor that contains all the information needed to convert the configuration into the basis matrix data object. E.g. it contains the basis table.
Formats.ORBITALCONFIGURATION
-> Formats.TORCH_BASISMATRIXDATA
- graph2mat.conversions.orbitalconfiguration_to_torch_basismatrixdata(config: BasisConfiguration, data_processor: MatrixDataProcessor, nsc=None) BasisMatrixData
Creates a basis matrix data object from a configuration.
- Parameters:
config – The configuration from which to create the basis matrix data object.
data_processor – The data processor that contains all the information needed to convert the configuration into the basis matrix data object. E.g. it contains the basis table.
Formats.SCIPY_COO
-> Formats.BASISMATRIX
- graph2mat.conversions.scipy_coo_to_basismatrix(coo: coo_array, atoms: Atoms, nsc: ndarray, geometry_atoms: Atoms | None = None, matrix_cls: Type[BasisMatrix] = graph2mat.core.data.matrices.physics.orbital_matrix.OrbitalMatrix) BasisMatrix
Conversion from ‘scipy_coo’ to ‘basismatrix’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
scipy_coo
-> [scipy_csr
->basismatrix
]- Parameters:
atoms – The atoms object for the matrix, containing orbital information.
nsc – The auxiliary supercell size.
matrix_cls – Matrix class to initialize.
geometry_atoms – The atoms object for the full geometry. This allows the matrix to contain atoms without any orbital. Geometry atoms should contain the matrix atoms first and then the orbital-less atoms.
See also
scipy_csr_to_basismatrix
The original converter that has been expanded to create this one.
Formats.SCIPY_COO
-> Formats.NUMPY
Formats.SCIPY_COO
-> Formats.SCIPY_CSR
Formats.SCIPY_COO
-> Formats.SISL
- graph2mat.conversions.scipy_coo_to_sisl(coo: coo_array, geometry: Geometry, sp_class: Type[SparseOrbital] = sisl.SparseOrbital) SparseOrbital
Conversion from ‘scipy_coo’ to ‘sisl’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
scipy_coo
-> [scipy_csr
->sisl
]See also
scipy_csr_to_sisl
The original converter that has been expanded to create this one.
Formats.SCIPY_COO
-> Formats.SISL_DM
- graph2mat.conversions.scipy_coo_to_sisl_DM(coo: coo_array, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.DensityMatrix) SparseOrbital
Conversion from ‘scipy_coo’ to ‘sisl_DM’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
scipy_coo
-> [scipy_csr
->sisl_DM
]See also
scipy_csr_to_sisl_DM
The original converter that has been expanded to create this one.
Formats.SCIPY_COO
-> Formats.SISL_EDM
- graph2mat.conversions.scipy_coo_to_sisl_EDM(coo: coo_array, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.EnergyDensityMatrix) SparseOrbital
Conversion from ‘scipy_coo’ to ‘sisl_EDM’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
scipy_coo
-> [scipy_csr
->sisl_EDM
]See also
scipy_csr_to_sisl_EDM
The original converter that has been expanded to create this one.
Formats.SCIPY_COO
-> Formats.SISL_H
- graph2mat.conversions.scipy_coo_to_sisl_H(coo: coo_array, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.Hamiltonian) SparseOrbital
Conversion from ‘scipy_coo’ to ‘sisl_H’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
scipy_coo
-> [scipy_csr
->sisl_H
]See also
scipy_csr_to_sisl_H
The original converter that has been expanded to create this one.
Formats.SCIPY_COO
-> Formats.TORCH
- graph2mat.conversions.scipy_coo_to_torch(coo: coo_array) Tensor
Conversion from ‘scipy_coo’ to ‘torch’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
scipy_coo
->numpy
] ->torch
See also
scipy_coo_to_numpy
The original converter that has been expanded to create this one.
Formats.SCIPY_CSR
-> Formats.BASISMATRIX
- graph2mat.conversions.scipy_csr_to_basismatrix(spmat: SparseCSR, atoms: Atoms, nsc: ndarray, geometry_atoms: Atoms | None = None, matrix_cls: Type[BasisMatrix] = graph2mat.core.data.matrices.physics.orbital_matrix.OrbitalMatrix) BasisMatrix
Creates a BasisMatrix object from a SparseCSR matrix
- Parameters:
spmat – The sparse matrix to convert to a block dictionary.
atoms – The atoms object for the matrix, containing orbital information.
nsc – The auxiliary supercell size.
matrix_cls – Matrix class to initialize.
geometry_atoms – The atoms object for the full geometry. This allows the matrix to contain atoms without any orbital. Geometry atoms should contain the matrix atoms first and then the orbital-less atoms.
Formats.SCIPY_CSR
-> Formats.NUMPY
Formats.SCIPY_CSR
-> Formats.SCIPY_COO
Formats.SCIPY_CSR
-> Formats.SISL
- graph2mat.conversions.scipy_csr_to_sisl(csr: csr_array, geometry: Geometry, sp_class: Type[SparseOrbital] = sisl.SparseOrbital) SparseOrbital
Converts a scipy CSR array to a sisl sparse orbital matrix.
Formats.SCIPY_CSR
-> Formats.SISL_DM
- graph2mat.conversions.scipy_csr_to_sisl_DM(csr: csr_array, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.DensityMatrix) SparseOrbital
Converts a scipy CSR array to a sisl sparse orbital matrix.
Formats.SCIPY_CSR
-> Formats.SISL_EDM
- graph2mat.conversions.scipy_csr_to_sisl_EDM(csr: csr_array, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.EnergyDensityMatrix) SparseOrbital
Converts a scipy CSR array to a sisl sparse orbital matrix.
Formats.SCIPY_CSR
-> Formats.SISL_H
- graph2mat.conversions.scipy_csr_to_sisl_H(csr: csr_array, geometry: Geometry, *, sp_class: Type[SparseOrbital] = sisl.physics.Hamiltonian) SparseOrbital
Converts a scipy CSR array to a sisl sparse orbital matrix.
Formats.SCIPY_CSR
-> Formats.TORCH
- graph2mat.conversions.scipy_csr_to_torch(csr: csr_array) Tensor
Conversion from ‘scipy_csr’ to ‘torch’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
scipy_csr
->numpy
] ->torch
See also
scipy_csr_to_numpy
The original converter that has been expanded to create this one.
Formats.SISL
-> Formats.BASISMATRIXDATA
- graph2mat.conversions.sisl_to_basismatrixdata(obj: BasisConfiguration | Geometry | SparseOrbital | str | Path, data_processor: MatrixDataProcessor, labels: bool = True, **kwargs) BasisMatrixData
Creates a new basis matrix data object.
If obj is a configuration, the from_config method is called. Otherwise, we try to first create a configuration from the provided arguments and then call the from_config method.
- Parameters:
obj – The object to convert into this class.
data_processor – If obj is not a configuration, the data processor is needed to understand how to create the basis matrix data object. In any case, the data processor is needed to convert from configuration to basis matrix data ready for models to use (e.g. because it contains the basis table).
See also
OrbitalConfiguration.new
The method called to initialize a configuration if obj is not a configuration.
from_config
The method called to initialize the basis matrix data object.
Formats.SISL
-> Formats.ORBITALCONFIGURATION
- graph2mat.conversions.sisl_to_orbitalconfiguration(matrix: SparseOrbital, geometry: Geometry | None = None, labels: bool = True, cls: type[OrbitalConfiguration] = graph2mat.core.data.configuration.OrbitalConfiguration, **kwargs) OrbitalConfiguration
Initializes an OrbitalConfiguration object from a sisl matrix.
- Parameters:
matrix – The matrix to associate to the OrbitalConfiguration. This matrix should have an associated geometry, which will be used.
geometry – The geometry to associate to the OrbitalConfiguration. If None, the geometry of the matrix will be used.
labels – Whether to process the labels from the matrix. If False, the only thing to read will be the atomic structure, which is likely the input of your model.
cls – Class to initialize, should be a subclass of
OrbitalConfiguration
.**kwargs – Additional arguments to be passed to the OrbitalConfiguration constructor.
Formats.SISL
-> Formats.TORCH_BASISMATRIXDATA
- graph2mat.conversions.sisl_to_torch_basismatrixdata(obj: BasisConfiguration | Geometry | SparseOrbital | str | Path, data_processor: MatrixDataProcessor, labels: bool = True, **kwargs) BasisMatrixData
Creates a new basis matrix data object.
If obj is a configuration, the from_config method is called. Otherwise, we try to first create a configuration from the provided arguments and then call the from_config method.
- Parameters:
obj – The object to convert into this class.
data_processor – If obj is not a configuration, the data processor is needed to understand how to create the basis matrix data object. In any case, the data processor is needed to convert from configuration to basis matrix data ready for models to use (e.g. because it contains the basis table).
See also
OrbitalConfiguration.new
The method called to initialize a configuration if obj is not a configuration.
from_config
The method called to initialize the basis matrix data object.
Formats.SISL_GEOMETRY
-> Formats.BASISMATRIXDATA
- graph2mat.conversions.sisl_geometry_to_basismatrixdata(obj: BasisConfiguration | Geometry | SparseOrbital | str | Path, data_processor: MatrixDataProcessor, labels: bool = True, **kwargs) BasisMatrixData
Creates a new basis matrix data object.
If obj is a configuration, the from_config method is called. Otherwise, we try to first create a configuration from the provided arguments and then call the from_config method.
- Parameters:
obj – The object to convert into this class.
data_processor – If obj is not a configuration, the data processor is needed to understand how to create the basis matrix data object. In any case, the data processor is needed to convert from configuration to basis matrix data ready for models to use (e.g. because it contains the basis table).
See also
OrbitalConfiguration.new
The method called to initialize a configuration if obj is not a configuration.
from_config
The method called to initialize the basis matrix data object.
Formats.SISL_GEOMETRY
-> Formats.ORBITALCONFIGURATION
- graph2mat.conversions.sisl_geometry_to_orbitalconfiguration(geometry: Geometry, cls: type[OrbitalConfiguration] = graph2mat.core.data.configuration.OrbitalConfiguration, **kwargs) OrbitalConfiguration
Initializes an
OrbitalConfiguration
object from a sisl geometry.Note that the created object will not have an associated matrix, unless it is passed explicitly as a keyword argument.
- Parameters:
geometry – The geometry to associate to the OrbitalConfiguration.
cls – Class to initialize, should be a subclass of
OrbitalConfiguration
.**kwargs – Additional arguments to be passed to the OrbitalConfiguration constructor.
Formats.SISL_GEOMETRY
-> Formats.TORCH_BASISMATRIXDATA
- graph2mat.conversions.sisl_geometry_to_torch_basismatrixdata(obj: BasisConfiguration | Geometry | SparseOrbital | str | Path, data_processor: MatrixDataProcessor, labels: bool = True, **kwargs) BasisMatrixData
Creates a new basis matrix data object.
If obj is a configuration, the from_config method is called. Otherwise, we try to first create a configuration from the provided arguments and then call the from_config method.
- Parameters:
obj – The object to convert into this class.
data_processor – If obj is not a configuration, the data processor is needed to understand how to create the basis matrix data object. In any case, the data processor is needed to convert from configuration to basis matrix data ready for models to use (e.g. because it contains the basis table).
See also
OrbitalConfiguration.new
The method called to initialize a configuration if obj is not a configuration.
from_config
The method called to initialize the basis matrix data object.
Formats.SISL_SILE
-> Formats.BASISMATRIXDATA
- graph2mat.conversions.sisl_sile_to_basismatrixdata(obj: BasisConfiguration | Geometry | SparseOrbital | str | Path, data_processor: MatrixDataProcessor, labels: bool = True, **kwargs) BasisMatrixData
Creates a new basis matrix data object.
If obj is a configuration, the from_config method is called. Otherwise, we try to first create a configuration from the provided arguments and then call the from_config method.
- Parameters:
obj – The object to convert into this class.
data_processor – If obj is not a configuration, the data processor is needed to understand how to create the basis matrix data object. In any case, the data processor is needed to convert from configuration to basis matrix data ready for models to use (e.g. because it contains the basis table).
See also
OrbitalConfiguration.new
The method called to initialize a configuration if obj is not a configuration.
from_config
The method called to initialize the basis matrix data object.
Formats.SISL_SILE
-> Formats.ORBITALCONFIGURATION
- graph2mat.conversions.sisl_sile_to_orbitalconfiguration(runfilepath: str | Path, geometry_path: str | Path | None = None, out_matrix: Literal['density_matrix', 'hamiltonian', 'energy_density_matrix', 'dynamical_matrix'] | None = None, cls: type[OrbitalConfiguration] = graph2mat.core.data.configuration.OrbitalConfiguration, basis: Atoms | None = None) OrbitalConfiguration
Initializes an OrbitalConfiguration object from the main input file of a run.
- Parameters:
runfilepath – The path of the main input file. E.g. in SIESTA this is the path to the “.fdf” file
geometry_path – The path to the geometry file. If None, the geometry will be read from the run file.
out_matrix – The matrix to be read from the output of the run. The configuration object will contain the matrix. If it is None, then no matrices are read from the output. This is the case when trying to predict matrices, since you don’t have the output yet.
cls – Class to initialize, should be a subclass of
OrbitalConfiguration
.basis – The basis to use for the configuration. If None, the basis of the read geometry will be used.
Formats.SISL_SILE
-> Formats.TORCH_BASISMATRIXDATA
- graph2mat.conversions.sisl_sile_to_torch_basismatrixdata(obj: BasisConfiguration | Geometry | SparseOrbital | str | Path, data_processor: MatrixDataProcessor, labels: bool = True, **kwargs) BasisMatrixData
Creates a new basis matrix data object.
If obj is a configuration, the from_config method is called. Otherwise, we try to first create a configuration from the provided arguments and then call the from_config method.
- Parameters:
obj – The object to convert into this class.
data_processor – If obj is not a configuration, the data processor is needed to understand how to create the basis matrix data object. In any case, the data processor is needed to convert from configuration to basis matrix data ready for models to use (e.g. because it contains the basis table).
See also
OrbitalConfiguration.new
The method called to initialize a configuration if obj is not a configuration.
from_config
The method called to initialize the basis matrix data object.
Formats.TORCH
-> Formats.NUMPY
Formats.TORCH_BASISMATRIXDATA
-> Formats.BASISMATRIXDATA
- graph2mat.conversions.torch_basismatrixdata_to_basismatrixdata(data) BasisMatrixData
Formats.TORCH_BASISMATRIXDATA
-> Formats.NUMPY
- graph2mat.conversions.torch_basismatrixdata_to_numpy(first_arg: None, threshold: float | None = None, **kwargs) ndarray
Conversion from ‘torch_basismatrixdata’ to ‘numpy’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
torch_basismatrixdata
-> [basismatrixdata
->scipy_csr
] ->numpy
See also
basismatrixdata_to_scipy_csr
The original converter that has been expanded to create this one.
Formats.TORCH_BASISMATRIXDATA
-> Formats.SCIPY_COO
- graph2mat.conversions.torch_basismatrixdata_to_scipy_coo(first_arg: None, threshold: float | None = None, **kwargs) coo_array
Conversion from ‘torch_basismatrixdata’ to ‘scipy_coo’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
torch_basismatrixdata
-> [basismatrixdata
->scipy_csr
] ->scipy_coo
See also
basismatrixdata_to_scipy_csr
The original converter that has been expanded to create this one.
Formats.TORCH_BASISMATRIXDATA
-> Formats.SCIPY_CSR
- graph2mat.conversions.torch_basismatrixdata_to_scipy_csr(first_arg: None, threshold: float | None = None, **kwargs)
Conversion from ‘torch_basismatrixdata’ to ‘scipy_csr’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
torch_basismatrixdata
-> [basismatrixdata
->scipy_csr
]See also
basismatrixdata_to_scipy_csr
The original converter that has been expanded to create this one.
Formats.TORCH_BASISMATRIXDATA
-> Formats.SISL
- graph2mat.conversions.torch_basismatrixdata_to_sisl(first_arg: None, threshold: float | None = None, **kwargs)
Conversion from ‘torch_basismatrixdata’ to ‘sisl’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
torch_basismatrixdata
-> [basismatrixdata
->sisl
]See also
basismatrixdata_to_sisl
The original converter that has been expanded to create this one.
Formats.TORCH_BASISMATRIXDATA
-> Formats.SISL_DM
- graph2mat.conversions.torch_basismatrixdata_to_sisl_DM(first_arg: None, threshold: float | None = None, **kwargs)
Conversion from ‘torch_basismatrixdata’ to ‘sisl_DM’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
torch_basismatrixdata
-> [basismatrixdata
->sisl_DM
]See also
basismatrixdata_to_sisl_DM
The original converter that has been expanded to create this one.
Formats.TORCH_BASISMATRIXDATA
-> Formats.SISL_EDM
- graph2mat.conversions.torch_basismatrixdata_to_sisl_EDM(first_arg: None, threshold: float | None = None, **kwargs)
Conversion from ‘torch_basismatrixdata’ to ‘sisl_EDM’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
torch_basismatrixdata
-> [basismatrixdata
->sisl_EDM
]See also
basismatrixdata_to_sisl_EDM
The original converter that has been expanded to create this one.
Formats.TORCH_BASISMATRIXDATA
-> Formats.SISL_H
- graph2mat.conversions.torch_basismatrixdata_to_sisl_H(first_arg: None, threshold: float | None = None, **kwargs)
Conversion from ‘torch_basismatrixdata’ to ‘sisl_H’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
torch_basismatrixdata
-> [basismatrixdata
->sisl_H
]See also
basismatrixdata_to_sisl_H
The original converter that has been expanded to create this one.
Formats.TORCH_BASISMATRIXDATA
-> Formats.TORCH
- graph2mat.conversions.torch_basismatrixdata_to_torch(first_arg: None, threshold: float | None = None, **kwargs) Tensor
Conversion from ‘torch_basismatrixdata’ to ‘torch’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
torch_basismatrixdata
-> [basismatrixdata
->scipy_csr
] ->torch
See also
basismatrixdata_to_scipy_csr
The original converter that has been expanded to create this one.
Formats.TORCH_BASISMATRIXDATA
-> Formats.TORCH_COO
- graph2mat.conversions.torch_basismatrixdata_to_torch_coo(data, threshold: float | None = None, **kwargs)
Formats.TORCH_BASISMATRIXDATA
-> Formats.TORCH_CSR
- graph2mat.conversions.torch_basismatrixdata_to_torch_csr(data, threshold: float | None = None, **kwargs) sparse_csr_tensor
Conversion from ‘torch_basismatrixdata’ to ‘torch_csr’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
torch_basismatrixdata
->torch_coo
] ->torch_csr
See also
torch_basismatrixdata_to_torch_coo
The original converter that has been expanded to create this one.
Formats.TORCH_COO
-> Formats.NUMPY
- graph2mat.conversions.torch_coo_to_numpy(coo: sparse_coo_tensor) ndarray
Conversion from ‘torch_coo’ to ‘numpy’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
torch_coo
->torch
] ->numpy
See also
torch_coo_to_torch
The original converter that has been expanded to create this one.
Formats.TORCH_COO
-> Formats.TORCH
Formats.TORCH_COO
-> Formats.TORCH_CSR
- graph2mat.conversions.torch_coo_to_torch_csr(coo: sparse_coo_tensor) sparse_csr_tensor
Formats.TORCH_CSR
-> Formats.NUMPY
- graph2mat.conversions.torch_csr_to_numpy(csr: sparse_csr_tensor) ndarray
Conversion from ‘torch_csr’ to ‘numpy’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
torch_csr
->torch
] ->numpy
See also
torch_csr_to_torch
The original converter that has been expanded to create this one.
Formats.TORCH_CSR
-> Formats.TORCH
Formats.TORCH_CSR
-> Formats.TORCH_COO
- graph2mat.conversions.torch_csr_to_torch_coo(csr: sparse_csr_tensor) sparse_coo_tensor
Formats.TORCH_NODESEDGES
-> Formats.TORCH
- graph2mat.conversions.torch_nodesedges_to_torch(node_vals: Tensor, edge_vals: Tensor, edge_index: Tensor, orbitals: Tensor, n_supercells: int = 1, edge_neigh_isc: Tensor | None = None, threshold: float | None = None, symmetrize_edges: bool = False) Tensor
Conversion from ‘torch_nodesedges’ to ‘torch’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
torch_nodesedges
->torch_coo
] ->torch
- Parameters:
node_vals – Flat array containing the values of the node blocks. The order of the values is first by node index, then row then column.
edge_vals – Flat array containing the values of the edge blocks. The order of the values is first by edge index, then row then column.
edge_index – Array of shape (2, n_edges) containing the indices of the atoms that participate in each edge.
orbitals – Array of shape (n_nodes, ) containing the number of orbitals for each atom.
n_supercells – Number of auxiliary supercells.
edge_neigh_isc – Array of shape (n_edges, ) containing the supercell index of the second atom in each edge with respect to the first atom. If not provided, all interactions are assumed to be in the unit cell.
threshold – Matrix elements with a value below this number are set to 0.
symmetrize_edges – whether for each edge only one direction is provided. The edge block for the opposite direction is then created as the transpose.
See also
torch_nodesedges_to_torch_coo
The original converter that has been expanded to create this one.
Formats.TORCH_NODESEDGES
-> Formats.TORCH_COO
- graph2mat.conversions.torch_nodesedges_to_torch_coo(node_vals: Tensor, edge_vals: Tensor, edge_index: Tensor, orbitals: Tensor, n_supercells: int = 1, edge_neigh_isc: Tensor | None = None, threshold: float | None = None, symmetrize_edges: bool = False) sparse_coo_tensor
Converts an orbital matrix from node and edges array to torch coo.
Conversions to any other sparse structure can be done once we’ve got the coo array.
- Parameters:
node_vals – Flat array containing the values of the node blocks. The order of the values is first by node index, then row then column.
edge_vals – Flat array containing the values of the edge blocks. The order of the values is first by edge index, then row then column.
edge_index – Array of shape (2, n_edges) containing the indices of the atoms that participate in each edge.
orbitals – Array of shape (n_nodes, ) containing the number of orbitals for each atom.
n_supercells – Number of auxiliary supercells.
edge_neigh_isc – Array of shape (n_edges, ) containing the supercell index of the second atom in each edge with respect to the first atom. If not provided, all interactions are assumed to be in the unit cell.
threshold – Matrix elements with a value below this number are set to 0.
symmetrize_edges – whether for each edge only one direction is provided. The edge block for the opposite direction is then created as the transpose.
Formats.TORCH_NODESEDGES
-> Formats.TORCH_CSR
- graph2mat.conversions.torch_nodesedges_to_torch_csr(node_vals: Tensor, edge_vals: Tensor, edge_index: Tensor, orbitals: Tensor, n_supercells: int = 1, edge_neigh_isc: Tensor | None = None, threshold: float | None = None, symmetrize_edges: bool = False) sparse_csr_tensor
Conversion from ‘torch_nodesedges’ to ‘torch_csr’.
This function has been defined automatically.
The full path of the conversion is (original converter in square brackets):
[
torch_nodesedges
->torch_coo
] ->torch_csr
- Parameters:
node_vals – Flat array containing the values of the node blocks. The order of the values is first by node index, then row then column.
edge_vals – Flat array containing the values of the edge blocks. The order of the values is first by edge index, then row then column.
edge_index – Array of shape (2, n_edges) containing the indices of the atoms that participate in each edge.
orbitals – Array of shape (n_nodes, ) containing the number of orbitals for each atom.
n_supercells – Number of auxiliary supercells.
edge_neigh_isc – Array of shape (n_edges, ) containing the supercell index of the second atom in each edge with respect to the first atom. If not provided, all interactions are assumed to be in the unit cell.
threshold – Matrix elements with a value below this number are set to 0.
symmetrize_edges – whether for each edge only one direction is provided. The edge block for the opposite direction is then created as the transpose.
See also
torch_nodesedges_to_torch_coo
The original converter that has been expanded to create this one.