Neural Network Predicts Ion Concentration Profiles under Nanoconfinement
Modeling the ion concentration profile in nanochannel plays an important role
in understanding the electrical double layer and electroosmotic flow. Due to
the non-negligible surface interaction and the effect of discrete solvent
molecules, molecular dynamics (MD) simulation is often used as an essential
tool to study the behavior of ions under nanoconfinement. Despite the accuracy
of MD simulation in modeling nanoconfinement systems, it is computationally
expensive. In this work, we propose neural network to predict ion concentration
profiles in nanochannels with different configurations, including channel
widths, ion molarity, and ion types. By modeling the ion concentration profile
as a probability distribution, our neural network can serve as a much faster
surrogate model for MD simulation with high accuracy. We further demonstrate
the superior prediction accuracy of neural network over XGBoost. Lastly, we
demonstrated that neural network is flexible in predicting ion concentration
profiles with different bin sizes. Overall, our deep learning model is a fast,
flexible, and accurate surrogate model to predict ion concentration profiles in
nanoconfinement.
Zhonglin Cao, Yuyang Wang, Cooper Lorsung, Amir Barati Farimani
# Neural Network Predicts Ion Concentration Profiles under Nanoconfinement

###### Abstract

Modeling the ion concentration profile in nanochannel plays an important role in understanding the electrical double layer and electroosmotic flow. Due to the non-negligible surface interaction and the effect of discrete solvent molecules, molecular dynamics (MD) simulation is often used as an essential tool to study the behavior of ions under nanoconfinement. Despite the accuracy of MD simulation in modeling nanoconfinement systems, it is computationally expensive. In this work, we propose neural network to predict ion concentration profiles in nanochannels with different configurations, including channel widths, ion molarity, and ion types. By modeling the ion concentration profile as a probability distribution, our neural network can serve as a much faster surrogate model for MD simulation with high accuracy. We further demonstrate the superior prediction accuracy of neural network over XGBoost. Lastly, we demonstrated that neural network is flexible in predicting ion concentration profiles with different bin sizes. Overall, our deep learning model is a fast, flexible, and accurate surrogate model to predict ion concentration profiles in nanoconfinement.

## I Introduction

Nanoconfinement defines a state when fluid is confined in nanoscale spaces such as nanotube and nanochannel [1]. Compared with bulk condition, nanoconfined fluid such as water exhibit anomalous viscosity [2; 3], diffusion coefficient [4; 5; 6], phase [7; 8], dynamics [9], and density [10; 11; 4]. These behaviors become more exotic once we add ions to water. When ionic solution is confined by charged nanochannel walls, electrical double layer (EDL) is formed by the ions at the solid-liquid interface [12; 13]. EDL is the basis for the development of advanced energy storage devices such as capacitors and batteries [14]. EDL can be engineered by surface modification to achieve the maximum charge storage capacity. Ions in EDL move with the solvent molecules when external electrical field is applied, resulting in electro-osmotic flow in the nanochannel [15]. Electro-osmotic flow is a widely-used fluidic transport mechanism as it is easily controllable and scalable [15; 16]. Moreover, nanoconfinement of the ionic solution is highly associated with the design and engineering of water treatment and transport systems [17; 18; 19]. By forcing the ionic solution through nanoconfined space, ions can be filtered out when fresh water is produced [20; 21]. Ion concentration distribution in nanoconfined space and EDL is related to the performance and efficiency of the water treatment device or plants [17; 22; 23; 24]. Given the connection between nanoconfined ionic solution and various aforementioned applications, understanding the ion concentration distribution in nanospace is essential for the future development of energy storage, nanofluidic device, and water treatment technologies.

Classical continuum models such as Poisson-Boltzmann equation have underwhelming accuracy in predicting ion concentration distribution under nanoconfinement [25; 26] because nanoscale physical properties such as the effect of discrete solvent molecules and surface-ion interactions are not incorporated in those models [15]. In the past two decades, molecular dynamics (MD) simulation has been the major tool for studying the ionic solutions in nanoconfinement as it models the physical interactions at molecular scale. MD simulation has significantly improved prediction accuracy on many properties of nanoconfined ionic solution such as ion and solvent concentration profile [27; 28; 29; 30; 13], ion transport and velocity [31; 32], and charge inversion [12; 15] over continuum models. Despite its high accuracy, MD simulation has the disadvantage of being computationally expensive and resource-demanding. Additionally, to study the ionic distribution in nanochannel, a unique molecular system needs to be created and simulated for each combination of channel width and ion concentration. The trajectories from MD simulation have to be stored (occupying disk storage) and post-processed for the calculation of the desired properties. Therefore, building a surrogate model that makes instantaneous inference on specific physical properties of the ionic solution under different nanoconfinement configurations is of great value.

Machine learning and deep learning methods have seen astonishing development in the past decade due to the exponential growth in computational resources and data repositories. They are proven competent in modeling physical phenomena. For example, machine learning is used in identifying and modeling fluid mechanics [33] and dynamical systems [34; 35; 36], and solving mathematical problems [37]. In the field of nanofluidics, graph neural network has been used to accelerate MD simulation [38] and identify the phase of water [39], while convolutional neural network is used for predicting nanoconfined water density profile [40; 41; 42] and self-diffusion [43] of Lennard-Jones fluids.

In this work, we propose to use neural network (NN) as a surrogate model for the fast prediction of ion concentration profiles in nanochannels. There are several challenges in developing a surrogate NN model for this problem. Firstly, the ion concentration profile has a high-dimensional correlation with many properties of the nanochannel including the channel width, ion molarity, and ion type. Also, the shape of the ion concentration profile varies based on the bin size during data sampling. With those challenges, training an NN for end-to-end prediction of the entire concentration profile can
be difficult and inflexible. To solve these issues, we treat the ion concentration profile in nanochannel as a probability distribution with respect to ion coordinates (details in the Method section) conditioned on nanochannel properties. We then train the NN as a parameterized approximator of the conditional cumulative density distribution of the ions in the nanochannel. Such a method is inspired by the fact that NNs are universal function approximators [44; 45], and it has achieved success in learning probability and cumulative distributions [46; 47; 48; 49]. NN trained in this manner learns a continuous distribution of ions in the nanochannel, which enables it to predict ion concentration profiles with arbitrary bin sizes. Results show that the NN can serve as a much faster surrogate model of MD simulation to accurately predict ion concentration profiles in nanochannels.

## II Method

The framework of this work (Fig. 1) consists of three sections. Firstly, we perform molecular dynamics (MD) simulations of different ion-nanochannel systems. Secondly, data points are sampled based on the cumulative density function of ions in nanochannel to form a training dataset and an interpolation test dataset. Lastly, different machine learning models including NN are trained and further evaluated for their accuracy in predicting the ion concentration profile.

### Molecular dynamics simulation

The initial configurations of the ion-nanochannel systems are created using VMD [50] and GROMACS [51]. Each system (Fig. 1a) contains a water box with ions sandwiched by two layers of graphene, which serve as the nanochannel walls. All systems have dimensions of 3.19 and 3.40 nm in the \(x\) and \(y\) direction, respectively. There are 832 carbon atoms in the simulation system. The surface-to-surface distance between the two graphene layers is the channel width denoted as \(w\), ranging from 0.8 to 3.0 nm with the spacing of 0.1 nm (\(w\in\{0.8,0.9,\cdots,3.0\}\), 23 variations). The number of water molecules in the nanochannel size of \(3.19\times 3.40\times w\) is controlled such that the water density is at 1 g/cm\({}^{-3}\). Ions of different molarity, \(c\), are added to the system, where \(c\) ranges from 0.8 to 3.6 M changing by 0.2 M (\(c\in\{0.8,1.0,\cdots,3.6\}\), 15 variations). Five types of ions are simulated including Na\({}^{+}\), Cl\({}^{-}\), K\({}^{+}\), Li\({}^{+}\), and Mg\({}^{2+}\). Each simulation system contains only one type of ion. To maintain charge neutrality, the same amount of opposite charges are evenly distributed to each carbon atom in the system, balancing the charge carried by the ions. In total, 1,725 simulations are run.

MD simulations are carried out using the LAMMPS [54] software. SPC/E [55] water model is used to simulate water molecules. The interatomic potentials consist of the Lennard-Jones (LJ) potentials and long-range Coulombic interaction, both with a cutoff distance of 10 A. The LJ potentials (Table 1) of ions and graphene are adopted from the ref [53; 56; 52] and ref [4], respectively. Other interatomic potentials are calculated by the arithmetic rule. Nose-Hoover thermostat [57; 58] is used to maintain the temperature of the simulation system at 300 K. In each simulation, the system is firstly run under canonical (NVT) ensemble for 1 ns for the ions to reach equilibration positions. With the ensemble remains unchanged, the simulation is then run for another 1 ns while the trajectories are recorded every 5 ps. Periodic boundary condition is applied to all three dimensions. Post-processing of MD trajectories is conducted using the MDTraj [59] package.

### Ion concentration profile as probability distribution

In this work, the ion concentration profile is regarded as the linear transformation of a conditional probability distribution (Fig. 1b). Namely, the ion concentration is the conditional probability multiplied with molar concentration. When the material of nanochannel wall and the solvent molecule remains unchanged (graphene and water in our case), the probability of the \(z\)-coordinate of a nanoconfined ion is at \(r\) nm away from the channel center follows the conditional probability density function (PDF):

\[P(|z-o|=r\mid\sigma,\epsilon,w,c,q), \tag{1}\]

where \(o\) is the \(z\)-coordinate of nanochannel center, \(\sigma\) and \(\epsilon\) are the LJ potentials of the ion, \(w\) is the nanochannel width, \(c\) is the molarity of ion in channel, and \(q\) is the charge of the ion. If we denote the set including all conditions as \(W=\{\sigma,\epsilon,w,c,q\}\), we get the conditional cumulative density function (CDF) as:

\[F(|z-o|=r\mid W)=P(|z-o|\leq r\mid W)=\frac{N_{|z-o|\leq r}}{N_{\text{total}}}, \tag{2}\]

where \(N_{|z-o|\leq r}\) is the number of ions having \(z\)-coordinate within \(r\) nm from the nanochannel center, and \(N_{\text{total}}\) is the total number of ions in the system. If the conditional CDF is known, then the ion concentration in any interval \(r_{1}<|z-o|\leq r_{2}\) can be obtained simply by first calculating the conditional PDF:

\[P(r_{1}<|z-o|\leq r_{2}\mid W)=\\ F(|z-o|=r_{2}\mid W)-F(|z-o|=r_{1}\mid W) \tag{3}\]

and then multiplying it by the molar concentration.

Since acquiring true conditional CDF shown by Eq.2 is challenging, we propose to use a neural network parameterized by \(\theta\), denoted as \(F_{\theta}(\cdot)\), to approximate it:

\[F_{\theta}(|z-o|=r\mid W)\approx F(|z-o|=r\mid W). \tag{4}\]

\begin{table}
\begin{tabular}{l l l l l l l}  & Na\({}^{52}\) & Cl\({}^{52}\) & Mg\({}^{53}\) & Li\({}^{52}\) & K\({}^{52}\) & C\({}^{4}\) \\ \hline \(\sigma\) (Å) & 2.1600 & 4.8305 & 2.1200 & 1.4094 & 2.8384 & 3.3900 \\ \(\epsilon\) (kcal/mol) & 0.3526 & 0.0128 & 0.8750 & 0.3367 & 0.4297 & 0.0692 \\ \(q\) (e) & +1 & -1 & +2 & +1 & +1 & - \\ \end{tabular}
\end{table}
Table 1: The Lennard-Jones potentials and the charge of ions simulated in this work.
Enough training data points should be sampled based on the true conditional CDF to ensure the expressivity of the neural network [60, 61]. In practice, we sample 2,000 data points using Eq.2 from each simulation (Fig. 1b). Among the 2,000 data points, half of them is sampled with uniformly chosen \(r\in\{0,\frac{w}{2}+0.1\}\) nm, which ensures the model learns that no ion should be present outside of the nanochannel. The other half is sampled with uniformly chosen \(r\in\{\max(0,\frac{w}{2}-0.5),\frac{w}{2}\}\) nm. Such a choice of interval includes more data points within 5 A of the nanochannel wall, thus helping the model to better learn the interfacial ion distribution. 3,450,000 data points are sampled in total from the 1,725 simulations. Each data point has features as \(\{r,\sigma,\epsilon,w,c,q\}\) and labels as the conditional cumulative density \(F(r\mid\sigma,\epsilon,w,c,q)\). Data points sampled from simulations with channel width \(w\in\{1.6,2.4,2.8\}\) nm or with molarity \(c\in\{1.4,2.2,3.0\}\) M are deposited into the test set, while the other ones into the training set. Overall, the training set contains 2,400,000 data points and the test set contains 1,050,000 data points.

### Machine learning models and training

In our work, we use NN to model the conditional CDF, \(F(|z-o|=r\mid W)\). Each sample \(i\) in \(N\) training data is denoted as \(\{r_{i},W_{i},F_{i}\}\) representing the descriptor \(W_{i}\) and its corresponding density function value \(F_{i}\) at position \(r_{i}\). The input to the machine learning models is thus a six-dimensional list \(\{r_{i},W_{i}\}=\{r_{i},\sigma_{i},\epsilon_{i},w_{i},c_{i},q_{i}\}\), which describes the conditions and position to predict (Fig. 1). The output is \(\hat{F_{i}}\) which approximates the ground truth CDF \(F_{i}\). An NN is developed as a surrogate model for ion concentration profile prediction. NN is based on fully-connected layers [62, 63] and each layer is given:

\[y=a(W^{(l)}x), \tag{5}\]

where \(x\) and \(y\) are the input and output for each layer respectively, \(W^{(l)}\) is the weight matrix at \(l\)-th layer, and \(a\) is the element-wise nonlinear activation function. In our case, we used ReLU [64] function for \(a\) in all hidden layers and apply sigmoid in the output layer to guarantee the predicted

Figure 1: Framework of predicting ion profiles in nanochannels via NN. **(a)** Data is generated by running MD simulation of nanoconfined ionic solution. Channel width, \(w\), is the surface-to-surface distance between the two charged graphene walls (colored teal). In the shown system, the ions are Na\({}^{+}\) (colored green) with molarity of 2 M and \(w\) is 2 nm. **(b)** shows the probability and cumulative density of ion distribution in the nanochannel. \(r\) is the distance from the \(z\)-direction center of the nanochannel. It is noticeable that the ion concentration distribution shown by the inset is just a linear transformation of the probability distribution. Data points are sampled from the cumulative density and used for the training of NN. **(c)** The NN model takes 6 inputs and predicts the cumulative density of ion within \(r\) nm of the channel center. The predicted cumulative density is then translated to ion concentration profile.
cumulative density value is between 0 and 1. By stacking multiple fully-connected layers, NN can work as a universal function approximator [65] which is expected to accurately predict the conditional ion profiles. The objective of the NN is to minimize the MSE between the predictions \(\{\tilde{F}_{i}\}_{i\in N}\) and the ground truth \(\{F_{i}\}_{i\in N}\). The NN is implemented with five hidden layers and the number of units in each hidden layer is \(\{1024,512,256,128,32\}\). We train the NN using Adam optimizer [66] with a learning rate of 0.005 for 100 epochs.

To demonstrate the superior performance of NN, we benchmarked the prediction of ion profiles using another machine learning model, extreme gradient boosting (XGBoost). XGBoost is a gradient-boosted decision tree (GBDT) machine learning method and has demonstrated superior and robust performance in many applications [67]. Unlike the NN, XGBoost is a non-parametric machine learning model without strong assumptions about the form of the mapping function from input to output. The model is based on decision trees which predict the labels via a series of if-then-else questions (levels) to the input features. An optimal decision tree estimates the minimum number of levels required to make a prediction during training. GBDT is an ensemble method for decision trees that combines multiple models to boost performance [68; 69]. Specifically, GDBT leverages the error residual of the previous decision tree to train the next and ensembles all the decision trees by a weighted summation of the outputs of the models. For a GBDT \(\tilde{F}_{M}\) with \(M\) decision trees, the ensembled result is given:

\[\tilde{F}_{M}(z,W)=\sum_{m}^{M}\gamma_{m}T_{m}(r,W), \tag{6}\]

where \(T_{m}\) denotes a single decision tree. And the weighted term \(\gamma_{m}\) is calculated by:

\[\gamma_{m}=\operatorname*{arg\,min}_{\gamma}\sum_{i}^{N}\ell(F_{i},\tilde{F}_ {m-1}(r_{i},W_{i})+\gamma T_{m}(r_{i},W_{i})), \tag{7}\]

where \(\ell\) is a mean square error (MSE) loss \(\ell(y,\tilde{y})=(y-\tilde{y})^{2}\) that measures the prediction accuracy. XGBoost is a scalable and distributed implementation of GDBT, which builds and trains decision trees in parallel. In our case, we set the level of decision trees as 15 and the \(L_{2}\) regularization coefficient as 5 to mitigate overfitting. Other hyperparameters follow the default settings in the XGBoost package [67].

## III Result and Discussion

### Prediction of ion concentration profile

To examine the performance of the NN and XGBoost models, we compare their predicted ion concentration profiles with the MD simulation results. Fig. 2 shows the ion concentration profile predicted using the three methods with different system configurations (combination of channel width and molarity), where the bin size is set as 0.05 nm. Plots enclosed by the red dashed lines have either channel width or molarity in the interpolation test set, while the other plots are results from the training set. For Na\({}^{+}\) (Fig. 2a), both models achieve close to perfect prediction for configurations in the training set. The location of the model-predicted concentration peaks fits perfectly with the MD simulation results. NN demonstrates more accurate interpolation capability than XGBoost as XGBoost has higher errors in predicting the peak concentration when molarity is 3 M. For Cl\({}^{-}\) (Fig. 2b), XGBoost shows a tendency of overpredicting the peak concentration when the molarity is

Figure 2: The comparison between ion concentration profiles predicted by MD simulation, neural network, and XGBoost model when channel width ranges from 1 to 3 nm and molarity ranges from 1 to 3 M. **(a)** shows the results of Na\({}^{+}\) and **(b)** shows the results of Cl\({}^{-}\). Results enclosed by the red dashed lines are included in the interpolation test set, while the others are included in the training set. \(r\) represents the distance to the center of nanochannel.
at 3 M. A single layer of Cl\({}^{-}\) occurs in the configuration [1 nm, 1 M], which is different from the other configurations where ion concentration peak occurs closer to the nanoconfinement wall. Both models accurately capture such a physical phenomenon. One small error made by NN is that it fails to predict the secondary concentration peak located at 0.5 nm from the channel center in the configuration [2 nm, 1 M]. In general, Fig. 2 demonstrates that NN is capable of accurately predicting the ion concentration profile by learning the CDF of ion in nanochannel, and NN interpolates better on unseen configurations compared with XGBoost.

Another variable besides channel width and molarity is the ion type. Fig. 3 shows the comparison between model-predicted ion concentration profiles and MD simulation results for five different ions. The channel width is 2 nm, the molarity is 2.2 M, and the bin size is 0.05 nm for all subplots in Fig. 3. It can be observed that the location of peaks predicted by both NN and XGBoost is correct compared with MD results. For Na\({}^{+}\), XGBoost underpredicts the concentration of the primary peak while largely overpredicting the secondary peak. XGBoost also significantly underpredicts the concentration of the secondary peak of Mg\({}^{2+}\). Despite minor prediction error found on the secondary peaks of Cl\({}^{-}\) and K\({}^{+}\) profiles, NN is shown to be a more accurate model than XGBoost in this task. Ion concentration profiles of all configurations are available on the GitHub page of this work. Fig. 3 shows that NN bears the potential as a generalizable predictor of ion concentration profile regardless of the type and charge of the ions.

### Error analysis and inference time

To thoroughly evaluate NN and XGBoost as a surrogate model to MD simulation, we benchmarked both models on their prediction accuracy and inference time. The mean absolute error (MAE) of Na\({}^{+}\) concentration profile prediction is the first metric of accuracy. Fig. 4a and 4b visualize the MAE heatmap of NN and XGBoost, respectively, for all simulated configurations. The MAE is calculated based on concentration profiles with bin size of 0.05 nm. The tick labels of the channel width and molarity included in the interpolation test set are colored red. Despite a slight increase of MAE when interpolating, NN achieves high prediction accuracy for all configurations. The highest MAE of NN is 0.53 M in the configuration [1.6 nm, 2.8 M]. On the other hand, the prediction accuracy of XGBoost suffers from overfitting. When interpolating Na\({}^{+}\) concentration profile for 1.6, 2.4, 3.0 nm channel width and 1.4, 2.2, 3.0 M molarity, MAE of XGBoost drastically increases. The highest MAE of XGBoost is 4.92 M, which occurs in the configuration [1.6 nm, 3.6 M]. The maximum value of the color bar of the heatmap is truncated at 0.6 M so that low MAE is more visible. Examples of XGBoost overfitting Na\({}^{+}\) and Cl\({}^{-}\) concentration profiles in configuration [1.6 nm, 2 M] are shown in Fig. 4c. For both Na\({}^{+}\) and Cl\({}^{-}\), the concentration peaks are mispredicted by XGBoost to be 0.05 nm away from the MD simulation results, leading to exceptionally high MAE. On the other hand, overfitting has a trivial effect on the prediction accuracy of NN. When channel width is 2.4 nm, no obvious MAE increase is shown in Fig. 4a.

Two metrics, MAE and peak deviation are calculated to quantitatively evaluate the advantage of NN in interpolation (Table 2). MAE measures the prediction error of the whole ion concentration profile. Peak deviation measures how well the shape of the predicted ion concentration profile is aligned with the MD simulation result. The lower the value for each metric, the better the model is expected in interpolation. The interpolation MAE of NN is only 14.9% of that of XGBoost. Moreover, the interpolation peak deviation of NN is 0.0019 nm, which is only 6.1% of that of XGBoost. Both metrics

\begin{table}
\begin{tabular}{l l l l}  & NN & XGBoost & MD \\ \hline Interp. MAE (M) & 0.1899 & 1.2764 & - \\ Interp. peak deviation (nm) & 0.0019 & 0.0314 & - \\ Inference time (s) & 0.80(0.10) & 2.56(0.11) & 11.72(0.42) \\ \end{tabular}
\end{table}
Table 2: Evaluation of the interpolation error and inference time of NN and XGBoost. All metrics are calculated given the bin size of 0.05 nm. Both MAE and peak deviation are averaged over all configurations in the interpolation set. Inference time measures the total time to generate ion concentration profiles for all 1,725 configurations (5 ions, 23 channel width, 15 molarity). The inference time of MD does not include the time used to load molecular trajectories. The inference time reported is averaged over 6 runs, with the standard deviation in parentheses. The lower value of each metric is the better model.

Figure 3: Comparison between model predicted ion concentration profile and MD simulation results for five different ions. The channel width is 2 nm and molarity is 2.2 M, which is a configuration included in the interpolation test set. Bin size is set as 0.05 nm.
prove that NN does not suffer from overfitting as XGBoost does, and is capable of accurately interpolating ion concentration profiles under different nanoconfinement conditions.

Using machine learning as a fast surrogate model for MD simulation is the major motivation for this work. To evaluate the improvement in computation speed, we benchmark the inference time of NN, XGBoost, and MD simulation. Here, we define the inference time to be the total time taken to predict the ion concentration profiles of all 1,725 system configurations (5 ions, 23 channel widths, 15 molarities) with bin size as 0.05 nm. For MD simulation, we only consider the post-processing time of the molecular trajectories using MDTraj[39] and NumPy[70; 71]. The time of loading molecular trajectories is not included for a fair comparison. The benchmark is conducted with an Intel Core i7-8086K CPU for all models (Table 2). Averaged over 6 runs, NN can predict all 1,725 ion concentration profiles in 0.8 s, whereas XGBoost takes 2.56 s and processing MD trajectories takes 11.72 s. NN is approximately 3.2\(\times\) faster than XGBoost and 14.7\(\times\) faster than processing MD simulation trajectories. The inference time benchmark demonstrates that NN is a fast surrogate model for MD simulation. It is noteworthy that running a single MD simulation takes about 8 hours on average using 6 CPU cores, indicating that running all 1,725 simulations takes approximately 82,800 core-hours. If we compare the inference time of NN to the time required to run MD simulation, NN is orders of magnitude faster. Considering the size of NN model is 2.8 MB, which is much smaller than XGBoost model (71.1 MB) and MD simulation trajectories (32.1 GB), NN is also more storage-efficient than the other two.

### Sampling with different bin sizes

One advantage of training a NN to learn the CDF instead of the whole ion concentration profile is the flexibility of sampling. By sampling on the CDF and converting probability to ion concentration, the NN can predict ion concentration profiles with arbitrary bin sizes. Fig. 5 shows the prediction of Na\({}^{+}\) concentration profile in the configuration [1.2 nm, 2.2 M] with bin size ranging from 0.01 to 0.1 nm. Both NN and XGBoost successfully model the shape of the profile regardless of

Figure 4: Mean absolute error of **(a)** NN and **(b)** XGBoost predicted Na\({}^{+}\) concentration profile in all system configurations. MAE is calculated based on the profiles with bin size of 0.05 nm. The highest MAE of XGBoost in the dark red blocks is 4.92 M. The maximum value of the color bar is truncated such that the MAE of NN can be distinguished. The tick labels of channel width and molarity in the test set are colored red. **(c)** shows examples of failed interpolation of XGBoost for the configuration [1.6 nm, 2.2 M] due to overfitting.

Figure 5: Predicted Na\({}^{+}\) concentration profile with bin size ranging from 0.01 to 0.1 nm. The shown configuration is [1.2 nm, 2.2 M], which is included in the interpolation set.
the bin size: a primary peak near the confinement wall and a secondary peak at the channel center. When bin size is as fine as 0.01 nm, the concentration profile near the channel center is noisy because of less ion presence. Given the stochastic nature of MD simulation, which is used to generate the training data, the minor prediction error near the channel center with such a fine bin size is expected. The effect of stochasticity reduces as the bin size increases, resulting in more accurate predictions by NN and XGBoost.

## IV Conclusion

In this work, we show the viability of using a neural network (NN) as a surrogate model for MD simulation in predicting the ion concentration profile in the nanochannel. We first model the ion concentration profile in nanochannel as a probability distribution conditioned on the configuration of nanochannel systems, such as LJ potentials of the ion, channel width, and molarity of ion. A NN is then trained to predict the conditional cumulative density probability (CDF) distribution of ions given the system configuration. The predicted CDF can be linearly transformed back to the concentration profile as the final output of the NN model. 1,725 MD simulations (5 types of ions, 23 variations of channel width, 15 variations of molarity) are run to generate training and test data for the NN model.

We benchmark NN against another machine learning model, XGBoost, to compare their interpolation ability. The two metrics we used are the mean absolute error (MAE) of the whole interpolated ion concentration profile, and the peak deviation from the MD simulation concentration profile. On average, NN achieves 85.1% lower mean absolute error and 93.9% lower peak deviation when interpolating Na+ concentration profiles compared with the XGBoost model. Such a benchmark demonstrates the superior ability of NN to interpolate ion concentration profiles given unseen system configurations. Further, we record the inference time taken by the NN and XGBoost models and compared that to the time taken to post-process MD simulation trajectories. To predict 1,725 ion concentration profiles, NN takes an inference time of 0.80 s, which is approximately 3.2\(\times\) and 14.7\(\times\) faster than the XGBoost and processing MD trajectories, respectively. At last, we show that NN can reliably predict ion concentration profile with any bin size. The accuracy of NN prediction increases with larger bin sizes because of the reduced effect of stochasticity. In conclusion, NN is a fast, flexible, and most importantly, accurate surrogate model to predict ion concentration profiles under nanoconfinement.

###### Acknowledgements.

 We wish to acknowledge the computational resources provided by the Pittsburgh Supercomputing Center (PSC). Z.C. acknowledges the funding from the Neil and Jo Bushnell Fellowship in Engineering.

## Data Availability Statement

The training data used for machine learning model training are openly available on GitHub ([https://github.com/zcao0420/IonNet](https://github.com/zcao0420/IonNet)).
