Class BatchRunner
java.lang.Object
neqsim.mcp.runners.BatchRunner
Stateless batch calculation runner for MCP integration.
Runs multiple flash calculations in a single call, sharing a common fluid definition. This is designed for sensitivity studies and property sweeps where an agent needs to explore a parameter space efficiently. Each case in the batch can vary temperature, pressure, or composition.
Input JSON Format:
{ "model": "SRK", "components": {"methane": 0.85, "ethane": 0.10, "propane": 0.05},
"mixingRule": "classic", "flashType": "TP", "cases": [ {"temperature": {"value": 0.0, "unit":
"C"}, "pressure": {"value": 50.0, "unit": "bara"}}, {"temperature": {"value": 25.0, "unit": "C"},
"pressure": {"value": 50.0, "unit": "bara"}}, {"temperature": {"value": 50.0, "unit": "C"},
"pressure": {"value": 50.0, "unit": "bara"}} ] }
Each case can also override components or flash type to explore composition sensitivity or different calculation modes within a single call.
- Author:
- Even Solbraa @version 1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor — all methods are static. -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringCreates a standard error JSON response.private static com.google.gson.JsonObjectmergeJsonObjects(com.google.gson.JsonObject base, com.google.gson.JsonObject overrides) Merges two JSON objects, with the override taking precedence.static StringRuns a batch of flash calculations from a JSON specification.
-
Field Details
-
GSON
private static final com.google.gson.Gson GSON -
MAX_CASES
private static final int MAX_CASESMaximum number of cases per batch to prevent resource exhaustion.- See Also:
-
-
Constructor Details
-
BatchRunner
private BatchRunner()Private constructor — all methods are static.
-
-
Method Details
-
run
Runs a batch of flash calculations from a JSON specification.Each case inherits the base fluid definition (model, components, mixingRule, flashType) and can override temperature, pressure, components, or flashType per case. Results are returned as an array with per-case status so partial failures don't block the entire batch.
- Parameters:
json- the JSON batch specification- Returns:
- a JSON string with batch results and provenance
-
mergeJsonObjects
private static com.google.gson.JsonObject mergeJsonObjects(com.google.gson.JsonObject base, com.google.gson.JsonObject overrides) Merges two JSON objects, with the override taking precedence.- Parameters:
base- the base objectoverrides- the overriding values- Returns:
- a new merged JSON object
-
errorJson
-