Class VesselDepressurization
- All Implemented Interfaces:
Serializable, Runnable, ProcessEquipmentInterface, ProcessElementInterface, 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 enumFire model type for external fire heat transfer.static enumPreset fire type configurations per industry standards.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 booleanprivate doubleprivate doubleprivate doubleprivate booleanprivate doubleprivate doubleprivate VesselDepressurization.FireTypeprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate TransientWallHeatTransferprivate doubleprivate booleanprivate doubleprivate doubleprivate doubleprivate SystemInterfaceprivate 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 static final doubleStefan-Boltzmann constant [W/(m^2*K^4)].private doubleprivate doubleprivate doubleprivate booleanprivate SystemInterfaceprivate booleanprivate 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 external heat transfer coefficient using natural convection correlations.private voidCalculates the flame temperature from the incident heat flux.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 specific enthalpy of the incoming gas during filling.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.doublecalculateSBFireFlux(double outerWallTemperatureK) Calculates the net fire heat flux at the outer wall surface using the Stefan-Boltzmann model.private doubleCalculates heat transfer rate for two-phase conditions.voidClears the fixed flow rate setting, reverting to orifice-based flow calculation.voidClears the history arrays.private doublecomputeThermalExpansionCoeff(PhaseInterface phase, double density, double temperatureK) Computes the volumetric thermal expansion coefficient from the equation of state.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.Gets the fire model type.Gets the current fire type.doubleGets the flame temperature used by the Stefan-Boltzmann fire model.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.booleanReturns whether the target pressure has been reached.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.voidsetCalculateExternalHTC(boolean calculate) Enables or disables automatic calculation of external heat transfer coefficient.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.voidSets the fire model type.voidSets a preset fire type with standard parameters.voidsetFixedInternalHTC(double h) Sets a fixed internal (gas-side) heat transfer coefficient.voidsetFixedMassFlowRate(double rate) Sets a fixed mass flow rate, overriding the orifice-based calculation.voidsetFixedQ(double q) Sets a fixed heat rate.voidsetFixedU(double u) Sets a fixed overall heat transfer coefficient.voidsetFixedVolumetricFlowRate(double rate, String unit) Sets a fixed volumetric flow rate at standard conditions, overriding the orifice calculation.voidsetFlameTemperature(double temperatureK) Sets the flame temperature directly for the Stefan-Boltzmann fire model.voidSets the flow direction.voidSets the heat transfer type.voidsetIncidentHeatFlux(double flux) Sets the incident heat flux for the Stefan-Boltzmann fire model.voidsetIncidentHeatFlux(double flux, String unit) Sets the incident heat flux with unit.voidsetInitialLiquidLevel(double level) Sets the initial liquid level as a fraction of vessel height.voidsetInitialWallTemperature(double temperatureK) Sets the initial wall temperature and re-initializes the wall model.voidsetInletStream(StreamInterface inletStream) Sets the inlet stream and initializes the vessel.voidsetInletTemperature(double temperature) Sets the inlet gas temperature for filling operations.voidsetInletTemperature(double temperature, String unit) Sets the inlet gas temperature for filling operations.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.voidsetSBFireParameters(double absorptivity, double flameEmissivity, double surfaceEmissivity, double convCoeff) Sets the Stefan-Boltzmann fire model parameters directly.voidsetTargetPressure(double pressure) Sets the target pressure for stopping the simulation.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
addCapacityConstraint, addController, copy, displayResult, equals, getAvailableMargin, getAvailableMarginPercent, getBottleneckConstraint, getCapacityConstraints, getConditionAnalysisMessage, getConstraintEvaluationReport, getController, getController, getControllers, getEffectiveCapacityFactor, getEnergyStream, getEntropyProduction, getExergyChange, getFailureMode, getMassBalance, getMassBalance, getMaxUtilization, getMaxUtilizationPercent, getMechanicalDesign, getMinimumFlow, getProperty, getReferenceDesignation, getReport_json, getResultTable, getSpecification, getUtilizationSummary, hashCode, initElectricalDesign, initializeDefaultConstraints, initInstrumentDesign, initMechanicalDesign, 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, simulateTrip, solved, toJson, toJsonMethods 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
getCapacityDuty, getCapacityMax, getElectricalDesign, getEquipmentState, getExergyChange, getExergyDestruction, getExergyDestruction, getFluid, getInletStreams, getInstrumentDesign, getOperatingEnvelopeViolation, getOutletFlowRate, getOutletPressure, getOutletStreams, getOutletTemperature, getReferenceDesignationString, getRestCapacity, getSimulationValidationErrors, isSimulationValid, isWithinOperatingEnvelope, 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 -
fireModelType
-
fireType
-
STEFAN_BOLTZMANN
private static final double STEFAN_BOLTZMANNStefan-Boltzmann constant [W/(m^2*K^4)].- See Also:
-
surfaceAbsorptivity
private double surfaceAbsorptivity -
flameEmissivity
private double flameEmissivity -
surfaceEmissivity
private double surfaceEmissivity -
fireConvectionCoeff
private double fireConvectionCoeff -
flameTemperature
private double flameTemperature -
incidentHeatFlux
private double incidentHeatFlux -
orificeDiameter
private double orificeDiameter -
dischargeCoefficient
private double dischargeCoefficient -
valveOpeningTime
private double valveOpeningTime -
valveOpeningFraction
private double valveOpeningFraction -
useFixedFlowRate
private boolean useFixedFlowRate -
fixedMassFlowRate
private double fixedMassFlowRate -
inletTemperature
private double inletTemperature -
inletFluid
-
targetPressure
private double targetPressure -
targetPressureReached
private boolean targetPressureReached -
calculateExternalHTC
private boolean calculateExternalHTC -
calculationType
-
heatTransferType
-
flowDirection
-
fixedU
private double fixedU -
fixedQ
private double fixedQ -
fixedInternalHTC
private double fixedInternalHTC -
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.Volume is calculated as cylinder + two hemispheres (one full sphere): V = pi/4 * D^2 * L + pi/6 * D^3
- Parameters:
length- Vessel cylindrical length [m] (excluding hemispheric caps)diameter- Vessel inner 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
-
setFireModelType
Sets the fire model type.CONSTANT_FLUX: Legacy model that applies fire heat directly to gas (existing behavior). STEFAN_BOLTZMANN: Physically correct model that applies fire heat to the outer wall surface. The wall then conducts heat inward to the gas via the normal heat transfer path.
- Parameters:
type- Fire model type
-
getFireModelType
Gets the fire model type.- Returns:
- Current fire model type
-
setFireType
Sets a preset fire type with standard parameters.Automatically configures the Stefan-Boltzmann fire model with industry-standard parameters and calculates the flame temperature from the incident heat flux.
- Parameters:
type- Preset fire type (SCANDPOWER_JET, SCANDPOWER_POOL, API_JET, API_POOL)
-
getFireType
Gets the current fire type.- Returns:
- Current fire type
-
setIncidentHeatFlux
public void setIncidentHeatFlux(double flux) Sets the incident heat flux for the Stefan-Boltzmann fire model.The flame temperature is back-calculated from this flux assuming the initial wall temperature equals ambient temperature. This is standard practice for Scandpower-type fire models.
- Parameters:
flux- Incident heat flux [W/m^2]
-
setIncidentHeatFlux
Sets the incident heat flux with unit.- Parameters:
flux- Heat flux valueunit- Unit ("W/m2", "kW/m2", "BTU/hr/ft2")
-
setSBFireParameters
public void setSBFireParameters(double absorptivity, double flameEmissivity, double surfaceEmissivity, double convCoeff) Sets the Stefan-Boltzmann fire model parameters directly.- Parameters:
absorptivity- Surface absorptivity [-], typically 0.75-0.90flameEmissivity- Flame emissivity [-], typically 0.3-1.0surfaceEmissivity- Surface emissivity [-], typically 0.75-0.90convCoeff- Fire convection coefficient [W/(m^2*K)], typically 30-100
-
setFlameTemperature
public void setFlameTemperature(double temperatureK) Sets the flame temperature directly for the Stefan-Boltzmann fire model.- Parameters:
temperatureK- Flame temperature [K]
-
getFlameTemperature
public double getFlameTemperature()Gets the flame temperature used by the Stefan-Boltzmann fire model.- Returns:
- Flame temperature [K]
-
calculateSBFireFlux
public double calculateSBFireFlux(double outerWallTemperatureK) Calculates the net fire heat flux at the outer wall surface using the Stefan-Boltzmann model.The net heat flux is: q_fire = alpha_s * epsilon_f * sigma * T_f^4 + h_f * (T_f - T_wall) - epsilon_s * sigma * T_wall^4
This models the combined radiation from the fire (absorbed by the wall), convection from the fire, and re-radiation from the hot wall surface back to the surroundings.
- Parameters:
outerWallTemperatureK- Outer wall surface temperature [K]- Returns:
- Net fire heat flux [W/m^2], positive into wall
-
calculateFlameTemperature
private void calculateFlameTemperature()Calculates the flame temperature from the incident heat flux.Uses Newton-Raphson iteration to solve: q_incident = alpha_s * epsilon_f * sigma * T_f^4 + h_f * (T_f - T_ref) for T_f, where T_ref is the ambient temperature.
-
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
-
setFixedMassFlowRate
public void setFixedMassFlowRate(double rate) Sets a fixed mass flow rate, overriding the orifice-based calculation.When set, the specified mass flow rate is used instead of computing flow from pressure difference across an orifice. The sign convention is handled automatically based on the flow direction.
- Parameters:
rate- Mass flow rate [kg/s] (positive value)
-
setFixedVolumetricFlowRate
Sets a fixed volumetric flow rate at standard conditions, overriding the orifice calculation.The volumetric rate at standard conditions is converted to mass flow rate using the standard gas density derived from the fluid molar mass and ideal gas law at 15 deg C, 1 atm.
- Parameters:
rate- Volumetric flow rate (positive value)unit- Unit string, e.g. "Sm3/day", "Sm3/hr", "Sm3/sec"
-
clearFixedFlowRate
public void clearFixedFlowRate()Clears the fixed flow rate setting, reverting to orifice-based flow calculation. -
setInletTemperature
public void setInletTemperature(double temperature) Sets the inlet gas temperature for filling operations.During filling, incoming gas enters at this temperature. The energy balance uses the enthalpy of the incoming gas at the inlet temperature and vessel pressure. If not set, the vessel gas temperature is used (less accurate).
- Parameters:
temperature- Inlet temperature [K]
-
setInletTemperature
Sets the inlet gas temperature for filling operations.- Parameters:
temperature- Inlet temperatureunit- Temperature unit ("K", "C")
-
setTargetPressure
public void setTargetPressure(double pressure) Sets the target pressure for stopping the simulation.For filling: simulation stops when vessel pressure reaches or exceeds the target. For discharge: simulation stops when vessel pressure drops to or below the target.
- Parameters:
pressure- Target pressure [bar]
-
isTargetPressureReached
public boolean isTargetPressureReached()Returns whether the target pressure has been reached.- Returns:
- true if target pressure was reached
-
setCalculateExternalHTC
public void setCalculateExternalHTC(boolean calculate) Enables or disables automatic calculation of external heat transfer coefficient.When enabled, the external HTC is calculated using Churchill-Chu natural convection correlation for a vertical or horizontal cylinder, based on the outer wall temperature and ambient air properties. When disabled, the fixed value from
setExternalHeatTransferCoefficient(double)is used.- Parameters:
calculate- true to enable automatic calculation
-
setFixedU
public void setFixedU(double u) Sets a fixed overall heat transfer coefficient.- Parameters:
u- U-value [W/(m²*K)]
-
setFixedInternalHTC
public void setFixedInternalHTC(double h) Sets a fixed internal (gas-side) heat transfer coefficient.When set (non-NaN), this value overrides the Churchill-Chu / mixed-convection correlation in CALCULATED and TRANSIENT_WALL modes. Use with TRANSIENT_WALL to keep transient wall conduction while fixing the internal film coefficient.
- Parameters:
h- Internal film coefficient [W/(m2*K)], or NaN to auto-calculate
-
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]
-
setInitialWallTemperature
public void setInitialWallTemperature(double temperatureK) Sets the initial wall temperature and re-initializes the wall model. Use this method to chain consecutive simulations (e.g. filling → transport → emptying) where the wall temperature at the start of one phase equals the wall temperature at the end of the previous phase.- Parameters:
temperatureK- Initial 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)
-
computeThermalExpansionCoeff
private double computeThermalExpansionCoeff(PhaseInterface phase, double density, double temperatureK) Computes the volumetric thermal expansion coefficient from the equation of state.The real-gas thermal expansion coefficient is defined as:
beta = -(1 / rho) * (drho / dT)_P
At high pressures this can deviate significantly from the ideal-gas value 1/T, which directly affects the Grashof number used in natural-convection correlations.
- Parameters:
phase- The thermodynamic phase to evaluatedensity- Phase density [kg/m^3]temperatureK- Phase temperature [K]- Returns:
- Thermal expansion coefficient [1/K], falls back to 1/T if EoS derivative is unavailable
-
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)]
-
calculateInletSpecificEnthalpy
private double calculateInletSpecificEnthalpy()Calculates the specific enthalpy of the incoming gas during filling.If an inlet temperature is set, the enthalpy is computed at the inlet temperature and the current vessel pressure using a clone of the feed fluid. Otherwise, the vessel gas enthalpy is used as a fallback.
- Returns:
- Specific enthalpy of incoming gas [J/kg]
-
calculateExternalHeatTransferCoefficient
private double calculateExternalHeatTransferCoefficient()Calculates the external heat transfer coefficient using natural convection correlations.Uses Churchill-Chu correlation for natural convection on a vertical or horizontal cylinder in still air. Air properties are evaluated at the film temperature (average of outer wall and ambient temperatures).
- Returns:
- External heat transfer coefficient [W/(m2*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
-