Skip to content

Pedersen-faithful gamma delumping with MW basis and conservation modes - #2337

Open
dupuypablo wants to merge 14 commits into
masterfrom
pr-2318
Open

Pedersen-faithful gamma delumping with MW basis and conservation modes#2337
dupuypablo wants to merge 14 commits into
masterfrom
pr-2318

Conversation

@dupuypablo

Copy link
Copy Markdown
Collaborator

Summary

Replaces the arbitrary fixed ±40 % molar-mass window in PseudoComponentCombiner.delumpContributions with a neighbour-aware, Whitson-gamma delumping faithful to Pedersen Chapter 5.

Changes

  • Neighbour-bounded ranges — each lump is delumped only inside its own carbon-number interval, set by the midpoints to its ordered neighbours (Eq. 5.27 inverted, M = 14C − 4); first/last lumps use a one-sided rule. Sub-fractions never cross into a neighbour's range or fabricate mass outside the lump.
  • Whitson gamma molar distribution on the molar-mass axis, fitted by the method of moments (local per-lump NEIGHBOURS or GLOBAL scope), sliced with the regularized incomplete gamma function; exponential Eq. 5.15 fallback when the gamma is degenerate.
  • Non-linear properties — molar mass from Eq. 5.27, normal boiling point from the Katz-Firoozabadi correlation (Eq. 5.28) anchored to the parent Tb, replacing the old Tb ∝ MW linear spread. Density and critical constants inherited from the parent.
  • User-selectable closures — new CharacterizationOptions: DelumpConservation {BOTH, MOLES, MASS} (default BOTH, conserves parent moles and mass to 1e-9), DelumpBinningBasis {MOLAR_MASS, BOILING_POINT} (default MOLAR_MASS), DelumpGammaScope {NEIGHBOURS, GLOBAL} (default NEIGHBOURS).
  • The shared-imaginary equal-mass boundary path reuses the same delumping.

Tests

  • New PseudoComponentDelumpDistributionTest on a synthetic 3-lump fluid asserts: (a) neighbour-bounded ranges, (b) unimodal gamma molar distribution, (c) the Katz-Firoozabadi MW–Tb relation, (d) per-lump mole/mass conservation to 1e-9. Added a package-private delumpForTesting seam.
  • All 397 characterization + PVT regression tests pass; Spotless clean.

Docs

  • Updated docs/pvtsimulation/fluid_characterization_mathematics.md (options table, builder example, and a rewritten delumping subsection).

dupuypablo and others added 11 commits June 19, 2026 21:05
…sen Ch. 5.6 common slate)

Adds a CharacterizationOptions.inheritReferenceProperties flag (default true) so that fluids characterized to a shared reference inherit an identical pseudo-component property slate (MW, Tc, Pc, omega, density, ...) and differ only in mole fractions - the Pedersen et al. Chapter 5.6 'Common EoS' slate. The bare two-arg characterizeToReference stays grid-only (backward compatible). Adds CharacterizeToReferenceCommonSlateTest.
Faithful common-slate characterization that keeps multiple fluids separate
while forcing them to share one mole-fraction weighted pseudo-component set.
Per shared cut: MW (Eq. 5.59), Tc/Pc/omega (Eqs. 5.55-5.58) are weighted means
X_i = sum_j Wgt(j) z_i^j X_i^j / sum_j Wgt(j) z_i^j; density reconstructed from
weighted MW + weighted molar volume (Peneloux basis, Eq. 5.6). Inputs unchanged;
clones returned in input order keeping each fluid's own lump mole fractions.

Distinct from characterizeToReference (snap to one reference, PR #2318) and
combineReservoirFluids (Ch. 5.5 merge into one fluid).

Adds CharacterizeToCommonSlateTest (6 tests).
Splits each coarse source pseudocomponent into N SCN sub-fractions before
distributeToProfiles, conserving parent moles and mass exactly. Sub-fractions
redistribute across reference cuts so per-cut MW and density are recomputed
self-consistently instead of being frozen by atomic PC-to-cut mapping.

Gated by new CharacterizationOptions.delumpBeforeRecharacterization (default
false, preserving today's behaviour). Resolution via delumpResolution
(default 12). Recommended faithful path: delump=true + inheritReferenceProperties=false.
…eToReference

Place reference cut boundaries as carbon-number equal-mass cut points on the
reference's delumped imaginary composition (Pedersen Ch. 5.6, Eqs. 5.58-5.59,
reference-only NFLUID=1) instead of boiling-point midpoints. Each equal-mass cut
is clamped into the gap between adjacent reference pseudo-components so the
one-to-one property-inheritance ordering is preserved even for unequal-mass
references.

Gated by new CharacterizationOptions.sharedImaginaryBoundaries (default false,
reusing delumpResolution as the fine grid). delumpResolution<=1 falls back to
midpoint boundaries. Backward compatible.
… equal-mass boundaries

Document the new PseudoComponentCombiner API surface added in this PR:
characterizeToCommonSlate (Pedersen Ch. 5.6, Eqs. 5.55-5.60 with worked math),
the inheritReferenceProperties / delumpBeforeRecharacterization / delumpResolution
/ sharedImaginaryBoundaries options, and a three-workflow comparison table.
Fixes the stale normalizeComposition default (false, not true) and the incorrect
combineReservoirFluids example signature. Requested by PR reviewer.
Replace the arbitrary fixed +/-40% molar-mass window in
PseudoComponentCombiner.delumpContributions with a neighbour-aware,
Whitson-gamma delumping faithful to Pedersen Chapter 5:

- Bound each lump's sub-fraction range by its neighbours' carbon-number
  midpoints (Eq. 5.27 inverted); first/last lumps use a one-sided rule, so
  sub-fractions never cross into a neighbour's interval or fabricate mass
  outside the lump.
- Shape the mole split with a shifted Whitson gamma fitted by the method of
  moments on the molar-mass axis (local per-lump or global scope), sliced via
  the regularized incomplete gamma function; exponential Eq. 5.15 fallback.
- Assign molar mass via Eq. 5.27 and normal boiling point via the non-linear
  Katz-Firoozabadi correlation (Eq. 5.28), anchored to the parent Tb, instead
  of a linear Tb-proportional-to-MW spread.
- Add user-selectable conservation (DelumpConservation BOTH/MOLES/MASS) and
  binning basis (DelumpBinningBasis MOLAR_MASS/BOILING_POINT) and gamma scope
  (DelumpGammaScope NEIGHBOURS/GLOBAL) options; BOTH conserves parent moles
  and mass to 1e-9.
- The shared-imaginary equal-mass boundary path reuses the same delumping.

Add PseudoComponentDelumpDistributionTest (synthetic 3-lump fluid) asserting
neighbour-bounded ranges, unimodal gamma molar distribution, the
Katz-Firoozabadi MW-Tb relation, and per-lump mole/mass conservation, plus a
package-private delumpForTesting seam. Update the characterization mathematics
docs to describe the gamma/MW/conservation scheme.
@dupuypablo
dupuypablo requested a review from EvenSol as a code owner June 22, 2026 11:32
# Conflicts:
#	CHANGELOG_AGENT_NOTES.md
#	docs/pvtsimulation/fluid_characterization_mathematics.md
#	src/main/java/neqsim/thermo/characterization/CharacterizationOptions.java
#	src/main/java/neqsim/thermo/characterization/PseudoComponentCombiner.java
#	src/test/java/neqsim/thermo/characterization/CharacterizeToCommonSlateTest.java
@dupuypablo dupuypablo closed this Jun 22, 2026
@dupuypablo dupuypablo reopened this Jun 22, 2026
… characterization

Adds an opt-in ReferenceBoundaryMode.CENTROID_SPAN to CharacterizationOptions so
each reference cut key becomes the centroid of its own span (recurrence
b_i = 2*key_i - b_(i-1), anchored at b_0 = key_0 - 0.5*(key_1 - key_0), walked
light->heavy, each boundary clamped strictly between adjacent keys with midpoint
fallback). Linear in molar mass, so only active on the MOLAR_MASS basis;
boiling-point falls back to midpoint. Default stays MIDPOINT (no behaviour
change). Includes JUnit test, docs, and changelog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants