This is in preparation for a study on formation of planets which also involves the agglomeration of particles into much larger bodies.
When particles collide and stick together just the total momentum is conserved but not the translational kinetic energy.
The difference between the incident kinetic energy and the final kinetic energy gets converted to internal energy which can
consist of, e.g., chemical energy or vibrational energy. A scattering case where the ratio of the internal energy increment to incident energy
is when two particles of the same mass collide head on and therefore the final momentum and energy are both zero.
It is assumed here that none of the internal energy gained due to collisions gets converted back to kinetic energy.
The internal energy CAN be lost as electromagnetic radiation according to the Stefan Boltzmann (SB) law. The SB law is proportional to the 4th power of the
absolute temperature. For our purpose, the absolute temperature is proportional to the internal energy of the composite particle.
One variable here is the fraction of collisions that result in conversion of kinetic energy to internal energy. This is
implemented by using the random number generator.
The other variable is the value of the gravitational constant, gConstant, which is in effect when the "Include Gravity Attraction" box is checked.
For 3D calculations internal energy conversion is slow so using gravity attraction speeds up conversion. Inclusion of gravity
causes the final total energy to be larger than the initial kinetic energy and that is to be expected.
The form of the gravitational force is gConstant*m1*m2/r where m1 and m2 are the particle masses and r is the distance between
their centers.
The particles are constrained by elastic scattering from the walls of the container. For 2D the container is a box of 500x500 pixels.
For 3D the container is a cube of 500x500x500 pixels.
We simulate internal energy of the combined particles by applying a color scheme.
The final kinetic energy is very small, in general, because almost all of the kinetic energy gets converted to internal energy.
At the end of the process, we are down to one particle and the energy results are printed at the top left of the container.