Class DistillationColumn
- All Implemented Interfaces:
Serializable, Runnable, DistillationInterface, ProcessEquipmentInterface, SimulationInterface, NamedInterface
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 classBuilder class for creating DistillationColumn instances with a fluent API.static enumAvailable solving strategies for the column. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) double(package private) doubleprivate double(package private) ProcessSystemprivate booleanprivate booleanprivate static final doubleTarget relative energy imbalance for the post-processing polish stage.private booleanControl whether energy residual must satisfy tolerance before convergence.private doubleEnthalpy balance convergence tolerance.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) StreamInterface(package private) boolean(package private) boolean(package private) Heaterprivate doubleprivate static final intMultiplier governing how much the solver can extend beyond the nominal iteration budget.private doubleLast recorded relative enthalpy residual.private intLast number of iterations executed by the active solver.private doubleLast recorded relative mass balance residual.private doubleDuration of the latest solve step in seconds.private doubleLast recorded average temperature residual in Kelvin.(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 doubleMaximum relaxation factor allowed by the adaptive controller.private doubleCap applied to energy residual when adjusting relaxation.(package private) intprivate 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.(package private) intprivate static final intExtra iterations granted when a polish stage is triggered.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.(package private) doubleprivate static final doubleScaling factor used to derive a tray-proportional iteration budget.protected ArrayList<SimpleTray> 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 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 DistillationColumn instances.booleancomponentMassBalanceCheck(String componentName) Check mass balance for a specific component.private intDetermine the iteration limit based on configuration and column size.voiddisplayResult.voidPrints a simple energy balance for each tray to the console.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.getCondenser.doubleGetter for the fieldcondenserTemperature.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.doubleGetter for the fieldinternalDiameter.doubleRetrieve the latest relative enthalpy residual.intRetrieve the iteration count of the most recent solve.doubleRetrieve the latest relative mass residual.doubleRetrieve the duration of the most recent solve in seconds.doubleRetrieve the latest average temperature residual in Kelvin.Getter for the fieldliquidOutStream.doublegetMassBalance(String unit) getMassBalance.doubleCalculate the relative mass balance error across the column.doubleAccess the configured relative mass balance tolerance.intgetNumerOfTrays.getReboiler.doubleGetter for the fieldreboilerTemperature.doubleAccess the configured average temperature tolerance.getTray(int trayNumber) getTray.getTrays()voidinit()Prepare the column for calculation by estimating tray temperatures and linking streams between trays.booleanisDoInitializion.booleanGetter for the fielddoMultiPhaseCheck.booleanCheck if the solver currently enforces the energy balance tolerance during convergence checks.static voidThe main method demonstrates the creation and operation of a distillation column using the NeqSim library.booleanCheck mass balance for all components.private intPrepare the column for a solving sequence by updating pressures and cloning feed systems.private voidReset cached solve metrics when no calculation is performed.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.private voidSolve the column using the adaptive sequential substitution scheme with a damped starting step.voidsetBottomPressure(double bottomPressure) setBottomPressure.voidsetCondenserTemperature(double condenserTemperature) Setter for the fieldcondenserTemperature.voidsetDoInitializion(boolean doInitializion) Setter for the fielddoInitializion.voidsetEnforceEnergyBalanceTolerance(boolean enforce) Control whether the solver enforces the energy balance tolerance when determining convergence.voidsetEnthalpyBalanceTolerance(double tol) Set enthalpy balance convergence tolerance.(package private) voidsetError(double err) voidsetInternalDiameter(double internalDiameter) Setter for the fieldinternalDiameter.voidsetMassBalanceTolerance(double tol) Set mass balance convergence tolerance.voidsetMaxNumberOfIterations(int maxIter) Setter for the fieldmaxNumberOfIterations.voidsetMultiPhaseCheck(boolean doMultiPhaseCheck) Setter for the fielddoMultiPhaseCheck.voidsetNumberOfTrays(int number) setNumberOfTrays.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.voidsetTopCondenserDuty(double duty) setTopCondenserDuty.voidsetTopPressure(double topPressure) setTopPressure.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.private voidsolveInsideOut(UUID id) Solve the column using an inside-out strategy with adaptive stream relaxation.private voidsolveSequential(UUID id, double initialRelaxation) Execute the sequential substitution solver with an adaptive relaxation controller.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.Validate the process equipment before execution.Methods inherited from class ProcessEquipmentBaseClass
copy, equals, getConditionAnalysisMessage, getController, getEnergyStream, getEntropyProduction, getExergyChange, getMassBalance, getMechanicalDesign, getMinimumFlow, getPressure, getPressure, getProperty, getReport_json, getResultTable, getSpecification, getTemperature, getTemperature, getThermoSystem, hashCode, initMechanicalDesign, isActive, isActive, isSetEnergyStream, reportResults, run_step, runConditionAnalysis, setController, setEnergyStream, setEnergyStream, setFlowValveController, setMinimumFlow, setPressure, setRegulatorOutSignal, setSpecification, setTemperatureMethods inherited from class SimulationBaseClass
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTimeMethods inherited from class NamedBaseClass
getName, getTagName, setName, setTagNameMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NamedInterface
getName, getTagName, setName, setTagNameMethods inherited from interface ProcessEquipmentInterface
equals, getCapacityDuty, getCapacityMax, getConditionAnalysisMessage, getController, getEntropyProduction, getExergyChange, getExergyChange, getFluid, getMassBalance, getMechanicalDesign, getPressure, getPressure, getReport_json, getRestCapacity, getResultTable, getSpecification, getTemperature, getTemperature, getThermoSystem, hashCode, initMechanicalDesign, needRecalculation, reportResults, runConditionAnalysis, setController, setPressure, setRegulatorOutSignal, setSpecification, setTemperatureMethods inherited from interface SimulationInterface
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, run, run_step, run_step, runTransient, 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:
-
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. -
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. -
doMultiPhaseCheck
private boolean doMultiPhaseCheck -
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. -
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
-
-
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
-
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
-
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 inside-out strategy with adaptive stream relaxation.- Parameters:
id- calculation identifier
-
runBroyden
Solve the column using a simple Broyden mixing of tray temperatures.- Parameters:
id- calculation identifier
-
runDamped
Solve the column using the adaptive sequential substitution scheme with a damped starting step.- Parameters:
id- calculation identifier
-
displayResult
public void displayResult()displayResult.
- Specified by:
displayResultin interfaceProcessEquipmentInterface- Overrides:
displayResultin classProcessEquipmentBaseClass
-
getTray
getTray.
- Parameters:
trayNumber- a int- Returns:
- a
SimpleTrayobject
-
getTrays
-
setNumberOfTrays
public void setNumberOfTrays(int number) setNumberOfTrays.
- Specified by:
setNumberOfTraysin interfaceDistillationInterface- Parameters:
number- a int
-
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
-
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
-
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
-
getEnthalpyBalanceTolerance
public double getEnthalpyBalanceTolerance()Access the configured relative enthalpy balance tolerance.- Returns:
- enthalpy balance 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
-
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
-
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
-
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
-
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)
-
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
-
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
Validates the distillation column setup before execution. Checks that:
- Equipment has a valid name
- At least one feed stream is connected
- Number of trays is positive
- Solver parameters are valid
- Specified by:
validateSetupin interfaceProcessEquipmentInterface- Returns:
- validation result with errors and warnings
-
builder
Creates a new Builder for constructing DistillationColumn instances.The builder pattern provides a fluent API for configuring complex distillation columns with many optional parameters. This is especially useful when configuring columns with multiple feed streams, custom tolerances, or specific solver settings.
Example usage:
DistillationColumn column = DistillationColumn.builder("Deethanizer").numberOfTrays(15) .withCondenser().withReboiler().topPressure(25.0, "bara").bottomPressure(26.0, "bara") .solverType(SolverType.INSIDE_OUT).temperatureTolerance(0.001).addFeedStream(feedStream, 8) .build();- Parameters:
name- the name of the distillation column- Returns:
- a new Builder instance
-