ethanol-rs · v0.1

Pharmacokinetic BAC
in your browser.

A small Rust crate for modelling blood alcohol concentration. It knows Widmark and Watson, first-order absorption, how to tell two drinking sessions apart, and when you’re sober again. Every chart on this page is the crate itself, compiled to WebAssembly and running locally in your tab.

A tour of the features

Every chart below is one library call drawn onto a canvas. Nothing fancy.

Widmark vs Watson

Same drinks, same profile, two different formulas. Widmark is the classic one (body weight and a sex-based constant). Watson tries to estimate total body water from weight, height and age. For most people they agree closely; at the extremes they start to bicker.

Widmark
Watson

Drink duration flattens the peak

duration_secs treats a drink as a constant-rate infusion. Shot it and you get a tall spike. Sip the same thing over an hour and the peak drops by 30–40%, with a longer tail to match.

shot (0s)
500ml @ 5%
duration30 min

Session detection

If the BAC from an earlier drinking bout has fully metabolised before your next drink, the crate calls that a new session and restarts the clock. No ghost alcohol carried over from brunch. Query the current BAC and you only see the session you're actually in.

Body weight sensitivity

The same three drinks, served to a 55, 75 and 95 kg drinker. Less body water means a bigger dose per kilo, so the lightest curve peaks around 1.7× as high as the heaviest one. Physics doesn't play favourites.

55 kg
75 kg
95 kg

Biological sex

Watson gives women a lower total body water fraction for the same weight, so the same dose of ethanol concentrates more. At identical weight, height and age a woman's BAC peaks noticeably higher than a man's.

♂ male 75 kg
♀ female 75 kg

Stomach state

Food slows gastric emptying, and with it absorption. The crate buckets this into three states (empty, some_food, full). More food in the stomach, lower and later peak. Mum was right about eating before going out.

empty
some food
full

Time to sober

Given your current drinks, the crate finds the minute at which BAC returns to zero. It accounts for drinks still being absorbed, so it's more honest than just current BAC divided by the metabolism rate.

current BAC

0.000

sober in

already sober

beers3

Now try it yourself

Everything from the tour above, stitched together in one sandbox. Add drinks, scrub through time, flip between male and female, drag the pace slider around. Same WASM crate as the charts, no server talking back.

Current BAC

0.00

Sober

Sober in

0:00:00
85 kg · 178 cm · 35 yrloading…

Plan your evening

Drop drinks onto the timeline, drag to adjust timing, and see the full projected BAC curve before your first sip.

Peak BAC

0.00

Sober in

Disclaimer

For educational and research purposes only.

This library provides estimates based on population-average pharmacokinetic models. Individual responses to alcohol vary significantly due to genetic polymorphisms in ADH/ALDH, liver health, chronic tolerance, medication interactions, and hydration status.

Do not use to determine fitness to drive, operate machinery, or make any safety-critical decision. BAC estimates are not a substitute for breathalyser or blood testing, clinical judgement, or following local laws regarding alcohol consumption.

When in doubt, don’t drive.