Class DistillationColumn
- All Implemented Interfaces:
Serializable, Runnable, DistillationInterface, ProcessEquipmentInterface, ProcessElementInterface, SimulationInterface, NamedInterface
- Direct Known Subclasses:
PackedColumn, ScrubColumn
The column is solved using a sequential substitution approach. The init() method sets
initial tray temperatures by running the feed tray and linearly distributing temperatures towards
the top and bottom. During run(UUID) the trays are iteratively solved in upward and
downward sweeps until the summed temperature change between iterations is below the configured
temperatureTolerance or the iteration limit is reached.
- Author:
- esol
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFluent builder forDistillationColumn.(package private) static classSimplified K-value model for the inside-out inner loop.static enumAvailable solving strategies for the column. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ColumnSpecificationColumn specification for the bottom (reboiler) end.(package private) double(package private) doubleprivate doubleprivate List<double[]> Per-iteration convergence history: [iteration][0=tempErr, 1=massErr, 2=energyErr].private static final doubleRecommended base enthalpy balance tolerance for adaptive defaults.private static final doubleRecommended base mass balance tolerance for adaptive defaults.private static final doubleDefault scaled MESH residual tolerance when residual gating is enabled.private static final doubleRecommended base temperature tolerance for adaptive defaults.(package private) ProcessSystemprivate booleanprivate booleanprivate booleanWhether the dynamic tray model is enabled for transient simulation.private booleanWhether per-tray energy balance is active (uses PH flash instead of TP).private static final doubleTarget relative energy imbalance for the post-processing polish stage.private booleanControl whether energy residual must satisfy tolerance before convergence.private booleanControl whether the MESH residual vector must satisfy tolerance before convergence.private doubleEnthalpy balance convergence tolerance.private booleanTrack whether enthalpy balance tolerance has been manually overridden.private doubleError measure used in solver to check convergence in run().(package private) Mixerprivate Map<Integer, List<StreamInterface>> Instead of Map<Integer,StreamInterface>, we store a list of feed streams per tray number.(package private) StreamInterfaceprivate booleanFlag tracking whether the column has been solved at least once.(package private) boolean(package private) boolean(package private) Heaterprivate intNumber of simplified inner-loop iterations between rigorous flash updates in the IO solver.private doubleprivate static final intMultiplier governing how much the solver can extend beyond the nominal iteration budget.private doubleLast reported bottom specification residual.private doubleLast recorded relative enthalpy residual.private intLast number of iterations executed by the active solver.private doubleLast recorded relative mass balance residual.private ColumnMeshResidualLatest MESH residual diagnostics.private doubleDuration of the latest solve step in seconds.private doubleLast recorded average temperature residual in Kelvin.private doubleLast reported top specification residual.private doubleTotal feed flow (kg/hr) recorded at the end of the previous solve.(package private) StreamInterface(package private) static org.apache.logging.log4j.LoggerLogger object for class.private static final doubleTarget relative mass imbalance for the post-processing polish stage.private doubleMass balance convergence tolerance.private booleanTrack whether mass balance tolerance has been manually overridden.private static final intMaximum number of entries stored in the convergence history list.private doubleMaximum relaxation factor allowed by the adaptive controller.private doubleCap applied to energy residual when adjusting relaxation.(package private) intMechanical design for the distillation column.private doubleScaled MESH residual convergence tolerance.private doubleMinimum relaxation factor allowed for the inside-out tear streams.private doubleMinimum relaxation factor used when adaptive damping scales down the sequential step.private doubleMinimum relaxation applied when blending tray temperatures.private doubleMurphree tray efficiency applied to each equilibrium stage (0..1).(package private) intprivate static final intExtra iterations granted when a polish stage is triggered.private booleanWhentrue, trays in the reactive section useReactiveTray(simultaneous chemical + phase equilibrium via the Modified RAND method) instead of standard VLESimpleTray.private intLast tray index (0-based, inclusive) of the reactive section.private intFirst tray index (0-based, inclusive) of the reactive section.private doubleprivate doubleFactor used to shrink the relaxation factor when residuals grow.private doubleRelaxation factor used whenDistillationColumn.SolverType.DAMPED_SUBSTITUTIONis active.private doubleFactor used to expand the relaxation factor when residuals shrink.(package private) Separatorprivate static final longSerialization version UID.private DistillationColumn.SolverTypeSelected solver algorithm.(package private) StreamInterface(package private) booleanprivate static final doubleTarget average temperature drift for the polishing stage in Kelvin.private doubleTemperature convergence tolerance.private booleanTrack whether temperature tolerance has been manually overridden.private ColumnSpecificationColumn specification for the top (condenser) end.(package private) doubleprivate static final doubleScaling factor used to derive a tray-proportional iteration budget.private doubleDry tray pressure drop in Pa per tray — for vapor hydraulic model.private double[]Per-tray enthalpy in J.private double[]Liquid holdup per tray in moles.protected ArrayList<SimpleTray> private doubleWeir height on each tray in metres.private doubleWeir length (crest length) on each tray in metres.private List<StreamInterface> Fields inherited from class ProcessEquipmentBaseClass
conditionAnalysisMessage, energyStream, hasController, isSolved, properties, reportFields inherited from class SimulationBaseClass
calcIdentifier, calculateSteadyState, timeFields inherited from class NamedBaseClass
name -
Constructor Summary
ConstructorsConstructorDescriptionDistillationColumn(String name, int numberOfTraysLocal, boolean hasReboiler, boolean hasCondenser) Constructor for DistillationColumn. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFeedStream(StreamInterface inputStream) Add a feed stream to the column without specifying the tray.voidaddFeedStream(StreamInterface inputStream, int feedTrayNumber) Add a feed stream to the specified tray.private voidApply a specification that does not require an outer iteration.private voidApply specifications that map directly to condenser or reboiler controls.private voidapplyMurphreeCorrection(int trayIndex) Apply Murphree tray efficiency correction to the vapor leaving a tray.private StreamInterfaceapplyRelaxation(StreamInterface previous, StreamInterface current, double relaxation) Blend the current stream update with the previous iterate using the provided relaxation factor.private voidstatic DistillationColumn.BuilderCreates a new Builder for constructing a DistillationColumn with a fluent API.private double[][]Cache K-values (y/x) for all components on all trays for use in the next iteration comparison.Create and run a column internals designer for this column with default sieve trays.calcColumnInternals(String internalsType) Create and run a column internals designer for this column.booleancomponentMassBalanceCheck(String componentName) Check mass balance for a specific component.private intDetermine the iteration limit based on configuration and column size.private doublecomputeKvalueResidual(double[][] previousKvalues) Compute the maximum relative K-value change compared to the previous iteration.private doubleCompute the average absolute temperature residual across all trays.private doubleEstimate a scaling factor that reflects the degree of distillation complexity.private SimpleTraycreateMiddleTray(String name, int middleTrayIndex) Create a middle tray (between reboiler and condenser).voiddisplayResult.voidPrints a simple energy balance for each tray to the console.private doubleEstimate a representative feed temperature from the assigned feed streams.private doubleEvaluate how far the current column solution is from satisfying a specification.private doubleEvaluate a specification residual for diagnostics without interrupting a solve.private voidfinalizeSolve(UUID id, int iterations, double temperatureResidual, double massResidual, double energyResidual, long startTime) Finalise a successful solver run by updating iteration metrics and product streams.intfindOptimalNumberOfTrays(double productSpec, String componentName, boolean isTopProduct, int maxTrays) Find the optimal number of trays to meet a product specification.Returns the bottom (reboiler) column specification.getCondenser.doubleGetter for the fieldcondenserTemperature.List<double[]> Return the per-iteration convergence history from the most recent solve.private doubleDerive the effective enthalpy balance tolerance based on column complexity unless overridden.private doubleDerive the effective mass balance tolerance based on column complexity unless overridden.private intCount the number of simple trays, excluding optional reboiler and condenser sections.private doubleDerive the effective temperature tolerance based on column complexity unless overridden.doubleCalculates the relative enthalpy imbalance across all trays.doubleAccess the configured relative enthalpy balance tolerance.getFeedStreams(int feedTrayNumber) Return the feed streams connected to a given tray.doubleCalculates the Fs factor for the distillation column.Getter for the fieldgasOutStream.intReturn the current number of simplified inner-loop iterations per outer flash update.doubleGetter for the fieldinternalDiameter.doubleRetrieve the latest bottom specification residual.doubleRetrieve the latest relative enthalpy residual.intRetrieve the iteration count of the most recent solve.doubleRetrieve the latest relative mass residual.doubleRetrieve the latest MESH energy residual infinity norm.doubleRetrieve the latest MESH equilibrium residual infinity norm.doubleRetrieve the latest MESH material residual infinity norm.(package private) ColumnMeshResidualRetrieve the latest internal MESH residual diagnostics.doubleRetrieve the latest MESH residual vector infinity norm.private doublegetLastMeshResidualNorm(ColumnMeshEquationType equationType) Get a MESH residual norm by equation type.double[]Retrieve a copy of the latest MESH residual vector.doubleRetrieve the latest MESH specification residual infinity norm.doubleRetrieve the latest MESH summation residual infinity norm.doubleRetrieve the duration of the most recent solve in seconds.doubleRetrieve the largest absolute active specification residual.doubleRetrieve the latest average temperature residual in Kelvin.doubleRetrieve the latest top specification residual.Getter for the fieldliquidOutStream.doublegetMassBalance(String unit) getMassBalance.doubleCalculate the relative mass balance error across the column.doubleAccess the configured relative mass balance tolerance.Get amechanicalDesignfor the equipment.doubleAccess the configured scaled MESH residual tolerance.doubleRetrieve the current Murphree tray efficiency.intgetNumerOfTrays.getReboiler.doubleGetter for the fieldreboilerTemperature.Retrieve the currently selected solver type.doubleAccess the configured average temperature tolerance.Returns the top (condenser) column specification.private doublegetTotalFeedComponentFlow(String componentName) Calculate the total feed flow of a named component across all feed streams.private intCount connected feed streams across all trays.getTray(int trayNumber) getTray.doubleReturns the dry tray pressure drop per tray in Pa.double[]Returns the per-tray enthalpy array in J.double[]Returns the liquid holdup array (moles per tray).getTrays()Returns the list of trays in this column.doubleGets the weir height for all trays.doubleGets the weir crest length for all trays.private booleanCheck whether any configured column specification requires iterative adjustment.voidinit()Prepare the column for calculation by estimating tray temperatures and linking streams between trays.voidInitialize ainitMechanicalDesignfor the equipment.private doubleinnerLoopIteration(DistillationColumn.SimplifiedKvalueModel model, double relaxation) Perform a simplified inner-loop iteration using the K-value model instead of rigorous flash.booleanisDoInitializion.booleanGetter for the fielddoMultiPhaseCheck.booleanReturns whether the dynamic tray-by-tray model is enabled.booleanReturns whether the per-tray energy balance is enabled.booleanCheck if the solver currently enforces the energy balance tolerance during convergence checks.booleanCheck if convergence requires the latest MESH residual vector to satisfy tolerance.private booleanisInReactiveSection(int middleTrayIndex) Check whether a middle-tray index falls inside the reactive section.booleanCheck whether reactive distillation mode is enabled.static voidThe main method demonstrates the creation and operation of a distillation column using the NeqSim library.booleanCheck mass balance for all components.private booleanCheck whether the latest MESH residual satisfies the optional convergence gate.private booleanChecks whether a specification requires iterative temperature adjustment.private voidperformFullTraySweep(UUID id, int firstFeedTrayNumber, StreamInterface[] previousGasStreams, StreamInterface[] previousLiquidStreams, double relaxation) Perform a full upward+downward tray sweep, running PH-flash on each tray.private intPrepare the column for a solving sequence by updating pressures and cloning feed systems.private voidrecordConvergence(double[] entry) Append a residual snapshot to the convergence history, capping atMAX_CONVERGENCE_HISTORYentries.private voidUpdate the reactive flash flag on middle trays to match the current reactive mode configuration.private voidReset cached solve metrics when no calculation is performed.voidRestore adaptive default tolerances, discarding manual overrides.voidIn this method all thermodynamic and unit operations will be calculated in a steady state calculation.voidrunBroyden(UUID id) Solve the column using a simple Broyden mixing of tray temperatures.voidrunTransient(double dt, UUID id) runTransientprivate doublesecantStep(double t0, double t1, double f0, double f1, double feedTemp) Compute the secant method step for temperature adjustment, with safeguards.voidsetBottomPressure(double bottomPressure) setBottomPressure.voidsetBottomProductFlowRate(double flowRate, String unit) Convenience method to specify a target molar flow rate for the bottom product.voidsetBottomProductPurity(String componentName, double purity) Convenience method to specify a target mole fraction purity for the bottom product.voidSets the bottom column specification with location validation.voidsetCondenserRefluxRatio(double refluxRatio) Sets the reflux ratio on the condenser (if present).voidsetCondenserTemperature(double condenserTemperature) Setter for the fieldcondenserTemperature.voidsetDoInitializion(boolean doInitializion) Setter for the fielddoInitializion.voidsetDynamicColumnEnabled(boolean enabled) Enables or disables the dynamic tray-by-tray model for transient simulation.voidsetDynamicEnergyEnabled(boolean enabled) Enables or disables the per-tray energy balance in dynamic mode.voidsetEnforceEnergyBalanceTolerance(boolean enforce) Control whether the solver enforces the energy balance tolerance when determining convergence.voidsetEnforceMeshResidualTolerance(boolean enforce) Control whether the latest MESH residual vector must satisfy tolerance during convergence checks.voidsetEnthalpyBalanceTolerance(double tol) Set enthalpy balance convergence tolerance.(package private) voidsetError(double err) voidsetInnerLoopSteps(int steps) Set the number of simplified inner-loop iterations between rigorous flash updates in the IO solver.voidsetInternalDiameter(double internalDiameter) Setter for the fieldinternalDiameter.voidsetMassBalanceTolerance(double tol) Set mass balance convergence tolerance.voidsetMaxNumberOfIterations(int maxIter) Setter for the fieldmaxNumberOfIterations.voidsetMeshResidualTolerance(double tol) Set the scaled MESH residual tolerance used when MESH residual gating is enabled.voidsetMultiPhaseCheck(boolean doMultiPhaseCheck) Setter for the fielddoMultiPhaseCheck.voidsetMurphreeEfficiency(double efficiency) Set the Murphree tray efficiency for all stages.voidsetNumberOfTrays(int number) setNumberOfTrays.voidsetReactive(boolean reactive) Enable or disable reactive distillation for all middle trays.voidsetReactive(boolean reactive, int startTray, int endTray) Enable reactive distillation on a specific section of middle trays.voidsetReboilerBoilupRatio(double boilupRatio) Convenience method to specify a reboiler boilup ratio (V/B).voidsetReboilerTemperature(double reboilerTemperature) Setter for the fieldreboilerTemperature.voidsetRelaxationFactor(double relaxationFactor) Set relaxation factor for the damped solver.voidsetSolverType(DistillationColumn.SolverType solverType) Select the algorithm used when solving the column.voidsetTemperatureTolerance(double tol) Set temperature convergence tolerance.voidsetTopComponentRecovery(String componentName, double recovery) Convenience method to specify a target component recovery in the top product.voidsetTopCondenserDuty(double duty) setTopCondenserDuty.voidsetTopPressure(double topPressure) setTopPressure.voidsetTopProductPurity(String componentName, double purity) Convenience method to specify a target mole fraction purity for the top product.voidSets the top column specification with location validation.voidsetTrayDryPressureDrop(double dpPa) Sets the dry tray pressure drop per tray in Pa.voidsetTrayWeirHeight(double weirHeight) Sets the weir height for all trays (used in Francis weir overflow).voidsetTrayWeirLength(double weirLength) Sets the weir crest length for all trays.private booleanshouldEvaluateBalances(int iteration, int iterationLimit, boolean polishing, double tempResidual, double baseTempTolerance, int balanceCheckStride) Decide whether mass and energy balance residuals should be recomputed this iteration.booleansolved()Returns whether or not the module has been solved.(package private) voidSolve using damped substitution and the configured relaxation factor.(package private) voidSolve using direct substitution.private voidsolveInner(UUID id) Run the inner column solver (one full solve with the currently selected solver type) without resetting convergence history.(package private) voidsolveInsideOut(UUID id) Solve the column using an improved inside-out strategy inspired by Boston and Sullivan (1974).private double[]solveLinearSystem(double[][] matrixA, double[] vectorB) Solve a dense linear system Ax = b using Gaussian elimination with partial pivoting.(package private) voidSolve using inside-out initialization and temperature-Newton polishing while reporting MESH residual diagnostics.(package private) voidsolveNewton(UUID id) Solve the column using a Newton-Raphson simultaneous temperature correction method.private ColumnSolveResultSolve the column using the currently selected inner solver.private voidsolveSequential(UUID id, double initialRelaxation) Execute the sequential substitution solver with an adaptive relaxation controller.(package private) voidsolveSumRates(UUID id) Solve the column using a sum-rates tearing method.(package private) voidsolveWegstein(UUID id) Solve the column using Wegstein acceleration of successive substitution.private voidSolve the column with an outer loop that adjusts condenser/reboiler temperatures to satisfy product specifications.private booleanCheck whether a single column specification is satisfied.private booleanCheck whether all active column specifications are within their configured tolerance.toJson()Serializes the Process Equipment along with its state to a JSON string.toJson(ReportConfig cfg) Serializes the Process Equipment with configurable level of detail.private voidUpdate the stored MESH residual diagnostics for the current column state.(package private) voidUpdate the stored specification residuals for package-level diagnostics.private voidUpdate the stored residuals for the currently configured column specifications.Validate the process equipment before execution.Methods inherited from class ProcessEquipmentBaseClass
addCapacityConstraint, addController, copy, equals, getAvailableMargin, getAvailableMarginPercent, getBottleneckConstraint, getCapacityConstraints, getConditionAnalysisMessage, getConstraintEvaluationReport, getController, getController, getControllers, getEffectiveCapacityFactor, getEnergyStream, getEntropyProduction, getExergyChange, getFailureMode, getMassBalance, getMaxUtilization, getMaxUtilizationPercent, getMinimumFlow, getPressure, getPressure, getProperty, getReferenceDesignation, getReport_json, getResultTable, getSpecification, getTemperature, getTemperature, getThermoSystem, getUtilizationSummary, hashCode, initElectricalDesign, initializeDefaultConstraints, initInstrumentDesign, isActive, isActive, isCapacityAnalysisEnabled, isCapacityExceeded, isFailed, isHardLimitExceeded, isNearCapacityLimit, isSetEnergyStream, reportResults, restoreFromFailure, run_step, runConditionAnalysis, setCapacityAnalysisEnabled, setController, setEnergyStream, setEnergyStream, setFailureMode, setFlowValveController, setMinimumFlow, setPressure, setReferenceDesignation, setRegulatorOutSignal, setSpecification, setTemperature, simulateDegradedOperation, simulateTripMethods inherited from class SimulationBaseClass
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTimeMethods inherited from class NamedBaseClass
getName, getTagNumber, setName, setTagNumberMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NamedInterface
getName, getTagName, getTagNumber, setName, setTagName, setTagNumberMethods inherited from interface ProcessEquipmentInterface
addCapacityConstraint, addController, equals, getAvailableMargin, getAvailableMarginPercent, getBottleneckConstraint, getCapacityConstraints, getCapacityDuty, getCapacityMax, getConditionAnalysisMessage, getController, getController, getControllers, getElectricalDesign, getEntropyProduction, getEquipmentState, getExergyChange, getExergyChange, getExergyDestruction, getExergyDestruction, getFluid, getInletStreams, getInstrumentDesign, getMassBalance, getMaxUtilization, getMaxUtilizationPercent, getOperatingEnvelopeViolation, getOutletFlowRate, getOutletPressure, getOutletStreams, getOutletTemperature, getPressure, getPressure, getReferenceDesignation, getReferenceDesignationString, getReport_json, getRestCapacity, getResultTable, getSimulationValidationErrors, getSpecification, getTemperature, getTemperature, getThermoSystem, getUtilizationSummary, hashCode, initElectricalDesign, initInstrumentDesign, isCapacityExceeded, isHardLimitExceeded, isNearCapacityLimit, isSimulationValid, isWithinOperatingEnvelope, needRecalculation, reportResults, runConditionAnalysis, setController, setPressure, setReferenceDesignation, setRegulatorOutSignal, setSpecification, setTemperatureMethods inherited from interface SimulationInterface
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, run, run_step, run_step, runTransient, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTime
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
logger
static org.apache.logging.log4j.Logger loggerLogger object for class. -
doInitializion
private boolean doInitializion -
hasReboiler
boolean hasReboiler -
hasCondenser
boolean hasCondenser -
trays
-
TRAY_ITERATION_FACTOR
private static final double TRAY_ITERATION_FACTORScaling factor used to derive a tray-proportional iteration budget.- See Also:
-
MASS_POLISH_TARGET
private static final double MASS_POLISH_TARGETTarget relative mass imbalance for the post-processing polish stage.- See Also:
-
ENERGY_POLISH_TARGET
private static final double ENERGY_POLISH_TARGETTarget relative energy imbalance for the post-processing polish stage.- See Also:
-
TEMPERATURE_POLISH_TARGET
private static final double TEMPERATURE_POLISH_TARGETTarget average temperature drift for the polishing stage in Kelvin.- See Also:
-
POLISH_ITERATION_MARGIN
private static final int POLISH_ITERATION_MARGINExtra iterations granted when a polish stage is triggered.- See Also:
-
ITERATION_OVERFLOW_MULTIPLIER
private static final int ITERATION_OVERFLOW_MULTIPLIERMultiplier governing how much the solver can extend beyond the nominal iteration budget.- See Also:
-
DEFAULT_TEMPERATURE_TOLERANCE
private static final double DEFAULT_TEMPERATURE_TOLERANCERecommended base temperature tolerance for adaptive defaults.- See Also:
-
DEFAULT_MASS_BALANCE_TOLERANCE
private static final double DEFAULT_MASS_BALANCE_TOLERANCERecommended base mass balance tolerance for adaptive defaults.- See Also:
-
DEFAULT_ENTHALPY_BALANCE_TOLERANCE
private static final double DEFAULT_ENTHALPY_BALANCE_TOLERANCERecommended base enthalpy balance tolerance for adaptive defaults.- See Also:
-
DEFAULT_MESH_RESIDUAL_TOLERANCE
private static final double DEFAULT_MESH_RESIDUAL_TOLERANCEDefault scaled MESH residual tolerance when residual gating is enabled.- See Also:
-
condenserCoolingDuty
double condenserCoolingDuty -
reboilerTemperature
private double reboilerTemperature -
condenserTemperature
private double condenserTemperature -
topTrayPressure
double topTrayPressure -
temperatureTolerance
private double temperatureToleranceTemperature convergence tolerance. -
massBalanceTolerance
private double massBalanceToleranceMass balance convergence tolerance. -
enthalpyBalanceTolerance
private double enthalpyBalanceToleranceEnthalpy balance convergence tolerance. -
meshResidualTolerance
private double meshResidualToleranceScaled MESH residual convergence tolerance. -
temperatureToleranceCustomized
private boolean temperatureToleranceCustomizedTrack whether temperature tolerance has been manually overridden. -
massBalanceToleranceCustomized
private boolean massBalanceToleranceCustomizedTrack whether mass balance tolerance has been manually overridden. -
enthalpyBalanceToleranceCustomized
private boolean enthalpyBalanceToleranceCustomizedTrack whether enthalpy balance tolerance has been manually overridden. -
solverType
Selected solver algorithm. Defaults to direct substitution. -
relaxationFactor
private double relaxationFactorRelaxation factor used whenDistillationColumn.SolverType.DAMPED_SUBSTITUTIONis active. -
minSequentialRelaxation
private double minSequentialRelaxationMinimum relaxation factor used when adaptive damping scales down the sequential step. -
minInsideOutRelaxation
private double minInsideOutRelaxationMinimum relaxation factor allowed for the inside-out tear streams. -
maxAdaptiveRelaxation
private double maxAdaptiveRelaxationMaximum relaxation factor allowed by the adaptive controller. -
relaxationIncreaseFactor
private double relaxationIncreaseFactorFactor used to expand the relaxation factor when residuals shrink. -
relaxationDecreaseFactor
private double relaxationDecreaseFactorFactor used to shrink the relaxation factor when residuals grow. -
minTemperatureRelaxation
private double minTemperatureRelaxationMinimum relaxation applied when blending tray temperatures. -
maxEnergyRelaxationWeight
private double maxEnergyRelaxationWeightCap applied to energy residual when adjusting relaxation. -
enforceEnergyBalanceTolerance
private boolean enforceEnergyBalanceToleranceControl whether energy residual must satisfy tolerance before convergence. -
enforceMeshResidualTolerance
private boolean enforceMeshResidualToleranceControl whether the MESH residual vector must satisfy tolerance before convergence. -
doMultiPhaseCheck
private boolean doMultiPhaseCheck -
reactive
private boolean reactiveWhentrue, trays in the reactive section useReactiveTray(simultaneous chemical + phase equilibrium via the Modified RAND method) instead of standard VLESimpleTray. Set this before the firstSimulationInterface.run()call. -
reactiveStartTray
private int reactiveStartTrayFirst tray index (0-based, inclusive) of the reactive section. A value of-1means all middle trays (i.e. excluding reboiler/condenser) are reactive. -
reactiveEndTray
private int reactiveEndTrayLast tray index (0-based, inclusive) of the reactive section. A value of-1means all middle trays are reactive. -
hasBeenSolvedBefore
private transient boolean hasBeenSolvedBeforeFlag tracking whether the column has been solved at least once. Used to seed the sequential solver with the previous tray state on re-runs, preventing divergence from an unrelaxed start. -
lastTotalFeedFlow
private transient double lastTotalFeedFlowTotal feed flow (kg/hr) recorded at the end of the previous solve. Used to detect whether the column needs to re-solve or can reuse the previous result. -
mechanicalDesign
Mechanical design for the distillation column. -
topSpecification
Column specification for the top (condenser) end. -
bottomSpecification
Column specification for the bottom (reboiler) end. -
feedmixer
Mixer feedmixer -
bottomTrayPressure
double bottomTrayPressure -
numberOfTrays
int numberOfTrays -
maxNumberOfIterations
int maxNumberOfIterations -
stream_3
StreamInterface stream_3 -
gasOutStream
StreamInterface gasOutStream -
liquidOutStream
StreamInterface liquidOutStream -
stream_3isset
boolean stream_3isset -
internalDiameter
private double internalDiameter -
distoperations
ProcessSystem distoperations -
heater
Heater heater -
separator2
Separator separator2 -
err
private double errError measure used in solver to check convergence in run(). -
lastIterationCount
private int lastIterationCountLast number of iterations executed by the active solver. -
lastTemperatureResidual
private double lastTemperatureResidualLast recorded average temperature residual in Kelvin. -
lastMassResidual
private double lastMassResidualLast recorded relative mass balance residual. -
lastEnergyResidual
private double lastEnergyResidualLast recorded relative enthalpy residual. -
lastTopSpecificationResidual
private double lastTopSpecificationResidualLast reported top specification residual. -
lastBottomSpecificationResidual
private double lastBottomSpecificationResidualLast reported bottom specification residual. -
lastMeshResidual
Latest MESH residual diagnostics. -
lastSolveTimeSeconds
private double lastSolveTimeSecondsDuration of the latest solve step in seconds. -
feedStreams
Instead of Map<Integer,StreamInterface>, we store a list of feed streams per tray number. This allows multiple feeds to the same tray. -
unassignedFeedStreams
-
murphreeEfficiency
private double murphreeEfficiencyMurphree tray efficiency applied to each equilibrium stage (0..1). Default 1.0 = ideal. -
convergenceHistory
Per-iteration convergence history: [iteration][0=tempErr, 1=massErr, 2=energyErr]. -
innerLoopSteps
private int innerLoopStepsNumber of simplified inner-loop iterations between rigorous flash updates in the IO solver. Higher values reduce flash count but may reduce accuracy. Default 3. -
dynamicColumnEnabled
private boolean dynamicColumnEnabledWhether the dynamic tray model is enabled for transient simulation. -
trayLiquidHoldup
private transient double[] trayLiquidHoldupLiquid holdup per tray in moles. Indexed by tray number. -
trayWeirHeight
private double trayWeirHeightWeir height on each tray in metres. -
trayWeirLength
private double trayWeirLengthWeir length (crest length) on each tray in metres. -
trayEnthalpy
private transient double[] trayEnthalpyPer-tray enthalpy in J. Indexed by tray number. Null until initialized. -
trayDryPressureDrop
private double trayDryPressureDropDry tray pressure drop in Pa per tray — for vapor hydraulic model. -
dynamicEnergyEnabled
private boolean dynamicEnergyEnabledWhether per-tray energy balance is active (uses PH flash instead of TP). -
MAX_CONVERGENCE_HISTORY
private static final int MAX_CONVERGENCE_HISTORYMaximum number of entries stored in the convergence history list.- See Also:
-
-
Constructor Details
-
DistillationColumn
public DistillationColumn(String name, int numberOfTraysLocal, boolean hasReboiler, boolean hasCondenser) Constructor for DistillationColumn.
- Parameters:
name- Name of distillation columnnumberOfTraysLocal- Number of SimpleTrays to add (excluding reboiler/condenser)hasReboiler- Set true to add reboilerhasCondenser- Set true to add Condenser
-
-
Method Details
-
setMultiPhaseCheck
public void setMultiPhaseCheck(boolean doMultiPhaseCheck) Setter for the field
doMultiPhaseCheck.- Parameters:
doMultiPhaseCheck- a boolean
-
isDoMultiPhaseCheck
public boolean isDoMultiPhaseCheck()Getter for the field
doMultiPhaseCheck.- Returns:
- a boolean
-
addFeedStream
Add a feed stream to the specified tray. (Now allows multiple streams on the same trayNumber, using a list.)
- Parameters:
inputStream- the feed streamfeedTrayNumber- the tray number (0-based in the code) to which this feed goes
-
addFeedStream
Add a feed stream to the column without specifying the tray. The optimal feed tray will be determined automatically based on temperature match.- Parameters:
inputStream- the feed stream
-
getFeedStreams
Return the feed streams connected to a given tray.- Parameters:
feedTrayNumber- tray index where feeds are connected- Returns:
- immutable view of feed streams connected to the tray
-
init
public void init()Prepare the column for calculation by estimating tray temperatures and linking streams between trays.The feed tray is solved first to obtain a temperature estimate. This temperature is then used to linearly guess temperatures upwards to the condenser and downwards to the reboiler. Gas and liquid outlet streams are connected to neighbouring trays so that a subsequent call to
run(UUID)can iterate to convergence. -
run
In this method all thermodynamic and unit operations will be calculated in a steady state calculation.
Solve the column until tray temperatures converge. The method applies sequential substitution with an adaptive relaxation controller. Pressures are set linearly between bottom and top. Each iteration performs an upward sweep where liquid flows downward followed by a downward sweep where vapour flows upward. Tray temperatures and inter-tray stream flow rates are relaxed if the combined temperature, mass and energy residuals grow, providing basic line-search behaviour.
- Specified by:
runin interfaceSimulationInterface- Parameters:
id- UUID
-
applyDirectSpecifications
private void applyDirectSpecifications()Apply specifications that map directly to condenser or reboiler controls. -
applyDirectSpecification
Apply a specification that does not require an outer iteration.- Parameters:
spec- the specification to apply
-
hasAdjustableSpecifications
private boolean hasAdjustableSpecifications()Check whether any configured column specification requires iterative adjustment.- Returns:
truewhen an active product/recovery/flow specification is present
-
specificationsSatisfied
private boolean specificationsSatisfied()Check whether all active column specifications are within their configured tolerance.- Returns:
trueif all specifications are satisfied
-
updateSpecificationResiduals
private void updateSpecificationResiduals()Update the stored residuals for the currently configured column specifications. -
updateSpecificationResidualDiagnostics
void updateSpecificationResidualDiagnostics()Update the stored specification residuals for package-level diagnostics. -
updateMeshResiduals
private void updateMeshResiduals()Update the stored MESH residual diagnostics for the current column state. -
evaluateSpecErrorSafely
Evaluate a specification residual for diagnostics without interrupting a solve.- Parameters:
spec- the specification to evaluate- Returns:
- current residual, zero for no specification, or
Double.NaNif unavailable
-
specificationSatisfied
Check whether a single column specification is satisfied.- Parameters:
spec- the specification to evaluate- Returns:
trueif no residual check is needed or the residual is within tolerance
-
solveSelectedSolver
Solve the column using the currently selected inner solver.- Parameters:
id- calculation identifier
-
solveWithSpecifications
Solve the column with an outer loop that adjusts condenser/reboiler temperatures to satisfy product specifications. Uses a secant method for each specification that requires adjustment.- Parameters:
id- calculation identifier
-
secantStep
private double secantStep(double t0, double t1, double f0, double f1, double feedTemp) Compute the secant method step for temperature adjustment, with safeguards.- Parameters:
t0- previous temperaturet1- current temperaturef0- spec error at t0f1- spec error at t1feedTemp- reference feed temperature for bounding- Returns:
- the next temperature guess
-
needsAdjustment
Checks whether a specification requires iterative temperature adjustment.- Parameters:
spec- the column specification to check- Returns:
- true if the specification is non-null and requires adjustment
-
solveInner
Run the inner column solver (one full solve with the currently selected solver type) without resetting convergence history. Used bysolveWithSpecifications(UUID)in the outer adjustment loop.- Parameters:
id- calculation identifier
-
solveDirectSubstitution
Solve using direct substitution.- Parameters:
id- calculation identifier
-
solveDampedSubstitution
Solve using damped substitution and the configured relaxation factor.- Parameters:
id- calculation identifier
-
solveMeshResidual
Solve using inside-out initialization and temperature-Newton polishing while reporting MESH residual diagnostics.- Parameters:
id- calculation identifier
-
evaluateSpecError
Evaluate how far the current column solution is from satisfying a specification.- Parameters:
spec- the column specification to evaluate- Returns:
- the error (current value minus target value); zero when satisfied
-
getTotalFeedComponentFlow
Calculate the total feed flow of a named component across all feed streams.- Parameters:
componentName- the component name- Returns:
- total molar flow in mol/hr
-
estimateFeedTemperature
private double estimateFeedTemperature()Estimate a representative feed temperature from the assigned feed streams.- Returns:
- average feed temperature in Kelvin
-
assignUnassignedFeeds
private void assignUnassignedFeeds() -
findOptimalNumberOfTrays
public int findOptimalNumberOfTrays(double productSpec, String componentName, boolean isTopProduct, int maxTrays) Find the optimal number of trays to meet a product specification.- Parameters:
productSpec- the target purity (mole fraction) of the key componentcomponentName- the name of the key componentisTopProduct- true if the spec is for the top product (distillate), false for bottommaxTrays- the maximum number of trays to try- Returns:
- the optimal number of trays, or -1 if the spec could not be met
-
solveSequential
Execute the sequential substitution solver with an adaptive relaxation controller.- Parameters:
id- calculation identifierinitialRelaxation- relaxation factor applied to the first iteration
-
computeIterationLimit
private int computeIterationLimit()Determine the iteration limit based on configuration and column size.- Returns:
- maximum number of solver iterations allowed
-
getEffectiveTemperatureTolerance
private double getEffectiveTemperatureTolerance()Derive the effective temperature tolerance based on column complexity unless overridden.- Returns:
- adaptive temperature tolerance in Kelvin
-
getEffectiveMassBalanceTolerance
private double getEffectiveMassBalanceTolerance()Derive the effective mass balance tolerance based on column complexity unless overridden.- Returns:
- adaptive mass balance tolerance (relative)
-
getEffectiveEnthalpyBalanceTolerance
private double getEffectiveEnthalpyBalanceTolerance()Derive the effective enthalpy balance tolerance based on column complexity unless overridden.- Returns:
- adaptive energy balance tolerance (relative)
-
computeToleranceComplexityMultiplier
private double computeToleranceComplexityMultiplier()Estimate a scaling factor that reflects the degree of distillation complexity.The factor increases with the number of theoretical stages and independent feed streams and is bounded to avoid overly loose convergence criteria.
- Returns:
- scaling multiplier for recommended tolerances
-
getEffectiveStageCount
private int getEffectiveStageCount()Count the number of simple trays, excluding optional reboiler and condenser sections.- Returns:
- effective number of equilibrium stages
-
getTotalFeedCount
private int getTotalFeedCount()Count connected feed streams across all trays.- Returns:
- total number of feeds currently attached to the column
-
shouldEvaluateBalances
private boolean shouldEvaluateBalances(int iteration, int iterationLimit, boolean polishing, double tempResidual, double baseTempTolerance, int balanceCheckStride) Decide whether mass and energy balance residuals should be recomputed this iteration.- Parameters:
iteration- current iteration index (1-based)iterationLimit- current iteration ceilingpolishing- whether the solver is in the polish stagetempResidual- average temperature residual this iterationbaseTempTolerance- nominal temperature tolerancebalanceCheckStride- cadence for periodic balance checks- Returns:
trueif balances should be evaluated
-
prepareColumnForSolve
private int prepareColumnForSolve()Prepare the column for a solving sequence by updating pressures and cloning feed systems.- Returns:
- index of the lowest feed tray in the column
-
solveInsideOut
Solve the column using an improved inside-out strategy inspired by Boston and Sullivan (1974).Key improvements over basic sequential substitution:
- K-value caching: previous iteration K-values are stored to track composition convergence and detect stagnation early.
- Composition-based convergence: monitors maximum relative K-value change alongside temperature and balance residuals.
- Stripping factor correction: applies a bulk flow correction between outer iterations based on the ratio of computed-to-assumed vapor/liquid split on each tray.
- Accelerated relaxation ramp: increases relaxation faster (1.3× vs 1.2×) when residuals decrease, enabling the IO method to reach full step sooner.
- Lazy balance evaluation: mass/energy balances are only recomputed when temperatures are close to tolerance, reducing expensive per-tray flow rate queries.
- Parameters:
id- calculation identifier
-
computeKvalueResidual
private double computeKvalueResidual(double[][] previousKvalues) Compute the maximum relative K-value change compared to the previous iteration.K-values are computed as the ratio of vapor to liquid mole fractions for each component on each tray. This provides a composition-based convergence metric that complements the temperature-based metric, similar to what commercial inside-out implementations track.
- Parameters:
previousKvalues- K-values from the previous iteration (null if first iteration)- Returns:
- maximum relative K-value change;
Double.POSITIVE_INFINITYif no previous data
-
cacheCurrentKvalues
private double[][] cacheCurrentKvalues()Cache K-values (y/x) for all components on all trays for use in the next iteration comparison.- Returns:
- 2D array [tray][component] of K-values
-
innerLoopIteration
private double innerLoopIteration(DistillationColumn.SimplifiedKvalueModel model, double relaxation) Perform a simplified inner-loop iteration using the K-value model instead of rigorous flash.This method updates tray compositions using the simplified K-value correlation and adjusts temperatures via a bubble-point calculation (sum of K*x = 1 condition). No PH-flash is called, making each inner iteration much cheaper than a rigorous outer iteration.
- Parameters:
model- the fitted simplified K-value modelrelaxation- current relaxation factor- Returns:
- average absolute temperature change across all trays
-
runBroyden
Solve the column using a simple Broyden mixing of tray temperatures.- Parameters:
id- calculation identifier
-
solveWegstein
Solve the column using Wegstein acceleration of successive substitution.Wegstein's method uses two consecutive fixed-point iterates to extrapolate a better estimate. For temperatures on each tray the acceleration factor q is computed from the slope of the fixed-point map: q = s / (s - 1) where s = (x_{k} - x_{k-1}) / (g(x_{k}) - g(x_{k-1})). The factor is bounded to [-5, 0] to prevent divergence.
- Parameters:
id- calculation identifier
-
solveSumRates
Solve the column using a sum-rates tearing method.The sum-rates method adjusts tray liquid flow rates based on the ratio of computed to assumed total flow leaving each tray. This is effective for absorber and stripper columns where the temperature profile is relatively flat. The method alternates between: (1) bubble-point temperature calculations on each tray, and (2) flow rate corrections using the sum-rates formula of Burningham and Otto (1967).
- Parameters:
id- calculation identifier
-
solveNewton
Solve the column using a Newton-Raphson simultaneous temperature correction method.This is inspired by the Naphtali-Sandholm (1971) approach of solving MESH equations simultaneously, adapted to NeqSim's tray-by-tray flash infrastructure. The method treats the N tray temperatures as the independent variables. A residual vector is formed by running full tray sweeps and measuring the temperature discrepancy each tray exhibits after equilibrium. The Jacobian is computed by finite-difference perturbation of each tray temperature.
Key features:
- Simultaneous correction: all tray temperatures are updated together using a dense N×N Jacobian solved by Gaussian elimination with partial pivoting.
- Line search: the full Newton step is scaled back if it increases residuals.
- Warm-up: a few direct-substitution iterations are performed first to get close to the solution basin where Newton convergence is quadratic.
- Parameters:
id- calculation identifier
-
performFullTraySweep
private void performFullTraySweep(UUID id, int firstFeedTrayNumber, StreamInterface[] previousGasStreams, StreamInterface[] previousLiquidStreams, double relaxation) Perform a full upward+downward tray sweep, running PH-flash on each tray.- Parameters:
id- calculation identifierfirstFeedTrayNumber- index of the lowest feed traypreviousGasStreams- cached gas streams from previous iteration (updated in-place)previousLiquidStreams- cached liquid streams from previous iteration (updated in-place)relaxation- relaxation factor for stream blending
-
computeTemperatureResidual
private double computeTemperatureResidual()Compute the average absolute temperature residual across all trays. The residual is the difference between the tray's stored temperature and its thermo system temperature after a flash.- Returns:
- average absolute temperature change per tray (K)
-
solveLinearSystem
private double[] solveLinearSystem(double[][] matrixA, double[] vectorB) Solve a dense linear system Ax = b using Gaussian elimination with partial pivoting.- Parameters:
matrixA- coefficient matrix (will be modified in-place)vectorB- right-hand side vector (will be modified in-place)- Returns:
- solution vector x, or null if the matrix is singular
-
displayResult
public void displayResult()displayResult.
- Specified by:
displayResultin interfaceProcessEquipmentInterface- Overrides:
displayResultin classProcessEquipmentBaseClass
-
getTray
getTray.
- Parameters:
trayNumber- a int- Returns:
- a
SimpleTrayobject
-
setNumberOfTrays
public void setNumberOfTrays(int number) setNumberOfTrays.
- Specified by:
setNumberOfTraysin interfaceDistillationInterface- Parameters:
number- a int
-
createMiddleTray
Create a middle tray (between reboiler and condenser). Sets the reactive flash flag when the column is in reactive mode and the tray index falls inside the reactive section.- Parameters:
name- the tray namemiddleTrayIndex- 0-based index among the middle trays (excluding reboiler/condenser)- Returns:
- a new SimpleTray with reactive flash configured
-
isInReactiveSection
private boolean isInReactiveSection(int middleTrayIndex) Check whether a middle-tray index falls inside the reactive section.- Parameters:
middleTrayIndex- 0-based index among middle trays- Returns:
truewhen the tray should use reactive flash
-
setReactive
public void setReactive(boolean reactive) Enable or disable reactive distillation for all middle trays. When enabled, middle trays useReactiveTray(simultaneous chemical + phase equilibrium via the Modified RAND method). Can be called after construction; existing trays will be replaced.- Parameters:
reactive-trueto enable reactive distillation
-
setReactive
public void setReactive(boolean reactive, int startTray, int endTray) Enable reactive distillation on a specific section of middle trays. Tray indices are 0-based among the middle trays (excluding reboiler/condenser). For example, in a column with reboiler + 10 middle trays + condenser,setReactive(true, 3, 7)makes trays 4–8 (1-based) of the middle section reactive.- Parameters:
reactive-trueto enable reactive distillationstartTray- first reactive middle-tray index (0-based, inclusive)endTray- last reactive middle-tray index (0-based, inclusive)
-
replaceMiddleTrays
private void replaceMiddleTrays()Update the reactive flash flag on middle trays to match the current reactive mode configuration. Called automatically bysetReactive(boolean). -
isReactive
public boolean isReactive()Check whether reactive distillation mode is enabled.- Returns:
truewhen the column has reactive trays
-
setSolverType
Select the algorithm used when solving the column.- Parameters:
solverType- choice of solver
-
setRelaxationFactor
public void setRelaxationFactor(double relaxationFactor) Set relaxation factor for the damped solver.- Parameters:
relaxationFactor- value between 0 and 1
-
setTopCondenserDuty
public void setTopCondenserDuty(double duty) setTopCondenserDuty.
- Parameters:
duty- a double
-
setTopPressure
public void setTopPressure(double topPressure) setTopPressure.
- Parameters:
topPressure- a double
-
setBottomPressure
public void setBottomPressure(double bottomPressure) setBottomPressure.
- Parameters:
bottomPressure- a double
-
solved
public boolean solved()Returns whether or not the module has been solved.
- Specified by:
solvedin interfaceSimulationInterface- Overrides:
solvedin classProcessEquipmentBaseClass- Returns:
- a boolean
-
meshResidualsSatisfied
private boolean meshResidualsSatisfied()Check whether the latest MESH residual satisfies the optional convergence gate.- Returns:
trueif MESH residual gating is disabled or the latest residual is acceptable
-
setError
void setError(double err) -
getLastIterationCount
public int getLastIterationCount()Retrieve the iteration count of the most recent solve.- Returns:
- iteration count
-
getLastTemperatureResidual
public double getLastTemperatureResidual()Retrieve the latest average temperature residual in Kelvin.- Returns:
- average temperature residual
-
getLastMassResidual
public double getLastMassResidual()Retrieve the latest relative mass residual.- Returns:
- relative mass balance residual
-
getLastEnergyResidual
public double getLastEnergyResidual()Retrieve the latest relative enthalpy residual.- Returns:
- relative enthalpy residual
-
getLastTopSpecificationResidual
public double getLastTopSpecificationResidual()Retrieve the latest top specification residual.- Returns:
- top specification residual as current value minus target value
-
getLastBottomSpecificationResidual
public double getLastBottomSpecificationResidual()Retrieve the latest bottom specification residual.- Returns:
- bottom specification residual as current value minus target value
-
getLastSpecificationResidual
public double getLastSpecificationResidual()Retrieve the largest absolute active specification residual.- Returns:
- maximum absolute top or bottom specification residual
-
getLastMeshResidualNorm
public double getLastMeshResidualNorm()Retrieve the latest MESH residual vector infinity norm.- Returns:
- maximum absolute MESH residual, or
Double.NaNif no solve has been run
-
getLastMeshMaterialResidualNorm
public double getLastMeshMaterialResidualNorm()Retrieve the latest MESH material residual infinity norm.- Returns:
- maximum absolute component material residual, or
Double.NaNif unavailable
-
getLastMeshEquilibriumResidualNorm
public double getLastMeshEquilibriumResidualNorm()Retrieve the latest MESH equilibrium residual infinity norm.- Returns:
- maximum absolute equilibrium residual, or
Double.NaNif unavailable
-
getLastMeshSummationResidualNorm
public double getLastMeshSummationResidualNorm()Retrieve the latest MESH summation residual infinity norm.- Returns:
- maximum absolute summation residual, or
Double.NaNif unavailable
-
getLastMeshEnergyResidualNorm
public double getLastMeshEnergyResidualNorm()Retrieve the latest MESH energy residual infinity norm.- Returns:
- maximum absolute energy residual, or
Double.NaNif unavailable
-
getLastMeshSpecificationResidualNorm
public double getLastMeshSpecificationResidualNorm()Retrieve the latest MESH specification residual infinity norm.- Returns:
- maximum absolute specification residual, or
Double.NaNif unavailable
-
getLastMeshResidualVector
public double[] getLastMeshResidualVector()Retrieve a copy of the latest MESH residual vector.- Returns:
- residual vector copy, or an empty array if no solve has been run
-
getLastMeshResidual
ColumnMeshResidual getLastMeshResidual()Retrieve the latest internal MESH residual diagnostics.- Returns:
- latest residual diagnostics, or null if no solve has been run
-
getLastMeshResidualNorm
Get a MESH residual norm by equation type.- Parameters:
equationType- equation type to inspect- Returns:
- infinity norm for that equation type, or
Double.NaNif unavailable
-
getLastSolveTimeSeconds
public double getLastSolveTimeSeconds()Retrieve the duration of the most recent solve in seconds.- Returns:
- solve time in seconds
-
getMassBalanceTolerance
public double getMassBalanceTolerance()Access the configured relative mass balance tolerance.- Returns:
- mass balance tolerance
-
setEnforceEnergyBalanceTolerance
public void setEnforceEnergyBalanceTolerance(boolean enforce) Control whether the solver enforces the energy balance tolerance when determining convergence.- Parameters:
enforce-trueto require the energy residual to satisfy the configured tolerance
-
isEnforceEnergyBalanceTolerance
public boolean isEnforceEnergyBalanceTolerance()Check if the solver currently enforces the energy balance tolerance during convergence checks.- Returns:
trueif the energy residual must satisfy its tolerance before convergence
-
setEnforceMeshResidualTolerance
public void setEnforceMeshResidualTolerance(boolean enforce) Control whether the latest MESH residual vector must satisfy tolerance during convergence checks.- Parameters:
enforce-trueto require MESH residuals to satisfy the configured tolerance
-
isEnforceMeshResidualTolerance
public boolean isEnforceMeshResidualTolerance()Check if convergence requires the latest MESH residual vector to satisfy tolerance.- Returns:
trueif MESH residuals are part of the convergence check
-
getEnthalpyBalanceTolerance
public double getEnthalpyBalanceTolerance()Access the configured relative enthalpy balance tolerance.- Returns:
- enthalpy balance tolerance
-
getMeshResidualTolerance
public double getMeshResidualTolerance()Access the configured scaled MESH residual tolerance.- Returns:
- MESH residual tolerance
-
getTemperatureTolerance
public double getTemperatureTolerance()Access the configured average temperature tolerance.- Returns:
- temperature tolerance in Kelvin
-
setMaxNumberOfIterations
public void setMaxNumberOfIterations(int maxIter) Setter for the field
maxNumberOfIterations.- Parameters:
maxIter- a int
-
setInternalDiameter
public void setInternalDiameter(double internalDiameter) Setter for the field
internalDiameter.- Parameters:
internalDiameter- a double
-
getInternalDiameter
public double getInternalDiameter()Getter for the field
internalDiameter.- Returns:
- a double
-
getFsFactor
public double getFsFactor()Calculates the Fs factor for the distillation column. The Fs factor is a measure of the gas flow rate through the column relative to the cross-sectional area and the density of the gas.- Returns:
- the Fs factor as a double value
-
calcColumnInternals
Create and run a column internals designer for this column.Evaluates hydraulics on every tray (flooding, weeping, entrainment, downcomer backup, pressure drop, efficiency) and sizes the column diameter from the controlling tray.
- Parameters:
internalsType- tray type ("sieve", "valve", "bubble-cap") or "packed"- Returns:
- a fully evaluated
ColumnInternalsDesignerwith per-tray results
-
calcColumnInternals
Create and run a column internals designer for this column with default sieve trays.- Returns:
- a fully evaluated
ColumnInternalsDesignerwith per-tray results
-
getGasOutStream
Getter for the field
gasOutStream.- Returns:
- a
StreamInterfaceobject
-
getLiquidOutStream
Getter for the field
liquidOutStream.- Returns:
- a
StreamInterfaceobject
-
getMassBalance
getMassBalance.
- Specified by:
getMassBalancein interfaceProcessEquipmentInterface- Overrides:
getMassBalancein classProcessEquipmentBaseClass- Parameters:
unit- aStringobject- Returns:
- a double
-
getReboiler
-
getCondenser
-
getReboilerTemperature
public double getReboilerTemperature()Getter for the field
reboilerTemperature.- Returns:
- a double
-
setReboilerTemperature
public void setReboilerTemperature(double reboilerTemperature) Setter for the field
reboilerTemperature.- Parameters:
reboilerTemperature- a double
-
getCondenserTemperature
public double getCondenserTemperature()Getter for the field
condenserTemperature.- Returns:
- a double
-
setCondenserTemperature
public void setCondenserTemperature(double condenserTemperature) Setter for the field
condenserTemperature.- Parameters:
condenserTemperature- a double
-
isDoInitializion
public boolean isDoInitializion()isDoInitializion.
- Returns:
- a boolean
-
setDoInitializion
public void setDoInitializion(boolean doInitializion) Setter for the field
doInitializion.- Parameters:
doInitializion- a boolean
-
getMechanicalDesign
Get a
mechanicalDesignfor the equipment.- Specified by:
getMechanicalDesignin interfaceProcessEquipmentInterface- Overrides:
getMechanicalDesignin classProcessEquipmentBaseClass- Returns:
- a
MechanicalDesignobject
-
initMechanicalDesign
public void initMechanicalDesign()Initialize a
initMechanicalDesignfor the equipment.- Specified by:
initMechanicalDesignin interfaceProcessEquipmentInterface- Overrides:
initMechanicalDesignin classProcessEquipmentBaseClass
-
setTemperatureTolerance
public void setTemperatureTolerance(double tol) Set temperature convergence tolerance.- Parameters:
tol- the tolerance
-
setMassBalanceTolerance
public void setMassBalanceTolerance(double tol) Set mass balance convergence tolerance.- Parameters:
tol- the tolerance
-
setEnthalpyBalanceTolerance
public void setEnthalpyBalanceTolerance(double tol) Set enthalpy balance convergence tolerance.- Parameters:
tol- the tolerance
-
setMeshResidualTolerance
public void setMeshResidualTolerance(double tol) Set the scaled MESH residual tolerance used when MESH residual gating is enabled.- Parameters:
tol- positive finite tolerance- Throws:
IllegalArgumentException- if the tolerance is not positive and finite
-
resetToleranceOverrides
public void resetToleranceOverrides()Restore adaptive default tolerances, discarding manual overrides. -
massBalanceCheck
public boolean massBalanceCheck()Check mass balance for all components.- Returns:
- true if mass balance is within 1e-6
-
componentMassBalanceCheck
Check mass balance for a specific component.- Parameters:
componentName- the component name- Returns:
- true if mass balance is within 1e-6
-
getMassBalanceError
public double getMassBalanceError()Calculate the relative mass balance error across the column.- Returns:
- maximum of tray-wise and overall relative mass imbalance
-
getEnergyBalanceError
public double getEnergyBalanceError()Calculates the relative enthalpy imbalance across all trays.- Returns:
- maximum of tray-wise and overall relative enthalpy imbalance
-
recordConvergence
private void recordConvergence(double[] entry) Append a residual snapshot to the convergence history, capping atMAX_CONVERGENCE_HISTORYentries.- Parameters:
entry- residual array to record
-
applyMurphreeCorrection
private void applyMurphreeCorrection(int trayIndex) Apply Murphree tray efficiency correction to the vapor leaving a tray. The correction blends the equilibrium vapor composition with the inlet vapor composition:y_i^out = y_i^in + E_MV * (y_i^eq - y_i^in)
whereE_MVis the Murphree efficiency,y_i^eqis the equilibrium composition from the flash, andy_i^inis the inlet vapor composition. When efficiency is 1.0, the tray is ideal and no correction is applied. The correction is skipped for reboilers and condensers (first and last trays).- Parameters:
trayIndex- index of the tray in thetrayslist
-
applyRelaxation
private StreamInterface applyRelaxation(StreamInterface previous, StreamInterface current, double relaxation) Blend the current stream update with the previous iterate using the provided relaxation factor.- Parameters:
previous- stream from the previous iteration (may benull)current- current iteration streamrelaxation- relaxation factor applied to the update- Returns:
- relaxed stream instance to be used in the next tear
-
finalizeSolve
private void finalizeSolve(UUID id, int iterations, double temperatureResidual, double massResidual, double energyResidual, long startTime) Finalise a successful solver run by updating iteration metrics and product streams.- Parameters:
id- calculation identifieriterations- number of iterations performedtemperatureResidual- final average temperature residualmassResidual- final relative mass residualenergyResidual- final relative energy residualstartTime- nano time when the solve started
-
resetLastSolveMetrics
private void resetLastSolveMetrics()Reset cached solve metrics when no calculation is performed. -
energyBalanceCheck
public void energyBalanceCheck()Prints a simple energy balance for each tray to the console. The method calculates the total enthalpy of all inlet streams and compares it with the outlet enthalpy in order to highlight any discrepancies in the column setup. -
main
The main method demonstrates the creation and operation of a distillation column using the NeqSim library. It performs the following steps:- Creates a test thermodynamic system with methane, ethane, and propane components.
- Performs a TP flash calculation on the test system.
- Creates two separate feed streams from the test system.
- Constructs a distillation column with 5 trays, a reboiler, and a condenser.
- Adds the two feed streams to the distillation column at tray 3.
- Builds and runs the process system.
- Displays the results of the distillation column, including the gas and liquid output streams.
- Parameters:
args- command line arguments (not used)
-
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
- Specified by:
validateSetupin interfaceProcessEquipmentInterface- Returns:
- validation result with errors and warnings
-
toJson
Serializes the Process Equipment along with its state to a JSON string.
- Specified by:
toJsonin interfaceProcessEquipmentInterface- Overrides:
toJsonin classProcessEquipmentBaseClass- Returns:
- json string.
-
toJson
Serializes the Process Equipment with configurable level of detail.- Specified by:
toJsonin interfaceProcessEquipmentInterface- Overrides:
toJsonin classProcessEquipmentBaseClass- Parameters:
cfg- report configuration- Returns:
- json string
-
getNumerOfTrays
public int getNumerOfTrays()getNumerOfTrays.
- Returns:
- a int
-
setMurphreeEfficiency
public void setMurphreeEfficiency(double efficiency) Set the Murphree tray efficiency for all stages.- Parameters:
efficiency- value between 0.0 (no separation) and 1.0 (ideal equilibrium stage)
-
getMurphreeEfficiency
public double getMurphreeEfficiency()Retrieve the current Murphree tray efficiency.- Returns:
- Murphree efficiency
-
setInnerLoopSteps
public void setInnerLoopSteps(int steps) Set the number of simplified inner-loop iterations between rigorous flash updates in the IO solver. A value of 0 disables the simplified model (all iterations use rigorous flash).- Parameters:
steps- number of inner-loop steps (0 to disable, typically 2-5)
-
getInnerLoopSteps
public int getInnerLoopSteps()Return the current number of simplified inner-loop iterations per outer flash update.- Returns:
- inner-loop step count
-
getConvergenceHistory
Return the per-iteration convergence history from the most recent solve.Each entry is a three-element array: [temperatureResidual, massResidual, energyResidual].
- Returns:
- list of residual arrays, one per iteration; empty if no solve has been run
-
getSolverType
Retrieve the currently selected solver type.- Returns:
- solver type enum value
-
getTrays
Returns the list of trays in this column.- Returns:
- list of
SimpleTrayobjects
-
setCondenserRefluxRatio
public void setCondenserRefluxRatio(double refluxRatio) Sets the reflux ratio on the condenser (if present). Also stores aREFLUX_RATIOtop specification so that the column records the user's intent.- Parameters:
refluxRatio- the desired reflux ratio (L/D)
-
getTopSpecification
Returns the top (condenser) column specification.- Returns:
- the top specification, or null if not set
-
getBottomSpecification
Returns the bottom (reboiler) column specification.- Returns:
- the bottom specification, or null if not set
-
setTopSpecification
Sets the top column specification with location validation.- Parameters:
spec- the specification (must have location TOP)- Throws:
IllegalArgumentException- if the specification location is not TOP
-
setBottomSpecification
Sets the bottom column specification with location validation.- Parameters:
spec- the specification (must have location BOTTOM)- Throws:
IllegalArgumentException- if the specification location is not BOTTOM
-
setTopProductPurity
Convenience method to specify a target mole fraction purity for the top product.- Parameters:
componentName- the component to constrainpurity- the desired mole fraction (0 to 1)
-
setBottomProductPurity
Convenience method to specify a target mole fraction purity for the bottom product.- Parameters:
componentName- the component to constrainpurity- the desired mole fraction (0 to 1)
-
setReboilerBoilupRatio
public void setReboilerBoilupRatio(double boilupRatio) Convenience method to specify a reboiler boilup ratio (V/B).- Parameters:
boilupRatio- the desired boilup ratio
-
setTopComponentRecovery
Convenience method to specify a target component recovery in the top product.- Parameters:
componentName- the component to constrainrecovery- the desired recovery fraction (0 to 1)
-
setBottomProductFlowRate
Convenience method to specify a target molar flow rate for the bottom product.- Parameters:
flowRate- the desired flow rate valueunit- the flow rate unit (e.g. "mol/hr")
-
builder
Creates a new Builder for constructing a DistillationColumn with a fluent API.- Parameters:
name- the column name- Returns:
- a new Builder instance
-
setDynamicColumnEnabled
public void setDynamicColumnEnabled(boolean enabled) Enables or disables the dynamic tray-by-tray model for transient simulation.- Parameters:
enabled- true to enable dynamic column model
-
isDynamicColumnEnabled
public boolean isDynamicColumnEnabled()Returns whether the dynamic tray-by-tray model is enabled.- Returns:
- true if dynamic column model is active
-
setTrayWeirHeight
public void setTrayWeirHeight(double weirHeight) Sets the weir height for all trays (used in Francis weir overflow).- Parameters:
weirHeight- weir height in metres
-
getTrayWeirHeight
public double getTrayWeirHeight()Gets the weir height for all trays.- Returns:
- weir height in metres
-
setTrayWeirLength
public void setTrayWeirLength(double weirLength) Sets the weir crest length for all trays.- Parameters:
weirLength- weir length in metres
-
getTrayWeirLength
public double getTrayWeirLength()Gets the weir crest length for all trays.- Returns:
- weir length in metres
-
getTrayLiquidHoldup
public double[] getTrayLiquidHoldup()Returns the liquid holdup array (moles per tray). May be null if dynamic model has not been initialized.- Returns:
- array of liquid holdups indexed by tray number, or null
-
getTrayEnthalpy
public double[] getTrayEnthalpy()Returns the per-tray enthalpy array in J. May be null if energy balance has not been initialized.- Returns:
- array of tray enthalpies indexed by tray number, or null
-
setTrayDryPressureDrop
public void setTrayDryPressureDrop(double dpPa) Sets the dry tray pressure drop per tray in Pa. Used in the dynamic vapor hydraulic model to compute vapor flow rate as a function of pressure difference between trays.- Parameters:
dpPa- dry tray pressure drop in Pascals (positive value)
-
getTrayDryPressureDrop
public double getTrayDryPressureDrop()Returns the dry tray pressure drop per tray in Pa.- Returns:
- dry tray pressure drop in Pa
-
setDynamicEnergyEnabled
public void setDynamicEnergyEnabled(boolean enabled) Enables or disables the per-tray energy balance in dynamic mode. When enabled, each tray's enthalpy is tracked and PH flash is used for re-equilibration instead of TP flash.- Parameters:
enabled- true to enable energy-balanced trays
-
isDynamicEnergyEnabled
public boolean isDynamicEnergyEnabled()Returns whether the per-tray energy balance is enabled.- Returns:
- true if energy-balanced trays are active
-
runTransient
runTransient
This method calculates thermodynamic and unit operations using difference equations if available and calculateSteadyState is true. Use setCalculateSteadyState to set the parameter. Sets calc identifier UUID.Dynamic distillation column model. When
dynamicColumnEnabledis true, performs a single forward-Euler integration step on each tray's liquid holdup using the MESH equations. Liquid leaving each tray is calculated using the Francis weir overflow formula.- Specified by:
runTransientin interfaceSimulationInterface- Parameters:
dt- time step in secondsid- calculation identifier
-