Two coupled first-order processes set the headspace gas composition inside a sealed Modified Atmosphere Package: the produce's own respiration, and diffusion of gas through the plastic film. This 2D engine integrates both as coupled ODEs every animation frame — the same equations used by the 3D version.
Respiration (Michaelis–Menten in O2, Q10 in temperature):
R_O2 = Vmax(T) · [O2] / (Km + [O2])
Vmax(T) = Vmax_ref · Q10^((T − Tref) / 10)
R_CO2 = RQ · R_O2 (RQ rises toward ~1.4 as O2 → 0, anaerobic shift)
Film permeation (Fick's law, driven by the gradient
across the film, scaled by the film's permeability):
J_O2 = P_O2 · (20.9% − [O2])
J_CO2 = P_CO2 · ([CO2] − 0.04%)
d[O2]/dt = −R_O2 · load/V_ref + J_O2
d[CO2]/dt = +R_CO2 · load/V_ref − J_CO2
[N2] = 100% − [O2] − [CO2]
Steady state is reached when respiration consumption/production
exactly balances film permeation (dO2/dt = dCO2/dt = 0) —
solved live below, plotted as O2/CO2 vs time converging to a plateau.
- Film type — a low-barrier film (LDPE-like) has high permeability, so it equilibrates with outside air quickly and the steady-state O2 stays close to ambient; a high-barrier film (EVOH-like) has low permeability, so respiration dominates and can pull O2 down to a much lower — potentially anaerobic — steady state for the same produce. Switch films and watch the plotted steady-state level move.
- Temperature — every +10 °C multiplies respiration (and O2 depletion) by Q10 ≈ 2.5, the same reason refrigeration extends shelf life.
- Produce loading — more product per litre of headspace consumes O2 and produces CO2 faster, pulling the steady state lower for the same film.
- Quality index — decays fastest when O2 sits in the optimal 2–8% "MA" band (slowest senescence); it collapses if O2 drops near 0% (anaerobic fermentation, off-flavours) or CO2 climbs past ~15% (tissue injury). A too-tight film for a fast-respiring produce drives O2 toward that dangerous near-zero region instead of the safe MA band.
This is the same balance real packers tune with gas-flushing (N2/CO2 blends) and film selection (OTR/CTR — oxygen/CO2 transmission rate) to hit a target shelf life for fresh-cut produce, meat and bakery goods — pick a film whose permeability matches the produce's own respiration rate, or the equilibrium atmosphere misses the safe window entirely.