You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tackle batch: P2 - shared thermo, phase, and basis correctness.
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
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.
Trigger: A multi-component VaporPhase with array-like temp, basis='mass', and at least one component above its critical temperature while another remains subcritical.
Wrong result:getHeatVaporization(temp_array, basis='mass') returns a reduced latent-heat array such as shape (2, 1) for a two-component phase, while getEnthalpy(temp=temp_array, basis='mass') dots that against a full length-2 mass-fraction vector and raises ValueError: shapes (2,1) and (2,) not aligned.
Suggested fix: Preserve the full component dimension in the mass-basis multi-temperature branch, converting only the populated subcritical columns to J/kg and leaving supercritical component columns at zero latent heat.
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.
Maintainer triage (July 7, 2026)
56c68351166867a09d3cdae8eb11cf029303c61f); adjacent code path is pre-existing and not introduced by PR Fix VaporPhase mass-basis latent heat weighting #100.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)andPharmaPy/Phases.py:732-733 (VaporPhase.getEnthalpy mixture weighting)When
getHeatVaporizationreceives multiple temperatures, it builds a full(num_temp, num_comp)deltahvaparray and fills only the subcritical component columns. In thebasis='mass'branch, it then reassignsdeltahvap = deltahvap[:, idx] / self.mw[idx] * 1000, shrinking the second dimension from all components to only the subcritical component subset.VaporPhase.getEnthalpy(..., basis='mass')subsequently computesnp.dot(deltaVap, mass_frac). When any component is supercritical across the requested temperatures,deltaVapno longer has the same component dimension asmass_frac, so the mixture enthalpy calculation raises a shape mismatch.VaporPhasewith array-liketemp,basis='mass', and at least one component above its critical temperature while another remains subcritical.getHeatVaporization(temp_array, basis='mass')returns a reduced latent-heat array such as shape(2, 1)for a two-component phase, whilegetEnthalpy(temp=temp_array, basis='mass')dots that against a full length-2 mass-fraction vector and raisesValueError: shapes (2,1) and (2,) not aligned.VaporPhasemass-basis latent heat, but Critical: [Phases] VaporPhase mass-basis enthalpy weights latent heat by mole fraction #18 is the single-temperature mixture-weighting bug fixed by PR Fix VaporPhase mass-basis latent heat weighting #100. This issue is a separate multi-temperature shape mismatch ingetHeatVaporization.Minimal reproduction on PR #100 head:
Observed error:
Related existing issues (referenced, not modified): #18 (
VaporPhase.getEnthalpymass-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.