Class ProcessScenarioRunner
java.lang.Object
neqsim.process.util.scenario.ProcessScenarioRunner
Utility class for running process scenarios with integrated logic execution.
This runner coordinates:
- Process system transient simulation
- Process logic execution (ESD, startup, shutdown, etc.)
- Scenario perturbation application
- Status monitoring and reporting
Example usage:
ProcessSystem system = new ProcessSystem();
// ... configure system ...
ProcessScenarioRunner runner = new ProcessScenarioRunner(system);
runner.addLogic(esdLogic);
runner.addLogic(startupLogic);
ProcessSafetyScenario scenario = ProcessSafetyScenario.builder("High Pressure")
.customManipulator("Feed", stream -> stream.setPressure(80.0, "bara")).build();
runner.runScenario("High Pressure Test", scenario, 60.0, 1.0);
- Version:
- 1.0
- Author:
- ESOL
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<ProcessLogic> private UUIDprivate final ProcessSystem -
Constructor Summary
ConstructorsConstructorDescriptionProcessScenarioRunner(ProcessSystem system) Creates a scenario runner for the given process system. -
Method Summary
Modifier and TypeMethodDescriptionbooleanactivateLogic(String logicName) Activates a logic sequence by name.voidaddLogic(ProcessLogic logic) Adds a process logic sequence to be executed.voidClears all registered logic sequences.Finds a logic sequence by name.Gets all registered logic sequences.private StringGets a summary of key process parameters for status monitoring.private StringgetShortState(LogicState state) Gets short form of logic state for display.Gets the process system being simulated.private booleanhasLogicStateChanged(List<ProcessLogic> logicList) Checks if any logic sequence has changed state since last check.voidEnsures the process system has a valid steady-state solution before running scenarios.private voidprintFinalSummary(ScenarioExecutionSummary summary, List<ProcessLogic> logicList) Prints final summary of scenario execution.private voidprintStatus(double time, List<ProcessLogic> logicList) Prints current status of scenario execution.booleanremoveLogic(String logicName) Removes a logic sequence by name.voidremoveLogic(ProcessLogic logic) Removes a process logic sequence.voidGets a new simulation ID for the next run.voidreset()Resets the system for the next scenario.voidResets all logic sequences to prepare for next scenario.runScenario(String scenarioName, ProcessSafetyScenario scenario, double duration, double timeStep) Runs a scenario with the given parameters.runScenarioWithLogic(String scenarioName, ProcessSafetyScenario scenario, double duration, double timeStep, List<String> enabledLogicNames) Runs a scenario with only specific logic sequences enabled.private voidValidates that process conditions are within reasonable ranges to prevent simulation errors.
-
Field Details
-
system
-
logicSequences
-
simulationId
-
-
Constructor Details
-
ProcessScenarioRunner
Creates a scenario runner for the given process system.- Parameters:
system- process system to simulate
-
-
Method Details
-
initializeSteadyState
public void initializeSteadyState()Ensures the process system has a valid steady-state solution before running scenarios. This method should be called before running any scenarios to establish baseline conditions.- Throws:
RuntimeException- if steady-state calculation fails
-
validateProcessConditions
private void validateProcessConditions()Validates that process conditions are within reasonable ranges to prevent simulation errors. -
addLogic
Adds a process logic sequence to be executed.- Parameters:
logic- logic sequence to add
-
removeLogic
Removes a process logic sequence.- Parameters:
logic- logic sequence to remove
-
removeLogic
Removes a logic sequence by name.- Parameters:
logicName- name of the logic sequence to remove- Returns:
- true if logic was found and removed, false otherwise
-
clearAllLogic
public void clearAllLogic()Clears all registered logic sequences. -
getLogicSequences
Gets all registered logic sequences.- Returns:
- list of logic sequences
-
runScenario
public ScenarioExecutionSummary runScenario(String scenarioName, ProcessSafetyScenario scenario, double duration, double timeStep) Runs a scenario with the given parameters.- Parameters:
scenarioName- descriptive name for loggingscenario- scenario perturbations to apply (can be null)duration- simulation duration in secondstimeStep- time step in seconds- Returns:
- scenario execution summary
-
runScenarioWithLogic
public ScenarioExecutionSummary runScenarioWithLogic(String scenarioName, ProcessSafetyScenario scenario, double duration, double timeStep, List<String> enabledLogicNames) Runs a scenario with only specific logic sequences enabled.This allows you to run a scenario with a subset of registered logic sequences. Only the logic sequences with names matching the provided list will be executed during this scenario.
Example:
runner.addLogic(hippsLogic); runner.addLogic(esdLogic); runner.addLogic(startupLogic); // Run scenario with only ESD logic active (HIPPS and startup will be ignored) runner.runScenarioWithLogic("ESD Test", scenario, 30.0, 1.0, List.of("ESD Level 1"));- Parameters:
scenarioName- descriptive name for loggingscenario- scenario perturbations to apply (can be null)duration- simulation duration in secondstimeStep- time step in secondsenabledLogicNames- names of logic sequences to enable (null = all logic enabled)- Returns:
- scenario execution summary
-
hasLogicStateChanged
Checks if any logic sequence has changed state since last check.- Parameters:
logicList- list of logic sequences to check- Returns:
- true if state has changed
-
printStatus
Prints current status of scenario execution.- Parameters:
time- current simulation timelogicList- list of logic sequences to monitor
-
getProcessStatus
Gets a summary of key process parameters for status monitoring. -
getShortState
Gets short form of logic state for display.- Parameters:
state- logic state- Returns:
- abbreviated state string
-
printFinalSummary
Prints final summary of scenario execution.- Parameters:
summary- execution summarylogicList- list of logic sequences that were active in this scenario
-
resetLogic
public void resetLogic()Resets all logic sequences to prepare for next scenario. -
renewSimulationId
public void renewSimulationId()Gets a new simulation ID for the next run. -
reset
public void reset()Resets the system for the next scenario.This method resets logic states and re-establishes steady-state conditions to ensure clean starting conditions for each scenario.
-
getSystem
Gets the process system being simulated.- Returns:
- the process system
-
activateLogic
Activates a logic sequence by name.- Parameters:
logicName- name of the logic sequence to activate- Returns:
- true if logic was found and activated, false otherwise
-
findLogic
Finds a logic sequence by name.- Parameters:
logicName- name of the logic sequence to find- Returns:
- the logic sequence if found, null otherwise
-