1 Introduction

Fig. 1
figure 1

Methodology: a bidisperse mixture is simulated in a silo configuration. Properties including grain velocity, acceleration and contact forces are then used to train a random forest classifier to distinguish large and small grains. Different combinations of properties are used to identify which present statistical differences between grain species. The random forest classifier is composed of 100 trees, each considering a subset of the features and producing a vote for classification. The final classification is the one receiving the most votes

The internal dynamics of granular flows is never steady and uniform. The velocity and contact forces of grains vary greatly in space and time, even when the granular packing is subjected to a steady and uniform shear [1,2,3,4]. Conventional statistics have previously enabled the characterisation of the the distribution of these quantities. In dense flows, they revealed a bi-modal distribution of contact forces with a mean scaling as \(Pd^2\), where P is the pressure and d the grain size, and extreme forces exceeding this by an order of magnitude. They also revealed a normal distribution of grain velocities, with a standard deviation scaling as \(\dot{\gamma }d\) in collisional flows [5,6,7] and \(\dot{\gamma }d/\sqrt{I}\) in dense flows [8,9,10,11,12], where \(\dot{\gamma }\) is the shear strain rate and I the inertial number. Understanding this dynamical heterogeneity is key to predicting the behaviour of granular flows as a continuum. For instance, several theories explain the \(\mu (I)\) rheology [13,14,15] and non-local models in terms of force network and grain kinematic [16,17,18,19].

Granular flows comprised of different grain sizes exhibit a more complex internal dynamics, which may give rise to some segregation [20]. Typically, larger grains migrate preferentially in zones of lower shear rate. This is the case in silo flows where large grains tends to concentrate in the center of the silo [21, 22] and may therefore be first to discharge. In bi-disperse flows, size segregation is understood to be driven by the differences in velocity fluctuations and contact force between species [23, 24]; these differences become more pronounced for larger size ratios. Segregation is counteracted by the remixing arising from shear-induced diffusion [25]. As a result, segregation develops only for large enough size differences. However, in mixture with moderate grain size differences, whether and how the dynamics of small grains might differ from that of larger grains remains to be established. We propose here to explore the potential for machine learning methods to assist with addressing this question.

Machine learning (ML) methods are designed to make predictions based on a training set of data, while being oblivious of any causal relationship. They have recently been used to predict the behaviour of granular matter. Image-based ML has related grain morphology to the effect on interfacial friction in tribology [26], to relate the grain velocity field to the frictional state of a sheared layer undergoing stick–slip [27], to predict of the discharge time of granular flows in hoppers [28], and to infer micromechanical parameters from X-ray imaging [29, 30]. ML not based on images were found to enable prediction of seismicity of laboratory-scale earthquakes, specifically of their stick–slip stress time series [31], and to enable optimal bulk-feeder system selection based on grain micro-mechanical properties [32]. They were also found effective at classifying different types of grains based on their kinematics while falling on an inclined plane [33] and to the behaviour of a packing undergoing compression from grain kinematics and contact texture [34]. Most relevant to granular rheology, a Support Vector Machine method was shown to enable the prediction of particle rearrangement from the knowledge of their microstructure in a variety of flowing soft materials [35].

In this Paper, we explore how the predictive power of machine learning can be used to better understand the internal dynamics of granular flows. We conducted discrete element method simulations of bidisperse granular flows in a silo configuration. The strategy consists of training a Machine Learning classifier to distinguish large grains from small grains, based on information such as contact forces, grain velocities and acceleration. Instances where classification fails are taken to mean that the dynamical features are similar between small and large grains. On the contrary, a successful classification would mean that the dynamical features present some noticeable differences between grain species.

The paper is organised as follows: the specifics of the DEM and ML methods are presented in Sect. 2 and the ML classification results are discussed in Sect. 3.

2 Methods

The method is comprised of the two steps illustrated in Fig. 1: first simulating a granular flow comprised of two grain sizes in a silo and then the use of a random forest classifier to attempt to classify small and large grains based on selected dynamical properties.

2.1 Granular flows in silo

We use the discrete element method (LIGGGHTS [36]) to simulate the flow of a bidisperse mixture of grains in a silo. The mixture is comprised of 14, 000 grains of diameter \(d=20\,\textrm{mm}\) or 30 mm. The proportion of small and large grains is equal in number. The density of the grains is \(\rho =2500\,\mathrm {kg/m}^3\). They interact via visco-dissipative elastic contact characterised by a linear stiffness \(k=10^7\,\mathrm {N/m}\), a coefficient of friction of 0.3 and a coefficient of restitution of 0.3. Gravity is set at 9.81 m/s\(^{2}\) and there is no long range interaction or contact adhesion.

Grains are gradually fed during a period of 5 s by placing them randomly and without contact at the top of the silo (see Fig. 1). They then free fall (zone I), form a dense flow above the silo outlet (zone II), exit the silo (zone III) and form a heap on the ground (zone IV). These zones are depicted on Fig. 1.

In zones I and II, the flow is collisional with large interparticle spacing and some binary collisions. In zones III and IV, the flow is dense or stopped with multiple, sustained contacts. The cylindrical part of the silo is 2 m tall and 1.52 m in diameter. The constriction is 0.97 m tall. The outlet is 0.43 m in diameter and is located 1.5 m above the ground. In the analysis below, the zones locations relative to the ground are: 4.1–3.6 m for I, 3–1.9 m for II, 1.2–0.8 m for III and 0.4–0 m for IV.

Individual grain properties including position \(\{x, y, z\}\), translational velocity \(\{v_x, v_y, v_z\}\), rotational velocity \(\{\Omega _x, \Omega _y, \Omega _z\}\) and the net force they are subjected to \(\{f_x, f_y,f_z\}\) (sum of contact forces and self weight) are recorded throughout the flow, for a period of 25 s. The present analysis focuses on classification using a discharge time of 25 s. We have checked that similar classification accuracy could be obtained considering period of time as short as 1 s.

2.2 Random forest classifier

We trained and tested a random forest classifier using one or more features including the time series of grain velocity, angular velocity, acceleration, and total force. The dataset was split into two parts: \(80\%\) of the grains were used to train the classifier, and the remaining \(20\%\) were used to test its predictive ability once trained. This process was repeated five times by taking random samplings of grains for training and testing. During the testing phase, a prediction was made for each grain in the testing sets, whereby the grain was classified as either small or large based on the time series of its selected features. The accuracy of the classifier was measured by evaluating the algorithm’s ability to classify particles as small or big. The classification was performed using a binary class separation method, where particles were detected as either small or large. The classifier accuracy is measured by:

$$\begin{aligned} \epsilon = \frac{\text {number of correct predictions}}{\text {number of predictions}} \end{aligned}$$

In a system comprised of an equal number of small and large grains, \(\epsilon \) typically varies from 0.5 to 1. \(\epsilon = 0.5\) corresponds to a random prediction, and indicates an inability for the random forest to distinguish large from small grains. \(\epsilon =1\) reflects a perfect prediction, where the random forest correctly classifies all small and large grains.

We chose to use a random forest method in preference to other classifiers, such as neural networks, due to its higher degree of interpretability. In particular, random forests are able to rank the features as a function of their importance in the prediction. This allows us to detect which features are the most important to achieve classification, and therefore which features distinguish small from large grains.

The raw data collected was subjected to preprocessing using the Visual Studio Code interface with Python version 3.10.6. This step was crucial in preparing the data for classification. For the construction, training and testing of the random forest classifier, we used the Sklearn library in Python. Specifically, we employed the Sklearn.ensemble. RandomForest Classifier algorithm due to its ability to effectively handle complex datasets.

We have checked that similar prediction accuracy could be obtained using different machine learning method including Support Vector Method (SVM) and Artificial Neural Network. We chose the random forest against (ANN) for its higher degree of interpretability, enabling the detection of the importance of individual features in the classification. While SVM are also interpretablility and could have been used for this study, we chose random forests for their lower susceptibility to over fitting [37].

Fig. 2
figure 2

Feature importance for the classification considering a all grains, b grains in the dense zones II and IV and c grains in the collisional zones I and III. (Main) relative importance of features when all features are feed to the classifier. (inset) iterative approach showing the classification accuracy evolution when features of the least importance are removed one after the other

3 Features enabling classification

We propose two approaches to identify the features enabling classification. The first approach is “iterative”: features are all used at first and then removed one by one. The second approach is “direct”: it probes some selected combinations of features.

3.1 Iterative approach

The first step of this approach is to consider all of the grains in the flow and to use all of the available features for training and testing the classifier. These features include the norm of the grain acceleration \(\big |{\textbf {a}}\big |\) and of the total force it is subjected to \(\big |{\textbf {f}}\big |\), the grain position, velocity and rotational velocity.

With all these features, the classifier accuracy reaches 0.92. This implies that some of these features are different for large and small grains. Figure 2a shows the relative importance of each feature for the final classification: the higher the score the more important the feature is. Three features stand out: the acceleration \(\big |{\textbf {a}}\big |\), the force \(\big |{\textbf {f}}\big |\) and the vertical position z. Other features such as velocity and rotational velocity seem to not contribute significantly to the classification.

To demonstrate this, we conducted a resilience test whereby features are excluded one after the other, starting with those of least importance. Resulting classification accuracy are shown in Fig. 2a (inset). Using all 16 features (listed on the y axis of Fig. 2a) yields an accuracy of 0.92. Removing features of least importance (in order: \(v_y\), then \(v_x\), then x etc.) does not significantly impact the classification accuracy. \(\epsilon \) remains above 0.9 until two features are left: the acceleration \(\big |{\textbf {a}}\big |\) and the force \(\big |{\textbf {f}}\big |\).

However, once the force is removed, the classification based on acceleration only drops significantly to 0.67. This suggests that the information distinguishing large from small grains is contained in both their acceleration \(\big |{\textbf {a}}\big |\) and the force \(\big |{\textbf {f}}\big |\) they experience.

We repeated the same iterative approach by selecting grains that are in the collisional zones (I and III) or in the dense zone (II and IV). Classification accuracy in Fig. 2b,c show that, in the dense zones, both force and acceleration are needed to achieve optimal classification while the other features play a negligible role. In contrast, only one feature—the vertical force—is sufficient to achieve classification in the collisional zones. This suggests that the information distinguishing small from large grains are different in dense and collisional flows.

Table 1 Classification accuracy obtained with the “direct approach”, using different features and combination of features
Fig. 3
figure 3

Distribution of (left to right) force \(\big |{\textbf {f}}\big |\), acceleration \(\big |{\textbf {a}}\big |\) and velocity \(\big |{\textbf {v}}\big |\) of small grains (blue) and large grains (orange) considering dense zones II and IV (top row) and collisional zones I and III (bottom row). The weigth \(w_{s,l}\) of small and large grains and the gravity are indicated for reference

3.2 Direct approach

With this alternative approach, classification accuracy is measured using individual features or some selected combinations of features. Results are summarised in Table 1 considering all grains, or grains belonging to the collisional or dense zones.

The first observation is that the position of the grains is not sufficient to distinguish small and large grains. This suggests an absence of significant size segregation.

The second observation is that the velocity (and rotational velocity) is also not a distinguishing feature of small and large grains. This suggests that large and small grains share a statistically similar velocity distribution in these bi-disperse flows. This differs from monodisperse flows, where a grain size effect on the velocity distribution was previously established as discussed in the introduction. One could expect that larger size ratio or different proportion of large grains could lead to differences in velocity distribution and therefore influence the classification efficiency. However, this remains to be established.

The third observation is that the grain acceleration only is not sufficient either to achieve classification. This contradicts the intuition that that larger, heavier and more inertial grains could exhibit lower accelerations than smaller grains.

The features yielding a successful classification (defined here to be \(\epsilon > 0.9\)) depend on the flow regime. In collisional zones, the force magnitude alone is sufficient. In dense flows, both force and acceleration magnitude are required. Force alone or acceleration alone are not sufficient. This suggests that the information distinguishing large and small grains is not contained in force or acceleration, but in their relationship.

Fig. 4
figure 4

Correlation between some selected features in dense and collisional zones

Fig. 5
figure 5

Visualisation of the dual correlation between force and acceleration in a system with two grain sizes (and two grain masses): distribution of force \(\big |{\textbf {f}}\big |\) versus acceleration \(\big |{\textbf {a}}\big |\). Colors reflect the number of grains falling into a particular bin combination

3.3 Interpretation

To guide the interpretation of what the classifier is sensitive to, we turned to conventional statistics and measured the distribution of force, acceleration and velocity for large and small grains, in dense and collisional flows (Fig. 3).

In both dense and collisional flows, the distribution of velocities are similar for large and small grains. This is consistent with the fact that this feature alone did not warrant classification.

In collisional flows, the force distributions exhibit two distinct peaks, corresponding to the weight of small and large grains. The classifier appears to be capable of distinguishing these. In contrast, small and large grain accelerations both exhibit a similar peak at g, which explains why classification based on acceleration fails. These distributions of force and acceleration indicate a regime dominated by free falls in zone I and III.

In dense flows, large and small grains exhibit similar distributions of force and similar distributions of acceleration. Consistently, the classification failed with either of these features. Nonetheless, classification succeeded using both force and acceleration.

To help understand what the classifier detected, Fig. 4 presents some cross-correlation between features. The correlation between force and acceleration is poor in collisional flows and much higher in dense flows. This is consistent with (i) a regime of free fall where the acceleration is set by g and independent on the weight of the grains, and therefore of their size; and (ii) a regime with multiple contacts where acceleration is proportional to the contact forces via the grain mass, according to Newton’s second law. Having two species of grains with differing masses means that there are two coexisting relationships between force and acceleration within the flow: \(m_s \big |{\textbf {a}}\big | = \big |{\textbf {f}}\big |\) and \(m_l \big |{\textbf {a}}\big | = \big |{\textbf {f}}\big |\), where \(m_{s,l}\) is the mass of the small and large grains. The classifier appears to be able to detect and distinguish these two relationships. In other words, the classifier detects the difference in grain mass via the difference in correlation between force and acceleration.

The data presented in Fig. 5 provides compelling evidence for the existence of a dual correlation in the dense zones of the granular system. The figure displays a subset of data incluing all the grains which acceleration is lower than 50 m/s\(^{2}\). It shows a clear linear trend between force and acceleration in the dense regime, in accordance with Newton’s law of motion. It appears that most grain accelerations in the collisional zones equate gravity, and only a few grains that experience contacts exhibit this detectable dual correlation.

4 Conclusion

This study shows the potential for machine learning to help with the understanding of the mechanical behaviour of granular flows. Using the predictive ability of a random forest classifier, we were able to infer the difference and similitude in dynamical features of large and small grains in a bidisperse flow.

Salient results include the lack of perceivable segregation, and similar velocity, angular velocity and acceleration between small and large grains. We also found that the classifier can detect not only differences in a single feature, but also a difference in the relationship between two features. Specifically, the classifier could detect Newton’s second law relating grain acceleration and force via their size-dependent mass. This ability to detect differences in feature correlation may prove useful to improve classification and to gain further insights in the dynamics of granular flows.

This method is directly applicable to granular materials with different mixtures flowing in other geomteries. More generally, machine learning appears here to be a tool that can complement conventional statistical method to comprehend the behaviour of granular materials and other particulate fluids.