Class FlowRateOptimizer
- All Implemented Interfaces:
Serializable
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
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple data class representing compressor operating state within a ProcessSystem.static classContains equipment utilization data for reporting.static classConfiguration class for professional lift curve generation.static classResult container for professional lift curve generation.static enumMode of operation for the optimizer.static classRepresents a 2D capacity table showing maximum flow rates at different pressure boundary conditions.static classProcess lift curve table for reservoir simulator integration.static classRepresents a complete process operating point with all equipment data.static classPerformance table for a process system at different flow rates.static interfaceCallback interface for monitoring optimization progress. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate SystemInterfaceprivate booleanprivate booleanprivate booleanprivate doubleprivate StreamInterfaceprivate Stringprivate static final org.apache.logging.log4j.LoggerLogger object for class.private doubleprivate doubleprivate intprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate FlowRateOptimizer.Modeprivate intprivate ProcessEquipmentInterfaceprivate StreamInterfaceprivate Stringprivate intprivate ProcessModelprivate ProcessSystemprivate static final longSerialization version UID.private booleanprivate doubleprivate double -
Constructor Summary
ConstructorsConstructorDescriptionFlowRateOptimizer(ProcessModel processModel, String inletStreamName, String outletStreamName) Creates a flow rate optimizer for a ProcessModel with multiple ProcessSystems.FlowRateOptimizer(ProcessSystem processSystem, String inletStreamName, String outletStreamName) Creates a flow rate optimizer for a ProcessSystem. -
Method Summary
Modifier and TypeMethodDescriptiondoublecalculateTotalCompressorPower(String powerUnit) Calculates the total power consumption of all compressors in the process.private booleanChecks if all compressors in the operating point are within feasible limits.Checks capacity constraints on all equipment.private voidConfigures a single compressor with a performance chart.voidConfigures all compressors in a ProcessSystem with performance charts.private FlowRateOptimizerCreates a thread-safe clone of this optimizer for parallel evaluation.private doubleevaluateOutletPressure(double flowRate, double inletPressure, String pressureUnit) Evaluates the outlet pressure for a given flow rate and inlet pressure.private doubleevaluateOutletPressureAtFlow(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit) Evaluates outlet pressure for given flow rate and inlet pressure.private doubleevaluateProcessModel(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit) Evaluates ProcessModel outlet pressure.private doubleevaluateProcessSystem(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit) Evaluates ProcessSystem outlet pressure.private doubleevaluateProcessWithPower(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit, FlowRateOptimizer.ProcessOperatingPoint point) Evaluates process and captures power data for each compressor.findFlowRate(double inletPressure, double outletPressure, String pressureUnit) Finds the flow rate required to achieve the specified outlet pressure given the inlet pressure.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.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.findMaximumFeasibleFlowRate(double inletPressure, String pressureUnit, double targetUtilization) Finds the maximum feasible flow rate within equipment constraints.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.findProcessOperatingPoint(double flowRate, String flowRateUnit, double inletPressure, String pressureUnit) Finds the process operating point at a given flow rate.generateCapacityCurve(double inletPressure, double[] outletPressures, String pressureUnit, double maxUtilization, String flowRateUnit) Generates a detailed process capacity curve for a fixed inlet pressure.private voidgenerateCapacityTableParallel(FlowRateOptimizer.ProcessCapacityTable table, double[] inletPressures, double[] outletPressures, String pressureUnit, double maxUtilization, int totalEvals) Generates capacity table using parallel evaluation with thread pool.private voidgenerateCapacityTableSequential(FlowRateOptimizer.ProcessCapacityTable table, double[] inletPressures, double[] outletPressures, String pressureUnit, double maxUtilization, int totalEvals) Generates capacity table using sequential evaluation.generateProcessCapacityTable(double[] inletPressures, double[] outletPressures, String pressureUnit, double maxUtilization) Generates a process capacity table showing maximum flow rate at different inlet/outlet pressure combinations.generateProcessLiftCurve(double[] flowRates, String flowRateUnit, double[] inletPressures, String pressureUnit) Generates a process lift curve suitable for reservoir simulator integration.generateProcessPerformanceTable(double[] flowRates, String flowRateUnit, double inletPressure, String pressureUnit) Generates a comprehensive process performance table.generateProfessionalLiftCurves(double minInletPressure, double maxInletPressure, double minOutletPressure, double maxOutletPressure, String pressureUnit) Generates professional lift curves using default configuration.Generates professional lift curves using the specified configuration.private List<ProcessEquipmentInterface> Gets list of all equipment to check for constraints.Gets a detailed report of equipment utilization.doubleGets the initial flow rate guess.doubleGets the maximum equipment utilization across all capacity-constrained equipment.doubleGets the maximum equipment utilization limit.doubleGets the maximum flow rate limit.intGets the maximum number of iterations.doubleGets the maximum power limit for compressor operation.doubleGets the maximum speed limit for compressor operation.doubleGets the maximum total power limit for all compressors.doubleGets the maximum velocity constraint.doubleGets the minimum flow rate limit.doubleGets the minimum speed limit for compressor operation.doubleGets the minimum surge margin for compressor operation.getMode()Gets the operation mode.intGets the number of speed lines for auto-generated charts.private ProcessEquipmentInterfaceGets the outlet equipment.intGets the number of threads configured for parallel evaluation.Gets all compressors in the process system or model.Gets all separators in the process system or model.Gets the progress callback.doubleGets the speed margin above design for auto-generated charts.doubleGets the convergence tolerance.private booleanChecks if any violations are hard violations.booleanGets whether to auto-configure compressor charts for process systems.booleanGets whether compressor charts are auto-generated if not configured.booleanChecks if capacity constraints are being checked.booleanChecks if parallel evaluation is enabled.booleanGets whether the optimizer will solve for compressor speed.private voidreportProgress(int current, int total, String message) Reports progress to callback and/or logger.voidsetAutoConfigureProcessCompressors(boolean autoConfigureProcessCompressors) Sets whether to auto-configure compressor charts for process systems.voidsetAutoGenerateCompressorChart(boolean autoGenerateCompressorChart) Sets whether to auto-generate compressor charts if not configured.voidsetCheckCapacityConstraints(boolean checkCapacityConstraints) Sets whether to check capacity constraints.voidsetEnableParallelEvaluation(boolean enabled) Enables or disables parallel evaluation for lift curve generation.voidsetEnableProgressLogging(boolean enabled) Enables or disables progress logging to the logger.voidsetInitialFlowGuess(double initialFlowGuess) Sets the initial flow rate guess.voidsetMaxEquipmentUtilizationLimit(double maxEquipmentUtilization) Sets the maximum equipment utilization limit.voidsetMaxFlowRate(double maxFlowRate) Sets the maximum flow rate limit.voidsetMaxIterations(int maxIterations) Sets the maximum number of iterations.voidsetMaxPowerLimit(double maxPowerLimit) Sets the maximum power limit for compressor operation.voidsetMaxSpeedLimit(double maxSpeedLimit) Sets the maximum speed limit for compressor operation.voidsetMaxTotalPowerLimit(double maxTotalPowerLimit) Sets the maximum total power limit for all compressors.voidsetMaxVelocity(double maxVelocity) Sets the maximum velocity constraint.voidsetMinFlowRate(double minFlowRate) Sets the minimum flow rate limit.voidsetMinSpeedLimit(double minSpeedLimit) Sets the minimum speed limit for compressor operation.voidsetMinSurgeMargin(double minSurgeMargin) Sets the minimum surge margin for compressor operation.voidsetNumberOfChartSpeeds(int numberOfChartSpeeds) Sets the number of speed lines for auto-generated charts.voidsetParallelThreads(int threads) Sets the number of threads to use for parallel lift curve generation.voidSets a progress callback for monitoring long-running operations.voidsetSolveSpeed(boolean solveSpeed) Sets whether to solve for compressor speed.voidsetSpeedMarginAboveDesign(double speedMarginAboveDesign) Sets the speed margin above design for auto-generated charts.voidsetTolerance(double tolerance) Sets the convergence tolerance.Validates the optimizer configuration before running optimization.voidValidates configuration and throws an exception if invalid.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
logger
private static final org.apache.logging.log4j.Logger loggerLogger object for class. -
mode
-
processSystem
-
processModel
-
inletStreamName
-
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
-
enableProgressLogging
private boolean enableProgressLogging -
inletStream
-
outletStream
-
outletEquipment
-
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 optimizeinletStreamName- name of the inlet streamoutletStreamName- 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 optimizeinletStreamName- name of the inlet stream (in first ProcessSystem)outletStreamName- name of the outlet stream (in last ProcessSystem)
-
-
Method Details
-
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 pressureoutletPressure- target outlet pressurepressureUnit- 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 rateflowRateUnit- unit of flow rateoutletPressure- target outlet pressurepressureUnit- unit of pressure- Returns:
- optimization result with inlet pressure
-
evaluateOutletPressure
Evaluates the outlet pressure for a given flow rate and inlet pressure.- Parameters:
flowRate- flow rate in kg/hrinletPressure- inlet pressurepressureUnit- 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 rateflowRateUnit- flow rate unitinletPressure- inlet pressurepressureUnit- 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
Configures a single compressor with a performance chart.- Parameters:
comp- the compressor to configure
-
getProcessCompressors
Gets all compressors in the process system or model.- Returns:
- list of all compressors
-
getProcessSeparators
-
calculateTotalCompressorPower
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
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 rateflowRateUnit- the flow rate unitinletPressure- the inlet pressurepressureUnit- 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
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 evaluateflowRateUnit- the flow rate unitinletPressure- the inlet pressurepressureUnit- 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 evaluateflowRateUnit- the flow rate unitinletPressures- array of inlet pressures to evaluatepressureUnit- 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 pressuretargetOutletPressure- the target outlet pressurepressureUnit- the pressure unitminFlow- minimum flow rate to searchmaxFlow- maximum flow rate to searchflowRateUnit- 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 pressurepressureUnit- the pressure unittargetUtilization- 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:
- At each flow rate, run the process and check outlet pressure and utilization
- If outlet pressure is above target and utilization is acceptable, increase flow
- If outlet pressure is below target or utilization exceeds limit, decrease flow
- 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 conditiontargetOutletPressure- the target outlet pressure boundary conditionpressureUnit- 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
Gets the outlet equipment.- Returns:
- the outlet equipment
-
checkCompressorsFeasible
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 pressuresoutletPressures- array of outlet pressurespressureUnit- the pressure unitmaxUtilization- 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 populateinletPressures- array of inlet pressuresoutletPressures- array of outlet pressurespressureUnit- the pressure unitmaxUtilization- maximum allowed equipment utilizationtotalEvals- 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 populateinletPressures- array of inlet pressuresoutletPressures- array of outlet pressurespressureUnit- the pressure unitmaxUtilization- maximum allowed equipment utilizationtotalEvals- total number of evaluations for progress
-
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 pressurespressureUnit- the pressure unitmaxUtilization- maximum allowed equipment utilizationflowRateUnit- unit for reporting flow rates- Returns:
- array of ProcessOperatingPoints for each outlet pressure
-
evaluateProcessSystem
-
evaluateProcessModel
-
checkConstraints
Checks capacity constraints on all equipment.- Returns:
- list of constraint violations
-
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
-
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
Sets a progress callback for monitoring long-running operations.- Parameters:
callback- the callback to receive progress updates
-
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
Reports progress to callback and/or logger.- Parameters:
current- current steptotal- total stepsmessage- 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 pressuremaxInletPressure- maximum inlet pressureminOutletPressure- minimum outlet pressuremaxOutletPressure- maximum outlet pressurepressureUnit- pressure unit- Returns:
- the lift curve result
-