Kenya Coffee School (KCS)
RoastLogic™ AI Engine
📐 Full Mathematical Model Equations Specification
Version 1.0 – Advanced Roast Analytics Core
Aligned with scientific roasting methodology referenced by the Specialty Coffee Association and adapted for Kenyan high-density coffees (820–850 g/L).
1️⃣ THERMAL DYNAMICS MODEL
Roasting can be modeled as a lumped-parameter heat transfer system.
1.1 Bean Temperature Differential Equation
Let:
- = Bean temperature
- = Environmental temperature
- = Bean mass
- = Specific heat capacity of coffee
- = Convective heat transfer coefficient
- = Effective heat exchange surface area
- = Radiative heat
- = Conductive heat
Governing Equation:
m_b c_b \frac{dT_b}{dt} =
hA(T_e - T_b) + Q_c + Q_r
Where:
Q_r = \sigma \epsilon A (T_e^4 - T_b^4)
= Stefan–Boltzmann constant
= emissivity
2️⃣ RATE OF RISE (RoR) MODEL
RoR(t) = \frac{dT_b}{dt}
Discrete approximation:
RoR_i = \frac{T_{b,i} - T_{b,i-1}}{\Delta t}
2.1 RoR Stability Index
Define:
S_{RoR} = 1 - \frac{\sum |RoR_{i} - RoR_{i-1}|}{N \cdot RoR_{max}}
Range: 0 (unstable) → 1 (perfectly smooth decline)
3️⃣ DEVELOPMENT TIME RATIO (DTR)
DTR = \frac{t_{drop} - t_{FC}}{t_{drop}} \times 100
Target band:
20\% \leq DTR \leq 23\%
3.1 DTR Penalty Function
P_{DTR} = e^{-\left(\frac{DTR - DTR_{target}}{\sigma}\right)^2}
Where:
Range: 0–1 (1 = optimal)
4️⃣ DENSITY-BASED ENERGY ADJUSTMENT MODEL
Let:
- = density (g/L)
Charge correction:
\Delta T_{charge} = \alpha(\rho - \rho_{ref})
Empirical coefficient:
\alpha = 0.25 °C \text{ per } 10 g/L
4.1 Heat Absorption Scaling
Higher density → slower heat penetration.
\tau_{heat} = \beta \cdot \rho
Where: = experimentally calibrated constant
5️⃣ SHRINKAGE MODEL
Shrinkage = \frac{W_{green} - W_{roasted}}{W_{green}} \times 100
5.1 Shrinkage vs Development Correlation
Shrinkage \approx k_1 \cdot DTR + k_2 \cdot T_{drop}
Regression-derived constants:
6️⃣ FIRST CRACK PREDICTION MODEL
Internal pressure modeled as:
P_{internal} = P_0 + \gamma T_b
First crack occurs when:
P_{internal} \geq P_{cell\_wall}
Predict FC time via regression:
t_{FC} = a_1 T_{charge} + a_2 \rho + a_3 moisture + c
7️⃣ RoR CRASH DETECTION FUNCTION
Define crash when:
\frac{d^2T_b}{dt^2} < -\delta
Where:
Discrete second derivative:
\frac{T_{i+1} - 2T_i + T_{i-1}}{\Delta t^2}
8️⃣ RoR FLICK DETECTION
Flick =
\begin{cases}
1 & \text{if } RoR_{postFC} > RoR_{preFC} + 4 \\
0 & \text{otherwise}
\end{cases}
9️⃣ PROFILE OPTIMIZATION COST FUNCTION
Define objective function:
J = w_1(1 - S_{RoR}) + w_2|DTR - DTR_{target}| + w_3|T_{drop} - T_{target}|
Weights:
Goal:
\min J
🔟 SENSORY PREDICTION REGRESSION MODEL
Let:
- = DTR
- = RoR stability
- = Drop temp deviation
- = Shrinkage
Sweetness prediction:
Sweetness = b_0 + b_1x_1 + b_2x_2 - b_3x_3 + b_4x_4
Acidity preservation:
Acidity = c_0 - c_1(DTR - 21.5)^2 - c_2 T_{drop}
Bitterness risk:
Bitterness = d_1(DTR > 25) + d_2 Flick + d_3 HighDrop
11️⃣ CERTIFICATION SCORING EQUATION
Score = 35P_{practical} + 20P_{profile} + 15S_{RoR} + 10P_{DTR} + 20S_{sensory}
Normalized to 100.
12️⃣ CARBON EMISSION MODEL
CO_2/kg = \frac{Gas_{m^3} \times 2.0}{Batch\_kg}
Energy efficiency index:
EEI = \frac{Batch\_kg}{Gas_{m^3}}
13️⃣ MACHINE LEARNING LOSS FUNCTION
For regression model:
Loss = \frac{1}{N} \sum (y_{pred} - y_{actual})^2
For classification (defect detection):
Loss = -\sum y \log(p) + (1-y)\log(1-p)
14️⃣ OPTIMIZATION VIA GRADIENT DESCENT
\theta_{new} = \theta_{old} - \eta \nabla J(\theta)
Where:
- = learning rate
- = cost function
15️⃣ MASTER PERFORMANCE INDEX (MPI)
MPI = 0.4S_{RoR} + 0.2P_{DTR} + 0.15(1 - DropDeviation) + 0.15ShrinkageScore + 0.1DensityCompliance
Range: 0–100
≥92 → Master Level
85–91 → Professional
<85 → Improvement required
STRATEGIC SIGNIFICANCE
These equations allow KCS RoastLogic™ to:
- Operate as a rule-based + ML hybrid AI
- Quantify roast quality mathematically
- Predict sensory outcome
- Automate certification scoring
- Create Kenya’s first roast-origin performance index
