Skip to content

Support UMR-CPA in SystemThermo.setModel and fail fast for unknown models #3119

Description

@EvenSol

Problem

SystemUMRCPAEoS is a public thermodynamic system, but the generic model-switch API does not support it.

Verified against equinor/neqsim master commit 44f705a903590749b9d150b865dd53a46d1d78a5.

Current behavior is internally inconsistent:

  • SystemUMRCPAEoS#getModelName() returns "UMR-CPA".
  • PhaseUMRCPA uses "UMR-CPA-EoS".
  • SystemThermo.autoSelectMixingRule() recognizes "UMR-CPA".
  • SystemThermo.setModel(...) recognizes UMR-PRU but neither "UMR-CPA" nor "UMR-CPA-EoS".

For an unknown name, setModel leaves tempModel == null, dereferences it inside the try, catches the resulting exception, logs it, and returns null. Notebook code that ignores the return value can therefore appear to have switched model while actually continuing with the original system.

Public reproducer

SystemInterface source = new SystemSrkEos(298.15, 70.0);
source.addComponent("methane", 0.99);
source.addTBPfraction2("C10", 0.01, 0.136, 447.15); // boiling point in K

SystemInterface converted = source.setModel("UMR-CPA");
// Observed on current master: converted == null

SystemInterface convertedAlias = source.setModel("UMR-CPA-EoS");
// Observed on current master: convertedAlias == null

The direct constructor works:

SystemInterface direct = new SystemUMRCPAEoS(298.15, 70.0);

Expected behavior

  • Supported UMR-CPA names return a non-null SystemUMRCPAEoS.
  • Unsupported names fail explicitly instead of returning null after a swallowed internal exception.
  • Temperature, pressure, component inventory, ordinary/TBP/plus-fraction metadata, relevant phase options, and the required HV/UNIFAC_UMRPRU mixing rule are preserved or deterministically initialized.

Engineering impact

Generic Java/Python workflows that change EOS by name can silently keep the wrong model or later fail far away from the call site. This is especially confusing in characterization and phase-envelope notebooks.

The issue was found while reviewing an external UMR-CPA notebook. The reproducer above uses only synthetic/public inputs.

Proposed implementation

  1. Add canonical UMR-CPA aliases to SystemThermo.setModel and instantiate SystemUMRCPAEoS.
  2. Centralize or normalize accepted model names so getModelName, phase model names, mixing-rule selection, and setModel cannot drift independently.
  3. Replace the unknown-model null return with a clear exception containing the unsupported value and supported alternatives.
  4. Add focused regression coverage for ordinary and TBP components.

Acceptance criteria

  • setModel("UMR-CPA") and the documented EOS alias return SystemUMRCPAEoS.
  • Returned system has model name UMR-CPA and Huron-Vidal / UNIFAC_UMRPRU mixing.
  • T, P, total/component moles, and TBP properties are preserved within numerical tolerance.
  • Unknown names raise a deterministic, actionable exception and never return null.
  • Tests cover case/alias handling and an nC10-like TBP fraction.
  • Documentation lists the canonical model name and aliases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions