Class VirtualFlowMeter

All Implemented Interfaces:
Serializable, MeasurementDeviceInterface, NamedInterface

public class VirtualFlowMeter extends StreamMeasurementDeviceBaseClass
Virtual Flow Meter for calculating multiphase flow rates from pressure and temperature measurements.

This class implements a physics-based virtual flow meter using NeqSim's thermodynamic models to estimate oil, gas, and water flow rates. It is designed for integration with AI-powered production optimization platforms that require accurate flow estimates with uncertainty quantification.

Key features:

  • Thermodynamic flash calculations for phase split
  • Uncertainty propagation from input measurements
  • Online calibration with well test data
  • Quality indicators for result confidence
Version:
1.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • upstreamPressure

      private double upstreamPressure
    • downstreamPressure

      private double downstreamPressure
    • temperature

      private double temperature
    • chokeOpening

      private double chokeOpening
    • pressureUncertainty

      private double pressureUncertainty
    • temperatureUncertainty

      private double temperatureUncertainty
    • flowCoefficient

      private double flowCoefficient
    • calibrationFactor

      private double calibrationFactor
    • calibrationHistory

      private List<VirtualFlowMeter.WellTestData> calibrationHistory
    • lastCalibration

      private Instant lastCalibration
    • lastResult

      private VFMResult lastResult
  • Constructor Details

    • VirtualFlowMeter

      public VirtualFlowMeter(String name, StreamInterface stream)
      Creates a new Virtual Flow Meter.
      Parameters:
      name - the meter name/tag
      stream - the stream to measure
  • Method Details

    • setUpstreamPressure

      public void setUpstreamPressure(double pressure)
      Sets the upstream pressure measurement.
      Parameters:
      pressure - pressure in bara
    • setDownstreamPressure

      public void setDownstreamPressure(double pressure)
      Sets the downstream pressure measurement.
      Parameters:
      pressure - pressure in bara
    • setTemperature

      public void setTemperature(double temperature)
      Sets the temperature measurement.
      Parameters:
      temperature - temperature in K
    • setChokeOpening

      public void setChokeOpening(double opening)
      Sets the choke opening.
      Parameters:
      opening - choke opening in percent (0-100)
    • setMeasurementUncertainties

      public void setMeasurementUncertainties(double pressureRelative, double temperatureAbsolute)
      Sets the measurement uncertainties.
      Parameters:
      pressureRelative - relative pressure uncertainty (e.g., 0.01 for 1%)
      temperatureAbsolute - absolute temperature uncertainty in K
    • calculateFlowRates

      public VFMResult calculateFlowRates()
      Calculates flow rates from current measurements.
      Returns:
      VFM result with flow rates and uncertainties
    • calculateFlowRates

      public VFMResult calculateFlowRates(double pressure, double differentialPressure, double temperature)
      Calculates flow rates from specified P, T, dP conditions.
      Parameters:
      pressure - upstream pressure in bara
      differentialPressure - pressure drop in bar
      temperature - temperature in K
      Returns:
      VFM result with flow rates and uncertainties
    • calculateUncertainty

      private double calculateUncertainty(double rate, double pressureUncert, double tempUncert)
      Calculates uncertainty using simplified error propagation.
      Parameters:
      rate - phase flow rate in Sm3/d
      pressureUncert - relative pressure uncertainty (fraction)
      tempUncert - absolute temperature uncertainty (K)
      Returns:
      one standard deviation of the flow-rate estimate
    • determineQuality

      private VFMResult.Quality determineQuality(double pressure, double temperature)
      Determines result quality based on operating conditions and calibration.
      Parameters:
      pressure - current operating pressure in bara
      temperature - current operating temperature in Kelvin
      Returns:
      quality indicator based on calibration range and age
    • calibrate

      public void calibrate(List<VirtualFlowMeter.WellTestData> wellTests)
      Calibrates the VFM using well test data.
      Parameters:
      wellTests - list of well test measurements
    • getLastResult

      public VFMResult getLastResult()
      Gets the last calculated result.
      Returns:
      the last VFM result
    • getUncertaintyBounds

      public UncertaintyBounds getUncertaintyBounds()
      Gets uncertainty bounds for the current measurement.
      Returns:
      uncertainty bounds for total flow rate
    • getMeasuredValue

      public double getMeasuredValue(String unit)
      Description copied from class: MeasurementDeviceBaseClass

      Get Measured value in specified unit.

      Specified by:
      getMeasuredValue in interface MeasurementDeviceInterface
      Overrides:
      getMeasuredValue in class MeasurementDeviceBaseClass
      Parameters:
      unit - a String object
      Returns:
      a double
    • setFlowCoefficient

      public void setFlowCoefficient(double coefficient)
      Sets the flow coefficient (Cv-like parameter).
      Parameters:
      coefficient - the flow coefficient
    • getCalibrationFactor

      public double getCalibrationFactor()
      Gets the calibration factor.
      Returns:
      the calibration factor
    • getLastCalibrationTime

      public Instant getLastCalibrationTime()
      Gets the last calibration timestamp.
      Returns:
      the last calibration time or null