Predicting structure and swelling of microgels with different crosslinker concentrations combining machine-learning with numerical simulations Susana Marín-Aguilar, Emanuela Zaccarelli Abstract Microgels made of poly(N-isopropylacrylamide) are the prototype of soft, thermoresponsive particles widely used to study fundamental problems in condensed matter physics. However, their internal structure is far from homogeneous, and existing mean-field approaches, such as Flory-Rehner theory, provide only qualitative descriptions of their thermoresponsive behavior. Here, we combine machine learning and numerical simulations to accurately predict the concentration and spatial distribution of crosslinkers, the latter hitherto unknown experimentally, as well as the full swelling behavior of microgels, using only polymer density profiles. Our approach provides unprecedented insight into structural and thermodynamic properties of any standard microgel, including experimental ones. Microgels are colloidal particles resulting from a complex chemical synthesis, that are nowadays used as the simplest model system of soft, deformable particles [ 1 , 2 ] . Since they are entirely made of polymers, arranged in a disordered network via chemical crosslinking, they are able to respond to external stimuli. For example, they can easily change their volume in response to a temperature variation when the constituent polymer is thermoresponsive, such as for poly(N-isopropylacrylamide) (pNIPAM) [ 3 , 4 , 5 ] . Therefore, at a characteristic temperature, the polymer network undergoes a so-called Volume Phase Transition (VPT), from a swollen to a collapsed state. This can be exploited to study fundamental physics problems via an in-situ tuning of the suspension packing fraction [ 6 , 7 ] . One important parameter that can be easily varied experimentally is the molar concentration of crosslinking molecules, hereafter abbreviated as crosslinker concentration c , which controls the overall softness of the microgel [ 2 ] . It is well-known that, in the standard synthesis protocol — precipitation polymerization — crosslinkers react faster than monomers, thereby accumulating within a central region of the microgel, the so-called core, which can be distinguished from the outer corona, where crosslinkers are almost absent. Despite several attempts using chemical kinetic modeling, to our knowledge, there is no available work able to predict the crosslinker distribution within pNIPAM microgels. Instead, to describe the VPT, there exists the celebrated theory of Flory and Rehner [ 8 ] , which combines mean-field-like theoretical assumptions with more phenomenological approaches, to describe the available experimental swelling curves. However, it is well-known that the theory suffers some important drawbacks, such as the presence of many fit parameters, whose physical meaning is often obscure [ 9 ] . Therefore, it would be important to have an alternative way to predict the swelling behavior of a microgel. In this Letter, we take advantage of a recently put forward monomer-resolved microgel model, that has been shown to accurately describe the internal structure of the experimental systems, both in bulk suspensions [ 10 ] and at liquid-liquid interfaces [ 11 ] , to fill this gap. To this aim, we perform extensive computer simulations of individual microgels with different crosslinker concentrations to create a comprehensive numerical database of microgel structures at many different temperatures across the VPT. Using a subset of these structures as training set, we apply machine learning (ML) techniques to predict crosslinker properties. Building on the concept that density profiles encode all relevant structural information, we demonstrate that the total polymer density profiles of microgels in the swollen state are enough to accurately predict the crosslinker concentration via unsupervised ML. This approach is subsequently validated against simulations of microgels with different sizes and c outside the training set, as well as for available experimental data. Following a similar approach, we then train a supervised neural network (NN) to predict the distribution of the crosslinkers, which is found to follow the fuzzy sphere model [ 12 , 13 ] , in analogy to the overall microgel. Our approach thus enables, for the first time, the prediction of the crosslinker distribution in experimental systems. Finally, we use our database to build a phenomenological framework to predict the complete swelling behavior of the microgels for a given c , similar in spirit to the Flory-Rehner theory. Therefore, from the sole knowledge of the microgel total density profile at low temperature, which can be extracted from the fit of the form factor, routinely measured nowadays by small-angle scattering techniques [ 12 ] , or directly obtained by super-resolution microscopy [ 13 ] , our ML approach is able to reliably predict the concentration of crosslinkers and their radial distribution, as well as the full swelling behavior of any standard pNIPAM microgel. Figure 1: Crosslinker concentration prediction. a) Averaged radial density profiles of microgels with N\sim 42000 for various crosslinker molar fractions c from simulations (symbols) and fuzzy sphere fits (lines); b) snapshots of high (i), medium (ii) and low (iii) crosslinked microgels; c) Fraction of Variance Explained (FVE) for the autoencoder with varying dimension d^{\prime} of the latent space L . The horizontal line indicates FVE=99\% ; d) probability distributions of L for N\sim 336000 microgels with different c for the training data; e) L as a function of c for all simulated microgels, including training (circles), test (triangles) data sets and experiments from Ref. [ 14 ] , corresponding to microgels of c=1.25,2.5,5.0 % (stars). The dashed line is a power-law fit. Inset: P(L) for two different microgel sizes with c=10.0 %. In order to generate a database of microgel particles we perform molecular dynamics (MD) simulations of monomer-resolved microgels, interacting with the bead-spring potential [ 15 , 16 ] , as described in the End Matter (EM). Microgels are made of a total number of beads either N\sim 42000 or N\sim 336000 , of which a fraction c identifies the molar crosslinker concentration varying from c=0.5 % to c=15 %, covering the usually employed experimental range. We start by reporting the dependence of microgel structure on crosslinker concentration in the swollen state. Fig. 1 (a) shows the radial density profiles \rho(r) of the microgels with N\sim 42000 . The change in c has a direct effect on the shape of the microgel, as reflected in the profiles, which become progressively sharper with increasing c . In particular, the behavior of \rho(r) displays an almost constant regime, representing the core, followed by a decay at large r in the corona region. The latter becomes progressively more extended and less distinct from the core with decreasing c . Typical snapshots of the microgels are reported in Fig. 1 (b), changing from a rather compact structure for c=10 % to a much more heterogeneous one for c=0.5 %, denoting the presence of so-called dangling ends in the exterior of the microgel. All density profiles are well-described by the fuzzy sphere model [ 12 ] , as shown in Fig. 1 (a), with the corresponding fit parameters reported in Table S1 of the Supplemental Material (SM) [ 17 ] . Variations in c also affect the microgel size. For instance, the hydrodynamic radius R_{H} displays a power-law dependence R_{H}\sim c^{-0.21\pm 0.01} , as shown in the SM [ 17 ] (Fig. S1), in good agreement with the predictions of the Flory-Rehner theory for polymer networks [ 8 , 18 ] . This behavior, also shared by the calculated gyration radius, was also previously reported in experimental works [ 19 , 14 ] . Instead, at the local scale, for individual polymer chains belonging to the network, the average end-to-end distance varies as R_{ee}\sim c^{-0.54\pm 0.01} (see Fig. S1). This behavior is relatively close to the Flory scaling for polymer chains in good solvent [ 14 ] , with a minor deviation likely attributed to the effect of the crosslinkers. The previous results suggest that the knowledge of the crosslinker concentration is encoded in some of the microgel features, in particular in the total density profile of the microgels. Therefore, in order to predict c of a given microgel, we propose to use unsupervised ML by means of autoencoders (AE) to extract this information from \rho(r) . This method consists of a neural network that encodes a high-dimensional input and projects it into a low-dimensional latent space. The latter is then decoded recovering the initial input as closely as possible. The key information that characterizes the initial input data is presumably conserved in the latent space, and hence, we expect this to correspond to the crosslinker concentration. To train the AE, we employ discretized density profiles obtained from simulations of microgels with varying c . In particular, the input of the AE, is a vector \mathbf{P} of dimension d=115 , where each entry corresponds to the density profile value at a given radial distance. To make the method scalable and transferable to microgels of different sizes, we preprocess the input data by rescaling the radial coordinate as described in the EM. This allows the method to be applied to any microgel, whose density profile is known, including experimental ones. Further, to provide sufficient data and variability to the AE, we employ averaged radial density profiles in small windows of time. We use c=1.25,2.5,5.0,12.5 % as a training set, while the simulations for additional c values are later used as test data sets. The AE consists of a neural network of 2 layers, the first one corresponding to the encoder with a hidden dimension of 80 , followed by a bottleneck that projects the data onto a d^{\prime} -dimensional space, and finally, the decoder that recovers the input data. We first determine the minimum number of dimensions to be used in the bottleneck d^{\prime} . To this aim, we train the AE for at least 3\times 10^{3} epocs varying d^{\prime} and then we compute the final mean squared error (MSE) and the fraction of variance explained (FVE) as defined in the EM. The resulting FVE is reported in Fig. 1 (c) as a function of d^{\prime} , showing that, even for d^{\prime}=1 , the AE is already able to capture more than 99\% of the variance of the input data by projecting it onto a single number. At higher dimensions, d^{\prime}\geq 2 , this improves, reaching a plateau of FVE\approx 0.993 . However, for simplicity, we choose to work with a bottleneck dimension of d^{\prime}=1 for the prediction of c , since it already yields very accurate results. Figure 2: Crosslinker distribution prediction a) Radial density profiles of the crosslinkers \rho_{c}(r) for microgels with N\sim 336000 at various c from simulations (symbols). Lines corresponds to fuzzy sphere fits (Table S1 [ 17 ] ); b) parity plot of target and predicted \rho_{c}(r) for the training set corresponding to c=1.25,2.5,5.0,10.0 % (circles) and test set (triangles); c) predicted \rho_{c}(r) outside the training set for simulations with c=7.0\% (circles) and experimental data with c=5.0\% triangles) from Ref. [ 14 ] , lines are fuzzy sphere fits. Once we trained the entire AE, we discard the decoder and apply the encoder, which projects the data into the latent space. We report in Fig. 1 (d) the probability distributions P(L) of the latent space values L for different c of the training data set with N\sim 336000 . These results confirm that d^{\prime}=1 is already able to distinguish between microgels with different c , since the distributions in the latent space are well separated, each following a normal distribution with a maximum standard deviation of 0.01 . We also observe that the mean values of the distributions, \bar{L} , shown in Fig. 1 (e), as a function of c , are unevenly distributed in the latent space, following a power law relation with c as \bar{L}(c)\sim A_{0}c^{\nu} , where A_{0}\sim 0.514 , and \nu\sim 0.59 are fit parameters. The latter is remarkably close to the Flory exponent of polymer chains in good solvent. A similar value of \nu is recovered by varying the number of neurons in the AE hidden layer. We conclude that the AE is able to capture the underlying physics of the system, with information taken solely from the density profile. Hence, the crosslinker concentration c can be easily predicted for any microgel by inverting \bar{L}(c)\sim A_{0}c^{\nu} and using the projection on the latent space of a given density profile. Figure 3: Swelling behavior a) Swelling ratio S as a function of crosslinker molar concentration c for various \alpha values, ranging from \alpha=0 , the swollen state, up to \alpha=0.724 . Dashed lines are power-law fits with Eq. 1 , determining h(\alpha) and f(\alpha) , reported in b) and c) as a function of \alpha . d) S as a function for \alpha for various values of c from simulations (circles), experimental experimental data from Ref. [ 14 ] (triangles) and predictions from Eqns. 1 - 2 (dashed lines). Indeed, we report in Fig. 1 (e) the latent values as a function of the predicted c of all simulated microgels. The AE predictions show remarkable agreement with the expected c -values of training and test data sets, with a confidence value ranging from \pm 1\% to \pm 10\% . We validate the method by applying it to microgels of different sizes. Apart from a small shift, very close values for the latent space are found for the two considered microgel sizes, as shown in the inset of Fig. 1 (e). In addition, the AE is applied to experimental data in Ref. [ 14 ] , providing accurate estimates of c , as shown in Fig. 1 (e), despite using a single density profile obtained from the fit of the form factor fuzzy sphere [ 14 ] . Once obtained c , we focus on the crosslinkers density profiles \rho_{c}(r) , calculated directly from simulations and shown in Fig. 2 (a). Similarly to the total density profiles, they are roughly constant in the core region, although with larger statistical noise due to the small amount of crosslinkers. However, they decay to zero at much shorter distances in r with respect to \rho(r) , signaling the accumulation of the crosslinkers within the core. In addition, this decay distance does not strongly depend on c in contrast to what is observed for \rho(r) . It is worth noting that also crosslinker profiles are found to be quite well-described by the fuzzy sphere model. The corresponding fits are also shown in Fig. 2 (a) with continuous lines with the fit parameters reported in Table S1 of the SM [ 17 ] . We then employ a NN to learn \rho_{c}(r) from the overall density profile from the same training and test data sets as for the AE. As before, our input data set comes from the discretized total density profile with the r -axis normalized. The output now corresponds to the averaged \rho_{c} computed from the fuzzy sphere fits, normalized in the radial axis and in the y -axis by the same factor of the total density profile and by the crosslinker concentration c , respectively. The chosen NN has 1 hidden layer with 96 neurons. To train the NN, we minimize an error function between the target \rho_{c} and the NN output (see EM). The input dataset includes data from microgels assembled with crosslinker concentrations c=1.25,2.5,5.0,10.0 %, with additional simulated values of c used as test data sets. In the same spirit of the previous section, we add variability to the input dataset by using short-time-average density profiles as input. The parity plot between the ground truth and the predicted \rho_{c}(r) is reported in Fig. 2 (b), where we observe remarkably good predictions for the training and also for the test data sets. This is confirmed by directly comparing the ML-predicted \rho_{c}(r) for a c=7.0 % microgel outside the training set with the one obtained from the simulations in Fig. 2 (c). We further test our method by applying it to the c=5.0 % experimental data taken from Ref. [ 14 ] , whose ML-predicted \rho_{c}(r) is also reported in Fig. 2 (c). In both cases the predicted profiles are in excellent agreement with those obtained by simulations, showing the robustness of our approach. Our final goal is to predict the swelling behavior of a microgel, given the ML-predicted crosslinker concentration. To do so, we first simulate the various microgels with different c at many different temperatures, by employing the solvophobic potential U_{\alpha} in Eq. 5 [ 20 ] (see EM). We then calculate the swelling ratio S from Eq. 9 and report it in Fig. 3 (a) as a function of c for different values of \alpha for N\sim 42000 microgels. We then fit the dependence of S on c with a generalized power-law as, S(\alpha,c)=\frac{R_{h}}{R_{h0}}=h(\alpha)c^{f(\alpha)}, (1) where h(\alpha) and f(\alpha) solely depend on \alpha and are reported in Fig. 3 (b) and (c), respectively. The \alpha -dependence of both functions can be written as, F(\alpha)\sim A_{0}^{X}+A_{1}^{X}\zeta((\alpha+A_{2}^{X})/A_{3}^{X}), (2) where \zeta(x)=1/(1+e^{x}) is a logistic function, X refers to either f or h and A_{i}^{X} are fit parameters associated to each function, reported in Table S2 of the SM [ 17 ] . We find that the physics of the VPT is directly encoded in these parameters for f(\alpha) , being A_{1}^{f}\sim 0.19 the expected Flory-Rehner exponent at \alpha=0.0 and A_{2}^{f}\sim-0.63 , coinciding with the \alpha value at which the VPT occurs. A similar value is also found for A_{2}^{h} . Once we know the dependence of h and f on temperature and c , we can finally reconstruct the full swelling behavior of any standard pNIPAM microgel. To test this hypothesis, we show the predictions of Eqns. 1 - 2 in Fig. 3 (d) for different c values in comparison to simulation results and to the experimental data of Ref. [ 14 ] . We find very good agreement at all temperatures, with minor deviations close to the VPT, where experimental error bars are largest. Interestingly, once S(\alpha) is known for example from DLS measurements, it can be used backwards to estimate c via Eq. 1 , and then an approximate density profile, if not available experimentally, by using our database, following the mapping described in the SM (Section S4). In summary, in this work we established a novel ML-approach that, through the sole knowledge of the total density profile of any standard microgel, is able to recover its crosslinker concentration, the crosslinker distribution and the full swelling curve. While the monomer density profile can be directly or indirectly obtained in experiments, the crosslinker profiles currently cannot be recovered experimentally. The present study exploits neural networks for the first time to predict them also for experimental systems. While we have validated the approach against the corresponding numerical profiles, it remains a challenge to detect them also experimentally to verify whether they also satisfy a fuzzy sphere decay, as shown in the present simulations. Our work further demonstrates the power of machine learning techniques with carefully selected data coming from simulations to uncover hidden relations. In particular, by using autoencoders (AE), we are able to extract the information of the crosslinker concentration encoded in the density profiles. The associated latent space is found to follow a power-law dependence on c with an exponent \sim 0.59 , remarkably close to the Flory prediction for polymers in good solvent, thereby demonstrating the ability of the AE to correctly recover the underlying physics of the system. The present methodology can be readily extended to different topologies or to the calculation of other microgel properties, such as elasticity or charge distribution, providing sufficient training data. Similarly, it can be applied to assess microgel deformation at interfaces as a function of crosslinker concentration [ 11 ] . The next step will then be to exploit similar ML-approaches to inverse-design tailored microgel architectures with desired swelling ratios and density profiles to optimize them for specific needs. We thank L. Tavagnacco for useful discussions. This project was funded by the European Union HORIZON-MSCA-2022-Postdoctoral Fellowships under grant agreement no. 101106848, MGELS. EZ also acknowledges funding from ICSC – Centro Nazionale di Ricerca in High Performance Computing, Big Data and Quantum Computing, funded by European Union – NextGenerationEU - PNRR, Missione 4 Componente 2 Investimento 1.4. We gratefully acknowledge the CINECA award under the ISCRA initiative, for the availability of high-performance computing resources and support. I End Matter I.1 Models and methods We prepare monomer-resolved microgels using the method established in Refs. [ 20 , 10 , 4 ] , which was shown to accurately describe the structure of experimental systems [ 10 , 14 ] . After the assembly, we simulate polymer networks with different crosslinker molar fractions c\in[0.5,1.25,2.0,2.5,3.0,4.0,5.0,6.0,7.0,10.0,12.5,15.0] , covering the full range of experimentally synthesized pNIPAM microgels. We fix the total number of particles in the microgel either to N\sim 42000 or N\sim 336000 particles, for which N_{c}=cN/100 particles correspond to crosslinkers (particles with four bonded neighbours), with the remaining to monomers (particles with two bonded neighbours). All particles interact with the Weeks-Chandler-Andersen (WCA) potential, U_{WCA}(r)=\begin{cases}4\epsilon\left[\left(\frac{\sigma}{r}\right)^{12}-\left(\frac{\sigma}{r}\right)^{6}\right]+\epsilon&r\leq 2^{1/6}\sigma\\ 0&r>2^{1/6}\sigma,\end{cases} (3) where r the distance between two beads, \sigma is the diameter of each bead, setting the unit of length, and \epsilon controls the energy scale and sets the unit of energy. For bonded beads, there is an additional interaction modeled by the Finite-Extensible-Nonlinear-Elastic (FENE) potential [ 15 ] : U_{FENE}(r)=-\epsilon k_{F}{R_{0}}^{2}\log{\left[1-\left(\frac{r}{R_{0}\sigma}\right)^{2}\right]}\text{ if }rR_{0}\end{cases} (5) where \gamma=(\pi(2.25-2^{1/3}))^{-1} , \beta=2\pi-2.25\gamma , and \alpha modulates the strength of the attractive interaction, thus amounting to an effective temperature. The network is in good solvent conditions for \alpha=0 , undergoes the VPT for \alpha\sim 0.63 and reaches the collapsed state observed in experiments for \alpha\sim 0.8-1.0 . Previous studies demonstrated that \alpha varies almost linearly with temperature across the VPT range [ 10 , 14 ] . We perform NVT MD simulations of individual microgels using the LAMMPS simulation package [ 21 ] with time step \delta t=0.002\tau , where \tau=\sqrt{m\sigma^{2}/\epsilon} corresponds to the time unit. The temperature is fixed to k_{B}T/\epsilon=1.0 , where k_{B} is the Boltzmann constant, while we vary the solvophobic parameter \alpha to mimic the effect of the real temperature, as described above. The center of mass of the microgel is fixed to the center of the simulation box. We equilibrate the system for at least 3\times 10^{6} timesteps followed by a production simulation of 1\times 10^{7} timesteps. We average results over at least three independent topologies to take into account the role of disorder in the assembled polymer networks. The main structural information used as input for the neural networks is the radial density profile of the monomers, with respect to the microgel center of mass, that is averaged over different time intervals. The averaged radial density profile \rho(r) is defined as, \rho(r)=\left<\frac{1}{N}\sum_{i=1}^{N}\delta(|\mathbf{r}_{i}-\mathbf{r}_{cm}|-r)\right>_{\Delta t}, (6) where \mathbf{r}_{cm} corresponds to the position of the center of mass of the microgel, \mathbf{r}_{i} that of particle i , and <> represent a time average over the window of time \Delta t . In order to generate a large pool of density profiles and maximize the variance related to noise coming from the simulations, we generate such profiles every 1\times 10^{4} timesteps averaging every 1\times 10^{5} timesteps inside the previous time window. In addition, we calculate the radial density profiles of the crosslinker monomers only, \rho_{c}(r) , by substituting N in Eq. 6 with N_{c} . We fit the density profiles using the well-established fuzzy sphere model [ 12 ] , that is obtained by combining the profile of a solid sphere of radius R with a Gaussian function representing the corona of the particle [ 12 ] . In an approximated version [ 22 ] that holds for standard core-corona microgels, this reduces to \rho(r)\sim A\textrm{ erfc}\left(\frac{r-R_{c}}{\sqrt{2}\sigma_{s}}\right), (7) where A is a fit parameter, R_{c} denotes the radius of the core, and \sigma_{s} the half-width of the corona shell. The same model in Eq. S1 is also used to fit the crosslinker density profiles. The corresponding fit parameters are reported in the SM [ 17 ] , Table S1. We also compute the hydrodynamic radius of the microgel, following the method established in Ref. [ 4 ] , where R_{H}=2\left[\int_{0}^{\infty}\frac{1}{\sqrt{(a^{2}+\theta)(b^{2}+\theta)(c^{2}+\theta)}}d\theta\right]^{-1}, (8) with a , b , and c the principal semiaxes of the gyration tensor associated to the semplices of the convex hull formed by the microgel particle. Then, we calculate the \alpha -dependent swelling ratio S_{\alpha} , defined as S_{\alpha}=R_{H}(\alpha)/R_{H}(\alpha^{*}=0.86), (9) where R_{H}(\alpha^{*}=0.86) roughly corresponds to the hydrodynamic radius of the collapsed microgel at the effective temperature \alpha^{*}=0.86 . The latter is estimated from the experimental data of Ref. [ 14 ] and also from Fig. 3 (c) where f(\alpha^{*})\sim 0 . I.2 Machine Learning Methods To learn different structural features of the microgels, we employ two types of machine learning (ML): unsupervised ML with autoencoders (AE) [ 23 , 24 ] and supervised ML with the use of neural networks (NN) [ 25 ] . The first method is employed to determine the crosslinker concentration, while the second one is used to calculate the crosslinker distribution. We use PyTorch [ 26 ] to build and train both the AE and the supervised NN. I.3 Autoencoders An autoencoder is a dimensionality reduction method that consists of a neural network whose main task is to reproduce its input as its output by passing through an intermediate step where the initial input is mapped onto a lower dimension, as explained in the main text. As input, we use a collection of discretized radial density profiles from MD simulations of microgels with different c values, represented by a set of vectors \mathbf{P}(i)\in\mathbb{R}^{d} , where \mathbf{P}(i)=\mathbf{\rho}_{i} denotes the discretized density profile of sample i and d the dimensionality of the vector. The choice of d allows us to control the resolution of the density profile. Here, we choose d=115 . In addition, the entries \mathbf{P}_{j}(i) of the input vector correspond to the value of the density profile evaluated at r_{j} , and thus, we ensure that for all considered data sets, regardless of the crosslinker concentration, the entry j always corresponds to the same distance r_{j} . In order to guarantee this condition and to be able to compare microgels of different sizes, we preprocess the data coming from the radial density profiles as follows. First, we use a scaled radial coordinate r^{*} that preserves the characteristic decay of each state point. This is done using the value of the integral of the density profile, which in simulations corresponds to the the total number of particles in the microgel N=\int\rho dV , and rescaling r^{*}=r/N^{1/3} . Second, \rho(r^{*}) is splined and P(i) is constructed by evaluating the splines in intervals of r^{*}=0.025 starting from r^{*}=0.125 . In the output layer, the density profiles, represented by a vector \mathbf{P}^{\prime}(i)\in\mathbb{R}^{d} , are recovered. Inside the encoder, we perform a nonlinear projection onto a low-dimensional space \mathbf{Y}(i)\in\mathbb{R}^{d^{\prime}} , where d^{\prime}