Skip to content

Vle fix - #101

Merged
yoelcortes merged 3 commits into
masterfrom
vle-fix
Sep 15, 2026
Merged

yoelcortes merged 3 commits into
masterfrom
vle-fix

Conversation

@yalinli2

Copy link
Copy Markdown
Member

Main things:

  1. Checks if the chemical has Tc/Pc first, prior to comparison.
  2. The P loop re-iterates the same index list the T-branch already consumed, without excluding indices it removed. A chemical above both Tc and Pc gets nonzero.remove(i) called twice, raising KeyError on the second call.
  3. There was a typo, the first HNK_index should LNK_index.
  4. chemicals._heavy_solutes is a fixed-size array computed once for the compile-time heavy chemicals, but HNK_index can grow at runtime with newly-excluded supercritical chemicals, so multiplying heavy_mol (sized to the grown HNK_index) by the unextended _heavy_solutes array raises a shape-mismatch ValueError.

Reproduction

import thermosteam as tmo

chemicals = tmo.Chemicals(['H2O', 'CH4'])
tmo.settings.set_thermo(chemicals)
s = tmo.Stream('s', H2O=10, CH4=5, units='kg/hr', phase='g')
s.vle(T=675.15, P=1.05e7)  # CH4 is above both Tc (~190.6 K) and Pc (~4.6 MPa)
# KeyError: 1

@yoelcortes yoelcortes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@yoelcortes
yoelcortes merged commit f927352 into master Sep 15, 2026
1 of 2 checks passed
@yalinli2
yalinli2 deleted the vle-fix branch September 15, 2026 13:38
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