Trying to grow some snowflakes with periodic boundary conditions
Channel: Nils Berglund
Date: 30/12/2023

This simulation is similar to the one shown in the recent video https://youtu.be/HL1FWgLEDdw , but with periodic boundary conditions, on a domain that is quite a bit larger in the vertical direction than what is shown on screen. As a result, the "snow cystals" forming in the lower half do not accumulate at the bottom, but are able to move further downwards. After a while, they would appear again at the top, but the simulation stops before that, as this is not the desired effect.
The larger particles represent oxygen atoms, while the smaller particles, marked with a +, represent hydrogen atoms. The charge of each oxygen atom is the opposite of the charge of two hydrogen atoms, and its mass is 16 times the mass of a hydrogen atom. The particles interact via a Coulomb potential, and in addition, there is a Lennard-Jones type repulsion between particles of different charge, in order to avoid their collapse on a single point. Particles considered as forming a molecule do not interact through a Coulomb or LJ potential, but instead via a harmonic interaction with a large spring constant, that tends to maintain their distance constant. The distance between hydrogen atoms is chosen here in such a way that at equilibrium, the H-O-H angle is 104.45 degrees, which is typical for water molecules under standard conditions. Note that since this simulation is in 2D instead of 3D, another angle might be more appropriate.  
The displayed region is subdivided into an upper half, where water molecules are coupled to a thermostat, and a lower half, where there is no thermostat but a strong viscous damping, that has an effect analogous to  a thermostat at zero temperature. There is a larger supply of molecules coupled to the thermostat off screen, above the displayed rectangle. The molecules are subject to gravity directed downwards.
This simulation has two parts, showing the evolution with two different playback speeds: 
Time lapse: 0:00
Slow motion: 1:08
In the first part, playback speed has been multiplied by 3. The particles' color depends on their kinetic energy (mass times speed squared, divided by 2).
To save on computation time, particles are placed into a "hash grid", each cell of which contains between 3 and 10 particles. Then only the influence of other particles in the same or neighboring cells is taken into account for each particle. 
The temperature is controlled by a thermostat, implemented here with the "Nosé-Hoover-Langevin" algorithm introduced by Ben Leimkuhler,  Emad Noorizadeh and Florian Theil, see reference below. The idea of the algorithm is to couple the momenta of the system to a single random process, which fluctuates around a temperature-dependent mean value. Lower temperatures lead to lower mean values. 
The Lennard-Jones potential is strongly repulsive at short distance, and mildly attracting at long distance. It is widely used as a simple yet realistic model for the motion of electrically neutral molecules. The force results from the repulsion between electrons due to Pauli's exclusion principle, while the attractive part is a more subtle effect appearing in a multipole expansion. For more details, see https://en.wikipedia.org/wiki/Lennard-Jones_potential

Render time: 47 minutes 1 second
Compression: crf 28
Color scheme: Particle color - Turbo, by Anton Mikhailov
https://gist.github.com/mikhailov-work/6a308c20e494d9e0ccc29036b28faa7a

Music: "Night Snow" by Asher Fulero@AsherFulero

Reference: Leimkuhler, B., Noorizadeh, E. & Theil, F. A Gentle Stochastic Thermostat for Molecular Dynamics. J Stat Phys 135, 261–277 (2009). https://doi.org/10.1007/s10955-009-9734-0
http://www.maths.warwick.ac.uk/~theil/HL12-3-2009.pdf

Current version of the C code used to make these animations: 
https://github.com/nilsberglund-orleans/YouTube-simulations
https://www.idpoisson.fr/berglund/software.html
Some outreach articles on mathematics:
https://images.math.cnrs.fr/_Berglund-Nils-1343_.html
(in French, some with a Spanish translation)

#molecular_dynamics #ions #water_molecules