Class Orifice

All Implemented Interfaces:
Serializable, Runnable, ProcessEquipmentInterface, TwoPortInterface, SimulationInterface, NamedInterface

public class Orifice extends TwoPortEquipment

Orifice class for flow restriction and measurement using ISO 5167 orifice plate calculations.

This class supports both steady-state and transient/dynamic simulations. In transient mode, the orifice calculates flow based on the pressure differential across the plate using ISO 5167 equations, making it suitable for depressurization and blowdown scenarios.

Key features:

  • ISO 5167 compliant flow calculations with Reader-Harris/Gallagher discharge coefficient
  • Support for corner, flange, D and D/2 pressure taps
  • Compressible flow with expansibility factor
  • Pressure-driven flow in transient simulations (flow = f(ΔP))
  • Automatic handling of zero/low flow conditions
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

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

      private Double dp
    • diameter

      private Double diameter
    • diameter_outer

      private Double diameter_outer
    • C

      private Double C
    • orificeDiameter

      private double orificeDiameter
    • pressureUpstream

      private double pressureUpstream
    • pressureDownstream

      private double pressureDownstream
    • dischargeCoefficient

      private double dischargeCoefficient
  • Constructor Details

    • Orifice

      public Orifice(String name)

      Constructor for Orifice.

      Parameters:
      name - a String object
    • Orifice

      public Orifice(String name, double diameter, double orificeDiameter, double pressureUpstream, double pressureDownstream, double dischargeCoefficient)
      Constructor for Orifice with full ISO 5167 parameters.

      Creates an orifice plate flow restriction device with specified geometry and operating conditions. This constructor is typically used for transient/dynamic simulations where the orifice controls flow based on pressure differential.

      Parameters:
      name - Name of the orifice equipment
      diameter - Upstream pipe internal diameter in meters
      orificeDiameter - Orifice bore diameter in meters
      pressureUpstream - Upstream design pressure in bara (used for reference)
      pressureDownstream - Downstream boundary pressure in bara (e.g., flare header pressure). This value is used in transient simulations to establish the driving pressure differential.
      dischargeCoefficient - Orifice discharge coefficient (typically 0.60-0.62 for sharp-edged orifices, or calculated using Reader-Harris/Gallagher method)
  • Method Details

    • setOrificeParameters

      @Deprecated public void setOrificeParameters(Double diameter, Double diameter_outer, Double C)
      Deprecated.
      Use constructor parameters instead
      Set orifice parameters for legacy compatibility.

      Note: These parameters are currently not used in the ISO 5167 calculations. Use the constructor with diameter, orificeDiameter, and dischargeCoefficient instead for transient simulations.

      Parameters:
      diameter - Orifice diameter
      diameter_outer - Outer diameter
      C - Discharge coefficient
    • calc_dp

      public Double calc_dp()
      Calculate the non-recoverable pressure drop across the orifice.

      This method calculates the permanent pressure loss (deltaW) across an orifice plate, which represents the portion of pressure drop that is not recovered downstream. The calculation is based on the discharge coefficient and beta ratio.

      Returns:
      Non-recoverable pressure drop in bar
    • calculateDischargeCoefficient

      public static double calculateDischargeCoefficient(double D, double Do, double rho, double mu, double m, String taps)
      Calculates the orifice discharge coefficient using the Reader-Harris Gallagher method.
      Parameters:
      D - Upstream internal pipe diameter, in meters.
      Do - Diameter of orifice at flow conditions, in meters.
      rho - Density of fluid at P1, in kg/m^3.
      mu - Viscosity of fluid at P1, in Pa*s.
      m - Mass flow rate of fluid through the orifice, in kg/s.
      taps - Tap type ("corner", "flange", "D", or "D/2").
      Returns:
      Discharge coefficient of the orifice.
    • calculateExpansibility

      public static double calculateExpansibility(double D, double Do, double P1, double P2, double k)
      Calculates the expansibility factor for orifice plate calculations.
      Parameters:
      D - Upstream internal pipe diameter, in meters.
      Do - Diameter of orifice at flow conditions, in meters.
      P1 - Static pressure of fluid upstream, in Pa.
      P2 - Static pressure of fluid downstream, in Pa.
      k - Isentropic exponent of fluid.
      Returns:
      Expansibility factor (1 for incompressible fluids).
    • calculatePressureDrop

      public static double calculatePressureDrop(double D, double Do, double P1, double P2, double C)
      Calculates the non-recoverable pressure drop across the orifice plate.
      Parameters:
      D - Upstream internal pipe diameter, in meters.
      Do - Diameter of orifice at flow conditions, in meters.
      P1 - Static pressure of fluid upstream, in Pa.
      P2 - Static pressure of fluid downstream, in Pa.
      C - Discharge coefficient.
      Returns:
      Non-recoverable pressure drop, in Pa.
    • calculateBetaRatio

      public static double calculateBetaRatio(double D, double Do)
      Calculates the diameter ratio (beta) of the orifice plate.
      Parameters:
      D - Upstream internal pipe diameter, in meters.
      Do - Diameter of orifice at flow conditions, in meters.
      Returns:
      Diameter ratio (beta).
    • calculateMassFlowRate

      public static double calculateMassFlowRate(double D, double Do, double P1, double P2, double rho, double mu, double k, String taps)
      Calculates the mass flow rate through an orifice plate using the ISO 5167 formulation.

      Inputs and output are all in SI units. The method iterates the Reader-Harris/Gallagher discharge coefficient until convergence.

      Parameters:
      D - upstream internal pipe diameter in meters
      Do - orifice diameter in meters
      P1 - upstream static pressure in Pa
      P2 - downstream static pressure in Pa
      rho - fluid density in kg/m3 at P1
      mu - fluid viscosity in Pa*s at P1
      k - isentropic exponent of the fluid
      taps - pressure tap type ("corner", "flange", "D", or "D/2")
      Returns:
      mass flow rate in kg/s
    • run

      public void run(UUID uuid)

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

      Parameters:
      uuid - UUID
    • runTransient

      public void runTransient(double dt, UUID id)
      Run transient simulation for the orifice.

      In transient mode, the orifice acts as a pressure-driven flow restriction device. The flow rate through the orifice is calculated based on the pressure differential using ISO 5167 equations:

      m = A × C × ε × √(2ρΔP / (1 - β⁴))
      

      where:

      • A = orifice area (m²)
      • C = discharge coefficient
      • ε = expansibility factor (accounts for compressibility)
      • ρ = fluid density at inlet (kg/m³)
      • ΔP = pressure drop across orifice (Pa)
      • β = diameter ratio (d/D)

      The downstream pressure is taken from the stored pressureDownstream value if available (e.g., flare header pressure), otherwise it reads from the outlet stream. This ensures proper flow calculation even when stream pressures aren't updated in the flow network.

      Important: In dynamic simulations, the orifice DETERMINES the flow rate based on available ΔP. This is different from steady-state mode where flow may be specified upstream. The calculated flow is set on both the thermoSystem and inStream to ensure consistency in the process network.

      Parameters:
      dt - Time step in seconds (not used for orifice as it has no accumulation/storage)
      id - Unique identifier for this simulation run