Maintainer triage (June 29, 2026)
- Status: Verified bug against the current
master source in this fork.
- Severity: High.
- Area labels: area:phases.
- Tackle batch: P2 - shared thermo, phase, and basis correctness.
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
Severity: High · Category: API misuse / units-basis · Part of #67
VaporPhase.__init__ passes mole_conc into LiquidPhase's mass_conc positional slot
Location: PharmaPy/Phases.py:515-517
VaporPhase.__init__ builds composition via
LiquidPhase(path_thermo, temp, pres, mass, vol, moles, mass_frac, mole_frac, mole_conc, ...).
The 9th positional parameter of LiquidPhase.__init__ is mass_conc (signature at Phases.py:98-102), so the vapor's mole_conc value binds to mass_conc. LiquidPhase then runs the mass-conc branch (mass_conc_to_frac), interpreting mol/L as kg/m³. VaporStream forwards the same parameter.
- Trigger:
VaporStream(path, mole_conc=[...], mass_flow=...) or VaporPhase(path, mole_conc=[...]).
- Wrong result: composition (
mass_frac/mole_frac/concentrations) and derived mw_av, moles, vol are computed from the wrong concentration basis (mol/L treated as kg/m³), silently corrupting every downstream amount/composition for that vapor phase. No error raised.
- Why major: silent wrong-basis composition feeds all subsequent mass/mole/energy balances for the vapor phase.
- Suggested fix: pass by keyword —
LiquidPhase(..., mole_frac=mole_frac, mole_conc=mole_conc, ...).
Related (not duplicates): #45 (VaporPhase.getDensity units), #18 (VaporPhase.getEnthalpy mole-vs-mass weighting), #58 (Distillation passes mole_frac as mole_conc) are different sites; this is the __init__ positional binding.
Maintainer triage (June 29, 2026)
mastersource in this fork.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
Severity: High · Category: API misuse / units-basis · Part of #67
VaporPhase.__init__passesmole_concinto LiquidPhase'smass_concpositional slotLocation:
PharmaPy/Phases.py:515-517VaporPhase.__init__builds composition viaLiquidPhase(path_thermo, temp, pres, mass, vol, moles, mass_frac, mole_frac, mole_conc, ...).The 9th positional parameter of
LiquidPhase.__init__ismass_conc(signature atPhases.py:98-102), so the vapor'smole_concvalue binds tomass_conc.LiquidPhasethen runs the mass-conc branch (mass_conc_to_frac), interpreting mol/L as kg/m³.VaporStreamforwards the same parameter.VaporStream(path, mole_conc=[...], mass_flow=...)orVaporPhase(path, mole_conc=[...]).mass_frac/mole_frac/concentrations) and derivedmw_av, moles, vol are computed from the wrong concentration basis (mol/L treated as kg/m³), silently corrupting every downstream amount/composition for that vapor phase. No error raised.LiquidPhase(..., mole_frac=mole_frac, mole_conc=mole_conc, ...).Related (not duplicates): #45 (
VaporPhase.getDensityunits), #18 (VaporPhase.getEnthalpymole-vs-mass weighting), #58 (Distillation passes mole_frac as mole_conc) are different sites; this is the__init__positional binding.