cluster

27 views
Skip to first unread message

jude vishnu

unread,
May 2, 2023, 9:06:46 AM5/2/23
to freud-users
Dear all,
I have a question regarding cluster analysis module. I read that the cluster module takes care of periodic boundaries. If I  want to use the clusters returned here and find the spanning clusters (cluster that span across box and connected across PBC) out of these, what should I do?
Just selecting clusters with particles near the box edges does not seem to work. Is there a way to identify such clusters easily by using other modules in freud? Here the clusters I am looking at are  of polymers under-going physical cross-links.

Regards,
Jude

Tommy Waltmann

unread,
May 2, 2023, 12:02:34 PM5/2/23
to freud-users
Hi Jude,

An algorithm which determines if a cluster is percolating will try to find a path P through the cluster network such that the path starts and ends at the same vertex and crosses the periodic boundaries at some point. Implementing this kind of algorithm yourself would require using a fairly straightforward variant of depth-first search which keeps track of whether the periodic boundaries have been crossed and terminates when the first node in the search is found again.

You may, however, find it more useful to use another package that does graph algorithms rather than write your own. I don't know if any such packages will implement the specific kind of DFS you are looking for here, however. NetworkX (https://networkx.org/) is the only python package I know of which implements these kinds of algorithms.

Let me know if you have any other questions!

Best,
Tommy

Bart Bruininks

unread,
Oct 4, 2023, 11:43:53 AM10/4/23
to freud-users
Hey Mohm and Tommy,

Sorry for invading in the thread here and maybe I am a bit late to the party but I have exactly implemented such a search in a package called MDVContainment. Altough it seems like a different problem to classify inside and outside it actually heavily relies on percolation theory. In other words anything which ends up to be non-percolating is contained in something which is (in a binary partitioning of density). This percolative property of the connected components is stored in a graph in my algorithm and is called the rank of the component. A rank of 0 is non-peroclative, a rank higher than 0 indicates the amount of orthogonal dimensions in which it is percolative.

Some demonstration code below on how to do it, the output will be a list of percolative atomgroups. WE can also get the percolations dict which says which compnent label is percolative or not. Components which are in the selection are positive and components which are not are negative integeres in the percolations dict.

## Example for obtaining percolative densities in periodic MD data in an efficient manner using MDVContainment (Bart Bruininks).
# pip install MDAnalysis
import MDAnalysis as mda
# git -clone https://github.com/BartBruininks/mdvcontainment; pip install -e .
import mdvcontainment as mdvc
# A simple periodic bilayer in xy (percolating the space)
universe = mda.Universe('/media/windows/Users/Bart/projects/test_systems/bilayer_chol_dry/eq_dry.gro')
selection = universe.select_atoms('not resname W WF ION') # place MDA selection here
# Run the containment analysis
containment = mdvc.Containers(selection, resolution=1)
# Obtain the ranks, the rank indicates the amount of orthogonal dimensions
#  the component is percolating. Therefore a rank 0 indicates
#  no percolation and any non-zero rank is percolating.
segment_ranks = containment.data['all_ranks']
segments2components_map = containment.data['combined_relabel_dict']
percolations = {}
for segments, rank in segment_ranks.items():
    if rank > 0:
        percolations[segments2components_map[segments]] = 'Percolative'
    else:
        percolations[segments2components_map[segments]] = 'Non-percolative'
# You can get the atomgroup (point cloud object) for every percolative component
percolative_atomgroups = []
for candidate in percolations:
    if percolations[candidate] == 'Percolative':
        percolative_atomgroups.append(containment.get_atomgroup_from_components([candidate]))
# The empty space is also perculating!
print(percolative_atomgroups)
#r_containment.plot()

Cheers,

Bart
Op dinsdag 2 mei 2023 om 18:02:34 UTC+2 schreef Tommy Waltmann:
Reply all
Reply to author
Forward
0 new messages