# Convection currents

I've finally stopped messing about with learning languages, messing about with my blog and sorting out photos, and have done some actual programming. After spending way too much time on what were effectively cosmetic changes to make the code more readable and adaptable, I finally got around to attempting to generate a convection current. Well, first I changed the display system so it always showed the minimum temperature as a deep blue, and the maximum as the lightest blue, and played with the diffusion and gravity constants to get a less extreme difference between the top and bottom of the pool, but after that I got started.

## Implementation

First, I had to add some borders to the pool: rock (temperature of 10 degrees – I’m not actually sure whether it should be hotter or colder than the water) at the bottom and edges and air (temperature of 20 degrees, same as the water) on the top. Then I adapted the diffusion system to allow for exchange of energy at the surfaces (but it’s not a true exchange as the temperature of the rock and air is current fixed) and was awed by the ease of adapting Python code. Then it was simply a case of making one of the pieces of rock 80 degrees. The effect, when the grid is a decent resolution (I’m now using a 20 x 12 grid, number fans), is quite pretty, with a bright spot above the heated rock that diffuses up and out over the pool.

## Detection

Whether the water is actually forming a current, I can’t yet say for sure. It certainly looks promising. By looking at the density of water in various sectors (using a very simple click-to-display-in-the-command-line-interface), it looks like the water should be moving in the way I would expect, but I’d like to be able to visualise it. There are a couple of ways I can think of doing and I’ll probably implement both. Both will take a bit of work (probably less than I expect because it’s Python), which is why I stopped last night. One way is to simulate the release of a chemical at the point where the water is heated and see where it goes. This should look quite pretty, but I’m not sure how well it will actually show the convection. It would be interesting to see what happens anyhow and at some point I’ll have to add chemicals to the water if I want life to exist there, so I might as well start now. The second way would be clearer, but less useful in the long run and would be to simply draw arrows showing which way the water is moving between each sector. This will require a bit of work because currently, the net flow is not calculated. Instead the individual flows are calculated, and the flows due to diffusion and gravity are separated, so I’d need to sum them. Maybe this could result in a more efficient program, but I’m not convinced.

## Future plans

After I have tested to see whether I can actually get currents, then I’d like to add some chemicals, play with their properties (such as their mass and buoyancy) and see what sort of gradients are set up. I’d also like to see whether I can change the shape of the pool from a dull rectangle to something more interesting without too much hassle. The first shape I’d like to try, and what should be easiest, is a pool of two depth, with a shallow half and a deeper half. I’d also like to introduce another ‘element’: light. The idea is that this would come from above and be absorbed by the water, heating it. Some would make to it the bottom of the pool (especially a shallow end, should there be one), heating that too. Then I would have to model the heat of the rock in a more sophisticated way, to allow it to change and also diffuse (I’m hoping I can co-opt the water diffusion equations for that). From there I can model light with varying intensities. Firstly, a simple light-dark, day-night cycle, and later a light that moves across the sky. Is this going too far? Am I just wasting time so I can put off the hard part of modelling the actual cell?