A phase-change material stores heat mostly as latent heat: while it melts it absorbs a large amount of energy at an almost constant temperature, instead of just warming up. This panel solves 2D transient heat conduction through an array of PCM capsules with the apparent (enthalpy) heat-capacity method:
ρ C_app(T) ∂T/∂t = k ∇²T
C_app(T) = c_p + L · g(T − T_m, ΔT)
g(x,σ) = exp(−x² / (2σ²)) / (σ√(2π))
cp is the ordinary (sensible) specific heat, L is the latent heat of fusion, Tm is the melting point and the Gaussian g smears that latent heat over a narrow "mushy" band ΔT so the finite-difference solver stays smooth at the melt front. Liquid fraction is read from where the local temperature sits inside that band:
f(T) = clamp( (T − (T_m − ΔT)) / (2ΔT), 0, 1 )
- Material buttons — switch k, ρ, cp, Tm and L to real PCM classes: paraffin wax (organic, cheap, low conductivity), a salt hydrate (higher conductivity, faster front, but prone to subcooling in reality), and a bio-based oil (low melting point, good for building comfort cooling).
- Charge / Discharge — the left wall of the panel is held at a fixed temperature (Dirichlet boundary); the other three sides are insulated. Charging heats the wall above Tm and melts the PCM from left to right; discharging cools it below Tm and re-solidifies it, releasing the stored latent heat back out.
- Wall temperature — sets how far above (charging) or below (discharging) the melting point the boundary sits; a bigger ΔT drives a faster front but the plateau temperature itself never changes — that's the whole point of using a PCM as a thermal buffer.
- Energy stored — numerically integrates ρ[cp(T−Tref) + L·f(T)] over every cell, so you can watch the big jump in stored energy that happens during the melt plateau, not during ordinary warm-up.
Real-world relevance: this exact mechanism cools buildings passively (PCM wallboard), buffers solar-thermal and ice-storage HVAC systems, and protects batteries and electronics from thermal spikes by soaking up heat at a fixed temperature instead of letting it rise.