K-means Clustering
Separate crystalline atoms from grain-boundary atoms in a nanocrystalline metal by K-means clustering of per-atom von Mises stress, potential energy and atomic volume.
K-means Clustering classifies atoms with per-atom physical quantities instead of their geometry. Following Amigo (2020), it clusters the atoms by von Mises stress, potential energy and atomic volume, which differ clearly between crystal interiors and grain boundaries. The cluster with the lowest stress is labeled FCC and the others grain boundary. Use it on nanocrystalline FCC metals when you already write these quantities from your simulation, and as a cutoff-free comparison with geometric methods.
| Key | Version | Builds |
|---|---|---|
kmeans-clustering | 1.1.0 | Linux, macOS, Windows |
K-means Clustering is a Python plugin with no browser build, so it can't be installed on a machine that runs in the browser or the desktop app. The machine running it creates a virtual environment and installs its requirements (numpy, pandas, pyarrow, scikit-learn) the first time.
How it works
- The plugin reads the three feature columns from the frame and scales each one to the range 0–10 (min-max scaling).
- It runs K-means with k-means++ initialization (Elkan's algorithm, up to 200 iterations), repeated K-means initializations times, and keeps the best run.
- The cluster whose centroid has the lowest von Mises stress is labeled
FCC. With two clusters the other one isGrain Boundary; with more they areGrain Boundary 1,Grain Boundary 2, and so on.
Inputs
The frame must have the columns id, x, y, z and the three feature columns, under the names you set. These usually come from your LAMMPS dump, for example the von Mises stress computed from compute stress/atom, the potential energy from compute pe/atom and the atomic volume from compute voronoi/atom. A missing column fails the stage with Columns [...] not found in dump, which lists the columns available.
Arguments
| Argument | Type | Default | Allowed values | Description |
|---|---|---|---|---|
Number of clusters n_clusters | number | 2 | ≥ 2, step 1 | Number of clusters. 2 separates crystal from grain boundary. |
K-means initializations n_init | number | 50 | ≥ 1, step 1 | How many times K-means runs from different starting centroids; the run with the lowest inertia is kept. |
Random seed seed | number | 36 | ≥ 0, step 1 | Seed of the centroid initialization, for reproducible clusters. |
Von Mises stress column col_svm | string | Svm | A column name of the frame | Column with the per-atom von Mises stress. It also decides which cluster is FCC. |
Potential energy column col_epot | string | Epot | A column name of the frame | Column with the per-atom potential energy. |
Atomic volume column col_vol | string | Vol | A column name of the frame | Column with the per-atom volume. |
Outputs
| Exposure | What you get |
|---|---|
| K-means Clustering | A listing with the number of atoms and clusters and the stress column used, and a clusters sub-listing: cluster_id, label, count, percentage, and the minimum, maximum and mean von Mises stress of the cluster. |
| K-means Model | A listing, and a 3D model of the atoms grouped by label (FCC, Grain Boundary, …). |
The workflow declares the per-atom properties cluster_id (Cluster ID), Svm (Von Mises stress), Epot (Potential energy) and Vol (Atomic volume). If you rename the columns, the table carries your names instead.
Reference
N. Amigo, "Crystalline structure and grain boundary identification in nanocrystalline aluminum using K-means clustering" (2020), submitted to Modelling Simul. Mater. Sci. Eng.