Correct!
Our current path of flight is therefore as outlined below.
Build Your Own Particle Simulator from Scratch
The code listed below is taken from this Discourse Post.
With 15 lines, Leandro Martinez (@lmiq) writes a code to perform a particle simulation with periodic boundary conditions, a langevin thermostat, a quadratic potential between the particles, and produce an animation (see below).
The code below uses the function wrap that in turn uses the ternary operator a?b:c explained at control flow.
Exercise Extend this code with:
- monitor the potential, kinetic and total energy on each particle. Verify in which conditions (implicit vs. explicit time stepping, order of time stepping method, fixed vs. adaptive time step, time step size) the total energy remains preserved (i.e. constant in time);
- assume a uniform mesh on the domain of computation. Compute the mixture fraction on the mesh;
- assume a computed mixture fraction on a uniform mesh. Compute the partion function on this mesh;
- differentiate the total energy wrt the position vector \mathbf{x}_i of particle i to obtain the force vector \mathbf{F}_i on particle i. Possibly use ForwardDiff or any for this differentiation;
- differentiate the force vector \mathbf{F}_i on particle i wrt its position vector \mathbf{x}_i (thus obtaining the second derivative of the energy) to obtain the coefficients in the constitutive force-strain relation;
- repeat above for alternative choices of the potential between particles. Choices include adding a cubic term to the potential (Duffing oscillators), Langevin and Van der Waals potentials. Verify whether the later allow to take particle sizes into account;
- taylor the above framework to emulsions formed by vegetable oil droplets in water by considering the entropic and interfacial free energy of the emulsion undergoing a shear force;
- verify to what extend the package Molly allows to automate and/or extend any of the above steps. Please note that the Molly package allows for differentiable simulations. This property motivates our choice for this package;