This system predicts cooking times using an exponential approach model based on the physics of heat transfer during cooking.
https://xkcd.com/612/ https://www.youtube.com/watch?v=9gTLDuxmQek
When you cook meat, the temperature doesn't rise linearly. Instead, it follows an exponential approach toward an equilibrium temperature. This happens because:
- Newton's Law of Cooling: The rate of temperature change is proportional to the temperature difference between the meat and its environment
- Thermal Mass: Larger pieces of meat heat up more slowly
- Heat Capacity: Different materials require different amounts of energy to change temperature
- Surface Area: More surface area = faster heat transfer
The temperature follows this equation:
T(t) = T_equilibrium - (T_equilibrium - T_start) × e^(-t/τ)
Where:
T(t)= temperature at time tT_equilibrium= final equilibrium temperature the meat approachesT_start= starting temperatureτ(tau) = time constant (how fast the meat heats up)t= elapsed time
Tau is the time it takes to reach 63.2% of the way to equilibrium. Think of it as the "cooking speed":
- Small tau (fast cooking): Thin chicken breast, high grill temp
- Large tau (slow cooking): Thick brisket, low-and-slow temperatures
Examples:
- Tau = 30 minutes: After 30 min → 63% done, after 60 min → 86% done, after 90 min → 95% done
- Tau = 2 hours: After 2 hours → 63% done, after 4 hours → 86% done, after 6 hours → 95% done
The predictor maintains:
- Historical data: Recent temperature, grill temp, and time measurements
- Model parameters: Current tau estimate, start/target temperatures
- Environmental factors: Grill temperature and setpoint for physics-based corrections
- Update(): Processes new temperature readings and re-estimates tau
- EstimateTimeToTarget(): Predicts time to reach target temperature
- estimateTimeConstant(): Finds the best tau by testing against historical data
- calculateEffectiveEquilibrium(): Adjusts target based on grill conditions
The system goes beyond simple exponential curves by considering real grill physics:
The meat doesn't just approach the probe target—it's influenced by grill temperature:
Effective Equilibrium = f(grill_temp, grill_setpoint, probe_target)
Examples:
- Grill at 250°F, target 204°F → meat can reach ~204°F
- Grill at 180°F, target 204°F → meat might only reach ~185°F (insufficient heat)
- Grill at 350°F, target 204°F → meat might overshoot to ~210°F (too much heat)
Unstable grill temperatures reduce prediction accuracy:
stability = 1.0 - |grill_temp - grill_setpoint| / 50.0
| Parameter | Default | Range | Purpose |
|---|---|---|---|
minDataPoints |
3 | 2-10 | Minimum measurements before estimating tau |
maxHistory |
20 | 10-50 | How many recent points to keep |
defaultTau |
3600s (1hr) | 300-28800s | Initial tau estimate |
| Parameter | Default | Range | Purpose |
|---|---|---|---|
tauMin |
300s (5min) | 60-1800s | Fastest possible cooking |
tauMax |
28800s (8hr) | 3600-86400s | Slowest possible cooking |
tauStep |
300s (5min) | 30-600s | Search granularity |
| Parameter | Default | Purpose |
|---|---|---|
| Very hot grill factor | 0.1 | When grill >50°F above target |
| Moderate hot factor | 0.2 | When grill 20-50°F above target |
| Slightly hot factor | 0.5 | When grill 0-20°F above target |
| Cool grill factor | 0.3 | When grill below target |
| Stability divisor | 50.0 | How much grill instability matters |
| Min stability | 0.5 | Prevents extreme instability penalties |
| Parameter | Default | Purpose |
|---|---|---|
| Error improvement | 0.9 | New tau must be 10% better to update |
| Max prediction time | 8 hours | Caps unrealistic predictions |
| Equilibrium threshold | 0.1°F | When start temp too close to target |
- Reduce
minDataPointsto 2 - Reduce
maxHistoryto 10 - Increase
tauStepto 60s for coarser search - Reduce error improvement threshold to 0.8
- Increase
minDataPointsto 5 - Increase
maxHistoryto 30 - Reduce
tauStepto 60s for finer search - Increase error improvement threshold to 0.95
High-Heat/Fast Cooking:
- Reduce
tauMinto 180s (3 minutes) - Reduce
tauMaxto 7200s (2 hours) - Increase grill factors (more aggressive heat transfer)
Low-and-Slow:
- Increase
tauMinto 600s (10 minutes) - Increase
tauMaxto 43200s (12 hours) - Reduce grill factors (gentler heat transfer)
Precision Cooking:
- Reduce
tauStepto 60s - Increase
maxHistoryto 50 - Increase
minDataPointsto 8
exponential.go: Main predictor logicestimateTimeConstant(): Tau calculation (lines ~85-110)calculateEffectiveEquilibrium(): Grill dynamics (lines ~200-240)
// In NewExponentialPredictor()
minDataPoints: 3, // Line 36
// In Update()
ep.timeConstant = 3600.0 // Line 55 (default tau)
// In estimateTimeConstant()
for tau := 300.0; tau <= 28800.0; tau += 300.0 // Line 103
// In calculateEffectiveEquilibrium()
effectiveEquilibrium = probeTarget + grillDelta*0.1 // Line 222
effectiveEquilibrium = probeTarget + grillDelta*0.2 // Line 225
effectiveEquilibrium = probeTarget + grillDelta*0.5 // Line 228
effectiveEquilibrium = grillTemp + math.Max(grillDelta*0.3, -20) // Line 232Test parameter changes against historical data:
./wifire forecast --input your_cook.json --actual 2025-01-17T20:49:45-05:00- Accuracy: How close predictions are to actual finish time
- Stability: How much predictions jump between measurements
- Convergence: How quickly the model settles on accurate predictions
- Tau Values: Are estimated tau values reasonable for your cooking style?
Time Delta Grill Probe Target Velocity Filtered Exp ETA Actual Accuracy
19:31:34 61 254 190 204 59.0 190.00 1h17m 1h18m -0.6%
- Good accuracy: ±5% error or better
- Reasonable tau: Visible in debug output (typically 1-6 hours for BBQ)
- Stable velocity: Not wildly fluctuating between measurements
You can create cooking-style-specific profiles by modifying the grill dynamics factors:
// Competition BBQ profile (conservative)
grillFactors := []float64{0.05, 0.1, 0.3, 0.2}
// Fast grilling profile (aggressive)
grillFactors := []float64{0.2, 0.4, 0.7, 0.5}Consider adding parameters for:
- Ambient temperature effects
- Wind/weather conditions
- Meat wrapping (Texas crutch)
- Probe placement (thickness dependency)
The exponential prediction system provides a solid physics-based foundation that can be tuned for your specific cooking environment and style.