RasmahRasmah

Natural-Convection Topology Optimization

Overview

Natural convection arises from buoyancy: a heated fluid expands, becomes lighter, and rises under gravity. NaturalConvectionTopOpt optimizes the fluid layout of the Boussinesq (u, p, T) system — buoyancy −β_T(T−T_ref)g coupling momentum to temperature — for maximum heat transfer.

using Rasmah

A heated cavity

Heat the bottom of a cavity, cool the top, and let the optimizer arrange the convective flow path.

m = tetrahedralize_box(1.0, 1.0, 1.0, 2, 2, 2)
fluid = FluidMaterial(name = "air", density = 1.0, dynamic_viscosity = 0.01)
nn = size(m.nodes, 2)

bottom = [i for i in 1:nn if m.nodes[3, i] < 1e-6]
top = [i for i in 1:nn if m.nodes[3, i] > 0.999]
fixed_T = vcat(bottom, top)
gT = vcat(ones(length(bottom)), zeros(length(top)))

x, hist = solve(NaturalConvectionTopOpt(), m, fluid; fixed_T = fixed_T, gT = gT,
                fixed_p = [1], β_T = 1.0, gravity = [0.0, 0.0, -1.0], T_ref = 0.0,
                volfrac = 0.5, max_iter = 10)
([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0  …  0.0, 0.0, 0.0, 0.0, 0.09637576673070662, 0.09570894452892259, 0.0, 0.0, 0.0, 0.0], [0.6248597475606207, 0.5708383442957772, 0.4857433518211672, 0.33093227051634583, 0.3188565354331191, 0.31358958871361486, 0.31339319602163274, 0.31339801008910273, 0.3133687838717077, 0.313346792439272])

Verification — the design stays feasible

The density field is finite and bounded:

println("all densities finite: ", all(isfinite, x))
println("density in [0,1]:    ", all(0 .<= x .<= 1))
all densities finite: true
density in [0,1]:    true
vtk(m; field = x, fieldname = "convection density", edges = true)

Next steps