Skip to content

Medium: [Phases] SolidPhase mass-fraction distribution path is unreachable and dimensionally wrong #64

Description

@bernalde

Maintainer triage (June 29, 2026)

  • Status: Verified bug against the current master source in this fork.
  • Severity: Medium.
  • Area labels: area:phases.
  • 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

SolidPhase documents distrib_type='mass_frac', but the implementation checks for 'mass_perc'; even that branch omits density and bin-width terms.

Evidence

  • Docstring says valid options are 'mass_frac' or 'vol_perc' at PharmaPy/Phases.py:836-838.
  • Code checks elif self.distrib_type == 'mass_perc' at PharmaPy/Phases.py:1015-1019.
  • The mass_perc conversion uses self.mass * distrib / x_distrib**3 / self.kv * 1e18, unlike the volume path at PharmaPy/Phases.py:985-987, which accounts for density and self.dx.

Impact

Documented mass-fraction CSD input either leaves distr undefined or produces a number distribution with incorrect units.

Likely fix

Use one documented spelling and convert mass fractions through mass -> solid volume -> bin number density, including density, kv, L^3, and bin width.

Metadata

Metadata

Assignees

Labels

area:phasesPhase, stream, and mixed-phase property handlingbugSomething isn't workingcorrectnessModel/numerical correctness defectrefactor:mpvOverlaps the MultiPhaseVessel refactor; revalidate after mergeseverity:mediumConfirmed bug with narrower scope or moderate numerical impactstatus:verifiedSource-reviewed against the current codebase

Type

No type

Projects

Status
No status

Relationships

None yet

Development

No branches or pull requests

Issue actions