Skip to content

Fix carbonation equation, add tests and metric/imperial unit switch - #25

Merged
kasperg3 merged 1 commit into
mainfrom
claude/add-carbonation-calculator-RjUjD
Apr 13, 2026
Merged

Fix carbonation equation, add tests and metric/imperial unit switch#25
kasperg3 merged 1 commit into
mainfrom
claude/add-carbonation-calculator-RjUjD

Conversation

@kasperg3

Copy link
Copy Markdown
Owner

No description provided.

The original Vail/Glass equation constants were wrong and produced
negative equilibrium pressures for typical targets (e.g. -0.34 bar for
2.5 vol at 4 C, when the correct answer is ~0.76 bar / 11 psi).

Replaces the formula with a metric polynomial derived from the standard
ASBC / Zahm & Nagel carbonation equation. Values now match published
brewing carbonation charts to within ~0.5 psi across 0-20 C and 1-5 vol.

Adds 34 unit tests covering: rule-of-thumb brewing chart values,
altitude correction, quadratic inverse round-trip, exponential
absorption model edge cases, shaking method, and vessel presets.

Also adds a metric/imperial SegmentedControl in the header. Internal
state stays metric; display values, slider ranges and input conversion
switch at the UI boundary so the math is unaffected.
@kasperg3
kasperg3 merged commit fa42867 into main Apr 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants