Class ThermodynamicCoupling

java.lang.Object
neqsim.process.equipment.pipeline.twophasepipe.ThermodynamicCoupling
All Implemented Interfaces:
Serializable

public class ThermodynamicCoupling extends Object implements Serializable
Thermodynamic coupling for the two-fluid transient pipe model.

Provides interface between the two-fluid hydrodynamic solver and NeqSim's thermodynamic calculations. Handles flash calculations to update phase properties and compositions along the pipeline.

Key Functions

  • Update phase densities, viscosities, and enthalpies from P-T flash
  • Calculate phase compositions and mass transfer rates
  • Provide sound speeds for wave propagation
  • Support for both rigorous flash and table interpolation

Performance Considerations

Flash calculations are computationally expensive. For transient simulations with many time steps and grid cells, consider using FlashTable for pre-computed property interpolation.

Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • referenceFluid

      private SystemInterface referenceFluid
      Reference fluid system for flash calculations.
    • thermoOps

      private transient ThermodynamicOperations thermoOps
      Thermodynamic operations object.
    • useFlashTable

      private boolean useFlashTable
      Whether to use table interpolation instead of rigorous flash.
    • flashTable

      private FlashTable flashTable
      Pre-computed flash table (optional).
    • minPressure

      private double minPressure
      Minimum pressure for valid flash (Pa).
    • maxPressure

      private double maxPressure
      Maximum pressure for valid flash (Pa).
    • minTemperature

      private double minTemperature
      Minimum temperature for valid flash (K).
    • maxTemperature

      private double maxTemperature
      Maximum temperature for valid flash (K).
    • flashTolerance

      private double flashTolerance
      Flash tolerance for convergence.
    • maxFlashIterations

      private int maxFlashIterations
      Maximum flash iterations.
  • Constructor Details

    • ThermodynamicCoupling

      public ThermodynamicCoupling()
      Default constructor.
    • ThermodynamicCoupling

      public ThermodynamicCoupling(SystemInterface referenceFluid)
      Constructor with reference fluid.
      Parameters:
      referenceFluid - Fluid system to use as template for flash calculations
  • Method Details

    • setReferenceFluid

      public void setReferenceFluid(SystemInterface fluid)
      Set the reference fluid for thermodynamic calculations.
      Parameters:
      fluid - Fluid system (will be cloned internally)
    • getReferenceFluid

      public SystemInterface getReferenceFluid()
      Get the reference fluid.
      Returns:
      Reference fluid system
    • flashPT

      public ThermodynamicCoupling.ThermoProperties flashPT(double pressure, double temperature)
      Perform PT flash and extract all thermodynamic properties.
      Parameters:
      pressure - Pressure (Pa)
      temperature - Temperature (K)
      Returns:
      ThermoProperties with all phase properties
    • flashPH

      public ThermodynamicCoupling.ThermoProperties flashPH(double pressure, double enthalpy)
      Perform PH flash (constant pressure and enthalpy) for adiabatic processes.
      Parameters:
      pressure - Pressure (Pa)
      enthalpy - Specific enthalpy (J/kg)
      Returns:
      ThermoProperties with updated temperature and phase properties
    • updateSectionProperties

      public void updateSectionProperties(TwoFluidSection section)
      Update a TwoFluidSection with thermodynamic properties at its P-T conditions.
      Parameters:
      section - Pipe section to update
    • updateAllSections

      public void updateAllSections(TwoFluidSection[] sections)
      Update all sections in an array with thermodynamic properties.
      Parameters:
      sections - Array of pipe sections
    • calcMassTransferRate

      public double calcMassTransferRate(TwoFluidSection section, double relaxationTime)
      Calculate mass transfer rate between phases (evaporation/condensation).

      Based on departure from equilibrium. Positive = liquid to gas.

      Parameters:
      section - Current section state
      relaxationTime - Mass transfer relaxation time (s)
      Returns:
      Mass transfer rate (kg/(m³·s))
    • calcMixtureSoundSpeed

      public double calcMixtureSoundSpeed(TwoFluidSection section)
      Calculate mixture sound speed for wave propagation.

      Uses Wood's equation for homogeneous mixture.

      Parameters:
      section - Pipe section with current state
      Returns:
      Mixture sound speed (m/s)
    • setFlashTable

      public void setFlashTable(FlashTable table)
      Enable flash table interpolation for performance.
      Parameters:
      table - Pre-computed flash table
    • getFlashTable

      public FlashTable getFlashTable()
      Get flash table.
      Returns:
      Current flash table or null
    • isUsingFlashTable

      public boolean isUsingFlashTable()
      Check if flash table interpolation is enabled.
      Returns:
      True if using table interpolation
    • setPressureRange

      public void setPressureRange(double min, double max)
      Set valid pressure range for flash calculations.
      Parameters:
      min - Minimum pressure (Pa)
      max - Maximum pressure (Pa)
    • setTemperatureRange

      public void setTemperatureRange(double min, double max)
      Set valid temperature range for flash calculations.
      Parameters:
      min - Minimum temperature (K)
      max - Maximum temperature (K)
    • setFlashTolerance

      public void setFlashTolerance(double tolerance)
      Set flash convergence tolerance.
      Parameters:
      tolerance - Convergence tolerance
    • getFlashTolerance

      public double getFlashTolerance()
      Get flash convergence tolerance.
      Returns:
      Current tolerance
    • setMaxFlashIterations

      public void setMaxFlashIterations(int maxIterations)
      Set maximum flash iterations.
      Parameters:
      maxIterations - Maximum iterations
    • getMaxFlashIterations

      public int getMaxFlashIterations()
      Get maximum flash iterations.
      Returns:
      Maximum iterations