Post-Processing the Results of Metastable States Molecular Dynamics Simulation Andrey Sozykin1,3 , Natalia Neustroeva1,3 , Vladimir Baidakov2 , Sergey Protsenko2 , Vasiliy Brukhanov2 , Konstantin Ushenin3 , and Arsenii Krasnobaev1 1 Krasovskii Institute of Mathematics and Mechanics, Yekaterinburg, Russia 2 Institute of Thermophysics, Ural Branch of the Russian Academy of Sciences, Yekaterinburg, Russia 3 Ural Federal University, Yekaterinburg, Russia Abstract. Molecular dynamics simulation should be combined with modern supercomputer technologies to obtain meaningful results in rea- sonable time. Widely used simulation software in MD is LAMMPS. It produces a dump with computational results of simulation, and such a large amount of data should be post-processed. However, LAMMPS does not provide ready-to-use utilities that would do it. In this paper we present the developed algorithm for LAMMPS output data process- ing for nucleation process. The analysis of implementation performance shows that it is shading that takes most of the time, hence, it should provide the greatest room for future optimization. Keywords: parallel computing systems · supercomputers · LAMMPS · MD simulation 1 Introduction One of the problems to be solved with the use of modern supercomputer tech- nologies is the molecular dynamics (MD) simulation of metastable phase states and phase transitions. The first stage of a new thermodynamic phase formation is nucleation. Nucleation is widespread in both nature and technological processes during which the phase transitions occur [1]. There are two types of nucleation: homogeneous and heterogeneous. Homogeneous nucleation is a process—with which the formation of a new thermodynamic phase begins—in substances free of impurities. [1]. Heterogeneous nucleation is a process—with which the forma- tion of a new thermodynamic phase begins—on a surface consisting of foreign particles. A popular method of nucleation study is molecular dynamics (MD) simu- lations [2, 3]. This method allows to compute the change of the particles’ co- ordinates and their velocities in time by the numerical solution of Newton’s equations of motion. The initial velocity and the coordinates of particles as well as the potential of their interaction must be defined. The most common model of interaction among nonpolar molecules is the Lennard-Jones (LJ) potential. 12 Andrey Sozykin et al. Using the coordinates and velocities of the particles at a specific point of time, one can compute [4] various physical quantities (temperature, pressure, etc.). For the study of nucleation, additional parameters should be calculated, for ex- ample, the volume of the biggest bubble, the contact angle, and components of the pressure tensor. The most widely used MD simulation software is the LAMMPS system [5]. LAMMPS is a classical molecular dynamics open source code with the parallel computing support. However, LAMMPS does not provide ready-to-use utilities for analysis of appearance and growth of new phases. Therefore, one has to im- plement the procedures for post-processing of the nucleation simulation results. 2 Description of Nucleation Study Experiments Several computational experiments for studying the nucleation properties were conducted at the Institute of Thermophysics. For modeling homogeneous nu- cleation, the Lennard-Jones (LJ) liquid gas mixture of methane and nitrogen is considered. The system under study contains N = 32000 LJ particles. The particles are placed in a cubic box with periodic boundary conditions (PBC) as presented in Fig. 1. Isothermal entry into metastable states of mixture is im- plemented by lowering the density through stretching the whole cell and then scaling the particles’ coordinates accordingly. Fig. 1. Two component liquids mixtures in the cell with PBC For study of heterogeneous nucleation, the system of LJ particles (model liquids consisting of monocenter molecules) placed between two flat crystalline Post-Processing the Results of Metastable States MD Simulation 13 walls is used, as shown in Fig. 2. The appearance of the vapor phase on the walls simulates the heterogeneous nucleation (Fig. 3). Fig. 2. Liquid between two crystalline walls An important property of nucleation is the rate of nucleation, which equals the average number of nuclei of a new phase formed per unit volume per unit time [6]. Rate of nucleation, according to the classical nucleation theory (CNT), is determined by the contact angle [7], which is the angle between a solid surface and the tangent to the curved boundary of the drop (bubble) at the point of its contact with the solid (Fig. 4). 3 Post-Processing Algorithm and Implementation As a result of numerical experiments in simulation of molecular dynamics, the LAMMPS system produces a text file with the coordinates of the particles. It is required to post-process these results to calculate the various characteristics of the models. For the homogeneous nucleation experiment with the gas mixture in cells with the periodic boundaries, we need to find an empty cluster with the 14 Andrey Sozykin et al. Fig. 3. Bubble in heterogeneous Fig. 4. Contact angle in heteroge- nucleation model neous nucleation maximum radius and then evaluate the parameters of the cluster such as volume, center of mass coordinates, and particles’ density distribution. We developed a four-step (Fig. 5) algorithm for detecting empty spaces: 1. Discretization of space. The model space is partitioned into equal cells, which are cubes with sides parallel to the model sides. The number of cubes is pre-selected so that each single particle of the model “gets” nclast partition cubes. 2. Shading non-empty cubes. The cubes the centers of which are less than the distance Rnearest away from some particle are shaded. 3. Clustering empty cubes. Unmarked cubes are clustered using the breadth-first search (BFS) algorithm. We assume that the two cubes belong to the same cluster if they share at least one edge. 4. Finding the cluster center. We determine the cells with the most distance from each other for the clusters in all three dimensions and calculate the center of the cluster. The algorithm was implemented using C++ with Intel Compiler. The current implementation is capable of processing existing LAMMPS output files with particle coordinates. The advantage of such an approach is the ability to process the data from previously conducted experiments. To analyze the performance of the implementation, the numerical experi- ments on specially prepared test data were carried out. The Intel Xeon X5675 processor was used during the experiments. Our implementation processed one frame with 1000000 particles and 300 partition cubes per particle (nclast ) in 440 seconds (including input/output time). The achieved performance is practical for frame numbers between 100 and 200. The performance of the implementation was studied with the help of the Intel VTune Amplifier profiler software. Shading takes 94% of the time on test data, 2% are occupied by BFS, and 1% by other tasks (discretization of the space, finding the cluster center, data input/output, etc.). Hence, shading offers the greatest room for optimization. Post-Processing the Results of Metastable States MD Simulation 15 1) 2) 3) 4) Fig. 5. The steps of the algorithm 4 Conclusion and Future Work We presented an algorithm for post-processing the MD simulation results: finding the biggest empty cluster and evaluating its parameters—the radius, the volume, the center of coordinates, and the particles’ density distribution. Directions of future work include improving the performance of the algorithm implementation using parallel computing in order to process frames with millions of particles. In addition, we plan to develop and implement algorithms for post-processing of heterogeneous nucleation simulation results (contact angle, tensor of pres- sure, etc.). The post-processing programs will be implemented as plugins for LAMMPS. Acknowledgements The work was supported by the Research Program of Ural Branch of RAS, project no. 15-7-12-8 and the Russian Foundation for Basic Research, project no. 15-08-03399. Our study was performed using the Uran supercomputer of the Krasovskii Institute of Mathematics and Mechanics. 16 Andrey Sozykin et al. References 1. Kashchiev, D.: Nucleation: Basic Theory with Applications. Butterworth- Heinemann, Oxford, 30 (2000) 2. Novak, B., Maginn, E., McCready, M.: Comparison of heterogeneous and homoge- neous bubble nucleation using molecular simulations. Physical Review B, Volume 75, Issue 8, 5413–5423 (2007) 3. Nagayama, G., Tsuruta, T., Cheng, P.: Molecular dynamics simulation on bubble formation in a nanochannel. International Journal of Heat and Mass Transfer, Vol- ume 49, Issue 23, 4437–4443 (2006) 4. Rapaport, D.: The Art of Molecular Dynamics Simulation 2nd Edition. Cambridge university press, Cambridge, 11–20 (2005) 5. LAMMPS Molecular Dynamics Simulator. http://codeblue.umich.edu/hoomd- blue/ 6. Skripov, V.: Metastable liquids. Wiley, New York, 15 (1974) 7. Blander, M., Katz, J.: Bubble nucleation in liquids. AIChE Journal, Volume 21, Issue 5, 833–848 (1975)