Class ProcessScenarioRunner

java.lang.Object
neqsim.process.util.scenario.ProcessScenarioRunner

public class ProcessScenarioRunner extends Object
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 Details

  • Constructor Details

    • ProcessScenarioRunner

      public ProcessScenarioRunner(ProcessSystem system)
      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

      public void addLogic(ProcessLogic logic)
      Adds a process logic sequence to be executed.
      Parameters:
      logic - logic sequence to add
    • removeLogic

      public void removeLogic(ProcessLogic logic)
      Removes a process logic sequence.
      Parameters:
      logic - logic sequence to remove
    • removeLogic

      public boolean removeLogic(String logicName)
      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

      public List<ProcessLogic> 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 logging
      scenario - scenario perturbations to apply (can be null)
      duration - simulation duration in seconds
      timeStep - 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 logging
      scenario - scenario perturbations to apply (can be null)
      duration - simulation duration in seconds
      timeStep - time step in seconds
      enabledLogicNames - names of logic sequences to enable (null = all logic enabled)
      Returns:
      scenario execution summary
    • hasLogicStateChanged

      private boolean hasLogicStateChanged(List<ProcessLogic> logicList)
      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

      private void printStatus(double time, List<ProcessLogic> logicList)
      Prints current status of scenario execution.
      Parameters:
      time - current simulation time
      logicList - list of logic sequences to monitor
    • getProcessStatus

      private String getProcessStatus()
      Gets a summary of key process parameters for status monitoring.
    • getShortState

      private String getShortState(LogicState state)
      Gets short form of logic state for display.
      Parameters:
      state - logic state
      Returns:
      abbreviated state string
    • printFinalSummary

      private void printFinalSummary(ScenarioExecutionSummary summary, List<ProcessLogic> logicList)
      Prints final summary of scenario execution.
      Parameters:
      summary - execution summary
      logicList - 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

      public ProcessSystem getSystem()
      Gets the process system being simulated.
      Returns:
      the process system
    • activateLogic

      public boolean activateLogic(String logicName)
      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

      public ProcessLogic findLogic(String logicName)
      Finds a logic sequence by name.
      Parameters:
      logicName - name of the logic sequence to find
      Returns:
      the logic sequence if found, null otherwise