Skip to content

Medium: [ThreePhaseSettler] design_space_check uses top-phase density for the bottom phase #79

Description

@sergey-gusev94

Maintainer triage (June 29, 2026)

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

Severity: Medium · Category: logic (copy-paste) · Part of #67

ThreePhaseSettler.design_space_check uses the top-phase density for the bottom phase

Location: PharmaPy/ThreePhaseSettler.py:137 (consumed at 146, 155, 162-164)

density_bot = self.TopPhase.Liquid_1.getDensity() (137) takes the top phase, while the adjacent viscosity_bot = self.BotPhase.Liquid_1.getViscosity() (136) correctly uses BotPhase (and material_balances uses self.BotPhase.Liquid_1.getDensity() at 178). Since the two liquids are split by density, density_top != density_bot. The wrong value feeds the Bond number (146), impeller Reynolds (155), and just-suspended speed N_js (162-164).

  • Trigger: ThreePhaseSettler.solve_unit (auto-invokes design_space_check at 198) on any settler whose two liquids differ in density — the premise of a three-phase settler.
  • Wrong result: Bond number, impeller Re, critical agitation speed N_cr, and N_js are computed with the wrong (lighter) liquid density, so crit2/crit3 are evaluated against incorrect physics; the unit prints a wrong design-feasibility verdict.
  • Why major: the design-space verdict is the unit's operability guarantee; a systematic density mix-up can both pass infeasible designs and fail feasible ones.
  • Suggested fix: density_bot = self.BotPhase.Liquid_1.getDensity().

Related (not duplicates): no settler/design_space issue exists in the tracker.

Metadata

Metadata

Assignees

Labels

area:settlersThree-phase settler design and checksbugSomething isn't workingcorrectnessModel/numerical correctness defectseverity:mediumConfirmed bug with narrower scope or moderate numerical impactstatus: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