Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add number of corr functions for sorting orbits, update max_lp and fix hierarchy tests #256

Merged
merged 2 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions smol/cofe/space/clusterspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,15 @@ def _gen_point_orbits(exp_struct, site_bases, nbits, symops):
if new_orbit not in pt_orbits:
pt_orbits.append(new_orbit)

# sorted by decreasing crystallographic multiplicity and finally by increasing
# number of correlation functions (bit combos) -> so that higher symmetry orbits
# come first
pt_orbits = sorted(
pt_orbits,
key=lambda x: (np.round(x.base_cluster.diameter, 6), -x.multiplicity),
key=lambda x: (
-x.multiplicity,
len(x),
),
)
return pt_orbits

Expand Down Expand Up @@ -1176,18 +1182,18 @@ def _gen_multi_orbits(point_orbits, exp_struct, cutoffs, site_bases, nbits, symo
dict:
{size: list of Orbits within diameter cutoff}
"""
# Vector sum of a, b, c divided by 2.
# diameter + max_lp gives maximum possible distance from
# [0.5, 0.5, 0.5] prim centoid to a point in all enumerable
# clusters. Add SITE_TOL as a numerical tolerance grace.
orbits = {1: point_orbits}
max_lp = np.linalg.norm(exp_struct.lattice.matrix.sum(axis=0)) / 2
max_lp += SITE_TOL
prim_center = exp_struct.lattice.get_cartesian_coords([0.5, 0.5, 0.5])
centroid = exp_struct.lattice.get_cartesian_coords([0.5, 0.5, 0.5])
coords = exp_struct.lattice.get_cartesian_coords(exp_struct.frac_coords)
max_lp = max(np.sum((coords - centroid) ** 2, axis=-1) ** 0.5) + SITE_TOL

for size, diameter in sorted(cutoffs.items()):
new_orbits = []
neighbors = exp_struct.get_sites_in_sphere(
prim_center, diameter + max_lp, include_index=True
centroid, diameter + max_lp, include_index=True
)
for orbit in orbits[size - 1]:
if orbit.base_cluster.diameter > diameter:
Expand Down Expand Up @@ -1218,12 +1224,16 @@ def _gen_multi_orbits(point_orbits, exp_struct, cutoffs, site_bases, nbits, symo
if new_orbit not in new_orbits:
new_orbits.append(new_orbit)

# sorted by increasing cluster diameter, then by decreasing crystallographic
# multiplicity and finally by increasing number of correlation functions
# (bit combos) -> so that higher symmetry orbits come first
if len(new_orbits) > 0:
orbits[size] = sorted(
new_orbits,
key=lambda x: (
np.round(x.base_cluster.diameter, 6),
-x.multiplicity,
len(x),
),
)
return orbits
Expand Down
8 changes: 4 additions & 4 deletions tests/test_cofe/test_clusterspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ def test_function_hierarchy_fixed(single_subspace):
assert sorted(hierarchy[-1]) == [17, 21]
assert sorted(hierarchy[15]) == []
assert sorted(hierarchy[35]) == [5, 7, 10]
assert sorted(hierarchy[55]) == [6, 8, 13]
assert sorted(hierarchy[75]) == [7, 16, 21]
assert sorted(hierarchy[95]) == [9, 19]
assert sorted(hierarchy[56]) == [7, 8, 16]
assert sorted(hierarchy[75]) == [7, 14, 20]
assert sorted(hierarchy[95]) == [13, 19, 21]
assert sorted(hierarchy[115]) == [13, 19, 21]


Expand All @@ -515,7 +515,7 @@ def test_orbit_hierarchy_fixed(single_subspace):
assert sorted(hierarchy[1]) == [] # point
assert sorted(hierarchy[3]) == [1, 2] # distinct site pair
assert sorted(hierarchy[4]) == [1] # same site pair
assert sorted(hierarchy[15]) == [3, 5] # triplet
assert sorted(hierarchy[15]) == [3, 6] # triplet
assert sorted(hierarchy[-1]) == [6, 7]


Expand Down