Thermodynamic Operations
Thermodynamic operations execute equilibrium and property tasks using a configured fluid. Most workflows create a ThermodynamicOperations object once and reuse it for multiple calls.
Flash Calculations
TPflash(): Calculates phase split at specified temperature and pressure. RuninitProperties()afterward for density/viscosity.PHflash(H)andPSflash(S): Solve for temperature/phase split given enthalpy or entropy targets—useful for compressors and turbines. Set the pressure on the fluid withsetPressure()before calling these.TVflash(V): Volume-constrained flash—finds pressure at fixed temperature and total volume.VUflash(V, U): Volume- and internal-energy-constrained flash for transient simulations.
ThermodynamicOperations ops = new ThermodynamicOperations(fluid);
ops.TPflash();
double vaporFraction = fluid.getBeta();
Phase Envelopes
- PT envelope:
ops.calcPTphaseEnvelope()fills critical point, cricondenbar, cricondentherm, and two-phase boundary. - Hydrate curves: Enable
hydrateCheck(true)before callingops.hydrateFormationTemperature(pressure). - Wax/solid envelopes: Use a solid-enabled system and call
ops.calcSolidFormationTemperature().
Property Routines
After flashes, properties are available on each phase:
getDensity()orgetNumberOfMoles()for molar/volume properties.getEnthalpy(),getEntropy(), andgetCp()for energy balances.getViscosity(),getThermalConductivity(), andgetInterfacialTension()for transport analyses.
Electrolytes and Reactions
- Electrolytes: Build systems such as
SystemFurstElectrolyteEosorSystemElectrolyteCPAstatoil, add salts/acids, and enable charge balance. Useops.electrolyteFlash()for salt precipitation studies. - Chemical reactions: Define reactions with stoichiometry and equilibrium constants, then call
ops.calcChemicalEquilibrium()to couple them into flashes.
Best Practices
- Always reinitialize (
fluid.init(3)) after changing temperature, pressure, or composition significantly. - Reuse the same
ThermodynamicOperationsinstance when sweeping conditions to avoid rebuilding internal caches. - For performance-sensitive loops, pre-allocate fluids and avoid repeated parsing of the component database.