Caffeine level at time t
For each drink, caffeine absorbs linearly over ~45 minutes, then decays exponentially:
if t < 45min: C(t) = dose × (t / 45)
if t ≥ 45min: C(t) = dose × 0.5^((t - 45) / half-life)
Total caffeine = sum of C(t) for all drinks. The chart plots this continuously for 24 hours centered on now.
Sleep threshold
Base threshold = body weight in kg × 0.6 mg/kg. This is a rough estimate of the caffeine level below which a caffeine-naive person can fall asleep, based on adenosine receptor binding studies. It’s then scaled by a tolerance multiplier based on habitual daily intake:
Light (<200 mg/day): ×1.0
Moderate (200–400): ×1.6
Heavy (400–600): ×2.2
Very heavy (600+): ×3.0
The multipliers reflect adenosine receptor upregulation from chronic caffeine exposure. Regular users develop pharmacodynamic tolerance — the brain adapts to baseline caffeine, so higher residual levels are needed before caffeine meaningfully blocks sleep. These are rough estimates; no published formula exists for this. Adjust threshold based on your actual experience.
Half-life
Default 5.7h is the population average. Actual range is 2–9h depending primarily on CYP1A2 genotype (rs762551): AA = fast (2–4h), AC = intermediate (4–6h), CC = slow (6–9h). Smoking, exercise, and oral contraceptives further modify this. Half-life affects when you cross the threshold, not the threshold itself.
Limitations
This model uses first-order kinetics with a simplified linear absorption phase. Real pharmacokinetics are messier — food slows absorption, liver saturation at very high doses changes the curve, and individual variation is substantial. Treat all times as estimates, not medical advice.