Class StreamingRunner
java.lang.Object
neqsim.mcp.runners.StreamingRunner
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classInternal state for a streaming operation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ExecutorServiceBackground thread pool for async simulations.private static final com.google.gson.Gsonprivate static final intMax concurrent streaming operations.private static final ConcurrentHashMap<String, StreamingRunner.StreamingOperation> Active streaming operations. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor — all methods are static. -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringcancelOperation(com.google.gson.JsonObject input) Cancels a streaming operation.private static doubleconvertToBara(double value, String unit) Converts pressure to bara.private static doubleconvertToKelvin(double value, String unit) Converts temperature to Kelvin.private static StringCreates a standard error JSON response.private static StringLists all active and recent streaming operations.private static doubleCalculates the mean of a list of doubles.private static doublepercentile(List<Double> values, int pct) Calculates a percentile from a list of doubles.private static StringpollResults(com.google.gson.JsonObject input) Polls for incremental results from a streaming operation.static StringMain entry point for streaming operations.private static StringstartDynamicStreaming(com.google.gson.JsonObject input) Starts a dynamic simulation that streams time-step results.private static StringstartMonteCarlo(com.google.gson.JsonObject input) Starts a Monte Carlo sweep that tracks convergence statistics.private static StringstartParametricSweep(com.google.gson.JsonObject input) Starts a parametric sweep that reports results incrementally.private static doubleCalculates the standard deviation of a list of doubles.
-
Field Details
-
GSON
private static final com.google.gson.Gson GSON -
EXECUTOR
Background thread pool for async simulations. -
OPERATIONS
Active streaming operations. -
MAX_OPERATIONS
private static final int MAX_OPERATIONSMax concurrent streaming operations.- See Also:
-
-
Constructor Details
-
StreamingRunner
private StreamingRunner()Private constructor — all methods are static.
-
-
Method Details
-
run
-
startParametricSweep
Starts a parametric sweep that reports results incrementally.- Parameters:
input- the sweep configuration- Returns:
- JSON with operation ID
-
startDynamicStreaming
Starts a dynamic simulation that streams time-step results.- Parameters:
input- the dynamic simulation configuration- Returns:
- JSON with operation ID
-
startMonteCarlo
Starts a Monte Carlo sweep that tracks convergence statistics.- Parameters:
input- the Monte Carlo configuration- Returns:
- JSON with operation ID
-
pollResults
Polls for incremental results from a streaming operation.- Parameters:
input- JSON with operationId and optional lastIndex- Returns:
- JSON with new results since lastIndex
-
cancelOperation
Cancels a streaming operation.- Parameters:
input- JSON with operationId- Returns:
- JSON confirmation
-
listOperations
Lists all active and recent streaming operations.- Returns:
- JSON with operation summaries
-
convertToKelvin
Converts temperature to Kelvin.- Parameters:
value- the temperature valueunit- the temperature unit- Returns:
- temperature in Kelvin
-
convertToBara
Converts pressure to bara.- Parameters:
value- the pressure valueunit- the pressure unit- Returns:
- pressure in bara
-
mean
-
stddev
-
percentile
-
errorJson
-