Class RateBasedPackedColumn

All Implemented Interfaces:
Serializable, Runnable, ProcessEquipmentInterface, ProcessElementInterface, SimulationInterface, NamedInterface

public class RateBasedPackedColumn extends ProcessEquipmentBaseClass
Counter-current rate-based packed column for non-reactive absorption and stripping.

The column is divided into axial segments. In each segment, NeqSim phase-equilibrium calculations provide the interfacial equilibrium driving force, PhysicalProperties provides effective diffusivities, and PackingHydraulicsCalculator provides packing hydraulics, wetted area, and film mass-transfer coefficients. Component transfer is bidirectional, so the same equipment can model gas-to-liquid absorption and liquid-to-gas stripping.

Version:
1.0
Author:
NeqSim
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • MIN_GAS_DIFFUSIVITY

      private static final double MIN_GAS_DIFFUSIVITY
      Minimum finite gas diffusivity used when a physical-property model is unavailable.
      See Also:
    • MIN_LIQUID_DIFFUSIVITY

      private static final double MIN_LIQUID_DIFFUSIVITY
      Minimum finite liquid diffusivity used when a physical-property model is unavailable.
      See Also:
    • DEFAULT_GAS_DIFFUSIVITY

      private static final double DEFAULT_GAS_DIFFUSIVITY
      Default gas diffusivity fallback in square metres per second.
      See Also:
    • DEFAULT_LIQUID_DIFFUSIVITY

      private static final double DEFAULT_LIQUID_DIFFUSIVITY
      Default liquid diffusivity fallback in square metres per second.
      See Also:
    • DEFAULT_SURFACE_TENSION

      private static final double DEFAULT_SURFACE_TENSION
      Default liquid surface tension in newtons per metre.
      See Also:
    • DEFAULT_GAS_THERMAL_CONDUCTIVITY

      private static final double DEFAULT_GAS_THERMAL_CONDUCTIVITY
      Default gas thermal conductivity in watts per metre kelvin.
      See Also:
    • DEFAULT_LIQUID_THERMAL_CONDUCTIVITY

      private static final double DEFAULT_LIQUID_THERMAL_CONDUCTIVITY
      Default liquid thermal conductivity in watts per metre kelvin.
      See Also:
    • DEFAULT_GAS_HEAT_CAPACITY

      private static final double DEFAULT_GAS_HEAT_CAPACITY
      Default gas heat capacity in joules per kilogram kelvin.
      See Also:
    • DEFAULT_LIQUID_HEAT_CAPACITY

      private static final double DEFAULT_LIQUID_HEAT_CAPACITY
      Default liquid heat capacity in joules per kilogram kelvin.
      See Also:
    • gasInStream

      private StreamInterface gasInStream
      Gas inlet stream entering the bottom of the packed section.
    • liquidInStream

      private StreamInterface liquidInStream
      Liquid inlet stream entering the top of the packed section.
    • gasOutStream

      private StreamInterface gasOutStream
      Gas outlet stream leaving the top of the packed section.
    • liquidOutStream

      private StreamInterface liquidOutStream
      Liquid outlet stream leaving the bottom of the packed section.
    • columnDiameter

      private double columnDiameter
      Column internal diameter in metres.
    • packedHeight

      private double packedHeight
      Packed height in metres.
    • numberOfSegments

      private int numberOfSegments
      Number of axial calculation segments.
    • maxIterations

      private int maxIterations
      Maximum profile iterations for counter-current convergence.
    • convergenceTolerance

      private double convergenceTolerance
      Outlet convergence tolerance in mol/s.
    • maxTransferFractionPerSegment

      private double maxTransferFractionPerSegment
      Maximum fraction of available component moles transferred in one segment.
    • massTransferCorrectionFactor

      private double massTransferCorrectionFactor
      Global correction factor for film mass-transfer coefficients.
    • packingSpecification

      private PackingSpecification packingSpecification
      Packing specification used in all segments.
    • transferComponents

      private final List<String> transferComponents
      Optional transfer component whitelist. Empty means all components are considered.
    • segmentResults

      private final List<RateBasedPackedColumn.SegmentResult> segmentResults
      Last calculated segment results from bottom to top.
    • componentTransferTotals

      private final Map<String,Double> componentTransferTotals
      Last calculated component transfer totals, positive for gas-to-liquid transfer.
    • lastIterationCount

      private int lastIterationCount
      Number of iterations used by the last run.
    • lastConvergenceResidual

      private double lastConvergenceResidual
      Last convergence residual in mol/s.
    • totalAbsoluteMolarTransfer

      private double totalAbsoluteMolarTransfer
      Total absolute molar transfer in the last converged profile.
    • massTransferCorrelation

      private RateBasedPackedColumn.MassTransferCorrelation massTransferCorrelation
      Mass-transfer correlation used by the segment calculations.
    • filmModel

      Multicomponent film model used for component-transfer calculations.
    • heatTransferModel

      private RateBasedPackedColumn.HeatTransferModel heatTransferModel
      Heat-transfer model used for interphase heat exchange.
    • segmentSolver

      private RateBasedPackedColumn.SegmentSolver segmentSolver
      Segment solver used for heat, mass, and interface-equilibrium coupling.
    • columnSolver

      private RateBasedPackedColumn.ColumnSolver columnSolver
      Column-level profile solver used for counter-current coupling.
    • heatTransferCorrectionFactor

      private double heatTransferCorrectionFactor
      Global correction factor for interphase heat-transfer coefficients.
    • maxHeatTransferFractionPerSegment

      private double maxHeatTransferFractionPerSegment
      Maximum fraction of the available thermal approach transferred in one segment.
    • maxSegmentResidualIterations

      private int maxSegmentResidualIterations
      Maximum Newton iterations for the simultaneous segment residual solve.
    • segmentResidualTolerance

      private double segmentResidualTolerance
      Normalized residual tolerance for the simultaneous segment solver.
    • maxColumnResidualIterations

      private int maxColumnResidualIterations
      Maximum Newton iterations for the column-wide equation-oriented solver.
    • columnHomotopySteps

      private int columnHomotopySteps
      Number of homotopy continuation steps for the equation-oriented solver.
    • columnResidualTolerance

      private double columnResidualTolerance
      Normalized residual tolerance for the column-wide equation-oriented solver.
    • lastColumnResidualNorm

      private double lastColumnResidualNorm
      Last equation-oriented residual norm.
    • lastColumnResidualIterations

      private int lastColumnResidualIterations
      Last equation-oriented Newton iteration count.
    • lastGasComponentBalanceResidual

      private double lastGasComponentBalanceResidual
      Last maximum gas component-balance residual in mol/s.
    • lastLiquidComponentBalanceResidual

      private double lastLiquidComponentBalanceResidual
      Last maximum liquid component-balance residual in mol/s.
    • lastColumnEnergyBalanceResidual

      private double lastColumnEnergyBalanceResidual
      Last maximum column energy-balance residual in W-equivalent stream basis.
  • Constructor Details

    • RateBasedPackedColumn

      public RateBasedPackedColumn(String name)
      Create a rate-based packed column.
      Parameters:
      name - equipment name
    • RateBasedPackedColumn

      public RateBasedPackedColumn(String name, StreamInterface gasInStream, StreamInterface liquidInStream)
      Create a rate-based packed column with inlet streams.
      Parameters:
      name - equipment name
      gasInStream - gas inlet stream entering the bottom of the packing
      liquidInStream - liquid inlet stream entering the top of the packing
  • Method Details

    • setGasInStream

      public void setGasInStream(StreamInterface gasInStream)
      Set the gas inlet stream.
      Parameters:
      gasInStream - gas inlet stream entering the bottom of the packing
    • addGasInStream

      public void addGasInStream(StreamInterface gasInStream)
      Add the gas inlet stream.
      Parameters:
      gasInStream - gas inlet stream entering the bottom of the packing
    • setLiquidInStream

      public void setLiquidInStream(StreamInterface liquidInStream)
      Set the liquid inlet stream.
      Parameters:
      liquidInStream - liquid inlet stream entering the top of the packing
    • addLiquidInStream

      public void addLiquidInStream(StreamInterface liquidInStream)
      Add the liquid or solvent inlet stream.
      Parameters:
      liquidInStream - liquid inlet stream entering the top of the packing
    • addSolventInStream

      public void addSolventInStream(StreamInterface solventInStream)
      Add the solvent inlet stream.
      Parameters:
      solventInStream - solvent inlet stream entering the top of the packing
    • getGasInStream

      public StreamInterface getGasInStream()
      Get the gas inlet stream.
      Returns:
      gas inlet stream
    • getLiquidInStream

      public StreamInterface getLiquidInStream()
      Get the liquid inlet stream.
      Returns:
      liquid inlet stream
    • getGasOutStream

      public StreamInterface getGasOutStream()
      Get the gas outlet stream.
      Returns:
      gas outlet stream leaving the top of the packing
    • getLiquidOutStream

      public StreamInterface getLiquidOutStream()
      Get the liquid outlet stream.
      Returns:
      liquid outlet stream leaving the bottom of the packing
    • getInletStreams

      public List<StreamInterface> getInletStreams()
      Returns all inlet streams connected to this equipment. Subclasses override to report their specific inlets. Used by graph builders, DEXPI export, and auto-instrumentation to discover topology without instanceof checks.
      Returns:
      unmodifiable list of inlet streams (empty by default)
    • getOutletStreams

      public List<StreamInterface> getOutletStreams()
      Returns all outlet streams produced by this equipment. Subclasses override to report their specific outlets. Used by graph builders, DEXPI export, and auto-instrumentation to discover topology without instanceof checks.
      Returns:
      unmodifiable list of outlet streams (empty by default)
    • setColumnDiameter

      public void setColumnDiameter(double columnDiameter)
      Set the column internal diameter.
      Parameters:
      columnDiameter - column internal diameter in metres, must be positive
      Throws:
      IllegalArgumentException - if the diameter is not positive
    • getColumnDiameter

      public double getColumnDiameter()
      Get the column internal diameter.
      Returns:
      column diameter in metres
    • setPackedHeight

      public void setPackedHeight(double packedHeight)
      Set the packed height.
      Parameters:
      packedHeight - packed height in metres, must be non-negative
      Throws:
      IllegalArgumentException - if the packed height is negative
    • getPackedHeight

      public double getPackedHeight()
      Get the packed height.
      Returns:
      packed height in metres
    • setNumberOfSegments

      public void setNumberOfSegments(int numberOfSegments)
      Set the number of axial calculation segments.
      Parameters:
      numberOfSegments - number of segments, must be at least one
      Throws:
      IllegalArgumentException - if the segment count is below one
    • getNumberOfSegments

      public int getNumberOfSegments()
      Get the number of axial calculation segments.
      Returns:
      number of segments
    • setMaxIterations

      public void setMaxIterations(int maxIterations)
      Set the maximum number of profile iterations.
      Parameters:
      maxIterations - maximum iterations, must be at least one
      Throws:
      IllegalArgumentException - if the iteration count is below one
    • getMaxIterations

      public int getMaxIterations()
      Get the maximum number of profile iterations.
      Returns:
      maximum iterations
    • setConvergenceTolerance

      public void setConvergenceTolerance(double convergenceTolerance)
      Set the convergence tolerance.
      Parameters:
      convergenceTolerance - outlet residual tolerance in mol/s, must be positive
      Throws:
      IllegalArgumentException - if the tolerance is not positive
    • getConvergenceTolerance

      public double getConvergenceTolerance()
      Get the convergence tolerance.
      Returns:
      convergence tolerance in mol/s
    • setMaxTransferFractionPerSegment

      public void setMaxTransferFractionPerSegment(double fraction)
      Set the maximum component transfer fraction per segment.
      Parameters:
      fraction - maximum fraction from zero to one
      Throws:
      IllegalArgumentException - if the fraction is outside zero to one
    • getMaxTransferFractionPerSegment

      public double getMaxTransferFractionPerSegment()
      Get the maximum component transfer fraction per segment.
      Returns:
      maximum component transfer fraction
    • setMassTransferCorrectionFactor

      public void setMassTransferCorrectionFactor(double correctionFactor)
      Set a global mass-transfer correction factor.
      Parameters:
      correctionFactor - correction factor, must be positive
      Throws:
      IllegalArgumentException - if the correction factor is not positive
    • getMassTransferCorrectionFactor

      public double getMassTransferCorrectionFactor()
      Get the global mass-transfer correction factor.
      Returns:
      mass-transfer correction factor
    • setPackingType

      public void setPackingType(String packingName)
      Set the packing by name or alias.
      Parameters:
      packingName - packing name or alias from PackingSpecificationLibrary
    • setPackingSpecification

      public void setPackingSpecification(PackingSpecification packingSpecification)
      Set the packing specification directly.
      Parameters:
      packingSpecification - packing specification to use
      Throws:
      IllegalArgumentException - if the specification is null
    • getPackingSpecification

      public PackingSpecification getPackingSpecification()
      Get the active packing specification.
      Returns:
      packing specification
    • setMassTransferCorrelation

      public void setMassTransferCorrelation(RateBasedPackedColumn.MassTransferCorrelation massTransferCorrelation)
      Set the mass-transfer correlation.
      Parameters:
      massTransferCorrelation - correlation to use
      Throws:
      IllegalArgumentException - if the correlation is null
    • getMassTransferCorrelation

      public RateBasedPackedColumn.MassTransferCorrelation getMassTransferCorrelation()
      Get the mass-transfer correlation.
      Returns:
      active mass-transfer correlation
    • setFilmModel

      public void setFilmModel(RateBasedPackedColumn.FilmModel filmModel)
      Set the gas-liquid film model used for component transfer.
      Parameters:
      filmModel - film model to use
      Throws:
      IllegalArgumentException - if the film model is null
    • getFilmModel

      public RateBasedPackedColumn.FilmModel getFilmModel()
      Get the active gas-liquid film model.
      Returns:
      active film model
    • setHeatTransferModel

      public void setHeatTransferModel(RateBasedPackedColumn.HeatTransferModel heatTransferModel)
      Set the interphase heat-transfer model.
      Parameters:
      heatTransferModel - heat-transfer model to use
      Throws:
      IllegalArgumentException - if the heat-transfer model is null
    • getHeatTransferModel

      public RateBasedPackedColumn.HeatTransferModel getHeatTransferModel()
      Get the active interphase heat-transfer model.
      Returns:
      active heat-transfer model
    • setSegmentSolver

      public void setSegmentSolver(RateBasedPackedColumn.SegmentSolver segmentSolver)
      Set the segment solver used for heat and mass coupling.
      Parameters:
      segmentSolver - segment solver to use
      Throws:
      IllegalArgumentException - if the segment solver is null
    • getSegmentSolver

      public RateBasedPackedColumn.SegmentSolver getSegmentSolver()
      Get the active segment solver.
      Returns:
      active segment solver
    • setColumnSolver

      public void setColumnSolver(RateBasedPackedColumn.ColumnSolver columnSolver)
      Set the column-level profile solver.
      Parameters:
      columnSolver - column solver to use
      Throws:
      IllegalArgumentException - if the column solver is null
    • getColumnSolver

      public RateBasedPackedColumn.ColumnSolver getColumnSolver()
      Get the active column-level profile solver.
      Returns:
      active column solver
    • setHeatTransferCorrectionFactor

      public void setHeatTransferCorrectionFactor(double correctionFactor)
      Set the global interphase heat-transfer correction factor.
      Parameters:
      correctionFactor - correction factor, must be positive
      Throws:
      IllegalArgumentException - if the correction factor is not positive
    • getHeatTransferCorrectionFactor

      public double getHeatTransferCorrectionFactor()
      Get the global interphase heat-transfer correction factor.
      Returns:
      heat-transfer correction factor
    • setMaxHeatTransferFractionPerSegment

      public void setMaxHeatTransferFractionPerSegment(double fraction)
      Set the maximum thermal approach transferred in one segment.
      Parameters:
      fraction - maximum fraction from zero to one
      Throws:
      IllegalArgumentException - if the fraction is outside zero to one
    • getMaxHeatTransferFractionPerSegment

      public double getMaxHeatTransferFractionPerSegment()
      Get the maximum thermal approach transferred in one segment.
      Returns:
      maximum heat-transfer fraction
    • setMaxSegmentResidualIterations

      public void setMaxSegmentResidualIterations(int maxSegmentResidualIterations)
      Set the maximum iterations for the simultaneous segment residual solver.
      Parameters:
      maxSegmentResidualIterations - maximum residual iterations, must be at least one
      Throws:
      IllegalArgumentException - if the iteration count is below one
    • getMaxSegmentResidualIterations

      public int getMaxSegmentResidualIterations()
      Get the maximum iterations for the simultaneous segment residual solver.
      Returns:
      maximum residual iterations
    • setSegmentResidualTolerance

      public void setSegmentResidualTolerance(double segmentResidualTolerance)
      Set the normalized residual tolerance for the simultaneous segment solver.
      Parameters:
      segmentResidualTolerance - normalized tolerance, must be positive
      Throws:
      IllegalArgumentException - if the tolerance is not positive
    • getSegmentResidualTolerance

      public double getSegmentResidualTolerance()
      Get the normalized residual tolerance for the simultaneous segment solver.
      Returns:
      normalized residual tolerance
    • setMaxColumnResidualIterations

      public void setMaxColumnResidualIterations(int maxColumnResidualIterations)
      Set the maximum Newton iterations for the column-wide equation-oriented solver.
      Parameters:
      maxColumnResidualIterations - maximum Newton iterations, must be at least one
      Throws:
      IllegalArgumentException - if the iteration count is below one
    • getMaxColumnResidualIterations

      public int getMaxColumnResidualIterations()
      Get the maximum Newton iterations for the column-wide equation-oriented solver.
      Returns:
      maximum Newton iterations
    • setColumnHomotopySteps

      public void setColumnHomotopySteps(int columnHomotopySteps)
      Set the number of homotopy continuation steps for the equation-oriented solver.
      Parameters:
      columnHomotopySteps - number of continuation steps, must be at least one
      Throws:
      IllegalArgumentException - if the step count is below one
    • getColumnHomotopySteps

      public int getColumnHomotopySteps()
      Get the number of homotopy continuation steps for the equation-oriented solver.
      Returns:
      homotopy continuation steps
    • setColumnResidualTolerance

      public void setColumnResidualTolerance(double columnResidualTolerance)
      Set the normalized residual tolerance for the column-wide equation-oriented solver.
      Parameters:
      columnResidualTolerance - normalized tolerance, must be positive
      Throws:
      IllegalArgumentException - if the tolerance is not positive
    • getColumnResidualTolerance

      public double getColumnResidualTolerance()
      Get the normalized residual tolerance for the column-wide equation-oriented solver.
      Returns:
      normalized column residual tolerance
    • getLastColumnResidualNorm

      public double getLastColumnResidualNorm()
      Get the last column-wide equation-oriented residual norm.
      Returns:
      last normalized column residual norm
    • getLastColumnResidualIterations

      public int getLastColumnResidualIterations()
      Get the last column-wide Newton iteration count.
      Returns:
      last column residual iterations
    • getLastGasComponentBalanceResidual

      public double getLastGasComponentBalanceResidual()
      Get the maximum gas component-balance residual from the last equation-oriented solve.
      Returns:
      gas component-balance residual in mol/s
    • getLastLiquidComponentBalanceResidual

      public double getLastLiquidComponentBalanceResidual()
      Get the maximum liquid component-balance residual from the last equation-oriented solve.
      Returns:
      liquid component-balance residual in mol/s
    • getLastColumnEnergyBalanceResidual

      public double getLastColumnEnergyBalanceResidual()
      Get the maximum column energy-balance residual from the last equation-oriented solve.
      Returns:
      energy-balance residual in W-equivalent stream basis
    • setTransferComponents

      public void setTransferComponents(String... componentNames)
      Set transfer components explicitly.

      When no components are supplied, all components in the inlet streams are considered.

      Parameters:
      componentNames - component names to include in transfer calculations
    • getTransferComponents

      public List<String> getTransferComponents()
      Get explicitly configured transfer components.
      Returns:
      unmodifiable list of transfer components; empty means automatic component discovery
    • getSegmentResults

      public List<RateBasedPackedColumn.SegmentResult> getSegmentResults()
      Get the last calculated segment profile.
      Returns:
      unmodifiable segment results from bottom to top
    • getComponentTransferTotals

      public Map<String,Double> getComponentTransferTotals()
      Get the last calculated component transfer totals.
      Returns:
      component transfer totals in mol/s, positive for gas-to-liquid transfer
    • getLastIterationCount

      public int getLastIterationCount()
      Get the last profile iteration count.
      Returns:
      number of iterations used by the last run
    • getLastConvergenceResidual

      public double getLastConvergenceResidual()
      Get the last convergence residual.
      Returns:
      convergence residual in mol/s
    • getTotalAbsoluteMolarTransfer

      public double getTotalAbsoluteMolarTransfer()
      Get total absolute molar transfer in the last profile.
      Returns:
      total absolute transfer in mol/s
    • getThermoSystem

      public SystemInterface getThermoSystem()

      getThermoSystem.

      Specified by:
      getThermoSystem in interface ProcessEquipmentInterface
      Overrides:
      getThermoSystem in class ProcessEquipmentBaseClass
      Returns:
      a SystemInterface object
    • run

      public void run(UUID id)

      In this method all thermodynamic and unit operations will be calculated in a steady state calculation.

      Parameters:
      id - UUID
    • displayResult

      public void displayResult()

      displayResult.

      Specified by:
      displayResult in interface ProcessEquipmentInterface
      Overrides:
      displayResult in class ProcessEquipmentBaseClass
    • validateSetup

      public ValidationResult validateSetup()
      Validate the process equipment before execution.

      Checks for common setup errors:

      • Equipment has a valid name
      • Input streams connected
      • Operating parameters in valid ranges
      Returns:
      validation result with errors and warnings
    • toJson

      public String toJson()
      Convert the last run results to JSON.
      Specified by:
      toJson in interface ProcessEquipmentInterface
      Overrides:
      toJson in class ProcessEquipmentBaseClass
      Returns:
      JSON report with configuration, hydraulics, transfer totals, and segment profiles
    • validateRuntimeSetup

      private void validateRuntimeSetup()
      Validate runtime setup and throw an exception on blocking errors.
      Throws:
      IllegalStateException - if the equipment setup is invalid
    • solveCounterCurrentProfile

      private RateBasedPackedColumn.CounterCurrentSolution solveCounterCurrentProfile(SystemInterface gasIn, SystemInterface liquidIn)
      Solve the counter-current segment profile by fixed-point iteration.
      Parameters:
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      Returns:
      converged counter-current solution
    • solveFixedPointProfile

      private RateBasedPackedColumn.CounterCurrentSolution solveFixedPointProfile(SystemInterface gasIn, SystemInterface liquidIn)
      Solve the counter-current profile by fixed-point liquid profile iteration.
      Parameters:
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      Returns:
      converged counter-current solution
    • resetColumnResidualDiagnostics

      private void resetColumnResidualDiagnostics()
      Reset column-wide residual diagnostics for non-equation-oriented profile solves.
    • solveEquationOrientedProfile

      private RateBasedPackedColumn.CounterCurrentSolution solveEquationOrientedProfile(SystemInterface gasIn, SystemInterface liquidIn)
      Solve the full packed section with a column-wide equation-oriented residual system.
      Parameters:
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      Returns:
      equation-oriented counter-current solution
    • createColumnUnknowns

      private double[] createColumnUnknowns(RateBasedPackedColumn.CounterCurrentSolution seed, List<String> components)
      Create a column-wide unknown vector from an existing profile solution.
      Parameters:
      seed - seed profile solution
      components - active transfer components
      Returns:
      unknown vector containing segment fluxes, interface temperatures, and outlet temperatures
    • solveColumnResiduals

      private RateBasedPackedColumn.ColumnResidualEvaluation solveColumnResiduals(SystemInterface gasIn, SystemInterface liquidIn, List<String> components, double[] initialUnknowns, double homotopyFactor)
      Solve the column-wide residual equations at one homotopy continuation factor.
      Parameters:
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      components - active transfer components
      initialUnknowns - initial unknown vector
      homotopyFactor - continuation factor from zero to one
      Returns:
      best residual evaluation found
    • evaluateColumnResidual

      private RateBasedPackedColumn.ColumnResidualEvaluation evaluateColumnResidual(SystemInterface gasIn, SystemInterface liquidIn, List<String> components, double[] unknowns, double homotopyFactor, int iterations)
      Evaluate the full column residual vector for the equation-oriented solver.
      Parameters:
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      components - active transfer components
      unknowns - column unknown vector
      homotopyFactor - continuation factor from zero to one
      iterations - iteration count represented by this evaluation
      Returns:
      column residual evaluation
    • calculateColumnResidualStep

      private Jama.Matrix calculateColumnResidualStep(SystemInterface gasIn, SystemInterface liquidIn, List<String> components, double[] unknowns, RateBasedPackedColumn.ColumnResidualEvaluation evaluation, double homotopyFactor)
      Calculate one sparse-pattern Newton step for the column residual equations.
      Parameters:
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      components - active transfer components
      unknowns - current column unknown vector
      evaluation - current residual evaluation
      homotopyFactor - continuation factor from zero to one
      Returns:
      Newton step, or null if the least-squares solve fails
    • applyColumnResidualStep

      private double[] applyColumnResidualStep(double[] unknowns, Jama.Matrix step, double damping, SystemInterface gasIn, SystemInterface liquidIn, List<String> components)
      Apply a damped column residual step and clamp to physical bounds.
      Parameters:
      unknowns - current unknown vector
      step - Newton step
      damping - damping factor from zero to one
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      components - active transfer components
      Returns:
      bounded candidate unknowns
    • buildColumnState

      private RateBasedPackedColumn.ColumnState buildColumnState(SystemInterface gasIn, SystemInterface liquidIn, List<String> components, double[] unknowns)
      Build gas and liquid segment states from column-wide flux and temperature unknowns.
      Parameters:
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      components - active transfer components
      unknowns - bounded column unknown vector
      Returns:
      reconstructed column state
    • clampColumnUnknowns

      private double[] clampColumnUnknowns(double[] unknowns, SystemInterface gasIn, SystemInterface liquidIn, List<String> components)
      Clamp column unknowns to inventory and temperature limits.
      Parameters:
      unknowns - column unknown vector
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      components - active transfer components
      Returns:
      clamped unknown vector
    • clampColumnTemperatureUnknown

      private void clampColumnTemperatureUnknown(double[] unknowns, int index, SystemInterface gasIn, SystemInterface liquidIn)
      Clamp one column temperature unknown.
      Parameters:
      unknowns - unknown vector to update
      index - temperature unknown index
      gasIn - gas inlet system
      liquidIn - liquid inlet system
    • componentInventoryMap

      private Map<String,Double> componentInventoryMap(SystemInterface system, List<String> components)
      Build a component inventory map for active components.
      Parameters:
      system - thermodynamic system
      components - active transfer components
      Returns:
      component moles by component name
    • addComponentDelta

      private void addComponentDelta(SystemInterface system, String component, double deltaMoles)
      Add a bounded component delta to a system.
      Parameters:
      system - system to update
      component - component name
      deltaMoles - component delta in mol/s stream basis
    • columnUnknownBlockSize

      private int columnUnknownBlockSize(List<String> components)
      Get the column unknown block size per segment.
      Parameters:
      components - active transfer components
      Returns:
      unknown count per segment
    • columnFluxIndex

      private int columnFluxIndex(int segment, int componentIndex, List<String> components)
      Get the unknown index for a segment component flux.
      Parameters:
      segment - segment index
      componentIndex - component index
      components - active transfer components
      Returns:
      flux unknown index
    • columnInterfaceTemperatureIndex

      private int columnInterfaceTemperatureIndex(int segment, List<String> components)
      Get the unknown index for a segment interface temperature.
      Parameters:
      segment - segment index
      components - active transfer components
      Returns:
      interface-temperature unknown index
    • columnGasOutletTemperatureIndex

      private int columnGasOutletTemperatureIndex(int segment, List<String> components)
      Get the unknown index for a segment gas outlet temperature.
      Parameters:
      segment - segment index
      components - active transfer components
      Returns:
      gas outlet temperature unknown index
    • columnLiquidOutletTemperatureIndex

      private int columnLiquidOutletTemperatureIndex(int segment, List<String> components)
      Get the unknown index for a segment liquid outlet temperature.
      Parameters:
      segment - segment index
      components - active transfer components
      Returns:
      liquid outlet temperature unknown index
    • columnResidualVariableStep

      private double columnResidualVariableStep(double[] unknowns, int variable, int componentCount)
      Calculate finite-difference step size for a column unknown.
      Parameters:
      unknowns - current unknown vector
      variable - variable index
      componentCount - number of component flux unknowns per segment
      Returns:
      finite-difference step
    • toPrimitiveArray

      private double[] toPrimitiveArray(List<Double> values)
      Convert a boxed residual list to a primitive array.
      Parameters:
      values - residual values
      Returns:
      primitive residual array
    • initializeLiquidProfile

      private List<SystemInterface> initializeLiquidProfile(SystemInterface liquidIn)
      Initialize all liquid segment inlets from the fresh liquid inlet.
      Parameters:
      liquidIn - fresh liquid inlet system
      Returns:
      list of liquid entering systems for each segment
    • runOneProfileIteration

      private RateBasedPackedColumn.CounterCurrentSolution runOneProfileIteration(SystemInterface gasIn, SystemInterface liquidIn, List<SystemInterface> liquidEntering)
      Run one bottom-to-top gas pass against the current counter-current liquid profile.
      Parameters:
      gasIn - gas inlet system
      liquidIn - liquid inlet system
      liquidEntering - liquid systems entering each segment
      Returns:
      one profile iteration solution
    • updateLiquidProfile

      private List<SystemInterface> updateLiquidProfile(SystemInterface liquidIn, List<SystemInterface> liquidLeaving)
      Shift liquid leaving one segment into the segment below for the next iteration.
      Parameters:
      liquidIn - fresh liquid inlet system
      liquidLeaving - liquid systems leaving each segment from the previous iteration
      Returns:
      updated segment liquid inlet profile
    • acceptSolution

      private void acceptSolution(RateBasedPackedColumn.CounterCurrentSolution solution)
      Accept a profile solution as the last calculated result.
      Parameters:
      solution - solution to accept
    • calculateSegment

      private RateBasedPackedColumn.SegmentComputation calculateSegment(int segment, SystemInterface gasIn, SystemInterface liquidIn)
      Calculate one rate-based segment.
      Parameters:
      segment - segment index from bottom, zero based
      gasIn - gas system entering the segment
      liquidIn - liquid system entering the segment
      Returns:
      segment computation with outlet systems and result data
    • calculateTransportSnapshot

      private RateBasedPackedColumn.TransportSnapshot calculateTransportSnapshot(SystemInterface gas, SystemInterface liquid, double segmentHeight)
      Calculate transport properties and packing coefficients for one segment.
      Parameters:
      gas - gas system in the segment
      liquid - liquid system in the segment
      segmentHeight - segment height in metres
      Returns:
      transport snapshot for the segment
    • calculateComponentTransfer

      private double calculateComponentTransfer(String component, SystemInterface gas, SystemInterface liquid, RateBasedPackedColumn.TransportSnapshot snapshot, RateBasedPackedColumn.InterfaceEquilibrium interfaceEquilibrium)
      Calculate component transfer rate for a component in one segment.
      Parameters:
      component - component name
      gas - gas system
      liquid - liquid system
      snapshot - transport snapshot for the segment
      interfaceEquilibrium - interface equilibrium data
      Returns:
      transfer rate in mol/s, positive from gas to liquid
    • calculateUnboundedComponentTransfer

      private double calculateUnboundedComponentTransfer(String component, SystemInterface gas, SystemInterface liquid, RateBasedPackedColumn.TransportSnapshot snapshot, RateBasedPackedColumn.InterfaceEquilibrium interfaceEquilibrium)
      Calculate the unbounded Maxwell-Stefan film transfer rate for one component.
      Parameters:
      component - component name
      gas - gas system
      liquid - liquid system
      snapshot - transport snapshot for the segment
      interfaceEquilibrium - interface equilibrium data
      Returns:
      unbounded transfer rate in mol/s, positive from gas to liquid
    • calculateSimultaneousResidualSegment

      private RateBasedPackedColumn.SegmentComputation calculateSimultaneousResidualSegment(int segment, SystemInterface gas, SystemInterface liquid, double segmentHeight)
      Calculate one segment using simultaneous flux and interfacial energy residuals.
      Parameters:
      segment - segment index from bottom, zero based
      gas - gas system entering the segment
      liquid - liquid system entering the segment
      segmentHeight - segment height in metres
      Returns:
      segment computation with outlet systems and residual diagnostics
    • solveSegmentResiduals

      Solve the simultaneous residual equations for a segment.
      Parameters:
      gas - gas system entering the segment
      liquid - liquid system entering the segment
      snapshot - transport snapshot for the segment
      components - active transfer components
      Returns:
      best residual evaluation found
    • createInitialResidualUnknowns

      private double[] createInitialResidualUnknowns(SystemInterface gas, SystemInterface liquid, RateBasedPackedColumn.TransportSnapshot snapshot, List<String> components)
      Create initial guesses for component transfers and interface temperature.
      Parameters:
      gas - gas system
      liquid - liquid system
      snapshot - transport snapshot
      components - active transfer components
      Returns:
      residual unknown vector
    • evaluateSegmentResidual

      private RateBasedPackedColumn.SegmentResidualEvaluation evaluateSegmentResidual(SystemInterface gas, SystemInterface liquid, RateBasedPackedColumn.TransportSnapshot snapshot, List<String> components, double[] unknowns, int iterations)
      Evaluate normalized residuals for the simultaneous segment equations.
      Parameters:
      gas - gas system
      liquid - liquid system
      snapshot - transport snapshot
      components - active transfer components
      unknowns - residual unknown vector
      iterations - iteration count represented by the evaluation
      Returns:
      residual evaluation
    • calculateResidualStep

      private Jama.Matrix calculateResidualStep(SystemInterface gas, SystemInterface liquid, RateBasedPackedColumn.TransportSnapshot snapshot, List<String> components, double[] unknowns, RateBasedPackedColumn.SegmentResidualEvaluation evaluation)
      Calculate a Newton step for normalized segment residuals.
      Parameters:
      gas - gas system
      liquid - liquid system
      snapshot - transport snapshot
      components - active transfer components
      unknowns - current unknown vector
      evaluation - current residual evaluation
      Returns:
      Newton step, or null if the linear solve fails
    • applyResidualStep

      private double[] applyResidualStep(double[] unknowns, Jama.Matrix step, double damping, SystemInterface gas, SystemInterface liquid, List<String> components)
      Apply a damped residual step and clamp the unknowns to physical bounds.
      Parameters:
      unknowns - current unknowns
      step - Newton step
      damping - damping factor from zero to one
      gas - gas system
      liquid - liquid system
      components - active transfer components
      Returns:
      bounded candidate unknowns
    • clampResidualUnknowns

      private double[] clampResidualUnknowns(double[] unknowns, SystemInterface gas, SystemInterface liquid, List<String> components)
      Clamp residual unknowns to available component inventory and temperature bounds.
      Parameters:
      unknowns - unknown vector to clamp
      gas - gas system
      liquid - liquid system
      components - active transfer components
      Returns:
      clamped unknown vector
    • residualVariableStep

      private double residualVariableStep(double[] unknowns, int variable, int componentCount)
      Calculate finite-difference step size for a residual unknown.
      Parameters:
      unknowns - current unknown vector
      variable - variable index
      componentCount - number of component transfer unknowns
      Returns:
      finite-difference step
    • transferResidualScale

      private double transferResidualScale(String component, double predictedTransfer, SystemInterface gas, SystemInterface liquid)
      Calculate the transfer residual scaling for one component.
      Parameters:
      component - component name
      predictedTransfer - predicted transfer rate in mol/s
      gas - gas system
      liquid - liquid system
      Returns:
      positive residual scaling in mol/s
    • heatResidualScale

      private double heatResidualScale(double gasSensibleHeat, double liquidSensibleHeat, double gasMassEnthalpy, double liquidMassEnthalpy)
      Calculate heat residual scaling.
      Parameters:
      gasSensibleHeat - gas-side sensible heat rate in W
      liquidSensibleHeat - liquid-side sensible heat rate in W
      gasMassEnthalpy - gas-side transferred component enthalpy rate in W
      liquidMassEnthalpy - liquid-side transferred component enthalpy rate in W
      Returns:
      positive residual scaling in W
    • residualNorm

      private double residualNorm(double[] residuals)
      Calculate infinity norm of normalized residuals.
      Parameters:
      residuals - normalized residual array
      Returns:
      maximum absolute residual
    • applyEnthalpyTarget

      private void applyEnthalpyTarget(SystemInterface system, double targetEnthalpy)
      Apply a total enthalpy target by pressure-enthalpy flash.
      Parameters:
      system - thermodynamic system to flash
      targetEnthalpy - target total enthalpy in J or W-equivalent stream basis
    • estimateTemperatureForTargetEnthalpy

      private double estimateTemperatureForTargetEnthalpy(SystemInterface system, double targetEnthalpy)
      Estimate a temperature for an enthalpy target if PH flash fails.
      Parameters:
      system - thermodynamic system
      targetEnthalpy - target total enthalpy in J or W-equivalent stream basis
      Returns:
      estimated temperature in kelvin
    • applyComponentTransfer

      private void applyComponentTransfer(String component, double transfer, SystemInterface gas, SystemInterface liquid)
      Apply a component transfer to gas and liquid systems.
      Parameters:
      component - component name
      transfer - transfer rate in mol/s, positive from gas to liquid
      gas - gas system to update
      liquid - liquid system to update
    • limitTransfer

      private double limitTransfer(String component, double proposedTransfer, SystemInterface gas, SystemInterface liquid)
      Limit transfer to available component inventory and configured stability fraction.
      Parameters:
      component - component name
      proposedTransfer - proposed transfer in mol/s, positive from gas to liquid
      gas - gas system
      liquid - liquid system
      Returns:
      bounded transfer in mol/s
    • calculateInterfaceEquilibrium

      Calculate interface equilibrium compositions for the mixed segment fluids.
      Parameters:
      gas - gas system
      liquid - liquid system
      snapshot - transport snapshot containing the interfacial temperature estimate
      Returns:
      interface equilibrium data
    • calculateInterfaceEquilibrium

      private RateBasedPackedColumn.InterfaceEquilibrium calculateInterfaceEquilibrium(SystemInterface gas, SystemInterface liquid, double interfaceTemperatureK)
      Calculate interface equilibrium at a specified temperature.
      Parameters:
      gas - gas system
      liquid - liquid system
      interfaceTemperatureK - interface temperature in kelvin
      Returns:
      interface equilibrium data
    • calculateFilmCoefficient

      private double calculateFilmCoefficient(PhaseInterface phase, String component, double baseCoefficient, double referenceDiffusivity, boolean gasPhase)
      Calculate the active film coefficient for one component.
      Parameters:
      phase - phase to inspect
      component - component name
      baseCoefficient - scalar packed-bed film coefficient
      referenceDiffusivity - reference effective diffusivity in m2/s
      gasPhase - true when the phase is gas
      Returns:
      component film coefficient in 1/s
    • maxwellStefanFilmCoefficient

      private double maxwellStefanFilmCoefficient(PhaseInterface phase, String component, double baseCoefficient, double referenceDiffusivity, boolean gasPhase)
      Calculate a Maxwell-Stefan matrix-corrected film coefficient for one component.
      Parameters:
      phase - phase to inspect
      component - component name
      baseCoefficient - scalar packed-bed film coefficient
      referenceDiffusivity - reference effective diffusivity in m2/s
      gasPhase - true when the phase is gas
      Returns:
      Maxwell-Stefan corrected film coefficient in 1/s
    • combineFilmFluxes

      private double combineFilmFluxes(double gasFluxDensity, double liquidFluxDensity)
      Combine gas- and liquid-side volumetric flux densities with a rate-limiting harmonic mean.
      Parameters:
      gasFluxDensity - gas-side flux density in mol/(m3 s)
      liquidFluxDensity - liquid-side flux density in mol/(m3 s)
      Returns:
      combined transfer density in mol/(m3 s)
    • applyInterphaseHeatTransfer

      private double applyInterphaseHeatTransfer(SystemInterface gas, SystemInterface liquid, RateBasedPackedColumn.TransportSnapshot snapshot)
      Apply interphase heat transfer to gas and liquid segment systems.
      Parameters:
      gas - gas system to update
      liquid - liquid system to update
      snapshot - transport snapshot for the segment
      Returns:
      heat-transfer rate in W, positive from gas to liquid
    • calculateVolumetricHeatTransferCoefficient

      private double calculateVolumetricHeatTransferCoefficient(double massTransferCoefficient, double density, double heatCapacity, double viscosity, double diffusivity, double thermalConductivity)
      Calculate a volumetric heat-transfer coefficient from the Chilton-Colburn analogy.
      Parameters:
      massTransferCoefficient - volumetric mass-transfer coefficient in 1/s
      density - phase density in kg/m3
      heatCapacity - phase heat capacity in J/(kg K)
      viscosity - phase viscosity in kg/(m s)
      diffusivity - phase diffusivity in m2/s
      thermalConductivity - thermal conductivity in W/(m K)
      Returns:
      volumetric heat-transfer coefficient in W/(m3 K)
    • combineHeatTransferCoefficients

      private double combineHeatTransferCoefficients(double gasCoefficient, double liquidCoefficient)
      Combine gas and liquid heat-transfer coefficients as series resistances.
      Parameters:
      gasCoefficient - gas-side volumetric heat-transfer coefficient in W/(m3 K)
      liquidCoefficient - liquid-side volumetric heat-transfer coefficient in W/(m3 K)
      Returns:
      overall volumetric heat-transfer coefficient in W/(m3 K)
    • calculateInterfaceTemperature

      private double calculateInterfaceTemperature(double gasTemperature, double liquidTemperature, double gasCoefficient, double liquidCoefficient)
      Calculate an interfacial temperature estimate from heat-transfer resistances.
      Parameters:
      gasTemperature - gas bulk temperature in K
      liquidTemperature - liquid bulk temperature in K
      gasCoefficient - gas-side heat-transfer coefficient in W/(m3 K)
      liquidCoefficient - liquid-side heat-transfer coefficient in W/(m3 K)
      Returns:
      estimated interface temperature in K
    • heatCapacityMass

      private double heatCapacityMass(PhaseInterface phase, double fallback)
      Get heat capacity on a mass basis.
      Parameters:
      phase - phase to inspect
      fallback - fallback heat capacity in J/(kg K)
      Returns:
      heat capacity in J/(kg K)
    • phaseMolarEnthalpy

      private double phaseMolarEnthalpy(PhaseInterface phase)
      Get phase molar enthalpy.
      Parameters:
      phase - phase to inspect
      Returns:
      molar enthalpy in J/mol
    • componentMolarEnthalpy

      private double componentMolarEnthalpy(PhaseInterface phase, String component, double temperature, double fallback)
      Get component molar enthalpy at an interface temperature.
      Parameters:
      phase - phase to inspect
      component - component name
      temperature - temperature in kelvin
      fallback - fallback molar enthalpy in J/mol
      Returns:
      component molar enthalpy in J/mol
    • thermalConductivity

      private double thermalConductivity(PhaseInterface phase, double fallback)
      Get phase thermal conductivity.
      Parameters:
      phase - phase to inspect
      fallback - fallback thermal conductivity in W/(m K)
      Returns:
      thermal conductivity in W/(m K)
    • heatCapacityRate

      private double heatCapacityRate(PhaseInterface phase, double heatCapacity)
      Calculate phase heat-capacity rate.
      Parameters:
      phase - phase to inspect
      heatCapacity - heat capacity in J/(kg K)
      Returns:
      heat-capacity rate in W/K
    • componentIndex

      private int componentIndex(PhaseInterface phase, String component)
      Find a component index in a phase.
      Parameters:
      phase - phase to inspect
      component - component name
      Returns:
      component index, or minus one if absent
    • moleFraction

      private double moleFraction(PhaseInterface phase, int componentIndex)
      Get a component mole fraction by component index.
      Parameters:
      phase - phase to inspect
      componentIndex - component index
      Returns:
      mole fraction, or zero if unavailable
    • binaryFilmCoefficient

      private double binaryFilmCoefficient(PhaseInterface phase, int firstComponent, int secondComponent, double baseCoefficient, double referenceDiffusivity, boolean gasPhase)
      Calculate a binary film coefficient by diffusivity scaling.
      Parameters:
      phase - phase to inspect
      firstComponent - first component index
      secondComponent - second component index
      baseCoefficient - scalar packed-bed film coefficient
      referenceDiffusivity - reference diffusivity in m2/s
      gasPhase - true for gas fallback diffusivity
      Returns:
      binary film coefficient in 1/s
    • scaleFilmCoefficient

      private double scaleFilmCoefficient(double baseCoefficient, double diffusivity, double referenceDiffusivity)
      Scale a film coefficient by diffusivity relative to a reference value.
      Parameters:
      baseCoefficient - scalar packed-bed film coefficient
      diffusivity - component or binary diffusivity in m2/s
      referenceDiffusivity - reference diffusivity in m2/s
      Returns:
      scaled film coefficient in 1/s
    • mixtureDiffusivityForComponent

      private double mixtureDiffusivityForComponent(PhaseInterface phase, int componentIndex, double referenceDiffusivity, boolean gasPhase)
      Calculate a mixture diffusivity for one component.
      Parameters:
      phase - phase to inspect
      componentIndex - component index
      referenceDiffusivity - reference diffusivity in m2/s
      gasPhase - true for gas fallback diffusivity
      Returns:
      mixture diffusivity in m2/s
    • binaryDiffusivity

      private double binaryDiffusivity(PhaseInterface phase, int firstComponent, int secondComponent, double referenceDiffusivity, boolean gasPhase)
      Get a binary diffusion coefficient from NeqSim physical properties.
      Parameters:
      phase - phase to inspect
      firstComponent - first component index
      secondComponent - second component index
      referenceDiffusivity - reference diffusivity in m2/s
      gasPhase - true for gas fallback diffusivity
      Returns:
      binary diffusivity in m2/s
    • calculateOutletResidual

      private double calculateOutletResidual(SystemInterface previousGas, SystemInterface currentGas, SystemInterface previousLiquid, SystemInterface currentLiquid)
      Calculate residual between previous and current outlets.
      Parameters:
      previousGas - previous gas outlet, or null on the first iteration
      currentGas - current gas outlet
      previousLiquid - previous liquid outlet, or null on the first iteration
      currentLiquid - current liquid outlet
      Returns:
      maximum absolute component residual in mol/s
    • flashAndInitialize

      private void flashAndInitialize(SystemInterface system)
      Flash and initialize a thermodynamic system including physical properties.
      Parameters:
      system - thermodynamic system to initialize
    • getGasPhase

      private PhaseInterface getGasPhase(SystemInterface system)
      Get the gas phase from a system.
      Parameters:
      system - thermodynamic system
      Returns:
      gas phase if present, otherwise phase zero
    • getLiquidPhase

      private PhaseInterface getLiquidPhase(SystemInterface system)
      Get the liquid phase from a system.
      Parameters:
      system - thermodynamic system
      Returns:
      liquid-like phase if present, otherwise phase zero
    • averageDiffusivity

      private double averageDiffusivity(PhaseInterface phase, boolean gasPhase)
      Estimate average diffusivity for a phase.
      Parameters:
      phase - phase to inspect
      gasPhase - true for gas fallback values, false for liquid fallback values
      Returns:
      finite diffusivity in m2/s
    • estimateSurfaceTension

      private double estimateSurfaceTension(SystemInterface gas, SystemInterface liquid)
      Estimate surface tension between the segment gas and liquid phases.
      Parameters:
      gas - gas system
      liquid - liquid system
      Returns:
      surface tension in N/m
    • addSystemComponents

      private void addSystemComponents(SystemInterface target, SystemInterface source)
      Add all positive-mole components from a source system to a target system.
      Parameters:
      target - target system receiving component moles
      source - source system providing component moles
    • refreshComponentDatabase

      private void refreshComponentDatabase(SystemInterface system)
      Refresh database and mixing-rule matrices after adding components to a cloned system.
      Parameters:
      system - thermodynamic system to refresh
    • getLiquidPhaseNumber

      private int getLiquidPhaseNumber(SystemInterface system)
      Get the first liquid-like phase number in a system.
      Parameters:
      system - thermodynamic system
      Returns:
      liquid phase number, or minus one if no liquid-like phase exists
    • molarConcentration

      private double molarConcentration(PhaseInterface phase)
      Calculate phase molar concentration.
      Parameters:
      phase - phase to inspect
      Returns:
      molar concentration in mol/m3
    • moleFraction

      private double moleFraction(PhaseInterface phase, String component)
      Get a component mole fraction in a phase.
      Parameters:
      phase - phase to inspect
      component - component name
      Returns:
      mole fraction, or zero if the component is absent
    • componentMoles

      private double componentMoles(SystemInterface system, String component)
      Get total component moles in a system.
      Parameters:
      system - thermodynamic system
      component - component name
      Returns:
      component moles in the system
    • getComponentNames

      private List<String> getComponentNames(SystemInterface system)
      Get component names from a thermodynamic system.
      Parameters:
      system - thermodynamic system
      Returns:
      component names in insertion order
    • getTransferComponentList

      private List<String> getTransferComponentList(SystemInterface gas, SystemInterface liquid)
      Get the active transfer component list.
      Parameters:
      gas - gas system
      liquid - liquid system
      Returns:
      active component names
    • validatePositive

      private void validatePositive(double value, String name)
      Validate a positive finite value.
      Parameters:
      value - numeric value
      name - field name for error messages
      Throws:
      IllegalArgumentException - if the value is not positive and finite
    • validateNonNegative

      private void validateNonNegative(double value, String name)
      Validate a non-negative finite value.
      Parameters:
      value - numeric value
      name - field name for error messages
      Throws:
      IllegalArgumentException - if the value is negative or not finite
    • isFinitePositive

      private boolean isFinitePositive(double value)
      Check whether a double is positive and finite.
      Parameters:
      value - value to check
      Returns:
      true if the value is finite and positive
    • finitePositive

      private double finitePositive(double value, double fallback)
      Replace invalid values with a fallback.
      Parameters:
      value - value to check
      fallback - fallback value
      Returns:
      value if positive and finite, otherwise fallback
    • finiteNonNegative

      private double finiteNonNegative(double value, double fallback)
      Replace invalid or negative values with a fallback.
      Parameters:
      value - value to check
      fallback - fallback value
      Returns:
      value if non-negative and finite, otherwise fallback
    • clamp

      private double clamp(double value, double min, double max)
      Clamp a value between lower and upper bounds.
      Parameters:
      value - value to clamp
      min - lower bound
      max - upper bound
      Returns:
      clamped value