This is a p5.js sketch that models basic heat-transfer through finite element analysis.
Each cell has a concept of temperature, and with each cycle will transfer (gaining or losing) heat with its neighbors.
The temperature is visualized along a gradient from blue (cold temperatures) to red (hot temperatures) with white in the middle.
Some other concepts:
Walls- denoted by solid, dark grey cells have zero-conductivity
Sinks and Sources- Will either absorb or generate heat on each cycle.
Heat Transfer is modeled off of:
q = - k * delta T
Similar to Thermal Conduction: Differential Form (wikipedia.org).
And implemented as
let heatGained = (otherCell.temp - this.temp) * this.condFactor; this.deltaTemp += heatGained; otherCell.deltaTemp -= heatGained;
Mouse / Keyboard
Click & Drag will modify the cell at the mouse location based on key pressed:
Wwill add a Wall cell
Qwill restore the cell to a plain cell (removing any Wall, Sink or Source)
Awill add a heat source
Swill add a heat sink
any other keywill remove heat from the cell
- (no key pressed) will add heat from the cell
- Wikipedia: Finite Element Method
With Walls and heat syncs in place: