Skip to content

Return a POH from PH.ToPOH instead of a pOH dressed as a pH [major] - #496

Open
matt-edmondson wants to merge 1 commit into
mainfrom
claude/482-poh-scale
Open

matt-edmondson wants to merge 1 commit into
mainfrom
claude/482-poh-scale

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #482

PH<T>.ToPOH() stored 14 − pH in a PH<T>, so every pH member misread it. The pOH of an acid reported IsBasic == true, printed as pH 11, and ToHydrogenConcentration() returned the hydroxide concentration.

This takes the issue's second option, which the triage comment preferred because it fits the generated logarithmic-scale pattern:

  • A new POH<T> entry in logarithmic.json. It is generated like PH<T>, with FromHydroxideConcentration and ToHydroxideConcentration, and prints as pOH {0}.
  • Chemistry/POH.cs adds ToPH(), which gives 14 − pOH at 25 °C.
  • PH<T>.ToPOH() now returns POH<T>. POH<T> has no IsAcidic, IsBasic or pH formatting.
  • The generated output and the four storage-type alias props are regenerated, so verify-generated sees no diff.
  • docs/migration-guide-6.0.md covers the breaking return type, and CLAUDE.md adds POH to its list of logarithmic scales.

Tests

  • POH_Of_An_Acid_Is_A_POH_And_Converts_Back: the pOH of PH.Create(3) is 11, prints as pOH …, gives [OH⁻] = 1e-11 mol/L, and converts back to an acidic pH 3.
  • POH_From_Hydroxide_Concentration_And_Back: round-trips through the hydroxide concentration.
  • With PH.cs reverted to main, the new test does not compile (CS0029: Cannot implicitly convert type 'PH<double>' to 'POH<double>'). With the fix it passes.
  • Results on net10.0 locally:
    • Semantics.Test: 1946 passed, 0 failed, 14 skipped.
    • Semantics.Cpp.Test: 45 passed. The one remaining error is a missing older .NET runtime in this container.

Open PR #493 is also [major]. If both merge for the same release, its notes belong in the same migration-guide-6.0.md.


Generated by Claude Code

ToPOH() put 14 - pH into a PH<T>, so every pH member misread it: the pOH
of an acid reported IsBasic, printed as "pH 11", and its
ToHydrogenConcentration() returned the hydroxide concentration.

Add a POH<T> scale to logarithmic.json, generated like PH<T> with
FromHydroxideConcentration/ToHydroxideConcentration, plus a ToPH()
partial. ToPOH() now returns it, which is a breaking return-type change,
so docs/migration-guide-6.0.md describes the move.

Fixes #482.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3DYWS7PHxcghEBi3T
@sonarqubecloud

Copy link
Copy Markdown

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.

PH.ToPOH() returns a PH<T>, so the pOH of an acid reports IsBasic == true and prints as "pH 11"

2 participants