Class SimulationQualityGate

java.lang.Object
neqsim.util.agentic.SimulationQualityGate
All Implemented Interfaces:
Serializable

public class SimulationQualityGate extends Object implements Serializable
Automated quality gate for simulation results validation.

Validates a completed ProcessSystem against physical and engineering constraints:

  • Mass balance closure across the entire process
  • Energy balance closure (if enthalpy data available)
  • Physical bounds (T > 0 K, P > 0, 0 <= compositions <= 1)
  • Stream consistency (no NaN or infinite values)

Designed to be called between Step 2 (analysis) and Step 3 (reporting) of the task-solving workflow. When called from Python via jpype, enables automated QA gates in notebooks.

Usage in Java:

ProcessSystem process = new ProcessSystem();
// ... build and run process ...
process.run();

SimulationQualityGate gate = new SimulationQualityGate(process);
gate.validate();
boolean passed = gate.isPassed();
String report = gate.toJson();

Usage in Python (jpype):

import jpype
SimulationQualityGate = jpype.JClass(
    "neqsim.util.agentic.SimulationQualityGate")
gate = SimulationQualityGate(process)
gate.validate()
assert gate.isPassed(), gate.toJson()
Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • DEFAULT_MASS_BALANCE_TOLERANCE

      public static final double DEFAULT_MASS_BALANCE_TOLERANCE
      Default tolerance for mass balance closure (fraction).
      See Also:
    • DEFAULT_ENERGY_BALANCE_TOLERANCE

      public static final double DEFAULT_ENERGY_BALANCE_TOLERANCE
      Default tolerance for energy balance closure (fraction).
      See Also:
    • process

      private final transient ProcessSystem process
    • massBalanceTolerance

      private double massBalanceTolerance
    • energyBalanceTolerance

      private double energyBalanceTolerance
    • validated

      private boolean validated
    • passed

      private boolean passed
    • issues

  • Constructor Details

    • SimulationQualityGate

      public SimulationQualityGate(ProcessSystem process)
      Constructor for SimulationQualityGate.
      Parameters:
      process - the ProcessSystem to validate
  • Method Details

    • validate

      public void validate()
      Run all validation checks.
    • checkMassBalance

      private void checkMassBalance()
      Check overall mass balance closure across the process.

      Compares total inlet mass flow to total outlet mass flow. Uses the first and last equipment in the process to identify boundary streams. Tolerance is configurable via setMassBalanceTolerance(double).

    • checkEnergyBalance

      private void checkEnergyBalance()
      Check overall energy balance closure across the process.

      Compares total inlet enthalpy flow to total outlet enthalpy flow plus external duties. Tolerance is configurable via setEnergyBalanceTolerance(double).

    • checkPhysicalBounds

      private void checkPhysicalBounds()
      Check physical bounds on all streams in the process.
    • checkStreamPhysicalBounds

      private void checkStreamPhysicalBounds(StreamInterface stream)
      Check physical bounds for a single stream.
      Parameters:
      stream - the stream to check
    • checkStreamConsistency

      private void checkStreamConsistency()
      Check for NaN or infinite values in stream properties.
    • checkCompositionNormalization

      private void checkCompositionNormalization()
      Check that component mole fractions sum to approximately 1.0 in all streams.
    • addIssue

      private void addIssue(SimulationQualityGate.Severity severity, String category, String message, String remediation)
      Add a quality issue.
      Parameters:
      severity - issue severity
      category - check category
      message - description of the issue
      remediation - suggested fix
    • isPassed

      public boolean isPassed()
      Check if validation passed (no errors).
      Returns:
      true if all checks passed without errors
    • getErrorCount

      public int getErrorCount()
      Get the number of errors found.
      Returns:
      error count
    • getWarningCount

      public int getWarningCount()
      Get the number of warnings found.
      Returns:
      warning count
    • getIssues

      Get all issues.
      Returns:
      list of quality issues
    • toJson

      public String toJson()
      Get results as JSON string.
      Returns:
      JSON report of validation results
    • setMassBalanceTolerance

      public void setMassBalanceTolerance(double tolerance)
      Set mass balance tolerance.
      Parameters:
      tolerance - tolerance as a fraction (e.g., 0.01 for 1%)
    • setEnergyBalanceTolerance

      public void setEnergyBalanceTolerance(double tolerance)
      Set energy balance tolerance.
      Parameters:
      tolerance - tolerance as a fraction (e.g., 0.05 for 5%)