Erlang n-body simulation
This is a simulation of the n-body problem using erlang. The program spawns a thread for each 'body' and simulates the effect of gravity in ticks. This is the standard brute-force approach.
It automatically generates bodies across a bi-dimensional space bounded by user input. The output is, for each round, the mass and position of each body.
body.erl implements the body functionality of updating position according to the gravity influence of nearby bodies
gravity.erl calculates the force vector between two bodies using the formula F = G*(mass1 * mass2) / (distance^2)
sum_forces.erl gives the resulting force vector for a given body
simulation.erl implements the main simulation function.
simulation:simulation accepts four arguments: body_count, ticks, max_mass and max_dimension_size. The first parameter, body_count, is the number of bodies to be initialized. Ticks is the number of rounds the simulation will run for. Max_mass is the maximum mass for any of the generated bodies. Max_dimension_size is the boundary of the 2D space each body is inserted into.
Compile each module with c(modulename).
Run the simulation module, for example as simulation:simulation(3, 80, 800, 800).