Class Tank

All Implemented Interfaces:
Serializable, Runnable, AutoSizeable, CapacityConstrainedEquipment, ProcessEquipmentInterface, SimulationInterface, NamedInterface

Tank class.

Version:
$Id: $Id
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

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

      static org.apache.logging.log4j.Logger logger
      Logger object for class.
    • mechanicalDesign

      private TankMechanicalDesign mechanicalDesign
      Mechanical design for the tank.
    • autoSized

      private boolean autoSized
      Whether tank has been auto-sized.
    • designLiquidLevel

      private double designLiquidLevel
      Design liquid level (fraction).
    • designResidenceTime

      private double designResidenceTime
      Design liquid residence time (seconds).
    • designVolume

      private double designVolume
      Design volume (m3).
    • minResidenceTime

      private double minResidenceTime
      Minimum residence time allowed (seconds).
    • maxLiquidLevel

      private double maxLiquidLevel
      Maximum liquid level allowed (fraction).
    • minLiquidLevel

      private double minLiquidLevel
      Minimum liquid level allowed (fraction).
    • tankCapacityConstraints

      private Map<String, CapacityConstraint> tankCapacityConstraints
      Tank capacity constraints map.
    • tankCapacityAnalysisEnabled

      private boolean tankCapacityAnalysisEnabled
      Whether capacity analysis is enabled.
    • thermoSystem

      SystemInterface thermoSystem
    • gasSystem

      SystemInterface gasSystem
    • waterSystem

      SystemInterface waterSystem
    • liquidSystem

      SystemInterface liquidSystem
    • thermoSystemCloned

      SystemInterface thermoSystemCloned
    • gasOutStream

      Stream gasOutStream
    • liquidOutStream

      Stream liquidOutStream
    • numberOfInputStreams

      private int numberOfInputStreams
    • inletStreamMixer

      Mixer inletStreamMixer
    • efficiency

      private double efficiency
    • liquidCarryoverFraction

      private double liquidCarryoverFraction
    • gasCarryunderFraction

      private double gasCarryunderFraction
    • volume

      private double volume
    • steelWallTemperature

      double steelWallTemperature
    • steelWallMass

      double steelWallMass
    • steelWallArea

      double steelWallArea
    • heatTransferNumber

      double heatTransferNumber
    • steelCp

      double steelCp
    • separatorLength

      double separatorLength
    • separatorDiameter

      double separatorDiameter
    • liquidVolume

      double liquidVolume
    • gasVolume

      double gasVolume
    • liquidLevel

      private double liquidLevel
  • Constructor Details

    • Tank

      public Tank(String name)
      Constructor for Tank.
      Parameters:
      name - name of tank
    • Tank

      public Tank(String name, StreamInterface inletStream)

      Constructor for Tank.

      Parameters:
      name - a String object
      inletStream - a StreamInterface object
  • Method Details

    • getMechanicalDesign

      public TankMechanicalDesign getMechanicalDesign()

      Get a mechanicalDesign for the equipment.

      Specified by:
      getMechanicalDesign in interface ProcessEquipmentInterface
      Overrides:
      getMechanicalDesign in class ProcessEquipmentBaseClass
      Returns:
      a MechanicalDesign object
    • initMechanicalDesign

      public void initMechanicalDesign()

      Initialize a initMechanicalDesign for the equipment.

      Specified by:
      initMechanicalDesign in interface ProcessEquipmentInterface
      Overrides:
      initMechanicalDesign in class ProcessEquipmentBaseClass
    • setInletStream

      public void setInletStream(StreamInterface inletStream)

      setInletStream.

      Parameters:
      inletStream - a StreamInterface object
    • addStream

      public void addStream(StreamInterface newStream)

      addStream.

      Parameters:
      newStream - a StreamInterface object
    • getLiquidOutStream

      public StreamInterface getLiquidOutStream()

      Getter for the field liquidOutStream.

      Returns:
      a Stream object
    • getGasOutStream

      public StreamInterface getGasOutStream()

      Getter for the field gasOutStream.

      Returns:
      a Stream object
    • getGas

      public StreamInterface getGas()

      getGas.

      Returns:
      a Stream object
    • getLiquid

      public StreamInterface getLiquid()

      getLiquid.

      Returns:
      a Stream object
    • run

      public void run(UUID id)

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

      Calculates the following properties:

      • steelWallTemperature
      • gasOutStream
      • liquidOutStream
      • thermoSystem including properties
      • liquidLevel
      • liquidVolume
      • gasVolume
      Specified by:
      run in interface SimulationInterface
      Parameters:
      id - UUID
    • displayResult

      public void displayResult()

      displayResult.

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

      public void runTransient(double dt, UUID id)

      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.
      Specified by:
      runTransient in interface SimulationInterface
      Parameters:
      dt - Delta time [s]
      id - Calculation identifier
    • setOutComposition

      public void setOutComposition(SystemInterface thermoSystem)

      setOutComposition.

      Parameters:
      thermoSystem - a SystemInterface object
    • setTempPres

      public void setTempPres(double temp, double pres)

      setTempPres.

      Parameters:
      temp - a double
      pres - a double
    • getEfficiency

      public double getEfficiency()

      Getter for the field efficiency.

      Returns:
      a double
    • setEfficiency

      public void setEfficiency(double efficiency)

      Setter for the field efficiency.

      Parameters:
      efficiency - a double
    • getLiquidCarryoverFraction

      public double getLiquidCarryoverFraction()

      Getter for the field liquidCarryoverFraction.

      Returns:
      a double
    • setLiquidCarryoverFraction

      public void setLiquidCarryoverFraction(double liquidCarryoverFraction)

      Setter for the field liquidCarryoverFraction.

      Parameters:
      liquidCarryoverFraction - a double
    • getGasCarryunderFraction

      public double getGasCarryunderFraction()

      Getter for the field gasCarryunderFraction.

      Returns:
      a double
    • setGasCarryunderFraction

      public void setGasCarryunderFraction(double gasCarryunderFraction)

      Setter for the field gasCarryunderFraction.

      Parameters:
      gasCarryunderFraction - a double
    • getLiquidLevel

      public double getLiquidLevel()

      Getter for the field liquidLevel.

      Returns:
      a double
    • getVolume

      public double getVolume()

      Getter for the field volume.

      Returns:
      a double
    • setVolume

      public void setVolume(double volume)

      Setter for the field volume.

      Parameters:
      volume - a double
    • getMassBalance

      public double getMassBalance(String unit)

      getMassBalance.

      Specified by:
      getMassBalance in interface ProcessEquipmentInterface
      Overrides:
      getMassBalance in class ProcessEquipmentBaseClass
      Parameters:
      unit - a String object
      Returns:
      a double
    • toJson

      public String toJson()

      Serializes the Process Equipment along with its state to a JSON string.

      Specified by:
      toJson in interface ProcessEquipmentInterface
      Overrides:
      toJson in class ProcessEquipmentBaseClass
      Returns:
      json string.
    • toJson

      public String toJson(ReportConfig cfg)
      Serializes the Process Equipment with configurable level of detail.
      Specified by:
      toJson in interface ProcessEquipmentInterface
      Overrides:
      toJson in class ProcessEquipmentBaseClass
      Parameters:
      cfg - report configuration
      Returns:
      json string
    • validateSetup

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

      Checks for common setup errors:

      • Equipment has a valid name
      • Input streams connected
      • Operating parameters in valid ranges

      Validates the tank setup before execution. Checks that:

      • Equipment has a valid name
      • At least one inlet stream is connected
      • Tank volume is positive
      • Liquid level is within valid range
      Specified by:
      validateSetup in interface ProcessEquipmentInterface
      Returns:
      validation result with errors and warnings
    • autoSize

      public void autoSize(double safetyFactor)
      Automatically size the equipment based on connected stream conditions.

      This method calculates dimensions and design parameters using the inlet stream properties and applies the specified safety factor. The equipment must have a valid inlet stream connected before calling this method.

      Specified by:
      autoSize in interface AutoSizeable
      Parameters:
      safetyFactor - multiplier for design capacity, typically 1.1-1.3 (10-30% over design)
    • autoSize

      public void autoSize()
      Automatically size using default safety factor (1.2 = 20% margin).
      Specified by:
      autoSize in interface AutoSizeable
    • autoSize

      public void autoSize(String companyStandard, String trDocument)
      Automatically size using company-specific design standards.

      This method applies design rules from the specified company's technical requirements (TR) documents. The standards are loaded from the NeqSim design database.

      Specified by:
      autoSize in interface AutoSizeable
      Parameters:
      companyStandard - company name (e.g., "Equinor", "Shell", "TotalEnergies")
      trDocument - TR document reference (e.g., "TR2000", "DEP-31.38.01.11")
    • isAutoSized

      public boolean isAutoSized()
      Check if equipment has been auto-sized.
      Specified by:
      isAutoSized in interface AutoSizeable
      Returns:
      true if autoSize() has been called successfully
    • getSizingReport

      public String getSizingReport()
      Get a detailed sizing report after auto-sizing.

      The report includes:

      • Design basis (flow rates, pressures, temperatures)
      • Calculated dimensions
      • Design parameters (K-factor, Cv, velocity, etc.)
      • Safety margins
      Specified by:
      getSizingReport in interface AutoSizeable
      Returns:
      formatted sizing report string
    • getSizingReportJson

      public String getSizingReportJson()
      Get sizing report as JSON for programmatic access.
      Specified by:
      getSizingReportJson in interface AutoSizeable
      Returns:
      JSON string with sizing data
    • initializeTankCapacityConstraints

      private void initializeTankCapacityConstraints()
      Initialize tank capacity constraints.
    • setDesignLiquidLevel

      public void setDesignLiquidLevel(double level)
      Sets the design liquid level.
      Parameters:
      level - design liquid level (0-1 fraction)
    • getDesignLiquidLevel

      public double getDesignLiquidLevel()
      Gets the design liquid level.
      Returns:
      design liquid level (0-1 fraction)
    • setDesignResidenceTime

      public void setDesignResidenceTime(double time)
      Sets the design residence time.
      Parameters:
      time - design residence time in seconds
    • getDesignResidenceTime

      public double getDesignResidenceTime()
      Gets the design residence time.
      Returns:
      design residence time in seconds
    • setMinResidenceTime

      public void setMinResidenceTime(double time)
      Sets the minimum residence time.
      Parameters:
      time - minimum residence time in seconds
    • getMinResidenceTime

      public double getMinResidenceTime()
      Gets the minimum residence time.
      Returns:
      minimum residence time in seconds
    • setMaxLiquidLevel

      public void setMaxLiquidLevel(double level)
      Sets the maximum liquid level.
      Parameters:
      level - maximum liquid level (0-1 fraction)
    • getMaxLiquidLevel

      public double getMaxLiquidLevel()
      Gets the maximum liquid level.
      Returns:
      maximum liquid level (0-1 fraction)
    • setMinLiquidLevel

      public void setMinLiquidLevel(double level)
      Sets the minimum liquid level.
      Parameters:
      level - minimum liquid level (0-1 fraction)
    • getMinLiquidLevel

      public double getMinLiquidLevel()
      Gets the minimum liquid level.
      Returns:
      minimum liquid level (0-1 fraction)
    • isCapacityAnalysisEnabled

      public boolean isCapacityAnalysisEnabled()
      Checks if capacity analysis is enabled for this equipment.

      When disabled, this equipment is excluded from bottleneck detection, capacity utilization summaries, and optimization routines. The equipment still tracks its constraints but doesn't contribute to system-level analysis.

      Specified by:
      isCapacityAnalysisEnabled in interface CapacityConstrainedEquipment
      Overrides:
      isCapacityAnalysisEnabled in class ProcessEquipmentBaseClass
      Returns:
      true if capacity analysis is enabled (default is true)
    • setCapacityAnalysisEnabled

      public void setCapacityAnalysisEnabled(boolean enabled)
      Enables or disables capacity analysis for this equipment.

      When disabled, this equipment is excluded from:

      • System bottleneck detection (ProcessSystem.findBottleneck())
      • Capacity utilization summaries (ProcessSystem.getCapacityUtilizationSummary())
      • Equipment near capacity lists (ProcessSystem.getEquipmentNearCapacityLimit())
      • Optimization constraint checking

      The equipment still calculates and tracks its constraints internally.

      Specified by:
      setCapacityAnalysisEnabled in interface CapacityConstrainedEquipment
      Overrides:
      setCapacityAnalysisEnabled in class ProcessEquipmentBaseClass
      Parameters:
      enabled - true to include in capacity analysis, false to exclude
    • getCapacityConstraints

      public Map<String, CapacityConstraint> getCapacityConstraints()
      Gets all capacity constraints defined for this equipment.

      The map keys are constraint names (e.g., "speed", "gasLoadFactor") and values are the corresponding CapacityConstraint objects containing design values, current values, and utilization calculations.

      Specified by:
      getCapacityConstraints in interface CapacityConstrainedEquipment
      Returns:
      unmodifiable map of constraint name to CapacityConstraint
    • getBottleneckConstraint

      public CapacityConstraint getBottleneckConstraint()
      Gets the constraint with the highest utilization (the bottleneck).

      This method identifies which constraint is closest to or exceeding its design limit. Use this to determine what is limiting equipment capacity.

      Specified by:
      getBottleneckConstraint in interface CapacityConstrainedEquipment
      Returns:
      the bottleneck constraint, or null if no constraints are defined
    • isCapacityExceeded

      public boolean isCapacityExceeded()
      Checks if any capacity constraint is violated (exceeds 100% utilization).

      A violated constraint means the equipment is operating beyond its design capacity. For HARD constraints, this may indicate equipment trip or failure. For SOFT constraints, this indicates reduced efficiency or accelerated wear.

      Specified by:
      isCapacityExceeded in interface CapacityConstrainedEquipment
      Returns:
      true if any constraint utilization exceeds 1.0 (100%)
    • isHardLimitExceeded

      public boolean isHardLimitExceeded()
      Checks if any HARD constraint limit is exceeded.

      HARD limits represent absolute equipment limits (e.g., maximum speed) that cannot be exceeded without equipment trip or damage. This is more severe than general capacity exceedance.

      Specified by:
      isHardLimitExceeded in interface CapacityConstrainedEquipment
      Returns:
      true if any HARD constraint's max value is exceeded
    • getMaxUtilization

      public double getMaxUtilization()
      Gets the maximum utilization across all constraints.

      This gives a single number representing how close the equipment is to its limiting constraint. Values above 1.0 indicate the equipment is over capacity.

      Specified by:
      getMaxUtilization in interface CapacityConstrainedEquipment
      Returns:
      maximum utilization as fraction (1.0 = 100% of design capacity)
    • addCapacityConstraint

      public void addCapacityConstraint(CapacityConstraint constraint)
      Adds a new capacity constraint to this equipment.

      This allows dynamic addition of constraints at runtime. Constraints can be added during equipment configuration or based on operating conditions.

      Specified by:
      addCapacityConstraint in interface CapacityConstrainedEquipment
      Parameters:
      constraint - the constraint to add
    • removeCapacityConstraint

      public boolean removeCapacityConstraint(String constraintName)
      Removes a capacity constraint by name.
      Specified by:
      removeCapacityConstraint in interface CapacityConstrainedEquipment
      Parameters:
      constraintName - the name of the constraint to remove
      Returns:
      true if the constraint was found and removed
    • clearCapacityConstraints

      public void clearCapacityConstraints()
      Clears all capacity constraints from this equipment.
      Specified by:
      clearCapacityConstraints in interface CapacityConstrainedEquipment