Skip to content
Snippets Groups Projects
Commit bb674c8c authored by Carl Poelking's avatar Carl Poelking
Browse files

Utilities.

parent 926cd6dd
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,19 @@ def mp_compute_column_block(gi, gj_list, kfct):
krow.append(k)
return krow
def mp_compute_column_block_idx(gi, gj_list, kfct):
"""
Evaluates kfct for each pair (i, j), with j from j_list
"""
krow = []
for gj in gj_list:
if gj < gi:
k = 0.
else:
k = kfct(gi, gj)
krow.append(k)
return krow
def compute_upper_triangle(
kfct,
g_list,
......@@ -79,7 +92,7 @@ def compute_upper_triangle(
gi = g_list[i]
for j in range(i, dim):
gj = g_list[j]
kij = kfct(gi, gj)
kij = kfct_primed(gi, gj)
kmat[i,j] = kij
kmat[j,i] = kij
return kmat
......@@ -93,6 +106,7 @@ def mp_compute_upper_triangle(
tstart_twall=(None,None),
backup=True,
verbose=True,
embed_idx=True,
**kwargs):
"""
Compute kernel matrix computed from pairs of objects in object list
......@@ -110,6 +124,7 @@ def mp_compute_upper_triangle(
t_wall = tstart_twall[1]
dim = len(g_list)
kmat = np.zeros((dim,dim))
if embed_idx:
# Embed mp index in g-list objects
for mp_idx, g in enumerate(g_list): g.mp_idx = mp_idx
# Divide onto column blocks
......@@ -130,7 +145,7 @@ def mp_compute_upper_triangle(
pool = mp.Pool(processes=n_procs)
# Prime mp function
mp_compute_column_block_primed = fct.partial(
mp_compute_column_block,
mp_compute_column_block if embed_idx else mp_compute_column_block_idx,
gj_list=gj_list,
kfct=kfct_primed)
# Map & close
......
......@@ -46,8 +46,8 @@ def structure_from_ase(
log=None):
# NOTE Center of mass is computed without considering PBC => Requires unwrapped coordinates
structure = None
frag_bond_matrix = None
atom_bond_matrix = None
frag_bond_matrix = np.array([], dtype=bool)
atom_bond_matrix = np.array([], dtype=bool)
frag_labels = []
atom_labels = []
# System properties
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment