Skip to content

Medium: [ThermoModule] Vectorized getKeqVLE applies Henry constants to all temperature rows #62

Description

@bernalde

Maintainer triage (June 29, 2026)

  • Status: Verified bug against the current master source in this fork.
  • Severity: Medium.
  • Area labels: area:thermo.
  • Tackle batch: P5 - medium-scope correctness defects.

The source review confirmed that the cited code path and failure mode are still present. The original audit details are preserved below for reproduction notes and suggested fixes.


Original audit details

Finding

The vectorized temperature branch of getKeqVLE replaces vapor pressures with Henry constants using a column mask built from each row, but assigns across all rows.

Evidence

  • ThermoPhysicalManager.getKeqVLE vector branch builds supercrit at PharmaPy/ThermoModule.py:541-547.
  • The loop for row in supercrit: p_vap[:, row] = self.henry_constant[row] applies each row mask to every temperature row.

Impact

If any time/temperature row is supercritical for a component, that component can be treated with Henry constants in rows where it is not supercritical, corrupting vectorized VLE profiles.

Likely fix

Assign elementwise with p_vap[supercrit] = ... using a broadcasted Henry-constant array, or loop over row indices and assign only that row.

Metadata

Metadata

Assignees

Labels

area:thermoThermodynamics, VLE, enthalpy, Cp, density, and viscositybugSomething isn't workingcorrectnessModel/numerical correctness defectseverity:mediumConfirmed bug with narrower scope or moderate numerical impactstatus:verifiedSource-reviewed against the current codebase

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions