Skip to content

High: [Phases] VaporPhase constructor maps mole_conc into LiquidPhase mass_conc #73

Description

@sergey-gusev94

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.

Metadata

Metadata

Assignees

Labels

area:phasesPhase, stream, and mixed-phase property handlingbugSomething 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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions