Class VesselDepressurization
- All Implemented Interfaces:
Serializable, Runnable, ProcessEquipmentInterface, SimulationInterface, NamedInterface
This class provides a comprehensive model for vessel dynamics including:
- Isothermal process (constant temperature)
- Isenthalpic/Adiabatic process (constant enthalpy)
- Isentropic process (constant entropy, with PV work)
- Isenergetic process (constant internal energy)
- Energy balance (full heat transfer modeling)
The implementation follows the approach of HydDown for hydrogen vessel calculations but extends it to support multi-component mixtures using NeqSim's thermodynamic backend.
Reference: Andreasen, A. (2021). HydDown: A Python package for calculation of hydrogen (or other gas) pressure vessel filling and discharge. Journal of Open Source Software, 6(66), 3695.
- Author:
- ESOL
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumCalculation type for vessel thermodynamics.static enumFlow direction.static enumHeat transfer type for energy balance calculations.static enumPreset liner materials for Type III/IV composite vessels.static classResult object containing simulation history data.static enumPreset material properties for common vessel constructions.static enumVessel orientation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate booleanprivate doubleprivate doubleprivate doubleprivate TransientWallHeatTransferprivate doubleprivate booleanprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate TransientWallHeatTransferprivate doubleprivate static final org.apache.logging.log4j.LoggerLogger object for class.private doubleprivate StreamInterfaceprivate static final longSerialization version UID.private SystemInterfaceprivate booleanprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate TransientWallHeatTransferprivate doubleprivate doubleprivate doubleprivate doubleFields inherited from class ProcessEquipmentBaseClass
conditionAnalysisMessage, energyStream, hasController, isSolved, properties, reportFields inherited from class SimulationBaseClass
calcIdentifier, calculateSteadyState, timeFields inherited from class NamedBaseClass
name -
Constructor Summary
ConstructorsConstructorDescriptionVesselDepressurization(String name) Constructor for VesselDepressurization.VesselDepressurization(String name, StreamInterface inletStream) Constructor for VesselDepressurization with inlet stream. -
Method Summary
Modifier and TypeMethodDescriptionComprehensive flow assurance risk assessment during blowdown.private doubleCalculates the gas phase heat transfer coefficient.private doubleCalculates the heat transfer rate to the fluid.private doublecalculateHorizontalLiquidLevel(double volumeFraction) Calculates liquid level for horizontal cylinder given volume fraction.private doubleCalculates the internal heat transfer coefficient.private doubleCalculates the liquid phase heat transfer coefficient.private doubleCalculates the current liquid level based on phase volumes.private doublecalculateLiquidVolumeFromLevel(double levelFraction) Calculates the liquid volume corresponding to a given liquid level fraction.private doubleCalculates the mass flow rate through the orifice.doublecalculateRequiredOrificeDiameter(double targetTime, double pressureReduction) Calculates required orifice diameter to meet API 521 blowdown time requirement.private doubleCalculates heat transfer rate for two-phase conditions.voidClears the history arrays.static SystemInterfacecreateTwoPhaseFluid(String componentName, double temperature, double vaporFraction) Creates a two-phase pure component system at its saturation conditions.static SystemInterfacecreateTwoPhaseFluidAtPressure(String componentName, double pressure, double vaporFraction) Creates a two-phase pure component system at specified pressure.Exports transient simulation results to CSV format.Exports transient results to JSON format.doubleGets the CO2 freezing subcooling (margin below freezing point).doubleGets the CO2 freezing (dry ice) temperature at current pressure.doubleGets the CO2 freezing temperature with unit conversion.doubleGets the current density.doublegetDischargeRate(String unit) Gets the current mass discharge rate.doubleGets the current enthalpy.doubleGets the current entropy.doublegetFireHeatInput(String unit) Gets the current fire heat input rate.doublegetFlareHeaderMach(double headerDiameter) Estimates Mach number in flare header.doublegetFlareHeaderVelocity(double headerDiameter, String unit) Estimates flare header velocity.doubleGets the gas-wetted wall temperature.Gets the gas wall temperature history.doubleCalculates hydrate formation temperature at current vessel conditions.doubleCalculates hydrate formation temperature at current conditions with unit conversion.doublegetHydrateSubcooling(String unit) Gets the hydrate subcooling (margin below hydrate temperature).doubleGets the current internal energy.doubleGets the current liquid level as a fraction of vessel height.Gets the liquid level history.doubleGets the liquid-wetted wall temperature.Gets the liquid wall temperature history.doublegetMass()Gets the current mass in the vessel.Gets the mass history.doubleGets the minimum hydrate subcooling (maximum risk) observed during blowdown history.doubleGets the minimum temperature reached during blowdown.doubleGets the minimum wall temperature reached during blowdown.doubleGets the liquid mass fraction in the outlet stream.Gets the outlet stream.doublegetPeakDischargeRate(String unit) Gets the peak mass discharge rate from simulation history.doubleGets the peak liquid fraction observed during blowdown.doubleGets the current vessel pressure.doublegetPressure(String unit) Gets the current vessel pressure in specified unit.Gets the pressure history.doubleGets the current fluid temperature.doublegetTemperature(String unit) Gets the current fluid temperature in specified unit.Gets the temperature history.Gets the thermoSystem.Gets the time history.doublegetTimeToReachPressure(double targetPressure) Gets the time to reach a target pressure.doublegetTotalMassDischarged(String unit) Gets the total mass discharged from simulation history.private doubleCalculates the unwetted (gas contact) wall area.doubleGets the current vapor fraction.doubleGets the vent temperature (temperature after expansion through orifice).doubleGets the vessel volume.private doubleGets the total inner wall surface area.doubleGets the current wall temperature.private doubleCalculates the wetted (liquid contact) wall area.booleanChecks if current temperature is below CO2 freezing point.booleanChecks if current vessel temperature is below hydrate formation temperature.booleanChecks for liquid rainout conditions in the outlet stream.private voidInitializes the transient wall heat transfer model.private voidInitializes the vessel with the specified initial liquid level.booleanChecks if fire case is enabled.private voidrecordState(double massFlowRate, double heatRate) Records the current state to history arrays.voidIn this method all thermodynamic and unit operations will be calculated in a steady state calculation.double[]runOrificeSensitivity(double[] orificeSizes, double targetPressure) Runs sensitivity analysis on orifice size.runSimulation(double endTime, double dt) Runs a complete simulation and returns structured results.runSimulation(double endTime, double dt, int recordInterval) Runs a complete simulation with configurable output interval.voidrunTransient(double dt, UUID id) runTransientvoidsetAmbientTemperature(double temperature) Sets the ambient temperature.voidsetBackPressure(double pressure) Sets the back pressure for discharge calculations.voidSets the calculation type.voidsetDischargeCoefficient(double cd) Sets the discharge coefficient.voidsetExternalHeatTransferCoefficient(double h) Sets the external heat transfer coefficient.voidsetFireCase(boolean enable) Enables fire case simulation per API 521.voidsetFireHeatFlux(double heatFlux) Sets the fire heat flux per API 521.voidsetFireHeatFlux(double heatFlux, String unit) Sets the fire heat flux with unit.voidsetFixedQ(double q) Sets a fixed heat rate.voidsetFixedU(double u) Sets a fixed overall heat transfer coefficient.voidSets the flow direction.voidSets the heat transfer type.voidsetInitialLiquidLevel(double level) Sets the initial liquid level as a fraction of vessel height.voidsetInletStream(StreamInterface inletStream) Sets the inlet stream and initializes the vessel.voidsetLinerMaterial(double thickness, VesselDepressurization.LinerMaterial material) Sets the liner properties using a preset material.voidsetLinerProperties(double thickness, double density, double heatCapacity, double thermalConductivity) Sets the liner properties for Type III/IV vessels.voidsetOrificeDiameter(double diameter) Sets the orifice diameter for flow calculations.voidsetTwoPhaseHeatTransfer(boolean enabled) Enables two-phase heat transfer modeling with separate gas and liquid wall zones.voidsetValveOpeningTime(double time) Sets the valve opening time for ESD valve dynamics.voidsetVesselGeometry(double length, double diameter, VesselDepressurization.VesselOrientation orientation) Sets the vessel geometry.voidsetVesselMaterial(double thickness, VesselDepressurization.VesselMaterial material) Sets the vessel wall properties using a preset material.voidsetVesselProperties(double thickness, double density, double heatCapacity, double thermalConductivity) Sets the vessel wall properties.voidsetVolume(double volume) Sets the vessel volume.voidsetWettedSurfaceFraction(double fraction) Sets the wetted surface fraction for fire relief calculations.private voidUpdates the outlet stream with current conditions.voidvalidate()Validates the vessel configuration and throws exceptions for invalid setups.Validates configuration and returns warnings without throwing exceptions.Methods inherited from class ProcessEquipmentBaseClass
copy, displayResult, equals, getConditionAnalysisMessage, getController, getEnergyStream, getEntropyProduction, getExergyChange, getMassBalance, getMassBalance, getMechanicalDesign, getMinimumFlow, getProperty, getReport_json, getResultTable, getSpecification, hashCode, initMechanicalDesign, isActive, isActive, isSetEnergyStream, reportResults, run_step, runConditionAnalysis, setController, setEnergyStream, setEnergyStream, setFlowValveController, setMinimumFlow, setPressure, setRegulatorOutSignal, setSpecification, setTemperature, solved, toJson, toJsonMethods 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
getCapacityDuty, getCapacityMax, getExergyChange, getFluid, getRestCapacity, needRecalculation, validateSetupMethods inherited from interface SimulationInterface
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, run, run_step, runTransient, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTime
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
logger
private static final org.apache.logging.log4j.Logger loggerLogger object for class. -
volume
private double volume -
vesselLength
private double vesselLength -
vesselDiameter
private double vesselDiameter -
orientation
-
wallThickness
private double wallThickness -
wallDensity
private double wallDensity -
wallHeatCapacity
private double wallHeatCapacity -
wallThermalConductivity
private double wallThermalConductivity -
hasLiner
private boolean hasLiner -
linerThickness
private double linerThickness -
linerDensity
private double linerDensity -
linerHeatCapacity
private double linerHeatCapacity -
linerThermalConductivity
private double linerThermalConductivity -
backPressure
private double backPressure -
ambientTemperature
private double ambientTemperature -
externalHeatTransferCoeff
private double externalHeatTransferCoeff -
fireCase
private boolean fireCase -
fireHeatFlux
private double fireHeatFlux -
wetSurfaceFraction
private double wetSurfaceFraction -
orificeDiameter
private double orificeDiameter -
dischargeCoefficient
private double dischargeCoefficient -
valveOpeningTime
private double valveOpeningTime -
valveOpeningFraction
private double valveOpeningFraction -
calculationType
-
heatTransferType
-
flowDirection
-
fixedU
private double fixedU -
fixedQ
private double fixedQ -
thermoSystem
-
outletStream
-
wallTemperature
private double wallTemperature -
wallModel
-
currentTime
private double currentTime -
twoPhaseHeatTransfer
private boolean twoPhaseHeatTransfer -
initialLiquidLevel
private double initialLiquidLevel -
initialBeta
private double initialBeta -
gasWallTemperature
private double gasWallTemperature -
liquidWallTemperature
private double liquidWallTemperature -
gasWallModel
-
liquidWallModel
-
liquidVolumeFraction
private double liquidVolumeFraction -
timeHistory
-
pressureHistory
-
temperatureHistory
-
massHistory
-
wallTemperatureHistory
-
massFlowHistory
-
heatRateHistory
-
gasWallTemperatureHistory
-
liquidWallTemperatureHistory
-
liquidLevelHistory
-
-
Constructor Details
-
VesselDepressurization
Constructor for VesselDepressurization.- Parameters:
name- Name of the vessel
-
VesselDepressurization
Constructor for VesselDepressurization with inlet stream.- Parameters:
name- Name of the vesselinletStream- Initial fluid stream
-
-
Method Details
-
setInletStream
Sets the inlet stream and initializes the vessel.- Parameters:
inletStream- Inlet stream
-
initializeWallModel
private void initializeWallModel()Initializes the transient wall heat transfer model. -
setTwoPhaseHeatTransfer
public void setTwoPhaseHeatTransfer(boolean enabled) Enables two-phase heat transfer modeling with separate gas and liquid wall zones.When enabled, the model tracks separate wall temperatures for the gas-wetted and liquid-wetted portions of the vessel. Heat transfer to the gas phase uses natural convection, while heat transfer to the liquid phase uses natural convection or nucleate boiling correlations.
- Parameters:
enabled- true to enable two-phase heat transfer modeling
-
setInitialLiquidLevel
public void setInitialLiquidLevel(double level) Sets the initial liquid level as a fraction of vessel height.For a vertical vessel, this is the fraction of the height filled with liquid. For a horizontal vessel, this is the fraction of the diameter filled with liquid (from bottom).
- Parameters:
level- Liquid level fraction (0.0 = empty, 1.0 = full)
-
getLiquidLevel
public double getLiquidLevel()Gets the current liquid level as a fraction of vessel height.- Returns:
- Liquid level fraction (0-1)
-
getGasWallTemperature
public double getGasWallTemperature()Gets the gas-wetted wall temperature.- Returns:
- Gas wall temperature [K]
-
getLiquidWallTemperature
public double getLiquidWallTemperature()Gets the liquid-wetted wall temperature.- Returns:
- Liquid wall temperature [K]
-
getGasWallTemperatureHistory
-
getLiquidWallTemperatureHistory
-
getLiquidLevelHistory
-
calculateLiquidLevel
private double calculateLiquidLevel()Calculates the current liquid level based on phase volumes.- Returns:
- Liquid level fraction (0-1)
-
calculateHorizontalLiquidLevel
private double calculateHorizontalLiquidLevel(double volumeFraction) Calculates liquid level for horizontal cylinder given volume fraction.- Parameters:
volumeFraction- Liquid volume fraction (0-1)- Returns:
- Liquid level fraction (0-1) based on height
-
getWettedWallArea
private double getWettedWallArea()Calculates the wetted (liquid contact) wall area.- Returns:
- Wetted wall area [m²]
-
getUnwettedWallArea
private double getUnwettedWallArea()Calculates the unwetted (gas contact) wall area.- Returns:
- Unwetted wall area [m²]
-
setVolume
public void setVolume(double volume) Sets the vessel volume.- Parameters:
volume- Volume [m³]
-
getVolume
public double getVolume()Gets the vessel volume.- Returns:
- Volume [m³]
-
setVesselGeometry
public void setVesselGeometry(double length, double diameter, VesselDepressurization.VesselOrientation orientation) Sets the vessel geometry.- Parameters:
length- Vessel length [m]diameter- Vessel diameter [m]orientation- Vessel orientation
-
setVesselProperties
public void setVesselProperties(double thickness, double density, double heatCapacity, double thermalConductivity) Sets the vessel wall properties.- Parameters:
thickness- Wall thickness [m]density- Wall material density [kg/m³]heatCapacity- Wall material heat capacity [J/(kg*K)]thermalConductivity- Wall thermal conductivity [W/(m*K)]
-
setVesselMaterial
Sets the vessel wall properties using a preset material.Example:
vessel.setVesselMaterial(0.015, VesselMaterial.CARBON_STEEL);
- Parameters:
thickness- Wall thickness [m]material- Preset material fromVesselDepressurization.VesselMaterial
-
setLinerProperties
public void setLinerProperties(double thickness, double density, double heatCapacity, double thermalConductivity) Sets the liner properties for Type III/IV vessels.- Parameters:
thickness- Liner thickness [m]density- Liner density [kg/m³]heatCapacity- Liner heat capacity [J/(kg*K)]thermalConductivity- Liner thermal conductivity [W/(m*K)]
-
setLinerMaterial
Sets the liner properties using a preset material.Example for Type IV vessel (CFRP shell with HDPE liner):
vessel.setVesselMaterial(0.017, VesselMaterial.CFRP); vessel.setLinerMaterial(0.007, LinerMaterial.HDPE);
- Parameters:
thickness- Liner thickness [m]material- Preset liner material fromVesselDepressurization.LinerMaterial
-
setOrificeDiameter
public void setOrificeDiameter(double diameter) Sets the orifice diameter for flow calculations.- Parameters:
diameter- Orifice diameter [m]
-
setDischargeCoefficient
public void setDischargeCoefficient(double cd) Sets the discharge coefficient.- Parameters:
cd- Discharge coefficient (typically 0.6-0.65 for sharp-edge orifice)
-
setBackPressure
public void setBackPressure(double pressure) Sets the back pressure for discharge calculations.- Parameters:
pressure- Back pressure [bara]
-
setAmbientTemperature
public void setAmbientTemperature(double temperature) Sets the ambient temperature.- Parameters:
temperature- Ambient temperature [K]
-
setExternalHeatTransferCoefficient
public void setExternalHeatTransferCoefficient(double h) Sets the external heat transfer coefficient.- Parameters:
h- External film coefficient [W/(m²*K)]
-
setFireCase
public void setFireCase(boolean enable) Enables fire case simulation per API 521.In fire case, external heat flux is applied to the vessel surface, representing pool fire or jet fire scenarios. The heat input is calculated as: Q = fireHeatFlux * wetSurfaceFraction * wallArea
- Parameters:
enable- True to enable fire case
-
setFireHeatFlux
public void setFireHeatFlux(double heatFlux) Sets the fire heat flux per API 521.Typical values per API 521:
- Pool fire (adequate drainage): 25,000 W/m² (25 kW/m²)
- Pool fire (inadequate drainage): 43,200 W/m² (43.2 kW/m²)
- Jet fire: 100,000+ W/m² (100+ kW/m²)
- Parameters:
heatFlux- Heat flux [W/m²]
-
setFireHeatFlux
Sets the fire heat flux with unit.- Parameters:
heatFlux- Heat flux valueunit- Unit ("W/m2", "kW/m2", "BTU/hr/ft2")
-
setWettedSurfaceFraction
public void setWettedSurfaceFraction(double fraction) Sets the wetted surface fraction for fire relief calculations.This is the fraction of vessel surface that is wetted by liquid and can absorb fire heat. Per API 521, only wetted surface should be considered for relief valve sizing.
- Parameters:
fraction- Wetted fraction (0-1), typically 0.25-0.5 for horizontal vessels
-
isFireCase
public boolean isFireCase()Checks if fire case is enabled.- Returns:
- True if fire case simulation is active
-
getFireHeatInput
Gets the current fire heat input rate.- Parameters:
unit- Unit ("W", "kW", "MW")- Returns:
- Fire heat input rate
-
setValveOpeningTime
public void setValveOpeningTime(double time) Sets the valve opening time for ESD valve dynamics.Models gradual valve opening at start of blowdown. The effective orifice area ramps from 0 to full over this time period.
- Parameters:
time- Opening time [s], 0 for instant opening
-
setCalculationType
Sets the calculation type.- Parameters:
type- Calculation type
-
setHeatTransferType
Sets the heat transfer type.- Parameters:
type- Heat transfer type
-
setFlowDirection
Sets the flow direction.- Parameters:
direction- Flow direction
-
setFixedU
public void setFixedU(double u) Sets a fixed overall heat transfer coefficient.- Parameters:
u- U-value [W/(m²*K)]
-
setFixedQ
public void setFixedQ(double q) Sets a fixed heat rate.- Parameters:
q- Heat rate [W] (positive = heat into vessel)
-
getPressure
public double getPressure()Gets the current vessel pressure.- Specified by:
getPressurein interfaceProcessEquipmentInterface- Overrides:
getPressurein classProcessEquipmentBaseClass- Returns:
- Pressure [Pa]
-
getPressure
Gets the current vessel pressure in specified unit.- Specified by:
getPressurein interfaceProcessEquipmentInterface- Overrides:
getPressurein classProcessEquipmentBaseClass- Parameters:
unit- Pressure unit ("Pa", "bar", "bara", "barg", "psi")- Returns:
- Pressure in specified unit
-
getTemperature
public double getTemperature()Gets the current fluid temperature.- Specified by:
getTemperaturein interfaceProcessEquipmentInterface- Overrides:
getTemperaturein classProcessEquipmentBaseClass- Returns:
- Temperature [K]
-
getTemperature
Gets the current fluid temperature in specified unit.- Specified by:
getTemperaturein interfaceProcessEquipmentInterface- Overrides:
getTemperaturein classProcessEquipmentBaseClass- Parameters:
unit- Temperature unit ("K", "C", "F")- Returns:
- Temperature in specified unit
-
getWallTemperature
public double getWallTemperature()Gets the current wall temperature.- Returns:
- Wall temperature [K]
-
getMass
public double getMass()Gets the current mass in the vessel.- Returns:
- Mass [kg]
-
getDensity
public double getDensity()Gets the current density.- Returns:
- Density [kg/m³]
-
getOutletStream
Gets the outlet stream.The outlet stream represents the gas leaving the vessel through the orifice. It can be connected to downstream equipment like a Flare or Mixer (flare header).
Example integration with flare system:
VesselDepressurization vessel = new VesselDepressurization("Tank", feed); vessel.run(); // Connect to flare Flare flare = new Flare("Emergency Flare", vessel.getOutletStream()); flare.setFlameHeight(50.0); // Or connect via flare header Mixer flareHeader = new Mixer("Flare Header"); flareHeader.addStream(vessel.getOutletStream()); Flare flare = new Flare("Flare", flareHeader.getOutletStream());- Returns:
- Outlet stream with current discharge conditions
-
getDischargeRate
Gets the current mass discharge rate.This is the instantaneous mass flow rate through the orifice, useful for flare capacity checks and header sizing.
- Parameters:
unit- Flow rate unit ("kg/s", "kg/hr", "kg/min")- Returns:
- Mass discharge rate in specified unit
-
getPeakDischargeRate
Gets the peak mass discharge rate from simulation history.This is critical for flare header sizing - the maximum flow rate determines the required capacity.
- Parameters:
unit- Flow rate unit ("kg/s", "kg/hr", "kg/min")- Returns:
- Peak mass discharge rate in specified unit
-
getTotalMassDischarged
Gets the total mass discharged from simulation history.- Parameters:
unit- Mass unit ("kg", "tonnes")- Returns:
- Total mass discharged
-
getTimeToReachPressure
public double getTimeToReachPressure(double targetPressure) Gets the time to reach a target pressure.Useful for blowdown time calculations per API 521.
- Parameters:
targetPressure- Target pressure [bar]- Returns:
- Time to reach target pressure [s], or -1 if not reached
-
getMinimumTemperatureReached
Gets the minimum temperature reached during blowdown.Critical for MDMT (Minimum Design Metal Temperature) assessment.
- Parameters:
unit- Temperature unit ("K", "C")- Returns:
- Minimum temperature reached
-
getMinimumWallTemperatureReached
Gets the minimum wall temperature reached during blowdown.Critical for MDMT assessment - wall temperature may be limiting for brittle fracture.
- Parameters:
unit- Temperature unit ("K", "C")- Returns:
- Minimum wall temperature reached
-
getTimeHistory
-
getPressureHistory
-
getTemperatureHistory
-
getMassHistory
-
clearHistory
public void clearHistory()Clears the history arrays. -
calculateMassFlowRate
private double calculateMassFlowRate()Calculates the mass flow rate through the orifice.- Returns:
- Mass flow rate [kg/s] (positive for discharge)
-
calculateInternalHeatTransferCoeff
private double calculateInternalHeatTransferCoeff()Calculates the internal heat transfer coefficient.- Returns:
- Internal film coefficient [W/(m²*K)]
-
calculateGasHeatTransferCoeff
private double calculateGasHeatTransferCoeff()Calculates the gas phase heat transfer coefficient.- Returns:
- Gas phase film coefficient [W/(m²*K)]
-
calculateLiquidHeatTransferCoeff
private double calculateLiquidHeatTransferCoeff()Calculates the liquid phase heat transfer coefficient.Uses natural convection or nucleate boiling correlation depending on wall superheat.
- Returns:
- Liquid phase film coefficient [W/(m²*K)]
-
calculateHeatRate
private double calculateHeatRate()Calculates the heat transfer rate to the fluid.- Returns:
- Heat rate [W] (positive = heat into fluid)
-
calculateTwoPhaseHeatRate
private double calculateTwoPhaseHeatRate()Calculates heat transfer rate for two-phase conditions.Computes separate heat transfer rates for the gas-wetted and liquid-wetted wall areas, using appropriate correlations for each phase.
- Returns:
- Total heat rate [W] (positive = heat into fluid)
-
getWallArea
private double getWallArea()Gets the total inner wall surface area.- Returns:
- Wall area [m²]
-
run
In this method all thermodynamic and unit operations will be calculated in a steady state calculation.
- Parameters:
id- UUID
-
initializeWithLiquidLevel
private void initializeWithLiquidLevel()Initializes the vessel with the specified initial liquid level.This method adjusts the moles in each phase to match the target liquid and gas volumes based on the specified initial liquid level fraction. Similar to the approach used in Separator.
-
calculateLiquidVolumeFromLevel
private double calculateLiquidVolumeFromLevel(double levelFraction) Calculates the liquid volume corresponding to a given liquid level fraction.- Parameters:
levelFraction- Liquid level fraction (0-1)- Returns:
- Liquid volume [m³]
-
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.- Parameters:
dt- Delta time [s]id- Calculation identifier
-
recordState
private void recordState(double massFlowRate, double heatRate) Records the current state to history arrays.- Parameters:
massFlowRate- Current mass flow rate [kg/s]heatRate- Current heat rate [W]
-
updateOutletStream
private void updateOutletStream()Updates the outlet stream with current conditions. -
getVentTemperature
public double getVentTemperature()Gets the vent temperature (temperature after expansion through orifice).- Returns:
- Vent temperature [K]
-
getVaporFraction
public double getVaporFraction()Gets the current vapor fraction.- Returns:
- Vapor mole fraction (0-1)
-
getInternalEnergy
public double getInternalEnergy()Gets the current internal energy.- Returns:
- Internal energy [J]
-
getEnthalpy
public double getEnthalpy()Gets the current enthalpy.- Returns:
- Enthalpy [J]
-
getEntropy
public double getEntropy()Gets the current entropy.- Returns:
- Entropy [J/K]
-
getThermoSystem
Gets the thermoSystem.- Specified by:
getThermoSystemin interfaceProcessEquipmentInterface- Overrides:
getThermoSystemin classProcessEquipmentBaseClass- Returns:
- The thermodynamic system
-
runSimulation
Runs a complete simulation and returns structured results.This is a convenience method that handles the time loop and data collection internally. It provides a cleaner API compared to manually calling
runTransient(double, UUID)in a loop.Example:
vessel.run(); SimulationResult result = vessel.runSimulation(300.0, 0.5); // 5 min, 0.5s steps System.out.println("Min temp: " + result.getMinTemperature()); System.out.println("Mass discharged: " + result.getMassDischarged() + " kg");- Parameters:
endTime- Total simulation time [s]dt- Time step [s]- Returns:
- SimulationResult containing all history data
-
runSimulation
public VesselDepressurization.SimulationResult runSimulation(double endTime, double dt, int recordInterval) Runs a complete simulation with configurable output interval.- Parameters:
endTime- Total simulation time [s]dt- Time step [s]recordInterval- Record data every N steps (1 = every step)- Returns:
- SimulationResult containing history data
-
validate
public void validate()Validates the vessel configuration and throws exceptions for invalid setups.Call this method before running a simulation to catch common configuration errors:
- Back pressure higher than initial pressure
- Unreasonably large orifice compared to vessel
- Invalid liquid level settings
- Missing heat transfer configuration for ENERGY_BALANCE mode
- Throws:
IllegalStateException- if configuration is invalid
-
validateWithWarnings
-
createTwoPhaseFluid
public static SystemInterface createTwoPhaseFluid(String componentName, double temperature, double vaporFraction) Creates a two-phase pure component system at its saturation conditions.This is a convenience method that handles the bubble point calculation and phase setup automatically. For pure components, a simple TPflash won't produce two phases - you need to be exactly at saturation and explicitly set the phase fraction.
Example:
// Create CO2 at 250K with 60% vapor, 40% liquid SystemInterface co2 = VesselDepressurization.createTwoPhaseFluid("CO2", 250.0, 0.6); Stream feed = new Stream("feed", co2);- Parameters:
componentName- Component name (e.g., "CO2", "propane", "methane")temperature- Temperature [K]vaporFraction- Desired vapor mole fraction (0 = all liquid, 1 = all vapor)- Returns:
- Configured two-phase thermodynamic system
-
createTwoPhaseFluidAtPressure
public static SystemInterface createTwoPhaseFluidAtPressure(String componentName, double pressure, double vaporFraction) Creates a two-phase pure component system at specified pressure.If the specified pressure corresponds to saturation conditions, two phases will form. The temperature will be the saturation temperature at the given pressure.
- Parameters:
componentName- Component namepressure- Pressure [bar]vaporFraction- Desired vapor mole fraction (0 = all liquid, 1 = all vapor)- Returns:
- Configured two-phase thermodynamic system
-
exportToCSV
Exports transient simulation results to CSV format.The CSV includes time, pressure, temperature, mass, wall temperature, mass flow rate, and heat rate. This can be used for post-processing in Excel, Python pandas, or other tools.
- Returns:
- CSV formatted string with header row
-
exportToJSON
Exports transient results to JSON format.- Returns:
- JSON formatted string
-
calculateRequiredOrificeDiameter
public double calculateRequiredOrificeDiameter(double targetTime, double pressureReduction) Calculates required orifice diameter to meet API 521 blowdown time requirement.API 521 requires depressurization to 50% of initial pressure (or 6.9 barg, whichever is lower) within 15 minutes for fire case.
- Parameters:
targetTime- Target blowdown time [s], typically 900s (15 min)pressureReduction- Fraction of pressure to reduce (0.5 = 50%)- Returns:
- Required orifice diameter [m]
-
runOrificeSensitivity
public double[] runOrificeSensitivity(double[] orificeSizes, double targetPressure) Runs sensitivity analysis on orifice size.Calculates blowdown time for a range of orifice diameters. Useful for selecting optimal orifice size considering multiple constraints.
- Parameters:
orificeSizes- Array of orifice diameters to test [m]targetPressure- Target pressure [bar]- Returns:
- Array of blowdown times [s] for each orifice size
-
hasLiquidRainout
public boolean hasLiquidRainout()Checks for liquid rainout conditions in the outlet stream.Liquid rainout can occur when two-phase flow exits the vessel during depressurization. This can cause problems in flare headers (liquid accumulation) and at the flare tip (unstable burning).
- Returns:
- True if outlet stream contains liquid phase
-
getOutletLiquidFraction
public double getOutletLiquidFraction()Gets the liquid mass fraction in the outlet stream.- Returns:
- Liquid mass fraction (0-1), 0 if all vapor
-
getPeakOutletLiquidFraction
public double getPeakOutletLiquidFraction()Gets the peak liquid fraction observed during blowdown.This indicates the worst-case liquid loading on the flare header. Values above 0.1 (10%) may require liquid knockout facilities.
- Returns:
- Peak liquid mass fraction in outlet
-
getFlareHeaderVelocity
Estimates flare header velocity.Typical design limits:
- Flare headers: 0.3-0.6 Mach (approximately 100-200 m/s)
- Relief valve outlets: 0.5 Mach max
- Parameters:
headerDiameter- Flare header internal diameter [m]unit- Velocity unit ("m/s", "ft/s")- Returns:
- Gas velocity in header at current flow rate
-
getFlareHeaderMach
public double getFlareHeaderMach(double headerDiameter) Estimates Mach number in flare header.- Parameters:
headerDiameter- Flare header internal diameter [m]- Returns:
- Mach number
-
getHydrateFormationTemperature
public double getHydrateFormationTemperature()Calculates hydrate formation temperature at current vessel conditions.Hydrate formation during depressurization can occur when temperature drops below the hydrate equilibrium temperature. This can cause flow restrictions in blowdown lines and safety hazards.
- Returns:
- Hydrate formation temperature [K], or -1 if calculation fails or no hydrate formers
-
getHydrateFormationTemperature
Calculates hydrate formation temperature at current conditions with unit conversion.- Parameters:
unit- Temperature unit ("K", "C")- Returns:
- Hydrate formation temperature in specified unit
-
hasHydrateRisk
public boolean hasHydrateRisk()Checks if current vessel temperature is below hydrate formation temperature.- Returns:
- True if hydrate formation risk exists (T_vessel < T_hydrate)
-
getHydrateSubcooling
Gets the hydrate subcooling (margin below hydrate temperature).Positive values indicate hydrate risk. Negative values indicate safety margin.
- Parameters:
unit- Temperature unit ("K", "C")- Returns:
- Subcooling = T_hydrate - T_vessel
-
getMaxHydrateSubcoolingDuringBlowdown
public double getMaxHydrateSubcoolingDuringBlowdown()Gets the minimum hydrate subcooling (maximum risk) observed during blowdown history.Tracks the point where temperature was furthest below hydrate curve during the entire depressurization.
- Returns:
- Maximum subcooling observed [K or C]
-
getCO2FreezingTemperature
public double getCO2FreezingTemperature()Gets the CO2 freezing (dry ice) temperature at current pressure.CO2 triple point is at 5.18 bar, -56.6°C (216.55 K). Below this pressure, CO2 sublimates directly from solid to vapor. At higher pressures, the solid-liquid melting line applies.
Key points on CO2 phase diagram:
- Sublimation at 1 bar: -78.5°C (194.7 K)
- Triple point: 5.18 bar, -56.6°C (216.55 K)
- Melting at 100 bar: approx -55°C (218 K)
- Melting at 500 bar: approx -45°C (228 K)
- Returns:
- CO2 freezing temperature [K], or -1 if no CO2 in system
-
getCO2FreezingTemperature
Gets the CO2 freezing temperature with unit conversion.- Parameters:
unit- Temperature unit ("K", "C")- Returns:
- CO2 freezing temperature
-
hasCO2FreezingRisk
public boolean hasCO2FreezingRisk()Checks if current temperature is below CO2 freezing point.- Returns:
- True if CO2 freezing (dry ice) risk exists
-
getCO2FreezingSubcooling
public double getCO2FreezingSubcooling()Gets the CO2 freezing subcooling (margin below freezing point).- Returns:
- Subcooling [K] = T_freeze - T_vessel (positive = freezing risk)
-
assessFlowAssuranceRisks
Comprehensive flow assurance risk assessment during blowdown.Returns a summary of all flow assurance risks including:
- Hydrate formation risk
- CO2 freezing (dry ice) risk
- MDMT (minimum design metal temperature) concerns
- Liquid rainout in flare header
- Returns:
- Map of risk assessments with descriptions
-