Heat Convection

Heating from below and cooling from above sets the fluid in motion. Colors show temperature in this simplified model.

Published

No video preview yet

Source

use "@hyle/maths";

// Temperature is false color: sapphire -> turquoise -> amber -> coral.
// A visible base opacity makes the entire medium readable, even before flow starts.
// Opacity is a display input only: it never changes the heat or momentum equations.
input airOpacity: Float [0.02, 0.4] = 0.12;
visual ThermalColor for ConvectionFluid {
	color {
		let t=maths::clip(self.temperature,0.0,1.0);
		let lower=maths::clip(t*3.0,0.0,1.0);
		let middle=maths::clip(t*3.0-1.0,0.0,1.0);
		let upper=maths::clip(t*3.0-2.0,0.0,1.0);
		let deviation=maths::clip(maths::abs(self.temperature-(1.0-self.height))*3.0,0.0,1.0);
		let motion=maths::clip(maths::sqrt(self.ux*self.ux+self.uy*self.uy+self.uz*self.uz)*35.0,0.0,1.0);
		rgba(0.10-0.04*lower+0.91*middle+0.02*upper,
			0.23+0.46*lower+0.06*middle-0.47*upper,
			0.88-0.18*lower-0.46*middle-0.07*upper,
			maths::clip(airOpacity+0.12*deviation+0.20*motion,0.0,0.8))
	}
}
visual FrameColor for ChamberFrame {
	color { rgba(0.14+0.68*self.hot,0.25+0.17*self.hot,0.64-0.43*self.hot,0.8) }
}
visualize ConvectionCell with ThermalColor;
visualize Frame with FrameColor;