This is the 2D top-down companion to the 3D packaging simulator: the same reaction-diffusion model, viewed as a live concentration map instead of a 3D box. A spoiling food surface off-gasses volatile biomarkers (biogenic amines such as putrescine and cadaverine). Concentration c(x,y,t) spreads across the packaging headspace by diffusion:
∂c/∂t = D·∇²c + S(x,y) − λc
D increases with temperature (Arrhenius-like Q10 ≈ 2.5 per 10 °C)
S(x,y) = emission source at the food footprint, ∝ bacterial load
A ring of 32 nanosensor nodes around the inside of the film continuously samples the local field. When the sampled concentration crosses the trigger threshold, its indicator dye undergoes a colorimetric shift (green → amber → red) — the same mechanism used in real gold-nanoparticle / pH-dye freshness labels.
dN/dt = r(T)·N·(1 − N/K) − k_AM·A·N
N = bacterial population (log CFU/g), K = carrying capacity
A = locally released antimicrobial-nanocapsule concentration
Once enough sensors trip, "active packaging" mode bursts antimicrobial nanocapsules embedded in the film (visualised as a blue release pulse from the ring). The released agent A diffuses inward and suppresses growth in the logistic equation above — turn active packaging off to see spoilage run unchecked.
Numerical note: the 3D sibling advances its diffusion field with one fixed explicit step per frame; at the top of its temperature slider the resulting stability number exceeds the limit for its update stencil, which can make the field ring or overshoot instead of smoothly relaxing. This 2D version fixes that by adaptively splitting each frame into enough sub-steps to keep the stability number bounded at every temperature (see the code comment near stepFields()).
- Storage temperature — raises both the diffusion rate and the bacterial growth rate r(T).
- Initial bacterial load — sets the starting population and emission strength.
- Sensor trigger threshold — how much biomarker a sensor node needs to see before it flags contamination.
- Active packaging toggle — enables/disables the antimicrobial release response.
- Drag / scroll — pan and zoom the diffusion map.