Class StreamingRunner

java.lang.Object
neqsim.mcp.runners.StreamingRunner

public final class StreamingRunner extends Object
Streaming simulation runner that executes long-running operations asynchronously and provides incremental result polling.

Supports: convergence monitoring during flash sweeps, parametric studies with per-case results, dynamic simulation time-step streaming, and Monte Carlo progress. Agents poll for intermediate results while the computation proceeds in background.

Version:
1.0
Author:
Even Solbraa
  • Field Details

  • Constructor Details

    • StreamingRunner

      private StreamingRunner()
      Private constructor — all methods are static.
  • Method Details

    • run

      public static String run(String json)
      Main entry point for streaming operations.
      Parameters:
      json - JSON with action (start, poll, cancel, list) and details
      Returns:
      JSON with operation status and results
    • startParametricSweep

      private static String startParametricSweep(com.google.gson.JsonObject input)
      Starts a parametric sweep that reports results incrementally.
      Parameters:
      input - the sweep configuration
      Returns:
      JSON with operation ID
    • startDynamicStreaming

      private static String startDynamicStreaming(com.google.gson.JsonObject input)
      Starts a dynamic simulation that streams time-step results.
      Parameters:
      input - the dynamic simulation configuration
      Returns:
      JSON with operation ID
    • startMonteCarlo

      private static String startMonteCarlo(com.google.gson.JsonObject input)
      Starts a Monte Carlo sweep that tracks convergence statistics.
      Parameters:
      input - the Monte Carlo configuration
      Returns:
      JSON with operation ID
    • pollResults

      private static String pollResults(com.google.gson.JsonObject input)
      Polls for incremental results from a streaming operation.
      Parameters:
      input - JSON with operationId and optional lastIndex
      Returns:
      JSON with new results since lastIndex
    • cancelOperation

      private static String cancelOperation(com.google.gson.JsonObject input)
      Cancels a streaming operation.
      Parameters:
      input - JSON with operationId
      Returns:
      JSON confirmation
    • listOperations

      private static String listOperations()
      Lists all active and recent streaming operations.
      Returns:
      JSON with operation summaries
    • convertToKelvin

      private static double convertToKelvin(double value, String unit)
      Converts temperature to Kelvin.
      Parameters:
      value - the temperature value
      unit - the temperature unit
      Returns:
      temperature in Kelvin
    • convertToBara

      private static double convertToBara(double value, String unit)
      Converts pressure to bara.
      Parameters:
      value - the pressure value
      unit - the pressure unit
      Returns:
      pressure in bara
    • mean

      private static double mean(List<Double> values)
      Calculates the mean of a list of doubles.
      Parameters:
      values - the values
      Returns:
      the mean
    • stddev

      private static double stddev(List<Double> values)
      Calculates the standard deviation of a list of doubles.
      Parameters:
      values - the values
      Returns:
      the standard deviation
    • percentile

      private static double percentile(List<Double> values, int pct)
      Calculates a percentile from a list of doubles.
      Parameters:
      values - the values
      pct - the percentile (0-100)
      Returns:
      the percentile value
    • errorJson

      private static String errorJson(String code, String message, String remediation)
      Creates a standard error JSON response.
      Parameters:
      code - the error code
      message - the error message
      remediation - the fix suggestion
      Returns:
      the JSON string