Skip to content

Commit

Permalink
2023/08/30-12:16:06 (Linux sv2111 unknown)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbenner committed Aug 30, 2023
1 parent 6fbd661 commit 734c064
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions coordinationnet/model_gnn_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,20 @@ def __init__(self, dataset) -> None:

@classmethod
def __compute_graph__(cls, features : CoordinationFeatures) -> GraphData:
# Initialize graph with isolated nodes for each site
x = {
'elements' : torch.empty((0,), dtype=torch.long),
'oxidations': torch.empty((0,), dtype=torch.long),
#'ces' : torch.empty((0,), dtype=torch.long),
#'csm' : torch.empty((0,), dtype=torch.float),
#'angles' : torch.empty((0,), dtype=torch.float),
#'distance' : torch.empty((0,), dtype=torch.float),
'elements' : torch.tensor(features.sites.elements , dtype=torch.long),
'oxidations': torch.tensor(features.sites.oxidations, dtype=torch.long),
}
# Global edge index
e = [[], []]
# Global edge index, initialize with self-connections for
# isolated nodes
e = [[ i for i, _ in enumerate(features.sites.elements) ],
[ i for i, _ in enumerate(features.sites.elements) ]]
# Global node index
i = len(features.sites.elements)
# Some materials do not have CE pairs
if len(features.ce_neighbors) == 0:
return GraphData(x=x, edge_index=torch.empty((2,0), dtype=torch.long), num_nodes=0)
return GraphData(x=x, edge_index=torch.tensor(e, dtype=torch.long), num_nodes=i)
# Get CE symbols and CSMs
site_ces = len(features.sites.elements)*[NumGeometries]
site_csm = len(features.sites.elements)*[0.0]
Expand All @@ -70,8 +71,6 @@ def __compute_graph__(cls, features : CoordinationFeatures) -> GraphData:
# Consider only the first CE symbol
site_ces[j] = ce['ce_symbols'][0]
site_csm[j] = ce['csms'][0]
# Global node index
i = 0
# Construct CE graphs
for nb in features.ce_neighbors:
l = len(nb['ligand_indices'])
Expand Down

0 comments on commit 734c064

Please sign in to comment.