Incremental improvements: refactors, edge cases, robustness#1
Open
Incremental improvements: refactors, edge cases, robustness#1
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Five small, atomic, incremental improvements found during a focused review pass. No methodology changes, no renames, no reformatting.
Commits
Test plan
Generated with Claude Code.