Skip to content

High: [Phases] Multi-temperature VaporPhase mass-basis latent heat drops component columns #101

Description

@andres9403

Maintainer triage (July 7, 2026)

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


Original audit details

Severity: High · Category: shape/basis mismatch · Found during PR #100 review

Multi-temperature mass-basis latent heat drops supercritical component columns before mixture weighting

Location: PharmaPy/Phases.py:651-655 (VaporPhase.getHeatVaporization, mass-basis multi-temperature branch) and PharmaPy/Phases.py:732-733 (VaporPhase.getEnthalpy mixture weighting)

When getHeatVaporization receives multiple temperatures, it builds a full (num_temp, num_comp) deltahvap array and fills only the subcritical component columns. In the basis='mass' branch, it then reassigns deltahvap = deltahvap[:, idx] / self.mw[idx] * 1000, shrinking the second dimension from all components to only the subcritical component subset.

VaporPhase.getEnthalpy(..., basis='mass') subsequently computes np.dot(deltaVap, mass_frac). When any component is supercritical across the requested temperatures, deltaVap no longer has the same component dimension as mass_frac, so the mixture enthalpy calculation raises a shape mismatch.

Minimal reproduction on PR #100 head:

temps = np.array([660.0, 680.0])
phase.getHeatVaporization(temps, basis="mass").shape  # (2, 1)
phase.getHeatVaporization(temps, basis="mole").shape  # (2, 2)
phase.getEnthalpy(temp=temps, basis="mass")

Observed error:

ValueError: shapes (2,1) and (2,) not aligned: 1 (dim 1) != 2 (dim 0)

Related existing issues (referenced, not modified): #18 (VaporPhase.getEnthalpy mass-basis latent heat weights by mole fraction) -- related but distinct; #18 does not cover the multi-temperature latent-heat array shape reduction.


Found during PR #100 review; confirmed by source review and a local reproducer.

Metadata

Metadata

Assignees

Labels

area:phasesPhase, stream, and mixed-phase property handlingarea:thermoThermodynamics, VLE, enthalpy, Cp, density, and viscositybugSomething isn't workingcorrectnessModel/numerical correctness defectseverity:highConfirmed bug with major correctness impact or broken documented workflowstatus:verifiedSource-reviewed against the current codebase

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions