Class SimulationQualityGate
java.lang.Object
neqsim.util.agentic.SimulationQualityGate
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a single quality gate issue.static enumIssue severity levels. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault tolerance for energy balance closure (fraction).static final doubleDefault tolerance for mass balance closure (fraction).private doubleprivate List<SimulationQualityGate.QualityIssue> private doubleprivate booleanprivate final ProcessSystemprivate static final longSerialization version UID.private boolean -
Constructor Summary
ConstructorsConstructorDescriptionSimulationQualityGate(ProcessSystem process) Constructor for SimulationQualityGate. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddIssue(SimulationQualityGate.Severity severity, String category, String message, String remediation) Add a quality issue.private voidCheck that component mole fractions sum to approximately 1.0 in all streams.private voidCheck overall energy balance closure across the process.private voidCheck overall mass balance closure across the process.private voidCheck physical bounds on all streams in the process.private voidCheck for NaN or infinite values in stream properties.private voidCheck physical bounds for a single stream.intGet the number of errors found.Get all issues.intGet the number of warnings found.booleanisPassed()Check if validation passed (no errors).voidsetEnergyBalanceTolerance(double tolerance) Set energy balance tolerance.voidsetMassBalanceTolerance(double tolerance) Set mass balance tolerance.toJson()Get results as JSON string.voidvalidate()Run all validation checks.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
DEFAULT_MASS_BALANCE_TOLERANCE
public static final double DEFAULT_MASS_BALANCE_TOLERANCEDefault tolerance for mass balance closure (fraction).- See Also:
-
DEFAULT_ENERGY_BALANCE_TOLERANCE
public static final double DEFAULT_ENERGY_BALANCE_TOLERANCEDefault tolerance for energy balance closure (fraction).- See Also:
-
process
-
massBalanceTolerance
private double massBalanceTolerance -
energyBalanceTolerance
private double energyBalanceTolerance -
validated
private boolean validated -
passed
private boolean passed -
issues
-
-
Constructor Details
-
SimulationQualityGate
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
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 severitycategory- check categorymessage- description of the issueremediation- 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
-
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%)
-