Overview
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-conductivitySinks 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;
Controls
Mouse / Keyboard
Click & Drag
will modify the cell at the mouse location based on key pressed:
W
will add a Wall cellQ
will restore the cell to a plain cell (removing any Wall, Sink or Source)A
will add a heat sourceS
will add a heat sinkany other key
will remove heat from the cell- (no key pressed) will add heat from the cell
References:
- Wikipedia: Finite Element Method
Links:
Screenshot:
With Walls and heat syncs in place: