This document describes the automatic safety scenario generation infrastructure added to NeqSim.
Overview
Process safety analysis requires systematic evaluation of failure modes. The AutomaticScenarioGenerator class automatically identifies potential failures from process topology and generates scenarios for what-if analysis.
Key Features
- Equipment-Specific Failures: Identifies applicable failure modes per equipment type
- Single Failures: Generate one failure at a time
- Combination Scenarios: Generate multiple simultaneous failures
- HAZOP Mapping: Links failures to standard deviation types
Usage
Basic Usage
ProcessSystem process = new ProcessSystem();
// ... configure process with valves, compressors, coolers, etc. ...
AutomaticScenarioGenerator generator = new AutomaticScenarioGenerator(process);
// Enable specific failure modes
generator.addFailureModes(
FailureMode.COOLING_LOSS,
FailureMode.VALVE_STUCK_CLOSED,
FailureMode.COMPRESSOR_TRIP
);
// Generate single-failure scenarios
List<ProcessSafetyScenario> singleFailures = generator.generateSingleFailures();
// Generate combination scenarios (up to 2 simultaneous failures)
List<ProcessSafetyScenario> combinations = generator.generateCombinations(2);
Convenience Methods on ProcessSystem
// Quick scenario generation
List<ProcessSafetyScenario> scenarios = process.generateSafetyScenarios();
// With combination depth
List<ProcessSafetyScenario> combinations = process.generateCombinationScenarios(2);
Failure Modes
| Mode | Description | HAZOP Deviation | Applicable To |
|---|---|---|---|
COOLING_LOSS |
Complete loss of cooling | No flow | Coolers |
HEATING_LOSS |
Complete loss of heating | No flow | Heaters |
VALVE_STUCK_CLOSED |
Valve stuck closed | No flow | Valves |
VALVE_STUCK_OPEN |
Valve stuck open | More flow | Valves |
VALVE_CONTROL_FAILURE |
Control valve failure | Other | Control valves |
COMPRESSOR_TRIP |
Compressor emergency stop | No flow | Compressors |
PUMP_TRIP |
Pump emergency stop | No flow | Pumps |
BLOCKED_OUTLET |
Downstream blockage | No flow | Separators |
POWER_FAILURE |
Loss of electrical power | Other | All electrical |
INSTRUMENT_FAILURE |
Instrument/control failure | Other | All |
EXTERNAL_FIRE |
Fire exposure | High temperature | All |
LOSS_OF_CONTAINMENT |
Leak or rupture | Less pressure | All |
HAZOP Deviations
| Deviation | Description |
|---|---|
NO_FLOW |
Complete loss of flow |
LESS_FLOW |
Reduced flow rate |
MORE_FLOW |
Increased flow rate |
REVERSE_FLOW |
Flow in wrong direction |
HIGH_PRESSURE |
Pressure above normal |
LOW_PRESSURE / LESS_PRESSURE |
Pressure below normal |
HIGH_TEMPERATURE |
Temperature above normal |
LOW_TEMPERATURE |
Temperature below normal |
HIGH_LEVEL |
Liquid level too high |
LOW_LEVEL |
Liquid level too low |
CONTAMINATION |
Unwanted substance present |
CORROSION |
Material degradation |
Running Scenarios
Manual Execution
// Generate scenarios
List<ProcessSafetyScenario> scenarios = generator.generateSingleFailures();
for (ProcessSafetyScenario scenario : scenarios) {
// Create a copy of the process for each scenario
ProcessSystem copy = process.copy();
// Apply the scenario
scenario.applyTo(copy);
// Run simulation
try {
copy.run();
// Analyze results
analyzeScenarioResults(scenario, copy);
} catch (Exception e) {
// Scenario caused simulation failure - important finding!
recordFailedScenario(scenario, e);
}
}
Automated Execution with ScenarioRunResult
The generator provides built-in scenario execution capabilities:
// Run all single-failure scenarios automatically
List<ScenarioRunResult> results = generator.runAllSingleFailures();
// Or run specific scenarios
List<ProcessSafetyScenario> scenarios = generator.generateSingleFailures();
List<ScenarioRunResult> results = generator.runScenarios(scenarios);
// Get execution summary
String summary = generator.summarizeResults(results);
System.out.println(summary);
ScenarioRunResult
Each result contains:
| Field | Type | Description |
|---|---|---|
scenario |
ProcessSafetyScenario | The scenario that was run |
successful |
boolean | Whether simulation completed without error |
errorMessage |
String | Error message if failed (null otherwise) |
resultValues |
Map<String, Double> | Key results: pressures, temperatures, levels |
executionTimeMs |
long | Execution time in milliseconds |
Example Summary Output
=== Scenario Execution Summary ===
Total scenarios: 12
Successful: 10 (83.3%)
Failed: 2 (16.7%)
Failed scenarios:
- COOLING_LOSS on Cooler-1: Simulation did not converge
- COMPRESSOR_TRIP on MainCompressor: Exceeded iteration limit
Failure Mode Summary
String summary = generator.getFailureModeSummary();
System.out.println(summary);
// Output:
// Failure Mode Analysis Summary
// =============================
// Total potential failures: 42
//
// By Equipment Type:
// ThrottlingValve: 12 failure modes
// Compressor: 8 failure modes
// Cooler: 6 failure modes
// Separator: 8 failure modes
// Pump: 8 failure modes
Integration with Existing Safety Framework
The AutomaticScenarioGenerator complements the existing safety framework:
- ProcessSafetyScenario: Manual scenario definition
- SafetyValve, RuptureDisk: Physical safety equipment
- AutomaticScenarioGenerator: Automated scenario identification
Best Practices
- Systematic Coverage: Enable all relevant failure modes for comprehensive analysis
- Prioritization: Focus detailed analysis on high-consequence scenarios
- Combination Limits: Limit combination depth to 2-3 for practical analysis
- Documentation: Record all scenario results for safety case
- Regular Updates: Regenerate scenarios after process modifications
Time-domain acceptance policy
The transient DynamicSafetyScenarioRunner is distinct from the steady-state
failure enumeration above. Its DynamicScenarioCriterion defaults to
REACH_BY_DEADLINE: one satisfactory observation by the deadline is enough. Use
that policy for reaching a declared valve position within an allowed response time.
A pressure reading within limits at the initiating event does not establish that
pressure stayed within limits afterward.
Select evaluationMode(DynamicScenarioCriterion.EvaluationMode.MAINTAIN_BOUNDS)
for a sampled invariant. Its positive deadlineSeconds defines the closed
event-relative observation window from zero to that deadline. Every observation
in the window must satisfy the inclusive limits, and both boundaries must be
observed within a timestamp tolerance capped at both one nanosecond and one part
per million of the window length, keeping the two boundaries distinct. Missing boundaries are not
interpolated. Set the deadline to the duration after the initiating event to assess
the full response horizon, and use event-exact stepping when boundaries require it.
Values outside the declared window are retained in the history but do not enter
that window’s verdict. This checks sampled behaviour, not unobserved peaks between
scans or a continuous-time safety guarantee.
The result records the evaluation mode, first violation, monitored sample count,
minimum/maximum and boundary coverage. An excursion followed by recovery still
fails MAINTAIN_BOUNDS. Early termination cannot clear its missing end boundary.
DynamicScenarioCriterionEvaluationTest distinguishes these cases from the
unchanged reach policy. Use independent full-history extrema and scan refinement
for decision-critical pressure, level and no-unintended-trip checks, and retain
mass, component and energy verdicts separately from response criteria.
Related Documentation
- Safety Systems Package - Safety equipment modeling
- Batch Studies - Run many scenarios in parallel
- Future Infrastructure Overview - Full infrastructure overview