Skip to content

Name the ice vapor-pressure coefficients and reuse Vapor_pressure - #40

Merged
Ickaser merged 1 commit into
LyoHUB:mainfrom
SECQUOIA:upstream-fix/vapor-pressure-constants
Aug 6, 2026
Merged

Name the ice vapor-pressure coefficients and reuse Vapor_pressure#40
Ickaser merged 1 commit into
LyoHUB:mainfrom
SECQUOIA:upstream-fix/vapor-pressure-constants

Conversation

@bernalde

@bernalde bernalde commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Closes #39. Refs #12.

The two coefficients of the ice vapor-pressure correlation appeared as bare literals in three places in lyopronto/functions.pyVapor_pressure, the inverted form in Tbot_max_eq_cap, and an inline re-derivation in Eq_Constraints. This names them once, with their units, and has Eq_Constraints call Vapor_pressure rather than duplicating the formula.

VAPOR_PRESSURE_PREEXPONENTIAL = 2.698e10
VAPOR_PRESSURE_TEMPERATURE_COEFFICIENT = 6144.96

No behavior change. The C1 rewrite is bitwise identical across the primary drying range:

>>> Tsub = np.linspace(-45.0, 5.0, 2001)
>>> old = 2.698e10*np.exp(-6144.96/(273.15+Tsub))
>>> np.array_equal(old, Vapor_pressure(Tsub))
True

The numeric values are untouched — this is a naming and de-duplication change only, so the correlation itself is unchanged and no fit or reference value moves.

Tests

pytest tests/ on this branch: 144 passed, 1 skipped (608 s), coverage 99%.

Branched from 4fb63df. Independent of #38, which touches a different module. Found while syncing SECQUOIA/LyoPRONTO, which carries the same change.

The two coefficients of the ice vapor-pressure correlation appeared as bare
literals in three places: Vapor_pressure, the inverted form in
Tbot_max_eq_cap, and an inline re-derivation in Eq_Constraints. A correction to
either coefficient had to be found in all three, and the inverted form is easy
to miss because the numbers appear rearranged.

Name them as module constants with their units, use them in both the forward
and inverted forms, and have Eq_Constraints call Vapor_pressure instead of
re-deriving it. The C1 rewrite is bitwise identical over the primary drying
range (max abs diff 0.0 across -45 to 5 degC).

Refs #12. Full test suite: 144 passed, 1 skipped.
@Ickaser

Ickaser commented Aug 6, 2026

Copy link
Copy Markdown
Member

I don't love the verbosity of the names but they are clear enough; there are enough other style problems in the repo that I think this is acceptable as is.

@Ickaser
Ickaser merged commit 7189858 into LyoHUB:main Aug 6, 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.

Ice vapor-pressure coefficients duplicated as bare literals in three places

2 participants