Skip to content

Incremental improvements: refactors, edge cases, robustness#1

Open
defnalk wants to merge 5 commits intomainfrom
review/incremental-improvements
Open

Incremental improvements: refactors, edge cases, robustness#1
defnalk wants to merge 5 commits intomainfrom
review/incremental-improvements

Conversation

@defnalk
Copy link
Copy Markdown
Owner

@defnalk defnalk commented Apr 9, 2026

Five small, atomic, incremental improvements found during a focused review pass. No methodology changes, no renames, no reformatting.

Commits

  • refactor(co2_capture): drop dead duplicate LRHX duty computation
  • fix(distillation): guard first-row zero pivot in Thomas solver
  • fix(shortcut): guard Gilliland correlation against non-positive x_g
  • fix(thermo): raise when bubble/dew bracketing fails
  • fix(asu): bound successive-substitution step in boiling-temp solver

Test plan

  • pytest -x -q passes after every commit (126 tests, ~0.5s)

Generated with Claude Code.

defnalk and others added 5 commits April 9, 2026 20:56
The first lrhx_duty_kw assignment was immediately overwritten by a
second, mathematically equivalent expression on the next line, making
it unreachable. Keep the single expression and note its units in a
comment so future readers don't rediscover the same redundancy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The rigorous MESH solver's Thomas forward sweep divided by b_diag[0]
without a guard, mirroring the protection applied to every subsequent
row. On a degenerate first stage (e.g. l_rect and v*K both near zero
during a cold start) this produced inf/NaN that silently corrupted
the entire composition profile and masked non-convergence as success.
Apply the same small-denominator guard used at j>=1 to the j=0 step.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Molokanov fit to the Gilliland curve contains x_g**0.5 in a
denominator and blows up as x_g -> 0 (r -> r_min) or goes complex
for x_g < 0, which is reachable when r_min is negative for near-
ideal splits. Likewise (1 - y_g) in the stage-count inversion can
reach zero at the tail of the correlation. Clamp both quantities
to tiny positive values so the shortcut column keeps returning a
finite, monotone N without silently corrupting the design.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bubble_point_temperature and dew_point_temperature expanded their
initial bracket up to 30 times and then fell through to bisection
unconditionally. If the expansion still failed to produce a sign
change (e.g. operating pressure above every component's critical
pressure, or an Antoine extrapolation that can't reach P_op inside
[150, 700] K), bisection would silently return one of the original
bracket endpoints as if it were a converged root, poisoning every
downstream calculation. Detect the same-sign case explicitly and
raise a RuntimeError that names the offending interval and pressure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
_boiling_temp_at_pressure multiplied T by ratio**0.15 on every
iteration with no bound on the step. For inputs where the initial
Antoine evaluation sits far from the target (off-database components
defaulting to 90 K, or pressures well outside the fitted range) the
ratio can be tiny or huge, pushing T towards zero - where
antoine_pressure raises - or off to thousands of kelvin before the
iteration has a chance to converge. Clamp the multiplicative step to
[0.5, 2.0] and keep T strictly positive so the solver either converges
or at least returns a physically meaningful temperature. Also reject
non-positive pressures at the entry point.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant