Productivity Simulator

Productivity Simulator

A personal experiment: predicted productivity from 0 to 1, as the product of a two-hour rhythm, daylight, active caffeine and the people around me. Adjust anything and watch the curve move.

What is this?

A small personal experiment: a mathematical guess at how productive I am at a given moment, built from four things I suspect matter: the time of day, how much daylight there is, how much caffeine is active in my body, and how many people are around me. Each factor is a multiplier between 0 and 1, and the prediction is their product, so the score is always between 0 (nothing gets done) and 1 (best case).

The score is not scientifically validated and is not medical advice. Only the caffeine absorption and elimination part rests on established pharmacology; the rest are hypotheses with knobs, meant to be tuned against my own logged productivity later.

The model

P(t,n)=T(t)⋅S(t)⋅C(A(t))⋅R(n)=T(t)⋅11+αD(t)⋅C(A(t))⋅[1−λH(n)]P(t,n) = T(t)\cdot S(t)\cdot C\big(A(t)\big)\cdot R(n) = T(t)\cdot\frac{1}{1+\alpha D(t)}\cdot C\big(A(t)\big)\cdot\big[1-\lambda H(n)\big]

Every curve on the chart is computed on the fly from these functions (every two minutes across the day, plus exact points at sunrise, sunset and each caffeine event). Nothing is precomputed.

1. Time of day: a two-hour rhythm

Productivity oscillates, peaking every two hours, with one peak aligned to 22:00 by default. A cosine keeps it smooth and continuous across midnight.

T(t)=m+1−m2(1+cos⁡2π(t−τ)p)T(t) = m + \frac{1-m}{2}\left(1+\cos\frac{2\pi(t-\tau)}{p}\right)

With p=2p=2, m=0.2m=0.2, τ=22\tau=22 this is 0.2+0.4 (1+cos⁡π(t−22))0.2+0.4\,(1+\cos\pi(t-22)): maximum 1 on the even hours, minimum 0.2 on the odd hours.

2. Daylight

The hypothesis is that bright daylight makes me less productive. Daylight is modeled as a smooth arch between sunrise and sunset, zero at night and highest halfway between them:

D(t)={sin⁡γ ⁣(π t−rs−r),r≤t≤s0,otherwiseS(t)=11+αD(t)D(t)=\begin{cases}\sin^{\gamma}\!\left(\pi\,\dfrac{t-r}{s-r}\right), & r\le t\le s\\[6pt] 0, & \text{otherwise}\end{cases}\qquad S(t)=\frac{1}{1+\alpha D(t)}

This is an approximation, not a solar irradiance calculation. Sunrise and sunset can be typed in or calculated for a date and location with SunCalc, which uses standard solar-position astronomy similar to NOAA's solar calculator equations.

3. Caffeine

Caffeine is handled in two steps: how much is active in the body over time (pharmacokinetics), and how that amount maps to productivity (a hypothesis).

How much is active

Caffeine is absorbed quickly and almost completely from the gut and eliminated with first-order kinetics, so a one-compartment model with first-order absorption and elimination is a common simplification. For a dose did_i taken at tit_i, with Δti=t−ti\Delta t_i = t-t_i:

Ai(t)=F di kaka−ke(e−keΔti−e−kaΔti),ke=ln⁡2h,A(t)=∑iAi(t)A_i(t) = F\,d_i\,\frac{k_a}{k_a-k_e}\left(e^{-k_e\Delta t_i}-e^{-k_a\Delta t_i}\right),\qquad k_e=\frac{\ln 2}{h},\qquad A(t)=\sum_i A_i(t)

Doses before tit_i contribute nothing, every earlier dose adds independently, and doses from previous days carry over midnight because the calculation uses absolute timestamps. A single dose peaks at

tpeak=ln⁡(ka/ke)ka−ke≈52 min(ka=4 h−1, h=5 h)t_{\text{peak}}=\frac{\ln(k_a/k_e)}{k_a-k_e}\approx 52\ \text{min}\quad(k_a=4\ \text{h}^{-1},\ h=5\ \text{h})

This is in line with peak plasma levels commonly reported within roughly 30–120 minutes of drinking caffeine. The half-life varies a lot between people (smoking shortens it; oral contraceptives lengthen it), which is why it is adjustable. When kak_a and kek_e are nearly equal the formula above becomes numerically unstable, so the simulator switches to its exact limit, Ai=Fdi k Δti e−kΔtiA_i = F d_i\,k\,\Delta t_i\,e^{-k\Delta t_i}.

A(t)A(t) is an estimated amount in the body in mg, not a measured blood concentration in mg/L.

How it maps to productivity (hypothesis)

C(A)={1−b(1−AA⋆)2,0≤A≤A⋆1−c(1−e−(A−A⋆w)2),A>A⋆C(A)=\begin{cases}1-b\left(1-\dfrac{A}{A_\star}\right)^{2}, & 0\le A\le A_\star\\[8pt] 1-c\left(1-e^{-\left(\frac{A-A_\star}{w}\right)^{2}}\right), & A>A_\star\end{cases}

With no caffeine the multiplier is 0.6; it rises to 1 at the hypothetical optimum A⋆=400A_\star = 400 mg of active caffeine, then slowly declines toward 0.9.

The 400 mg optimum is my modeling assumption, not an established optimal level and not a recommendation. The FDA's commonly cited 400 mg figure is about total daily intake for most adults, not an amount to have active in your body. Don't use this page to decide how much caffeine to consume.

4. People nearby

I'm most productive alone. One other person causes the biggest single drop (sudden self-consciousness). Each extra person adds less, up to a maximum around 20 people. Beyond that, a crowd makes me feel less individually watched, so productivity recovers a little, but never back to being alone.

H(n)={ln⁡(1+an)ln⁡(1+aN),0≤n≤N1−ρ(1−e−(n−N)/δ),n>NR(n)=1−λH(n)H(n)=\begin{cases}\dfrac{\ln(1+a n)}{\ln(1+a N)}, & 0\le n\le N\\[10pt] 1-\rho\left(1-e^{-(n-N)/\delta}\right), & n>N\end{cases}\qquad R(n)=1-\lambda H(n)

HH is the social-awareness penalty (0 alone, 1 at its peak); RR is the productivity multiplier. The curve is continuous at NN, with a corner there. With the defaults (a=8, N=20a=8,\ N=20, so the denominator is ln⁡161\ln 161):

PeopleR(n)
01.000
10.849
50.744
200.650
1000.729

What's established and what's a guess

  • Established (simplified): caffeine absorption and elimination as a one-compartment, first-order process. Real people vary, and the model ignores body weight, volume of distribution and metabolites.
  • Hypotheses: the two-hour rhythm, the daylight penalty, the caffeine-to-productivity response and the social-awareness curve. These are my assumptions, chosen to be tested against self-recorded productivity, not findings from the literature.
All parameters and defaults
SymbolMeaningDefault
ttLocal time of day, decimal hours (0–24)—
nnPeople nearby0
ppRhythm period2 h
τ\tauRhythm phase (time of a peak)22:00
mmMinimum rhythm multiplier0.2
r, sr,\ sSunrise, sunset07:00, 19:00
γ\gammaDaylight curve exponent1
α\alphaSunlight sensitivity2
di, tid_i,\ t_iDose (mg) and time of caffeine event i—
FFBioavailability1
kak_aAbsorption rate constant4 h⁻¹
hhElimination half-life5 h
kek_eElimination rate constant, ln 2 / h≈ 0.139 h⁻¹
A⋆A_\starHypothetical caffeine-response optimum400 mg
b, cb,\ cBelow- and above-optimum response strengths0.4, 0.1
wwAbove-optimum decline width200 mg
λ\lambdaMaximum social productivity penalty0.35
NNCrowd size at maximum self-consciousness20
aaInitial sensitivity to the first few people8
ρ\rhoCrowd recovery strength0.25
δ\deltaCrowd recovery decay (people)35

References

  1. U.S. Food and Drug Administration. Spilling the Beans: How Much Caffeine Is Too Much? (400 mg/day cited for most adults, as total daily intake.)
  2. Institute of Medicine (2001). Pharmacology of Caffeine. In Caffeine for the Sustainment of Mental Task Performance: Formulations for Military Operations. National Academies Press.
  3. Grzegorzewski J, Bartsch F, Köller A, König M (2022). Pharmacokinetics of Caffeine: A Systematic Analysis of Reported Data for Application in Metabolic Phenotyping and Liver Function Testing. Frontiers in Pharmacology 12.
  4. NOAA Global Monitoring Laboratory. General Solar Position Calculations.
  5. Agafonkin V. SunCalc, a JavaScript library for sun position and sunlight phases.