## Introduction

The connection between structure and dynamics in supercooled liquids and glasses is one of the most intriguing puzzles in condensed matter physics. The conundrum: close to the glass transition, the dynamics slow down dramatically and become heterogeneous1,2 while the structure appears largely unperturbed. Largely unperturbed, however, is not the same as unperturbed, and many studies have attempted to identify slow local structures by exploiting dynamical information3,4. Unsupervised machine learning (UML) techniques may provide a novel way forward for shedding light on this problem.

Machine learning (ML) techniques are rapidly becoming a game-changer in the study of materials. Examples include speeding up computationally expensive calculations5, accurately distinguishing different crystal phases6,7, and even developing design rules for structural and material properties8. An exciting development is the design of UML algorithms that can autonomously classify particles based on patterns in their local environment9,10,11, even in disordered systems12. A key strength of these UML approaches is that they can find variations in local structure without any a priori knowledge of what might appear, opening the door to finding new, unanticipated structures.

The idea of an autonomous algorithm that picks out structural heterogeneities is a particularly appealing one in the context of supercooled liquids. In this field, the last few years have seen a frantic hunt for local structural features that can be interpreted as the underlying cause for dynamical heterogeneities. To this end, a number of studies have examined the prevalence and lifetimes of a large variety of locally favored structures13,14, correlated dynamics with local order parameters based on, e.g., tetrahedrality or packing efficiency15,16,17, and have looked at the dynamical effects of promoting specific local features18,19,20.

A major advance in correlating structure and dynamics was made through the use of supervised ML techniques. In particular, a number of studies have demonstrated that support-vector machines could be taught to recognize more mobile particles in several glass formers21,22,23,24. More recently, it was shown that even better dynamical predictions could be made using both convolutional neural networks and graph neural networks25. However, in order to train these algorithms, data linking structure to future dynamics had to be used. Methods that can autonomously detect purely structural heterogeneities offer an unbiased fresh look at the problem.

Here we show that a simple, efficient UML algorithm that we recently developed10 for detecting crystalline structure can be harnessed to detect structural heterogeneities in glasses. Our algorithm—which requires only a single snapshot as input—uses bond-order parameters (BOPs) to encode the local environments of the particles. Combining a neural network-based autoencoder with Gaussian mixture models, it then autonomously designs a structural order parameter capable of detecting the largest structural variation in the system.

We test the performance of the algorithm on three archetypical glass forming systems: binary hard spheres, Wahnström, and Kob–Andersen. These three model systems have been extensively studied in the context of fundamental glass formers, and have proven extremely valuable in unraveling many aspects of the glass transition (see e.g. refs. 3,26,27). Additionally, extensive past research has indicated that both binary hard spheres and the Wahnström model display a strong correlation between local structure and dynamical slowdown3,28, while these correlations are more nebulous for the Kob–Andersen model28. Collectively, these models provide an ideal playground for testing the ability of our UML technique to find local structural features in supercooled liquids.

## Results

### Setting up the UML algorithm

We construct configurations for our UML analysis by running molecular dynamics simulations of three glass formers inside the glassy regime. The glass formers we consider are all three-dimensional models and include binary hard spheres, Wahnström, and Kob–Andersen (see “Methods” for more details). We then select one equilibrated configuration in the glassy regime for each glass former to start our UML analysis.

The UML method we explore here is based on an algorithm we recently developed10 for detecting crystalline structures. As shown in Fig. 1, this analysis consists of three steps. First, the local environment of each particle is encoded into a vector of eight BOPs (see “Methods”). This local environment includes information regarding (approximately) the first two shells of neighbors. Secondly, an autoencoder is used to lower the dimensionality of this vector. The autoencoder is a neural network trained to reproduce its input as its output. This neural network is especially designed to contain a “bottleneck” with a lower dimensionality than the input vector, such that the network is forced to compress the information, and subsequently decompress it again. After training the autoencoder, we only retain the compression part of the network, and use it as our dimensionality reducer. Note that this algorithm allows for non-linear transformations to a lower dimension. Third, the particles are then grouped in this lower-dimensional space using Gaussian mixture models. A full description of this algorithm is given in the Supplementary Methods.

This UML algorithm has two main parameters that need to be chosen: (i) the dimensionality of the bottleneck of the autoencoder c and (ii) the number of Gaussian components NG used to fit the distribution in the lower-dimensional space. To choose the dimensionality of the bottleneck, we require that the autoencoder reproduces at least 75% of the variance of the input data. In Fig. 2a–c we show the fraction of variance explained (FVE, see “Methods”) by the autoencoder as a function of c for the chosen snapshots from all three models. Based on this analysis, we choose c = 2 for both the binary hard spheres and the Wahnström models, and c = 4 for the Kob–Andersen model. To determine the number of Gaussians NG, we measure the Bayesian Information Criterion (BIC, see Supplementary Methods) as a function of NG, and plot it for each snapshot in Fig. 2d–f. The optimum number of Gaussians corresponds to the minimum in the BIC analysis, which for all models is found at NG = 2. As each Gaussian can be seen as generating a cluster in the data, this means that the UML identifies two clusters of particles for all three models.

In addition to these two parameters, the depth and width of the neural network forming the autoencoder can be varied. In this paper we always use a network geometry of one hidden layer of dimension 40 for both the encoder and the decoder parts of the network. In the Supplementary Note 1, we explore the behavior of our UML algorithm, with respect to, e.g., the dimensionality of the input vector, repeated network trainings, network structure, and the dimensionality of the bottleneck c. We find the algorithm to be largely robust with respect to changes in these parameters.

### Extracting a scalar order parameter Pred

To encode the UML clustering into a single scalar order parameter, each particle is assigned a probability to belong to one of the two clusters. To this end, we label the two clusters with different colors—white and red, see Fig. 1. For each particle i, we then define Pred(i) as the probability that the particle belongs to the red cluster based on the Gaussian mixture model (see “Methods”). This results in a single scalar order parameter between 0 and 1, with values near 0 indicating particles whose environment more closely matches the white cluster, and values near 1 indicating particles whose environment more closely matches the red cluster. Note that by definition this order parameter captures the largest structural heterogeneities in the system, as found by the UML approach. We would like to stress that in contrast with supervised ML studies of glasses21,22, our approach uses no dynamical information, and is trained on a single static snapshot for each system.

Using this scalar order parameter, we analyze the three glassy configurations, and color each particle based on Pred. The results are shown in Fig. 3a–c. In all three systems, the system shows clear structural heterogeneity, consisting of regions of both environments.

### Correlating Pred with dynamics

The question now is whether the structural variations detected by Pred are correlated with the dynamics. To probe this, we measure the dynamic propensity Di(δt) of particle i: a measure for how mobile particle i will be over the next time interval δt (see “Methods”), which has proven useful in supercooled liquids15,16,29,30. In Fig. 3j–l, we plot the Spearman’s correlation coefficient between Pred and Di(δt), as a function of the time interval δt. As one might expect, this correlation is weak both for very short time scales, where particles are simply rattling within their cages, and for long time scales where the system loses memory of its initial configuration. It peaks slightly below the structural relaxation time τα, indicating that we have indeed identified structures connected to the structural relaxation.

To further investigate the correlation between the UML order parameter and the dynamics, in Fig. 3d–f, we color the particles according to their dynamic propensity, with δt chosen to correspond to the maximum in the correlation. Comparing to Fig. 3a–c, it is clear that regions of high dynamic propensity correspond to high values of Pred, indicating that the particles identified as part of the red cluster also largely correspond to the faster particles in the system. The correlation can be further improved by averaging Pred over particles within a small local region, similar to what was found in previous studies15,16,31. This is shown in the snapshots in Fig. 3g–i and the solid lines in Fig. 3j–l, where we show the results for a local averaging radius rc = 2σ. In all cases, the correlation between the averaged $${\bar{P}}_{{\rm{red}}}$$ and Di peaks very close to τα. This is slightly later than the unaveraged version, likely because we are now looking at larger regions, which will take more time to rearrange. Note that here we resolved the inherent symmetry between red and white clusters, by always labeling as red the cluster that on average turns out to be faster.

As also found in previous work28, Kob–Andersen seems to be the model whose behavior is less well captured by our analysis. This might be related to the attraction that could induce heterogeneities over large length scales due to the proximity of a gas–liquid phase coexistence32,33. This kind of effect would not be fully captured by our (highly local) observables.

To summarize, in all cases the structural heterogeneities identified by our UML order parameter correlate significantly with the local dynamics. This leads to two intriguing questions: (i) are these structural correlations to the dynamics strong or weak in comparison to literature? and (ii) how does the method perform when compared to supervised learning algorithms specifically designed to predict dynamics?

With respect to the first question (i), in the case of binary hard spheres, previous literature has shown a strong correlation between local tetrahedrality and both global and local dynamics. At the same state point shown in Fig. 3 for binary hard spheres, the correlation between local tetrahedrality and local dynamics was shown to reach  ≈0.63 for small particles15. Our UML order parameter significantly exceeds this with a value of  ≈0.72. For Wahnström, and Kob–Andersen, Hocky et al.28 examined the correlation between locally favored structures and dynamic propensity. Although the state points are not exactly the same as ours, they found a slightly stronger correlation for Wahnström, and a slightly weaker one for Kob–Andersen.

With respect to the second question (ii), we will focus on the Kob–Andersen system where the most extensive data exist. In a recent article, Bapst et al.25 examined both a variety of physics-based methods for predicting propensity (based on soft modes34, the Debye–Waller factor30, or potential energy29,35), as well as state of the art supervised ML algorithms21,25. As shown in Supplementary Fig. 7, at the strongest supercooling $${\bar{P}}_{{\rm{red}}}$$ (with a correlation of 0.4) correlates better than any of the physics-based methods (best correlation: 0.35), but worse than the supervised ML algorithms (range of correlations: 0.4–0.6). The higher correlations in the supervised algorithms were expected as these algorithms explicitly fit dynamic propensity as a function of structural features. However, in contrast to the UML algorithm, such fitting requires a large amount of data and computational effort.

### Variation of Pred with supercooling

Thus far, we have shown that Pred is capable of predicting local variations in the dynamics in each of our systems. A natural next question is whether the same order parameter can be used globally, i.e. to capture the onset of dynamical arrest as the glass former is supercooled. This can be done by checking whether the “slow” structural group becomes more dominant as we move closer to the glass transition, similar to what was seen in, e.g., refs. 15,23,36. To confirm that the UML-designed order parameters are able to capture the onset of dynamical arrest without the need for retraining, we use the exact same UML order parameter trained on the snapshots of Fig. 3 on systems equilibrated at lower degrees of supercooling: lower packing fractions η for hard spheres, and higher temperatures T* for the other two models. In Fig. 4, we plot 〈Pred〉, defined as the globally averaged value of Pred, as a function of the degree of supercooling for each glass former. In all cases, 〈Pred〉 increases monotonically as the system moves out of the glassy regime. Hence, the structures we identify as white (slow) at strong supercooling disappear as we move away from the glass transition—clearly showing that the UML order parameter identifies local structures that are important for the dynamical slowdown. Interestingly, as shown in the insets in Fig. 4, the relationship between 〈Pred〉 and the structural relaxation time is exponential for both the hard sphere and the Wahnström system.

### Predictive power as a function of supercooling

It is well known that the dynamical heterogeneities of supercooled liquids become weaker and shift to shorter time scales as we move away from the glass transition. As a result, the correlation between structure and dynamics should also become weaker3,15,16. To test how the predictive power of our UML analysis depends on the degree of supercooling, we perform a new UML analysis on each of the glass formers at different packing fractions and temperatures. Specifically, for each state point we find a new projection and classification, and determine the correlation between $${\bar{P}}_{{\rm{red}}}$$ and Di. Note that this is different from our analysis for Fig. 4 as there we used only a single-order parameter for each system. By retraining the order parameter, we correlate the dynamical heterogeneity with the largest structural variation that we can find at each individual state point. In Fig. 5 we show that indeed the correlations become weaker and shift to shorter times (along with τα) as we move away from the glassy regime.

In Fig. 5 we have kept the local averaging radius rc fixed at 2σA for the calculation of $${\bar{P}}_{{\rm{red}}}$$. However, in practice, the maximum in the correlation depends on the choice of rc, as shown in the Supplementary Note 4. Specifically, the optimal value of rc tends to increase with the degree of supercooling. It might be tempting to interpret this growth as a growing static length scale, a topic of significant debate in the glass community (see, e.g., refs. 3,37,38,39,40). However, it is important to realize that this optimum value is determined by using dynamical data (i.e. the correlation with the dynamic propensity). As such, the optimum in rc should be seen as a dynamic length scale. In contrast, one can straightforwardly extract a static correlation length from our order parameter Pred, by determining its autocorrelation function as a function of distance. As shown in the Supplementary Note 5, this method gives an essentially constant correlation length for each of our three systems, with little to no growth with increasing supercooling. Hence, our method does not yield a clearly growing, purely static length scale.

### Characterizing the local structure of the different clusters

As the UML is based on a description of local environments in terms of BOPs41, a natural question to ask is how the two identified clusters differ in terms of their BOPs. In Fig. 6, we plot the mean value of all BOPs q1, … , q8 for both red (more mobile, Pred > 0.5) and white clusters (Pred < 0.5) for the three snapshots depicted in Fig. 3. Perhaps surprisingly, we do not observe dramatic differences in the average BOPs of the two clusters. The small variations that are seen, however, exhibit a few notable trends. Specifically for all three models, q2, q3, q4, q5, and q8 are higher in the red, more mobile cluster. Additionally, for both hard spheres and Wahnström, q6 is the highest in the slow cluster; note that q6 is often connected to close packed crystal structures like face-centered cubic and hexagonal-close packed.

As a second avenue for differentiating the local structure in each group we use topological cluster classification (TCC)42. This algorithm detects a set of pre-defined clusters corresponding to low-energy (or high-packing) structures in a few model systems. As shown in Fig. 7, we find that for the hard sphere and Wahnström systems, Pred negatively correlates strongly with local structures built up out of one or more tetrahedra, while it positively correlates with TCC clusters built from square pyramids. For the Kob–Andersen mixture, Pred still negatively correlates best with tetrahedral environments, but correlations are significantly weaker. Interestingly, TCC detects essentially no clusters that correlate positively with Pred, suggesting that these particles have local environments not detected by TCC—indicating that our UML is picking up on structures not included in the low-energy (or high-packing) structures built into TCC. This is one area where the UML approach shines: it is not restricted by a priori assumptions about the features that are considered in the clustering.

## Discussion

Overall, our results are consistent with the idea that at least part of the dynamical slowdown is driven by the emergence of a set of locally favored structures, in agreement with earlier observations on these models (see, e.g., refs. 19,43,44). As the system is pushed closer to the glass transition, these structures become more stable, due to a more favorable local packing or potential energy, with a profound impact on both local and global dynamics3. What is intriguing is the observation that this variation in local structure can be effectively captured by a one-dimensional machine-learned order parameter, and that this structural order parameter strongly correlates with the dynamics.

Interestingly, our Gaussian clustering approach indicates that the structural features of all of our systems, once projected onto the lower-dimensional space, are best described by two Gaussians. This is consistent with a previously proposed picture where supercooled liquids can be interpreted as a mixture of two competing structural populations20. Note that a similar two-state picture has been extremely successful in understanding the glassy behavior of supercooled water31,45, where the competing local structures are ostensibly linked to different thermodynamic phases at extreme supercooling.

The UML analysis used here is both extremely simple to implement as well as very efficient to run. The input is a single snapshot, and the analysis involves standard BOP calculations, fitting a small neural network-based autoencoder, and Gaussian mixture models; all of which are fast, standard methods that are commonly available in open-source libraries. The total analysis costs only a few minutes of computational time. While the simplicity of this algorithm is one of its main strengths, this also implies that there are many potential routes towards expanding this method—for instance, adding information about the local density to the local descriptors, and/or projecting the information onto higher dimensional order parameters. Such additions might increase the accuracy, although likely at the cost of the simplicity and speed. Already, a number of UML techniques exist that classify particles based on local structure9,10,11,12, using different definitions of local structures, and different approaches for classification. It will be interesting to see which of these performs best in purely heterogeneous environments like glasses.

In conclusion, we have demonstrated that a simple and fast autoencoder-based UML approach is a powerful tool in the development of new structural order parameters in supercooled liquids. We demonstrated that the structural heterogeneities captured by this order parameter are strongly correlated with the dynamical heterogeneities in all three glass formers studied here, creating a new way forward for unraveling the microscopic origins of dynamical slowdown in supercooled liquids.

## Methods

### Models

We consider three model glass formers in three dimensions: binary hard spheres, Wahnström26, and Kob–Andersen27. Both Wahnström and Kob–Andersen are binary mixtures of Lennard–Jones (LJ) particles.

The binary hard-sphere model we consider is a mixtures of 30% large A particles and 70% small B particles, with size ratio σB/σA = 0.85. The mode coupling theory (MCT) packing fraction for this model is ηMCT = 0.584 (see Supplementary Note 7).

The Wahnström model26 is an equimolar (50–50%) mixture of A and B particles. The LJ interaction strength between all pairs of particles is identical (ϵAA = ϵAB =  ϵBB), but the B particles are slightly larger than the A particles (σBB = 1.2σAA and σAB = 1.1σAA). The LJ potential is truncated and shifted at the minimum in the potential, such that the interactions are purely repulsive. The MCT temperature is kBTMCT/ϵAA = 0.652 (see Supplementary Note 7).

The Kob–Andersen model27 is a non-additive mixture of 80% (large) A particles and 20% (small) B particles. The interaction parameters are σBB = 0.88σAA, σAB  = 0.8σAA, ϵBB = 0.5ϵAA, and ϵAB = 1.5ϵAA. The LJ potential is truncated and shifted at a cutoff distance rc,ij = 2.5σij (where ij {AB}), such that the attractive part of the potential is retained. The MCT temperature for this model is kBTMCT/ϵAA = 0.42 (see Supplementary Note 7).

For both Wahnström and Kob–Andersen, we define the reduced number density $${\rho }^{* }=\rho {\sigma }_{AA}^{3}$$ and reduced temperature T* = kBT/ϵAA, with kB Boltzmann’s constant.

### Simulations

For all models, we use molecular dynamics simulations in the canonical ensemble. In the case of hard spheres, the simulations are performed using an event-driven approach. For Wahnström and Kob–Andersen, we use the simulation package LAMMPS46.

Dynamic propensities are calculated as an isoconfigurational ensemble average of the absolute displacement of each particle. In other words, we perform at least 32 independent simulations starting from the same initial configuration, but with randomly chosen velocities for all particles. The dynamic propensity of particle i after a time interval δt is then defined as

$${D}_{i}(\delta t)={\langle \left|{{\bf{r}}}_{i}(\delta t)-{{\bf{r}}}_{i}(0)\right|\rangle }_{{\rm{c}}},$$
(1)

where ri(t) is the position of particle i at time t, and the average is taken over the independent runs.

In order to obtain the relaxation time τα, we calculate the self-intermediate scattering function (ISF) for the Wahnström and the Kob–Andersen systems, and the total intermediate scattering function for the hard spheres:

$$F(q,t)=\frac{\left\langle{\sum }_{j,k}\exp \left\{i{\bf{q}}\left[{{\bf{r}}}_{j}(t)-{{\bf{r}}}_{k}(0)\right]\right\}\right\rangle}{\left\langle{\sum }_{j,k}\exp \left\{i{\bf{q}}\left[{{\bf{r}}}_{j}(0)-{{\bf{r}}}_{k}(0)\right]\right\}\right\rangle},$$
(2)

where ri is the position of particle i and q is a wave vector. We calculate the ISF at an inverse wavelength q = q corresponding to the first peak of the structure factor. After that, we fit the long-time decay of the ISF with a stretched exponential function $$\gamma \exp \left[-{(t/{\tau }_{\alpha })}^{\beta }\right]$$, where γ, β, and the relaxation time τα are fit parameters.

### Local environment description

To characterize the local environment of each particle, we use an averaged version of the local BOPs introduced by Steinhardt et al.41. First, we define for any given particle i the complex quantities

$${q}_{lm}(i)=\frac{1}{{N}_{b}(i)}\sum _{j\in {{\mathcal{N}}}_{b}(i)}{Y}_{l}^{m}({{\bf{r}}}_{ij}),$$
(3)

where $${Y}_{l}^{m}({{\bf{r}}}_{ij})$$ are the spherical harmonics of order l, with m an integer that runs from m = −l to m = +l. Additionally, rij is the vector from particle i to particle j, and $${{\mathcal{N}}}_{b}(i)$$ is the set of nearest neighbors of particle i, which we will define later. Note that $${{\mathcal{N}}}_{b}(i)$$ contains Nb(i) particles. Then, the rotationally invariant BOPs, ql, are defined as41

$${q}_{l}(i)=\sqrt{\frac{4\pi }{2l+1}\mathop{\sum }\limits_{m=-l}^{l}| {q}_{lm}(i){| }^{2}}.$$
(4)

Finally, we define an average $${\bar{q}}_{l}(i)$$ as

$${\bar{q}}_{l}(i)=\frac{1}{{N}_{b}(i)+1}\left[{q}_{l}(i)+\sum _{k\in {{\mathcal{N}}}_{b}(i)}{q}_{l}(k)\right].$$
(5)

Note that by taking this average, $${\bar{q}}_{l}(i)$$ depends on the positions of not only the nearest neighbor shell of particles but also the second neighbor shell. Additionally, the quantities in Eq. (5) differ from the averaged BOPs introduced by Lechner and Dellago47 where first the averaging is performed on the non-rotational-invariant qlm, and then rotational-invariant quantities are built.

Our description of the local environment of particle i consists of an eight-dimensional vector,

$${\bf{Q}}(i)=(\{{\bar{q}}_{l}(i)\}),$$
(6)

with l [1, 8].

The set of nearest neighbors of each particle is identified with a parameter-free criterion called SANN (solid angle nearest neighbor)48 for the hard spheres and Wahnström models. In this approach, an effective individual cutoff radius, rc(i), is found for every particle i in the system based on its local environment. This method is not inherently symmetric, i.e., j might be a neighbor of i while i is not a neighbor of j. However, symmetry can be enforced by either adding j to the neighbors of i or removing i from the neighbors of j. In this study, we applied the latter solution. For the Kob–Andersen mixture, we obtained better results with a fixed cutoff radius (see Supplementary Note 8 for a comparison).

### Unsupervised ML

The UML approach used here follows the method outlined in ref. 10. A detailed description is provided in the Supplementary Methods.

### Fraction of variance explained

The optimal number of nodes in the bottleneck layer of the autoencoder, c, is determined by computing the FVE by the reconstruction,

$$\,{\text{FVE}}\,=1-\frac{\mathop{\sum }\nolimits_{i = 1}^{N}{\left\Vert {\bf{Q}}(i)-{\hat{\bf{Q}}}(i)\right\Vert }^{2}}{\mathop{\sum }\nolimits_{i = 1}^{N}{\left\Vert {\bf{Q}}(i)-{\bar{{\bf{Q}}}}\right\Vert }^{2}},$$
(7)

where $$\bar{{\bf{Q}}}$$ is the mean input vector and N is the number of particles. To choose c we require that this fraction is at least 75%.

### Definition of Pred

As described in the main text, for all three models, after using the UML method to reduce the dimensionality of the data, we then cluster the data using Gaussian mixture models. In all cases, the optimum number of clusters was found to be two, which we label red and white. We then used this clustering to create a scalar order parameter Pred which quantifies the local structure around the particles as follows:

$${P}_{{\rm{red}}}=\frac{{g}_{{\rm{red}}}}{{g}_{{\rm{white}}}+{g}_{{\rm{red}}}},$$
(8)

where gwhite(red) is the value of the fitted Gaussian peak associated with the white (red) cluster. Note that by definition Pwhite + Pred = 1. Hence, as we go from the white peak to the red peak and beyond (where gwhite is very small), Pred monotonically increases. Note that even though dynamics are not used in this analysis, a posteriori we always assigned the label red to the cluster with the most mobile particles.

### TCC analysis

To correlate Pred with locally favored structures in the three model systems, we use the TCC algorithm42. Specifically, we count for each particle the number of clusters it is involved in of each type detected by the algorithm. We then calculate the correlation between the number of clusters of a given type a particle is a part of, and Pred. Note that in its original form, TCC does not accurately count simple clusters (specifically tetrahedra, square pyramids, and pentagonal pyramids) which are subsumed into larger combinations of such clusters. Here we have adapted the algorithm to correct for this choice.