N-Body Simulation
After learning a great deal more about pointers and dynamic memory allocation from Petri. I decided to try my hand at something more in line with my physics education. Somewhat ambitiously, my first thought was to create a program that generated a random set of stars and placed them on a grid to form a kind of proto-galaxy based on their interactions.
The first thing I looked at was stellar evolution and Hertzprung-Russell diagrams, which I had not studied formally since I was in sixth form. This seemed simple enough, there was a nice relationship between mass and luminosity for main sequence stars so I would only need a relationship between mass and time for 80% of stars.
\[ L = L_{sun} (\frac{M}{M_{sun}})^{\sim 3.5} \]
Additionally, it seemed like there might even be a numerical way to determine in which direction a star proceeds along the HR diagram... Read More
Petri: now with dynamic allocation
Recently I started writing a cellular automata program called “petri” that attempts to simulate a population of cells doing “life-like” activities. It is still extremely basic, but I found myself obsessively drawn to improving this program and therefore my own c++ abilities, so spent the better part of the last few days working on improving the program.
One of the issues with the first build of the program was that memory was statically defined by the maximum population with the programming constructing a number of objects equal to that amount, which was defined as a constant in the program. Instead, the cell class had a Boolean parameter that told program whether to consider the cell in processing and display. This meant that cell variables had to be reassigned after each compute step in order to prevent iteration over the whole population, which could potentially become very resource demanding if the... Read More
Petri, the petri-dish simulator
Lately I’ve been very interested in the idea of cellular automata and had an couple of attempts at replicating Conway’s game of life or played around with existing implementations. However, after being particularly bored on a Saturday afternoon I decided to start writing what I disingenuously called a petri dish simulator.
At the moment the program is rather simple, there are cell objects and food objects that are randomly placed in a grid of constant size. These cells have a few properties including size, energy and metabolism. The basic idea is that cells with higher metabolism will move around faster but die quicker without food, while cells with greater size will be able to consume smaller cells for energy but move more slowly and require more energy to do so. The eventual plan is to have these properties be passed on... Read More