Class SensitivityAnalysis

java.lang.Object
neqsim.process.util.fielddevelopment.SensitivityAnalysis
All Implemented Interfaces:
Serializable

public class SensitivityAnalysis extends Object implements Serializable
Monte Carlo sensitivity analysis for field development uncertainty quantification.

This class provides comprehensive uncertainty analysis capabilities including:

  • Monte Carlo simulation with configurable probability distributions
  • P10/P50/P90 calculation for key outputs
  • Tornado diagram generation for sensitivity ranking
  • Spider plot data generation
  • Parallel execution for performance
  • Integration with ProductionOptimizer for process simulation

Uncertainty Quantification Concepts

Field development decisions are made under uncertainty. Key uncertain parameters include:

  • Reservoir properties (permeability, porosity, STOIIP)
  • Fluid properties (GOR, API gravity, viscosity)
  • Facility performance (equipment efficiencies, capacities)
  • Operating conditions (temperatures, pressures)
  • Economic factors (oil price, CAPEX, OPEX)

Probability Distributions

The following distributions are supported:

Sensitivity Analysis Methods

The class supports multiple sensitivity analysis approaches:

  • Monte Carlo: Random sampling of all parameters simultaneously
  • Tornado (One-at-a-time): Vary each parameter from P10 to P90 individually
  • Spider Plot: Systematic variation of each parameter across its range

Example Usage

SensitivityAnalysis sensitivity = new SensitivityAnalysis(facilityProcess);

// Add uncertain parameters
sensitivity.addParameter(UncertainParameter.triangular("feedTemperature", 15.0, 20.0, 25.0,
    (proc, val) -> feedStream.setTemperature(val, "C")));

sensitivity.addParameter(UncertainParameter.lognormal("reservoirPressure", 180.0, 200.0, 230.0,
    (proc, val) -> feedStream.setPressure(val, "bara")));

// Run Monte Carlo simulation
SensitivityConfig config = new SensitivityConfig().numberOfTrials(1000).parallel(true);

MonteCarloResult result = sensitivity.runMonteCarloOptimization(feedStream, 1000.0, 50000.0,
    "kg/hr", opt -> opt.getOptimalRate(), config);

System.out.printf("P10: %.0f, P50: %.0f, P90: %.0f%n", result.getP10(), result.getP50(),
    result.getP90());
System.out.println(result.toTornadoMarkdown());
Version:
1.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

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

      public static final int DEFAULT_NUMBER_OF_TRIALS
      Default number of Monte Carlo trials.
      See Also:
    • baseProcess

      private final ProcessSystem baseProcess
      Base process system for simulation.
    • parameters

      private final List<SensitivityAnalysis.UncertainParameter> parameters
      List of uncertain parameters.
    • rng

      private transient Random rng
      Random number generator.
  • Constructor Details

    • SensitivityAnalysis

      public SensitivityAnalysis(ProcessSystem process)
      Creates a sensitivity analysis for a process system.
      Parameters:
      process - base process system
    • SensitivityAnalysis

      public SensitivityAnalysis(ProcessSystem process, Random rng)
      Creates a sensitivity analysis with specified RNG.
      Parameters:
      process - base process system
      rng - random number generator
  • Method Details

    • addParameter

      Adds an uncertain parameter.
      Parameters:
      param - parameter to add
      Returns:
      this for chaining
    • clearParameters

      public SensitivityAnalysis clearParameters()
      Removes all parameters.
      Returns:
      this for chaining
    • getParameters

      Gets the list of parameters.
      Returns:
      unmodifiable list of parameters
    • runMonteCarloOptimization

      public SensitivityAnalysis.MonteCarloResult runMonteCarloOptimization(StreamInterface feedStream, double lowerBound, double upperBound, String rateUnit, ToDoubleFunction<ProductionOptimizer.OptimizationResult> outputMetric, SensitivityAnalysis.SensitivityConfig config)
      Runs Monte Carlo simulation on feed rate optimization.

      For each trial:

      1. Sample all uncertain parameters
      2. Apply parameters to the process
      3. Run production optimization
      4. Extract the output metric
      Parameters:
      feedStream - feed stream for optimization
      lowerBound - lower bound for rate
      upperBound - upper bound for rate
      rateUnit - rate unit
      outputMetric - function to extract output from optimization result
      config - simulation configuration
      Returns:
      Monte Carlo result with statistics
    • runSequentialTrials

      private List<SensitivityAnalysis.TrialResult> runSequentialTrials(StreamInterface feedStream, double lowerBound, double upperBound, String rateUnit, ToDoubleFunction<ProductionOptimizer.OptimizationResult> outputMetric, SensitivityAnalysis.SensitivityConfig config, Random localRng)
      Runs trials sequentially.
      Parameters:
      feedStream - the feed stream for optimization
      lowerBound - the lower bound of the rate search range
      upperBound - the upper bound of the rate search range
      rateUnit - the unit for rate values
      outputMetric - the function extracting the output metric from optimization results
      config - the sensitivity analysis configuration
      localRng - the random number generator for sampling
      Returns:
      the list of trial results
    • runParallelTrials

      private List<SensitivityAnalysis.TrialResult> runParallelTrials(StreamInterface feedStream, double lowerBound, double upperBound, String rateUnit, ToDoubleFunction<ProductionOptimizer.OptimizationResult> outputMetric, SensitivityAnalysis.SensitivityConfig config, Random localRng)
      Runs trials in parallel.
      Parameters:
      feedStream - the feed stream for optimization
      lowerBound - lower bound of the rate range
      upperBound - upper bound of the rate range
      rateUnit - unit for production rates
      outputMetric - function to extract output metric from optimization result
      config - sensitivity analysis configuration
      localRng - random number generator for sampling
      Returns:
      list of trial results
    • runSingleTrial

      private SensitivityAnalysis.TrialResult runSingleTrial(int trialNum, Map<String,Double> sampled, StreamInterface feedStream, double lowerBound, double upperBound, String rateUnit, ToDoubleFunction<ProductionOptimizer.OptimizationResult> outputMetric)
      Runs a single trial (used for parallel execution).
      Parameters:
      trialNum - the trial number
      sampled - map of sampled parameter values
      feedStream - the feed stream for optimization
      lowerBound - lower bound of the rate range
      upperBound - upper bound of the rate range
      rateUnit - unit for production rates
      outputMetric - function to extract output metric from optimization result
      Returns:
      the trial result
    • runTornadoAnalysis

      public Map<String,Double> runTornadoAnalysis(StreamInterface feedStream, double lowerBound, double upperBound, String rateUnit, ToDoubleFunction<ProductionOptimizer.OptimizationResult> outputMetric)
      Runs one-at-a-time sensitivity analysis (tornado diagram).

      For each parameter:

      1. Set all parameters to P50 (base case)
      2. Vary target parameter to P10, run, record output
      3. Vary target parameter to P90, run, record output
      4. Calculate sensitivity as |output_P90 - output_P10|
      Parameters:
      feedStream - feed stream for optimization
      lowerBound - lower bound for rate
      upperBound - upper bound for rate
      rateUnit - rate unit
      outputMetric - function to extract output
      Returns:
      map of parameter name to sensitivity magnitude
    • runTornadoAnalysisInternal

      private Map<String,Double> runTornadoAnalysisInternal(StreamInterface feedStream, double lowerBound, double upperBound, String rateUnit, ToDoubleFunction<ProductionOptimizer.OptimizationResult> outputMetric)
    • runSpiderAnalysis

      public Map<String, List<SensitivityAnalysis.SpiderPoint>> runSpiderAnalysis(StreamInterface feedStream, double lowerBound, double upperBound, String rateUnit, int stepsPerParameter, ToDoubleFunction<ProductionOptimizer.OptimizationResult> outputMetric)
      Generates spider plot data for each parameter.

      Varies each parameter systematically from P10 to P90 while holding others at P50, recording the output at each step.

      Parameters:
      feedStream - feed stream for optimization
      lowerBound - lower bound for rate
      upperBound - upper bound for rate
      rateUnit - rate unit
      stepsPerParameter - number of steps from P10 to P90
      outputMetric - function to extract output
      Returns:
      map of parameter name to list of spider points
    • getRng

      private Random getRng()
      Gets the random number generator.
      Returns:
      RNG (creates if null)
    • setRng

      public void setRng(Random rng)
      Sets the random number generator.
      Parameters:
      rng - new RNG
    • getBaseProcess

      public ProcessSystem getBaseProcess()
      Gets the base process system.
      Returns:
      base process