Class ParametricStudyRunner

java.lang.Object
neqsim.mcp.runners.ParametricStudyRunner

public class ParametricStudyRunner extends Object
Parametric study runner for sensitivity analysis and optimization sweeps.

Enables license-free batch exploration of a process design space. A typical cooperative UniSim–NeqSim workflow:

  1. Engineer builds the base case in UniSim (industry-accepted model)
  2. Convert to NeqSim JSON via unisim_reader.py
  3. Run a parametric study with this runner (hundreds of cases, no license)
  4. Identify optimal operating point
  5. Write the optimal case back to UniSim via unisim_writer.py

Input JSON Format:

{ "baseProcess": { ... standard process JSON ... }, "sweeps": [ { "address":
"Feed.temperature", "unit": "C", "values": [10.0, 20.0, 30.0, 40.0, 50.0] }, { "address":
"Feed.pressure", "unit": "bara", "from": 30.0, "to": 80.0, "steps": 6 } ], "outputs": [
{"address": "HP Sep.gasOutStream.flowRate", "unit": "MSm3/day"}, {"address": "Compressor.power",
"unit": "kW"} ], "mode": "full_factorial" } 
Author:
Even Solbraa @version 1.0
  • Field Details

    • GSON

      private static final com.google.gson.Gson GSON
    • MAX_TOTAL_CASES

      private static final int MAX_TOTAL_CASES
      Maximum total cases to prevent resource exhaustion.
      See Also:
  • Constructor Details

    • ParametricStudyRunner

      private ParametricStudyRunner()
  • Method Details

    • run

      public static String run(String json)
      Runs a parametric study by sweeping input variables and recording outputs.

      Supports two modes:

      • full_factorial — all combinations of sweep values (N1 × N2 × ...)
      • one_at_a_time — vary one parameter while keeping others at base (default)
      Parameters:
      json - the parametric study specification
      Returns:
      JSON with all case results and summary statistics
    • runCase

      private static com.google.gson.JsonObject runCase(com.google.gson.JsonObject baseProcess, List<ParametricStudyRunner.SweepDef> sweeps, Map<String,Double> inputValues, List<ParametricStudyRunner.OutputDef> outputs, int caseIndex)
      Runs a single parametric case.
      Parameters:
      baseProcess - the base process JSON definition
      sweeps - the sweep parameter definitions
      inputValues - the input values for this case
      outputs - the output definitions to collect
      caseIndex - the index of this case
      Returns:
      a JsonObject containing the case results
    • generateFullFactorialCases

      private static List<Map<String,Double>> generateFullFactorialCases(List<ParametricStudyRunner.SweepDef> sweeps)
      Generates all combinations for full-factorial design.
      Parameters:
      sweeps - the sweep parameter definitions
      Returns:
      a list of maps, each representing one factorial case
    • generateFactorialRecursive

      private static void generateFactorialRecursive(List<ParametricStudyRunner.SweepDef> sweeps, int depth, Map<String,Double> current, List<Map<String,Double>> cases)
    • generateOneAtATimeCases

      private static List<Map<String,Double>> generateOneAtATimeCases(List<ParametricStudyRunner.SweepDef> sweeps)
      Generates one-at-a-time cases: vary one parameter while keeping others at midpoint.
      Parameters:
      sweeps - the sweep definitions for each parameter
      Returns:
      list of parameter cases, each mapping address to value
    • buildOutputSummary

      private static com.google.gson.JsonObject buildOutputSummary(List<ParametricStudyRunner.OutputDef> outputs, com.google.gson.JsonArray caseResults)
      Builds summary statistics for each output variable across all converged cases.
      Parameters:
      outputs - the output variable definitions
      caseResults - the JSON array of individual case results
      Returns:
      JSON object containing min, max, mean, and std for each output
    • errorJson

      private static String errorJson(String code, String message, String remediation)