Skip to content

Commit

Permalink
Debug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyue Ping Ong committed Nov 16, 2022
1 parent 9fa14a0 commit b9dfab9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 13 additions & 4 deletions m3gnet/graph/_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,27 @@ def _compute_threebody(bond_atom_indices, n_atoms):
n_triple_i = np.zeros(n_atom, dtype=np.int32)
n_triple_ij = np.zeros(n_bond, dtype=np.int32)
n_triple_s = np.zeros(n_struct, dtype=np.int32)
triple_bond_indices = []

n_triple = 0
start = 0

for i, bpa in enumerate(n_bond_per_atom):
n_triple_temp = bpa * (bpa - 1)
n_triple_ij[start : start + bpa] = bpa - 1
for j in range(bpa):
n_triple_ij[start : start + bpa] = bpa - 1
n_triple += n_triple_temp
n_triple_i[i] = n_triple_temp
start += bpa

triple_bond_indices = np.empty(shape=(n_triple, 2), dtype=np.int32)

start = 0
index = 0
for i in range(n_atom):
bpa = n_bond_per_atom[i]
for j, k in itertools.permutations(range(bpa), 2):
triple_bond_indices.append([start + j, start + k])
triple_bond_indices[index] = [start + j, start + k]
index += 1
start += bpa

start = 0
Expand All @@ -58,7 +67,7 @@ def _compute_threebody(bond_atom_indices, n_atoms):
n_triple_s[i] += n_triple_i[j]
start = end

return np.array(triple_bond_indices), n_triple_ij, n_triple_i, n_triple_s
return triple_bond_indices, n_triple_ij, n_triple_i, n_triple_s


def get_pair_vector_from_graph(graph: List):
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"numpy",
"monty",
"sympy",
"cython",
"ase",
],
description="Materials Graph with Three-body Interactions",
Expand Down

0 comments on commit b9dfab9

Please sign in to comment.