Class FlowRateOptimizer

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

public class FlowRateOptimizer extends Object implements Serializable
Optimizer for finding flow rate given inlet and outlet pressure constraints.

This class determines the flow rate required to achieve a specified pressure drop across process systems containing equipment such as pipelines, compressors, separators, and heat exchangers. It uses bisection search with constraint checking to find the optimal operating point.

Supported Configurations

  • ProcessSystem - Single process system with inlet/outlet streams
  • ProcessModel - Multiple coordinated ProcessSystems

Key Features for Production Optimization

  • Automatic compressor chart generation based on design point
  • Equipment capacity constraint checking (surge, stonewall, power limits)
  • Lift curve generation for Eclipse/E300 reservoir simulator integration
  • Total power optimization across multiple compressors
  • Equipment utilization tracking and reporting

Constraint Handling

The optimizer checks capacity constraints at each iteration including:

  • Compressor surge margin (configurable via setMinSurgeMargin(double))
  • Compressor stonewall limits
  • Power limits (individual and total)
  • Speed limits
  • Equipment utilization limits
If hard constraints are violated at all feasible flow rates, the result is marked as INFEASIBLE_CONSTRAINT.

Example Usage - ProcessSystem with Compressors

// Create a compression process
SystemInterface gas = new SystemSrkEos(298.15, 50.0);
gas.addComponent("methane", 0.9);
gas.addComponent("ethane", 0.1);
gas.setMixingRule("classic");

Stream feed = new Stream("Feed", gas);
feed.setFlowRate(50000, "kg/hr");

Compressor comp1 = new Compressor("LP Compressor", feed);
comp1.setOutletPressure(100.0, "bara");

Compressor comp2 = new Compressor("HP Compressor", comp1.getOutletStream());
comp2.setOutletPressure(150.0, "bara");

ProcessSystem process = new ProcessSystem();
process.add(feed);
process.add(comp1);
process.add(comp2);
process.run();

// Create optimizer and generate lift curves
FlowRateOptimizer optimizer = new FlowRateOptimizer(process, "Feed", "HP Compressor");
optimizer.setMinSurgeMargin(0.15); // 15% surge margin
optimizer.setMaxPowerLimit(5000.0); // 5 MW per compressor
optimizer.configureProcessCompressorCharts();

// Generate capacity table for reservoir simulator
double[] inletPressures = {50, 60, 70, 80}; // bara
double[] outletPressures = {140, 145, 150, 155}; // bara
ProcessCapacityTable table =
    optimizer.generateProcessCapacityTable(inletPressures, outletPressures, "bara", 0.95);

System.out.println(table.toEclipseFormat());

Example Usage - ProcessModel

ProcessModel model = new ProcessModel();
model.add("upstream", upstreamSystem);
model.add("downstream", downstreamSystem);

FlowRateOptimizer optimizer = new FlowRateOptimizer(model, "inletStream", "outletStream");
FlowRateOptimizationResult result = optimizer.findFlowRate(150.0, 50.0, "bara");
Version:
2.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.
    • mode

      private FlowRateOptimizer.Mode mode
    • processSystem

      private ProcessSystem processSystem
    • processModel

      private ProcessModel processModel
    • inletStreamName

      private String inletStreamName
    • outletStreamName

      private String outletStreamName
    • maxIterations

      private int maxIterations
    • tolerance

      private double tolerance
    • minFlowRate

      private double minFlowRate
    • maxFlowRate

      private double maxFlowRate
    • initialFlowGuess

      private double initialFlowGuess
    • maxVelocity

      private double maxVelocity
    • checkCapacityConstraints

      private boolean checkCapacityConstraints
    • minSurgeMargin

      private double minSurgeMargin
    • solveSpeed

      private boolean solveSpeed
    • maxPowerLimit

      private double maxPowerLimit
    • maxSpeedLimit

      private double maxSpeedLimit
    • minSpeedLimit

      private double minSpeedLimit
    • autoGenerateCompressorChart

      private boolean autoGenerateCompressorChart
    • numberOfChartSpeeds

      private int numberOfChartSpeeds
    • speedMarginAboveDesign

      private double speedMarginAboveDesign
    • autoConfigureProcessCompressors

      private boolean autoConfigureProcessCompressors
    • maxTotalPowerLimit

      private double maxTotalPowerLimit
    • maxEquipmentUtilization

      private double maxEquipmentUtilization
    • enableParallelEvaluation

      private boolean enableParallelEvaluation
    • parallelThreads

      private int parallelThreads
    • progressCallback

      private transient FlowRateOptimizer.ProgressCallback progressCallback
    • enableProgressLogging

      private boolean enableProgressLogging
    • inletStream

      private StreamInterface inletStream
    • outletStream

      private StreamInterface outletStream
    • outletEquipment

      private ProcessEquipmentInterface outletEquipment
    • baseFluid

      private SystemInterface baseFluid
  • Constructor Details

    • FlowRateOptimizer

      public FlowRateOptimizer(ProcessSystem processSystem, String inletStreamName, String outletStreamName)
      Creates a flow rate optimizer for a ProcessSystem.
      Parameters:
      processSystem - the process system to optimize
      inletStreamName - name of the inlet stream
      outletStreamName - name of the outlet stream
    • FlowRateOptimizer

      public FlowRateOptimizer(ProcessModel processModel, String inletStreamName, String outletStreamName)
      Creates a flow rate optimizer for a ProcessModel with multiple ProcessSystems.
      Parameters:
      processModel - the process model to optimize
      inletStreamName - name of the inlet stream (in first ProcessSystem)
      outletStreamName - name of the outlet stream (in last ProcessSystem)
  • Method Details

    • validateConfiguration

      public List<String> validateConfiguration()
      Validates the optimizer configuration before running optimization.

      This method checks that:

      • Inlet stream is properly configured with a valid thermo system
      • Outlet stream/equipment is accessible
      • Process system/model is ready for simulation
      • Compressors have charts configured (if auto-configure is disabled)
      Returns:
      list of validation issues (empty if valid)
    • validateOrThrow

      public void validateOrThrow()
      Validates configuration and throws an exception if invalid.
      Throws:
      IllegalStateException - if configuration is invalid
    • findFlowRate

      public FlowRateOptimizationResult findFlowRate(double inletPressure, double outletPressure, String pressureUnit)
      Finds the flow rate required to achieve the specified outlet pressure given the inlet pressure.

      This method sets the inlet stream to the specified pressure and temperature, then iterates to find the flow rate that produces the target outlet pressure.

      Parameters:
      inletPressure - inlet pressure
      outletPressure - target outlet pressure
      pressureUnit - unit of pressure (e.g., "bara", "barg", "psia")
      Returns:
      optimization result
    • findInletPressure

      public FlowRateOptimizationResult findInletPressure(double flowRate, String flowRateUnit, double outletPressure, String pressureUnit)
      Finds the inlet pressure required to achieve the specified outlet pressure at a given flow rate.

      This is a simpler forward calculation - just run the process at the specified flow rate and read the inlet pressure required.

      Parameters:
      flowRate - flow rate
      flowRateUnit - unit of flow rate
      outletPressure - target outlet pressure
      pressureUnit - unit of pressure
      Returns:
      optimization result with inlet pressure
    • evaluateOutletPressure

      private double evaluateOutletPressure(double flowRate, double inletPressure, String pressureUnit)
      Evaluates the outlet pressure for a given flow rate and inlet pressure.
      Parameters:
      flowRate - flow rate in kg/hr
      inletPressure - inlet pressure
      pressureUnit - pressure unit
      Returns:
      outlet pressure in the same unit
    • evaluateOutletPressureAtFlow

      private double evaluateOutletPressureAtFlow(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit)
      Evaluates outlet pressure for given flow rate and inlet pressure.
      Parameters:
      flowRate - flow rate
      flowRateUnit - flow rate unit
      inletPressure - inlet pressure
      pressureUnit - pressure unit
      Returns:
      outlet pressure
    • configureProcessCompressorCharts

      public void configureProcessCompressorCharts()
      Configures all compressors in a ProcessSystem with performance charts.

      This method sets up compressor performance charts for all compressors in the process system, following the pattern established in ProcessOptimizationExampleTest. It:

      • Generates performance charts using CompressorChartGenerator
      • Sets maximum speed with appropriate margin above design speed
      • Reinitializes capacity constraints after chart setup

      Example Usage

      FlowRateOptimizer optimizer = new FlowRateOptimizer(process, "Feed", "Export");
      optimizer.configureProcessCompressorCharts();
      
    • configureCompressorChart

      private void configureCompressorChart(Compressor comp)
      Configures a single compressor with a performance chart.
      Parameters:
      comp - the compressor to configure
    • getProcessCompressors

      public List<Compressor> getProcessCompressors()
      Gets all compressors in the process system or model.
      Returns:
      list of all compressors
    • getProcessSeparators

      public List<Separator> getProcessSeparators()
      Gets all separators in the process system or model.
      Returns:
      list of all separators
    • calculateTotalCompressorPower

      public double calculateTotalCompressorPower(String powerUnit)
      Calculates the total power consumption of all compressors in the process.
      Parameters:
      powerUnit - the unit for power (e.g., "kW", "MW", "W")
      Returns:
      total power consumption in the specified unit
    • getMaxEquipmentUtilization

      public double getMaxEquipmentUtilization()
      Gets the maximum equipment utilization across all capacity-constrained equipment.
      Returns:
      maximum utilization as a fraction (1.0 = 100%)
    • getEquipmentUtilizationReport

      public Map<String, FlowRateOptimizer.EquipmentUtilizationData> getEquipmentUtilizationReport()
      Gets a detailed report of equipment utilization.
      Returns:
      map of equipment name to utilization data
    • findProcessOperatingPoint

      public FlowRateOptimizer.ProcessOperatingPoint findProcessOperatingPoint(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit)
      Finds the process operating point at a given flow rate.

      This method runs the process at the specified flow rate and inlet pressure, then extracts comprehensive operating data including:

      • Outlet pressure
      • Total compressor power and individual compressor powers
      • Equipment utilization data
      • Constraint status
      Parameters:
      flowRate - the flow rate
      flowRateUnit - the flow rate unit
      inletPressure - the inlet pressure
      pressureUnit - the pressure unit
      Returns:
      the process operating point
    • evaluateProcessWithPower

      private double evaluateProcessWithPower(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit, FlowRateOptimizer.ProcessOperatingPoint point)
      Evaluates process and captures power data for each compressor.
    • hasHardViolations

      private boolean hasHardViolations(List<FlowRateOptimizationResult.ConstraintViolation> violations)
      Checks if any violations are hard violations.
    • generateProcessPerformanceTable

      public FlowRateOptimizer.ProcessPerformanceTable generateProcessPerformanceTable(double[] flowRates, String flowRateUnit, double inletPressure, String pressureUnit)
      Generates a comprehensive process performance table.

      This method creates a table of process operating points for different flow rates, reporting:

      • Outlet pressure at each flow rate
      • Total compressor power
      • Individual compressor powers
      • Maximum equipment utilization
      • Feasibility status

      Example Usage

      FlowRateOptimizer optimizer = new FlowRateOptimizer(process, "Feed", "Export");
      optimizer.configureProcessCompressorCharts();
      
      ProcessPerformanceTable table = optimizer.generateProcessPerformanceTable(
          new double[] {30000, 50000, 70000, 90000}, "kg/hr", 80.0, "bara");
      
      System.out.println(table.toFormattedString());
      System.out.println("Total power at 50000 kg/hr: " + table.getTotalPower(1) + " kW");
      
      Parameters:
      flowRates - array of flow rates to evaluate
      flowRateUnit - the flow rate unit
      inletPressure - the inlet pressure
      pressureUnit - the pressure unit
      Returns:
      a ProcessPerformanceTable with comprehensive process data
    • generateProcessLiftCurve

      public FlowRateOptimizer.ProcessLiftCurveTable generateProcessLiftCurve(double[] flowRates, String flowRateUnit, double[] inletPressures, String pressureUnit)
      Generates a process lift curve suitable for reservoir simulator integration.

      This method creates a table of outlet pressures and total power for different flow rates and inlet pressures. The output format is suitable for conversion to VFP (Vertical Flow Performance) tables used by reservoir simulators like Eclipse.

      Example Usage

      double[] flowRates = {20000, 40000, 60000, 80000, 100000};
      double[] inletPressures = {60, 70, 80, 90};
      
      ProcessLiftCurveTable table =
          optimizer.generateProcessLiftCurve(flowRates, "kg/hr", inletPressures, "bara");
      
      System.out.println(table.toEclipseFormat());
      System.out.println("Minimum power operating point: " + table.findMinimumPowerPoint());
      
      Parameters:
      flowRates - array of flow rates to evaluate
      flowRateUnit - the flow rate unit
      inletPressures - array of inlet pressures to evaluate
      pressureUnit - the pressure unit
      Returns:
      a ProcessLiftCurveTable with lift curve data and power information
    • findMinimumTotalPowerOperatingPoint

      public FlowRateOptimizer.ProcessOperatingPoint findMinimumTotalPowerOperatingPoint(double inletPressure, double targetOutletPressure, String pressureUnit, double minFlow, double maxFlow, String flowRateUnit)
      Finds the flow rate that achieves minimum total power for a given pressure ratio.

      This method searches for the flow rate that results in minimum total compressor power consumption while achieving the target outlet pressure and staying within all equipment constraints.

      Example Usage

      ProcessOperatingPoint minPowerPoint =
          optimizer.findMinimumTotalPowerOperatingPoint(80.0, 150.0, "bara", 20000, 100000, "kg/hr");
      
      System.out.println("Minimum total power: " + minPowerPoint.getTotalPower() + " kW");
      System.out.println("At flow rate: " + minPowerPoint.getFlowRate() + " kg/hr");
      
      Parameters:
      inletPressure - the inlet pressure
      targetOutletPressure - the target outlet pressure
      pressureUnit - the pressure unit
      minFlow - minimum flow rate to search
      maxFlow - maximum flow rate to search
      flowRateUnit - the flow rate unit
      Returns:
      the process operating point with minimum total power, or null if no feasible point
    • findMaximumFeasibleFlowRate

      public FlowRateOptimizer.ProcessOperatingPoint findMaximumFeasibleFlowRate(double inletPressure, String pressureUnit, double targetUtilization)
      Finds the maximum feasible flow rate within equipment constraints.

      This method uses bisection search to find the maximum flow rate that can be processed while keeping all equipment within their capacity constraints.

      Parameters:
      inletPressure - the inlet pressure
      pressureUnit - the pressure unit
      targetUtilization - the target maximum utilization (e.g., 0.95 for 95%)
      Returns:
      the process operating point at maximum feasible flow
    • findMaxFlowRateAtPressureBoundaries

      public FlowRateOptimizer.ProcessOperatingPoint findMaxFlowRateAtPressureBoundaries(double inletPressure, double targetOutletPressure, String pressureUnit, double maxUtilization)
      Finds the maximum flow rate that achieves a specified outlet pressure while respecting equipment capacity constraints.

      This method solves the inverse problem: given inlet and outlet pressure boundary conditions, find the maximum feed flow rate that keeps all equipment within their capacity limits. This is useful for generating lift curves for reservoir simulators where pressure boundary conditions are known from reservoir deliverability.

      The algorithm uses bisection search on flow rate:

      1. At each flow rate, run the process and check outlet pressure and utilization
      2. If outlet pressure is above target and utilization is acceptable, increase flow
      3. If outlet pressure is below target or utilization exceeds limit, decrease flow
      4. Converge to the maximum flow that achieves target outlet pressure within constraints

      Example Usage

      FlowRateOptimizer optimizer = new FlowRateOptimizer(process, "Feed", "Export");
      optimizer.configureProcessCompressorCharts();
      
      // Find max flow rate for given pressure boundary conditions
      ProcessOperatingPoint result =
          optimizer.findMaxFlowRateAtPressureBoundaries(80.0, 150.0, "bara", 0.95);
      
      if (result != null && result.isFeasible()) {
        System.out.println("Max flow: " + result.getFlowRate() + " kg/hr");
        System.out.println("Total power: " + result.getTotalPower() + " kW");
      }
      
      Parameters:
      inletPressure - the inlet pressure boundary condition
      targetOutletPressure - the target outlet pressure boundary condition
      pressureUnit - the pressure unit (e.g., "bara", "barg")
      maxUtilization - the maximum allowed equipment utilization (e.g., 0.95 for 95%)
      Returns:
      the process operating point at maximum flow, or null if no feasible point exists
    • getOutletEquipment

      private ProcessEquipmentInterface getOutletEquipment()
      Gets the outlet equipment.
      Returns:
      the outlet equipment
    • checkCompressorsFeasible

      private boolean checkCompressorsFeasible(FlowRateOptimizer.ProcessOperatingPoint point)
      Checks if all compressors in the operating point are within feasible limits.
      Parameters:
      point - the process operating point
      Returns:
      true if all compressors are feasible
    • generateProcessCapacityTable

      public FlowRateOptimizer.ProcessCapacityTable generateProcessCapacityTable(double[] inletPressures, double[] outletPressures, String pressureUnit, double maxUtilization)
      Generates a process capacity table showing maximum flow rate at different inlet/outlet pressure combinations.

      This method creates a 2D table where each cell contains the maximum flow rate achievable for the given inlet pressure (row) and outlet pressure (column) while respecting equipment constraints. This is the natural format for lift curve generation where pressures are the boundary conditions.

      Example Usage

      double[] inletPressures = {60, 70, 80, 90}; // bara
      double[] outletPressures = {130, 140, 150, 160}; // bara
      
      ProcessCapacityTable table =
          optimizer.generateProcessCapacityTable(inletPressures, outletPressures, "bara", 0.95);
      
      System.out.println(table.toFormattedString());
      System.out.println(table.toEclipseFormat());
      
      Parameters:
      inletPressures - array of inlet pressures
      outletPressures - array of outlet pressures
      pressureUnit - the pressure unit
      maxUtilization - the maximum allowed equipment utilization
      Returns:
      a ProcessCapacityTable with maximum flow rates and power data
    • generateCapacityTableSequential

      private void generateCapacityTableSequential(FlowRateOptimizer.ProcessCapacityTable table, double[] inletPressures, double[] outletPressures, String pressureUnit, double maxUtilization, int totalEvals)
      Generates capacity table using sequential evaluation.
      Parameters:
      table - the table to populate
      inletPressures - array of inlet pressures
      outletPressures - array of outlet pressures
      pressureUnit - the pressure unit
      maxUtilization - maximum allowed equipment utilization
      totalEvals - total number of evaluations for progress
    • generateCapacityTableParallel

      private void generateCapacityTableParallel(FlowRateOptimizer.ProcessCapacityTable table, double[] inletPressures, double[] outletPressures, String pressureUnit, double maxUtilization, int totalEvals)
      Generates capacity table using parallel evaluation with thread pool.

      This method creates a cloned FlowRateOptimizer for each thread to ensure thread safety. Each evaluation is submitted to a thread pool, and results are collected into the table.

      Parameters:
      table - the table to populate
      inletPressures - array of inlet pressures
      outletPressures - array of outlet pressures
      pressureUnit - the pressure unit
      maxUtilization - maximum allowed equipment utilization
      totalEvals - total number of evaluations for progress
    • createThreadSafeClone

      private FlowRateOptimizer createThreadSafeClone()
      Creates a thread-safe clone of this optimizer for parallel evaluation.

      This method clones the underlying ProcessSystem to ensure each thread has its own independent copy. The clone maintains all configuration settings but operates on a separate process instance.

      Returns:
      a cloned FlowRateOptimizer for thread-safe use
    • generateCapacityCurve

      public FlowRateOptimizer.ProcessOperatingPoint[] generateCapacityCurve(double inletPressure, double[] outletPressures, String pressureUnit, double maxUtilization, String flowRateUnit)
      Generates a detailed process capacity curve for a fixed inlet pressure.

      For each target outlet pressure, finds the maximum flow rate and reports total power, equipment utilizations, and bottleneck information. This is useful for understanding process capacity versus delivery pressure.

      Parameters:
      inletPressure - the inlet pressure (fixed)
      outletPressures - array of target outlet pressures
      pressureUnit - the pressure unit
      maxUtilization - maximum allowed equipment utilization
      flowRateUnit - unit for reporting flow rates
      Returns:
      array of ProcessOperatingPoints for each outlet pressure
    • evaluateProcessSystem

      private double evaluateProcessSystem(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit)
      Evaluates ProcessSystem outlet pressure.
    • evaluateProcessModel

      private double evaluateProcessModel(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit)
      Evaluates ProcessModel outlet pressure.
    • checkConstraints

      Checks capacity constraints on all equipment.
      Returns:
      list of constraint violations
    • getEquipmentList

      private List<ProcessEquipmentInterface> getEquipmentList()
      Gets list of all equipment to check for constraints.
    • getMaxIterations

      public int getMaxIterations()
      Gets the maximum number of iterations.
      Returns:
      max iterations
    • setMaxIterations

      public void setMaxIterations(int maxIterations)
      Sets the maximum number of iterations.
      Parameters:
      maxIterations - max iterations
    • getTolerance

      public double getTolerance()
      Gets the convergence tolerance.
      Returns:
      tolerance (relative error)
    • setTolerance

      public void setTolerance(double tolerance)
      Sets the convergence tolerance.
      Parameters:
      tolerance - tolerance (relative error)
    • getMinFlowRate

      public double getMinFlowRate()
      Gets the minimum flow rate limit.
      Returns:
      minimum flow rate in kg/hr
    • setMinFlowRate

      public void setMinFlowRate(double minFlowRate)
      Sets the minimum flow rate limit.
      Parameters:
      minFlowRate - minimum flow rate in kg/hr
    • getMaxFlowRate

      public double getMaxFlowRate()
      Gets the maximum flow rate limit.
      Returns:
      maximum flow rate in kg/hr
    • setMaxFlowRate

      public void setMaxFlowRate(double maxFlowRate)
      Sets the maximum flow rate limit.
      Parameters:
      maxFlowRate - maximum flow rate in kg/hr
    • getInitialFlowGuess

      public double getInitialFlowGuess()
      Gets the initial flow rate guess.
      Returns:
      initial flow rate in kg/hr
    • setInitialFlowGuess

      public void setInitialFlowGuess(double initialFlowGuess)
      Sets the initial flow rate guess.
      Parameters:
      initialFlowGuess - initial flow rate in kg/hr
    • getMaxVelocity

      public double getMaxVelocity()
      Gets the maximum velocity constraint.
      Returns:
      maximum velocity in m/s
    • setMaxVelocity

      public void setMaxVelocity(double maxVelocity)
      Sets the maximum velocity constraint.
      Parameters:
      maxVelocity - maximum velocity in m/s
    • isCheckCapacityConstraints

      public boolean isCheckCapacityConstraints()
      Checks if capacity constraints are being checked.
      Returns:
      true if checking constraints
    • setCheckCapacityConstraints

      public void setCheckCapacityConstraints(boolean checkCapacityConstraints)
      Sets whether to check capacity constraints.
      Parameters:
      checkCapacityConstraints - true to check constraints
    • getMode

      public FlowRateOptimizer.Mode getMode()
      Gets the operation mode.
      Returns:
      the mode
    • getMinSurgeMargin

      public double getMinSurgeMargin()
      Gets the minimum surge margin for compressor operation.
      Returns:
      minimum surge margin as a fraction (0.1 = 10%)
    • setMinSurgeMargin

      public void setMinSurgeMargin(double minSurgeMargin)
      Sets the minimum surge margin for compressor operation.

      Operating points with surge margin below this value will be marked as infeasible. Typical values are 0.10 to 0.20 (10-20% margin).

      Parameters:
      minSurgeMargin - minimum surge margin as a fraction
    • isSolveSpeed

      public boolean isSolveSpeed()
      Gets whether the optimizer will solve for compressor speed.
      Returns:
      true if solving for speed
    • setSolveSpeed

      public void setSolveSpeed(boolean solveSpeed)
      Sets whether to solve for compressor speed.
      Parameters:
      solveSpeed - true to solve for speed
    • getMaxPowerLimit

      public double getMaxPowerLimit()
      Gets the maximum power limit for compressor operation.
      Returns:
      maximum power in kW
    • setMaxPowerLimit

      public void setMaxPowerLimit(double maxPowerLimit)
      Sets the maximum power limit for compressor operation.

      Operating points where compressor power exceeds this limit will be marked as infeasible. This is typically set based on driver rated power or mechanical design limits.

      Parameters:
      maxPowerLimit - maximum power in kW
    • getMaxSpeedLimit

      public double getMaxSpeedLimit()
      Gets the maximum speed limit for compressor operation.
      Returns:
      maximum speed in RPM
    • setMaxSpeedLimit

      public void setMaxSpeedLimit(double maxSpeedLimit)
      Sets the maximum speed limit for compressor operation.

      Operating points where compressor speed exceeds this limit will be marked as infeasible. This is typically set based on mechanical design or compressor chart limits.

      Parameters:
      maxSpeedLimit - maximum speed in RPM
    • getMinSpeedLimit

      public double getMinSpeedLimit()
      Gets the minimum speed limit for compressor operation.
      Returns:
      minimum speed in RPM
    • setMinSpeedLimit

      public void setMinSpeedLimit(double minSpeedLimit)
      Sets the minimum speed limit for compressor operation.

      Operating points where compressor speed is below this limit will be marked as infeasible. This may be set based on stability limits or minimum turndown.

      Parameters:
      minSpeedLimit - minimum speed in RPM
    • isAutoGenerateCompressorChart

      public boolean isAutoGenerateCompressorChart()
      Gets whether compressor charts are auto-generated if not configured.
      Returns:
      true if auto-generating charts
    • setAutoGenerateCompressorChart

      public void setAutoGenerateCompressorChart(boolean autoGenerateCompressorChart)
      Sets whether to auto-generate compressor charts if not configured.

      When enabled (default), if the compressor doesn't have a chart configured, one will be auto-generated using the CompressorChartGenerator based on the current design point. This follows the pattern used in the ProductionOptimizer framework.

      Parameters:
      autoGenerateCompressorChart - true to auto-generate charts
    • getNumberOfChartSpeeds

      public int getNumberOfChartSpeeds()
      Gets the number of speed lines for auto-generated charts.
      Returns:
      number of speed lines
    • setNumberOfChartSpeeds

      public void setNumberOfChartSpeeds(int numberOfChartSpeeds)
      Sets the number of speed lines for auto-generated charts.
      Parameters:
      numberOfChartSpeeds - number of speed lines (typically 3-7)
    • getSpeedMarginAboveDesign

      public double getSpeedMarginAboveDesign()
      Gets the speed margin above design for auto-generated charts.
      Returns:
      speed margin as fraction (0.15 = 15% above design)
    • setSpeedMarginAboveDesign

      public void setSpeedMarginAboveDesign(double speedMarginAboveDesign)
      Sets the speed margin above design for auto-generated charts.

      When auto-generating charts, the maximum speed is set to the design speed times (1 + margin). Typical values are 0.10 to 0.20 (10-20% margin above design).

      Parameters:
      speedMarginAboveDesign - speed margin as fraction
    • isAutoConfigureProcessCompressors

      public boolean isAutoConfigureProcessCompressors()
      Gets whether to auto-configure compressor charts for process systems.
      Returns:
      true if auto-configuring
    • setAutoConfigureProcessCompressors

      public void setAutoConfigureProcessCompressors(boolean autoConfigureProcessCompressors)
      Sets whether to auto-configure compressor charts for process systems.

      When enabled (default), all compressors in the process will have their charts auto-generated if not already configured. This follows the pattern from ProcessOptimizationExampleTest.

      Parameters:
      autoConfigureProcessCompressors - true to auto-configure
    • getMaxTotalPowerLimit

      public double getMaxTotalPowerLimit()
      Gets the maximum total power limit for all compressors.
      Returns:
      maximum total power in kW
    • setMaxTotalPowerLimit

      public void setMaxTotalPowerLimit(double maxTotalPowerLimit)
      Sets the maximum total power limit for all compressors.

      Operating points where the sum of all compressor powers exceeds this limit will be marked as infeasible. This is useful for overall process power constraints.

      Parameters:
      maxTotalPowerLimit - maximum total power in kW
    • getMaxEquipmentUtilizationLimit

      public double getMaxEquipmentUtilizationLimit()
      Gets the maximum equipment utilization limit.
      Returns:
      maximum utilization as a fraction (1.0 = 100%)
    • setMaxEquipmentUtilizationLimit

      public void setMaxEquipmentUtilizationLimit(double maxEquipmentUtilization)
      Sets the maximum equipment utilization limit.

      Operating points where any equipment exceeds this utilization will be marked as infeasible. Default is 1.0 (100%). Set to 0.95 for a 5% margin.

      Parameters:
      maxEquipmentUtilization - maximum utilization as a fraction
    • setProgressCallback

      public void setProgressCallback(FlowRateOptimizer.ProgressCallback callback)
      Sets a progress callback for monitoring long-running operations.
      Parameters:
      callback - the callback to receive progress updates
    • getProgressCallback

      public FlowRateOptimizer.ProgressCallback getProgressCallback()
      Gets the progress callback.
      Returns:
      the progress callback, or null if not set
    • setEnableProgressLogging

      public void setEnableProgressLogging(boolean enabled)
      Enables or disables progress logging to the logger.

      When enabled, progress messages will be logged at INFO level during long-running operations like lift curve generation.

      Parameters:
      enabled - true to enable progress logging
    • setEnableParallelEvaluation

      public void setEnableParallelEvaluation(boolean enabled)
      Enables or disables parallel evaluation for lift curve generation.

      When enabled, multiple pressure combinations are evaluated in parallel using a thread pool. This can significantly speed up lift curve generation for large tables. Note that parallel evaluation requires the process system to be thread-safe or uses process cloning.

      Important: Parallel evaluation creates cloned copies of the process system for each thread, which increases memory usage but ensures thread safety.

      Parameters:
      enabled - true to enable parallel evaluation, false for sequential (default)
    • isParallelEvaluationEnabled

      public boolean isParallelEvaluationEnabled()
      Checks if parallel evaluation is enabled.
      Returns:
      true if parallel evaluation is enabled
    • setParallelThreads

      public void setParallelThreads(int threads)
      Sets the number of threads to use for parallel lift curve generation.

      Default is the number of available processors. Setting this too high may cause memory issues as each thread maintains a cloned copy of the process system.

      Parameters:
      threads - number of threads (must be at least 1)
    • getParallelThreads

      public int getParallelThreads()
      Gets the number of threads configured for parallel evaluation.
      Returns:
      the number of threads
    • reportProgress

      private void reportProgress(int current, int total, String message)
      Reports progress to callback and/or logger.
      Parameters:
      current - current step
      total - total steps
      message - progress message
    • generateProfessionalLiftCurves

      public FlowRateOptimizer.LiftCurveResult generateProfessionalLiftCurves(FlowRateOptimizer.LiftCurveConfiguration config)
      Generates professional lift curves using the specified configuration.

      This method applies all best practices for lift curve generation:

      • Validates configuration before starting
      • Configures compressor charts automatically
      • Applies all constraint limits
      • Generates multiple table formats
      • Reports progress during generation
      • Captures warnings and statistics
      Parameters:
      config - the lift curve configuration
      Returns:
      the lift curve result containing all generated tables
      Throws:
      IllegalStateException - if the optimizer is not properly configured
    • generateProfessionalLiftCurves

      public FlowRateOptimizer.LiftCurveResult generateProfessionalLiftCurves(double minInletPressure, double maxInletPressure, double minOutletPressure, double maxOutletPressure, String pressureUnit)
      Generates professional lift curves using default configuration.

      This convenience method uses sensible defaults suitable for typical offshore gas compression applications. For customization, use generateProfessionalLiftCurves(LiftCurveConfiguration) with a custom configuration.

      Parameters:
      minInletPressure - minimum inlet pressure
      maxInletPressure - maximum inlet pressure
      minOutletPressure - minimum outlet pressure
      maxOutletPressure - maximum outlet pressure
      pressureUnit - pressure unit
      Returns:
      the lift curve result