# Tank State

**Night Lab 021** — The invisible chemistry of aquarium water

Your ammonia reading looks fine. Your pH looks fine. Your temperature looks fine. But the *combination* might be killing your fish.

## What it does

Standard aquarium test kits measure total ammonia nitrogen (TAN) — the sum of toxic free ammonia (NH₃) and harmless ammonium (NH₄⁺). The ratio between these two forms follows a chemical equilibrium that shifts with pH and temperature. At pH 7.0 and 25°C, less than 1% of measured ammonia is in toxic form. At pH 8.5 and 30°C, over 15% is toxic.

Tank State maps this invisible interaction as a 2D state space — pH on one axis, temperature on the other, with free ammonia toxicity rendered as a color field. You place your readings on the map and see where you sit relative to the safe, cautionary, and dangerous zones.

The key insight: the danger threshold isn't a straight line on any single parameter. It's a curve through the combined space.

## How to use it

1. Enter your Total Ammonia Nitrogen (TAN) reading from your test kit
2. Set your pH and temperature (or click directly on the map)
3. See your position in the toxicity landscape
4. Try the presets to see how common setups compare

## Presets

- **Community** — pH 7.2, 25°C, TAN 0.25 — typical freshwater, low risk
- **Cichlid** — pH 8.2, 27°C, TAN 0.5 — high pH turns moderate ammonia 17x more toxic
- **Summer** — pH 7.5, 30°C, TAN 0.5 — heat amplifies danger invisibly
- **Cycling** — pH 7.0, 24°C, TAN 2.0 — ammonia spike during cycling

## Science

Based on the Emerson et al. (1975) dissociation constant for ammonia in water:

```
pKa = 0.09018 + 2729.92 / (T + 273.15)
fraction_NH3 = 1 / (1 + 10^(pKa - pH))
free_NH3 = TAN x fraction_NH3
```

Thresholds: < 0.02 mg/L safe, 0.02-0.05 mg/L caution, > 0.05 mg/L danger.

## Stack

React + Vite + Tailwind CSS v4. Canvas-rendered heat map with analytical contour lines.
