diffusion #12

Merged
ktyl merged 6 commits from diffusion into main 2022-12-09 01:36:48 +01:00
1 changed files with 21 additions and 0 deletions
Showing only changes of commit 2b02ccfe33 - Show all commits

21
gdd.md
View File

@ -28,6 +28,27 @@ Add a tick counter as a UI element.
Diffusing should use 'pull' operations; tiles should pull values from surrounding tiles.
This is an attempt to think forwards to parallelising computation of diffusiong - ideally using the GPU.
#### Diffusion Algorithm
Diffusion is modelled as two-dimensional steady-state heat conduction.
This means that the amount of a value does not change between the start and end of the computation of the diffusion step.
The value at one 2D location is calculated based on the values of itself and its neighbours in the previous step.
A diffusion coefficient controls the rate of diffusion.
[Video explanation](https://www.youtube.com/watch?v=RGbV7T_iWT8)
[Derivation](https://www.tec-science.com/thermodynamics/heat/heat-equation-diffusion-equation/)
Implementation:
```cs
private float TransferHeat(float t0, float alpha, float nx, float ny, float px, float py)
{
float d2tdx2 = nx - 2 * t0 + px;
float d2tdy2 = ny - 2 * t0 + py;
return t0 + alpha * (d2tdx2 + d2tdy2);
}
```
### Tile Types
Tiles start as wild tiles.