Skip to content

feat: Add compositional enthalpy model#3705

Open
dkachuma wants to merge 44 commits into
developfrom
dkachuma/compositional-enthalpy
Open

feat: Add compositional enthalpy model#3705
dkachuma wants to merge 44 commits into
developfrom
dkachuma/compositional-enthalpy

Conversation

@dkachuma
Copy link
Copy Markdown
Contributor

@dkachuma dkachuma commented Jun 13, 2025

This pull request implements a compositional enthalpy model for a multiphase fluid system. The total enthalpy of the phase is computed as the sum of an ideal (polynomial) enthalpy and a real fluid correction (or departure enthalpy), which is derived from the equation of state.

The total enthalpy of a fluid phase is defined as:

$$H_{total} = H_{ideal} + H_{dep}$$

The ideal enthalpy represents the enthalpy of the mixture assuming it behaves as an ideal gas, relying on the heat capacity of the individual components. The specific heat capacity $C_{p,i}$ for each component $i$ is modeled as a 4th-order Poling polynomial based on the temperature difference from a reference state, $\Delta T = T - T_{ref}$:

$$C_{p,i}(T) = a_{i,0} + a_{i,1}\Delta T + a_{i,2}\Delta T^2 + a_{i,3}\Delta T^3 + a_{i,4}\Delta T^4$$

To find the ideal enthalpy for a component, this heat capacity is integrated with respect to temperature from the reference temperature to the current temperature, and then added to a baseline reference enthalpy $H_{ref,i}$:

$$H_{ideal,i}(T) = H_{ref,i} + \Delta T \left( a_{i,0} + \frac{a_{i,1}}{2}\Delta T + \frac{a_{i,2}}{3}\Delta T^2 + \frac{a_{i,3}}{4}\Delta T^3 + \frac{a_{i,4}}{5}\Delta T^4 \right)$$

The total ideal enthalpy for the phase is simply the mole-fraction weighted sum of the individual component ideal enthalpies:

$$H_{ideal} = \sum_{i} x_i H_{ideal,i}(T)$$

The dimensionless enthalpy departure is given by:

$$\frac{H_{dep}}{RT} = Z - 1 + \frac{A + T \frac{\partial A}{\partial T}}{B(\delta_1 - \delta_2)} \ln \left( \frac{Z + \delta_1 B}{Z + \delta_2 B} \right)$$

where $Z$ is the compressibility factor of the mixture.

3 new user parameters parameters in HeatCapacityCoefficients.cpp:

  • enthalpyReferenceTemperature: (Optional) A scalar defining the reference temperature $T_{ref}$ with a default of $298.15$ K ($25$ C).
  • referenceEnthalpy: (Optional) A 2D array mapping the reference enthalpy for each component within each phase at the reference temperature. The dimensions must match [number of phases, number of components]. Defaults to zero.
  • componentHeatCapacityCoefficients: (Required) A 2D array containing the 5 polynomial coefficients ($a_0$ to $a_4$) for the specific heat capacity of each component. The dimensions must strictly be [number of components, 5].

Unit tests:

  • testCompositionalEnthalpy.cpp:

    • Values: Compares the computed total enthalpy against hardcoded expected values for enthalpy and the Joule-Thomson coefficient (approximated via $- \frac{\partial H}{\partial P} / \frac{\partial H}{\partial T}$). The values were checked against the thermo package.
    • Derivatives: Numerical derivative tests.
  • testHeatCapacityCoefficients.cpp:

    • Ensures that invalid user inputs (like negative reference temperatures, improperly sized coefficient arrays, or physically impossible reference enthalpy ordering between phases like gas having lower enthalpy than oil) throw appropriate initialization errors.
    • Tests that enthalpy of a component is an ever increasing function of temperature.
  • testCubicEOS.cpp, testSoreideWhitsonEOSPhaseModel.cpp: Extended existing EOS tests to specifically cover the new second-order temperature derivatives of the $A$ parameter (ddaMixture) and the isolated EOS departure enthalpy values/derivatives.

Requires a rebaseline because the ordering of the computations has landed into a state with small values which lead to small differences as below.

********************************************************************************
Error: /Problem/domain/MeshBodies/mesh/meshLevels/Level0/ElementRegions/elementRegionsGroup/CLAY/elementSubRegions/2_hexahedra/globalCompDensity
	Arrays of types float64 and float64 have 80 values of which 1 fail both the relative and absolute tests.
		Max absolute difference is at index (np.int64(2), np.int64(3)): value = 49660.75227691308, base_value = 49660.72630427334
		Max relative difference is at index (np.int64(6), np.int64(1)): value = 3.101139082758628, base_value = 3.101173632486486
	Statistics of the q values greater than 1.0 defined by absolute tolerance: N = 0
	Statistics of the q values greater than 1.0 defined by relative tolerance: N = 1
		max = 1.1140855673570071, mean = 0.01392606959196259, std = 0.12377761400243027
		max is at index (np.int64(6), np.int64(1)), value = 3.101139082758628, base_value = 3.101173632486486
********************************************************************************

@dkachuma dkachuma self-assigned this Jun 13, 2025
@dkachuma dkachuma added type: feature New feature or request ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: no rebaseline Does not require rebaseline ci: run code coverage enables running of the code coverage CI jobs labels Jun 3, 2026
@dkachuma dkachuma marked this pull request as ready for review June 3, 2026 00:43
@dkachuma dkachuma requested a review from rrsettgast as a code owner June 3, 2026 00:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a compositional enthalpy capability for the multiphase compositional fluid models, combining an ideal-mixture enthalpy (via Poling heat-capacity polynomials) with an EOS-based departure enthalpy and extending EOS derivative support needed for temperature sensitivity.

Changes:

  • Added a new CompositionalEnthalpy model and unit tests validating enthalpy values and derivatives.
  • Added HeatCapacityCoefficients model-parameter support (reference temperature, reference enthalpy, Cp polynomial coefficients) with input validation.
  • Extended cubic EOS stack variables and unit tests to cover second-order temperature-related derivative paths (ddaMixture) and EOS departure enthalpy derivatives.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/coreComponents/constitutive/unitTests/testSoreideWhitsonEOSPhaseModel.cpp Adds numerical-derivative tests for ddaMixture and EOS enthalpy in the Soreide-Whitson phase model tests.
src/coreComponents/constitutive/unitTests/testHeatCapacityCoefficients.cpp New tests for HeatCapacityCoefficients input validation and positivity checks.
src/coreComponents/constitutive/unitTests/testCubicEOS.cpp Adds numerical-derivative tests for ddaMixture and EOS enthalpy for cubic EOS models.
src/coreComponents/constitutive/unitTests/testCompositionalEnthalpy.cpp New tests for compositional enthalpy values and derivatives.
src/coreComponents/constitutive/unitTests/CMakeLists.txt Registers the two new unit test sources.
src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/HeatCapacityCoefficients.hpp New parameter class interface and view keys for Cp/enthalpy reference inputs.
src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/HeatCapacityCoefficients.cpp Implements registration + post-init validation (sizes, ordering, Cp positivity).
src/coreComponents/constitutive/fluid/multifluid/compositional/models/CompositionalEnthalpy.hpp New enthalpy function/model implementation (ideal + departure enthalpy).
src/coreComponents/constitutive/fluid/multifluid/compositional/models/CompositionalEnthalpy.cpp Wires CompositionalEnthalpy to parameters and EOS selection.
src/coreComponents/constitutive/fluid/multifluid/compositional/functions/EOSStackVariables.hpp Adds storage for ddaMixture derivatives.
src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CubicEOSPhaseModel.hpp Declares EOS departure enthalpy computation API.
src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CubicEOSPhaseModel_impl.hpp Implements EOS departure enthalpy and ddaMixture population.
src/coreComponents/constitutive/CMakeLists.txt Adds new sources/headers to the constitutive target.

Copy link
Copy Markdown
Contributor

@joshua-white joshua-white left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@dkachuma dkachuma added flag: ready for review flag: requires rebaseline Requires rebaseline branch in integratedTests and removed flag: no rebaseline Does not require rebaseline labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: run code coverage enables running of the code coverage CI jobs ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: ready for review flag: requires rebaseline Requires rebaseline branch in integratedTests type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants