Class MultiScenarioVFPGenerator

java.lang.Object
neqsim.process.util.optimizer.MultiScenarioVFPGenerator
All Implemented Interfaces:
Serializable

public class MultiScenarioVFPGenerator extends Object implements Serializable
Generates Eclipse VFP tables (VFPPROD/VFPEXP format) with GOR and water cut dimensions.

For each combination of (flow rate, outlet pressure, water cut, GOR), calculates the required inlet pressure by running the process simulation. This is the standard Eclipse VFP format for export systems/pipelines.

Table Format

BHP[rate][outletP][WC][GOR] = required inlet pressure (bara)

Where:
  - BHP = inlet pressure required to achieve the given rate
  - THP = outlet pressure constraint
  - rate = target flow rate (Sm3/d or kg/hr)
  - WC = water cut (fraction 0-1)
  - GOR = gas-oil ratio (Sm3/Sm3)

Thread Safety

The generator uses a process factory to create fresh ProcessSystem instances for parallel execution, ensuring thread safety. This pattern follows the established approach in eclipse_lift_curve_manifold_pressure_paralell_run.ipynb.

Usage Example

// Setup fluid input and generator
FluidMagicInput input = FluidMagicInput.fromE300File("FLUID.E300");
input.setGORRange(250, 10000);
input.setWaterCutRange(0.05, 0.60);
input.separateToStandardConditions();

RecombinationFlashGenerator flashGen = new RecombinationFlashGenerator(input);

// Create VFP generator with process factory
MultiScenarioVFPGenerator vfpGen = new MultiScenarioVFPGenerator(() -> createMyProcess(), // Factory
                                                                                          // for
                                                                                          // thread-safe
                                                                                          // execution
    "Feed", "Export");
vfpGen.setFlashGenerator(flashGen);

// Configure table axes
vfpGen.setFlowRates(new double[] {5000, 10000, 20000, 40000, 60000});
vfpGen.setOutletPressures(new double[] {50, 60, 70, 80});
vfpGen.setWaterCuts(new double[] {0.05, 0.20, 0.40, 0.60});
vfpGen.setGORs(new double[] {250, 500, 1000, 2000, 5000, 10000});

// Generate table
VFPTable table = vfpGen.generateVFPTable();

// Export to Eclipse format
vfpGen.exportVFPEXP("process_vfp.inc", 1);
Version:
1.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

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

      private static final org.apache.logging.log4j.Logger logger
      Logger object for class.
    • processFactory

      private transient Supplier<ProcessSystem> processFactory
    • feedStreamName

      private String feedStreamName
    • outletStreamName

      private String outletStreamName
    • flashGenerator

      private RecombinationFlashGenerator flashGenerator
    • inletTemperature

      private double inletTemperature
    • flowRates

      private double[] flowRates
    • outletPressures

      private double[] outletPressures
    • waterCuts

      private double[] waterCuts
    • GORs

      private double[] GORs
    • flowRateUnit

      private String flowRateUnit
    • minInletPressure

      private double minInletPressure
    • maxInletPressure

      private double maxInletPressure
    • pressureTolerance

      private double pressureTolerance
    • enableParallel

      private boolean enableParallel
    • numberOfWorkers

      private int numberOfWorkers
    • vfpTable

  • Constructor Details

    • MultiScenarioVFPGenerator

      public MultiScenarioVFPGenerator(Supplier<ProcessSystem> processFactory, String feedStreamName, String outletStreamName)
      Constructor with process factory for thread-safe parallel execution.
      Parameters:
      processFactory - factory function that creates a fresh process system
      feedStreamName - name of inlet stream
      outletStreamName - name of outlet stream (pressure target)
    • MultiScenarioVFPGenerator

      public MultiScenarioVFPGenerator(ProcessSystem process, String feedStreamName, String outletStreamName)
      Constructor with single process (for sequential execution or when process is thread-safe).
      Parameters:
      process - the process system (will be copied for parallel execution)
      feedStreamName - name of inlet stream
      outletStreamName - name of outlet stream
  • Method Details

    • generateVFPTable

      public MultiScenarioVFPGenerator.VFPTable generateVFPTable()
      Generate the VFP table by simulating all combinations.

      For each (rate, outletP, WC, GOR) combination, finds the minimum inlet pressure required to achieve the target rate at the specified outlet pressure.

      Returns:
      VFPTable with all results
    • executeSequential

      private void executeSequential(List<MultiScenarioVFPGenerator.VFPTask> tasks)
      Execute tasks sequentially.
      Parameters:
      tasks - list of VFP tasks
    • executeParallel

      private void executeParallel(List<MultiScenarioVFPGenerator.VFPTask> tasks)
      Execute tasks in parallel using ThreadPoolExecutor.
      Parameters:
      tasks - list of VFP tasks
    • calculateVFPPoint

      Calculate single VFP point with fresh process system (thread-safe).

      Uses binary search to find minimum inlet pressure that achieves target outlet pressure at the specified flow rate.

      Parameters:
      task - the VFP task to calculate
      Returns:
      VFPPoint with results
    • tryInletPressure

      private boolean tryInletPressure(ProcessSystem process, StreamInterface feedStream, SystemInterface fluid, double flowRate, double targetOutletP, double inletP)
      Try running process at given inlet pressure, check if outlet target achieved.
      Parameters:
      process - the process system
      feedStream - the feed stream to modify
      fluid - the fluid composition
      flowRate - target flow rate
      targetOutletP - target outlet pressure
      inletP - inlet pressure to try
      Returns:
      true if target achieved
    • validateConfiguration

      private void validateConfiguration()
      Validate configuration before running.
    • exportVFPEXP

      public void exportVFPEXP(String filePath, int tableNumber) throws IOException
      Export to Eclipse VFPEXP format.
      Parameters:
      filePath - output file path
      tableNumber - VFP table number
      Throws:
      IOException - if writing fails
    • exportVFPEXP

      public void exportVFPEXP(Path filePath, int tableNumber) throws IOException
      Export to Eclipse VFPEXP format.
      Parameters:
      filePath - output file path
      tableNumber - VFP table number
      Throws:
      IOException - if writing fails
    • toVFPEXPString

      public String toVFPEXPString(int tableNumber)
      Generate Eclipse VFPEXP format string.
      Parameters:
      tableNumber - VFP table number
      Returns:
      VFPEXP format string
    • setFluidInput

      public void setFluidInput(FluidMagicInput fluidInput)
      Set fluid input configuration (convenience method).

      This is a convenience method that creates a RecombinationFlashGenerator from the fluid input and automatically configures the water cut and GOR arrays from the fluid input settings.

      Parameters:
      fluidInput - the fluid input configuration
    • setFlashGenerator

      public void setFlashGenerator(RecombinationFlashGenerator flashGenerator)
      Set the recombination flash generator.
      Parameters:
      flashGenerator - the flash generator
    • getFlashGenerator

      public RecombinationFlashGenerator getFlashGenerator()
      Get the flash generator.
      Returns:
      the flash generator
    • setFlowRates

      public void setFlowRates(double[] flowRates)
      Set flow rates for VFP table.
      Parameters:
      flowRates - array of flow rates
    • getFlowRates

      public double[] getFlowRates()
      Get flow rates.
      Returns:
      array of flow rates
    • setOutletPressures

      public void setOutletPressures(double[] outletPressures)
      Set outlet pressures (THP) for VFP table.
      Parameters:
      outletPressures - array of outlet pressures in bara
    • getOutletPressures

      public double[] getOutletPressures()
      Get outlet pressures.
      Returns:
      array of outlet pressures
    • setWaterCuts

      public void setWaterCuts(double[] waterCuts)
      Set water cuts for VFP table.
      Parameters:
      waterCuts - array of water cuts (0-1)
    • getWaterCuts

      public double[] getWaterCuts()
      Get water cuts.
      Returns:
      array of water cuts
    • setGORs

      public void setGORs(double[] gors)
      Set GOR values for VFP table.
      Parameters:
      gors - array of GOR values in Sm3/Sm3
    • getGORs

      public double[] getGORs()
      Get GOR values.
      Returns:
      array of GOR values
    • setFlowRateUnit

      public void setFlowRateUnit(String unit)
      Set flow rate unit.
      Parameters:
      unit - flow rate unit (e.g., "Sm3/day", "kg/hr")
    • getFlowRateUnit

      public String getFlowRateUnit()
      Get flow rate unit.
      Returns:
      flow rate unit
    • setInletTemperature

      public void setInletTemperature(double temperatureK)
      Set inlet temperature for fluid generation.
      Parameters:
      temperatureK - temperature in Kelvin
    • getInletTemperature

      public double getInletTemperature()
      Get inlet temperature.
      Returns:
      temperature in Kelvin
    • setMinInletPressure

      public void setMinInletPressure(double pressure)
      Set minimum inlet pressure for binary search.
      Parameters:
      pressure - minimum pressure in bara
    • setMaxInletPressure

      public void setMaxInletPressure(double pressure)
      Set maximum inlet pressure for binary search.
      Parameters:
      pressure - maximum pressure in bara
    • setPressureTolerance

      public void setPressureTolerance(double tolerance)
      Set pressure tolerance for binary search.
      Parameters:
      tolerance - tolerance in bara
    • setEnableParallel

      public void setEnableParallel(boolean enable)
      Enable or disable parallel execution.
      Parameters:
      enable - true to enable parallel execution
    • setNumberOfWorkers

      public void setNumberOfWorkers(int workers)
      Set number of worker threads.
      Parameters:
      workers - number of workers
    • getVfpTable

      public MultiScenarioVFPGenerator.VFPTable getVfpTable()
      Get the generated VFP table.
      Returns:
      VFP table or null if not yet generated