Buildings.Utilities.Diagnostics

Library with models to diagnose model errors

Information

This package contains component models for run-time diagnostics. The models in this package can be used to stop a simulation if a test is violated.

Extends from Modelica.Icons.VariantsPackage (Icon for package containing variants).

Package Content

Name Description
Buildings.Utilities.Diagnostics.AssertEquality AssertEquality Assert when condition is violated
Buildings.Utilities.Diagnostics.AssertInequality AssertInequality Assert when condition is violated
Buildings.Utilities.Diagnostics.CheckEquality CheckEquality Check equality between inputs up to a threshold
Buildings.Utilities.Diagnostics.Validation Validation Collection of models that validate the diagnostics models
Buildings.Utilities.Diagnostics.BaseClasses BaseClasses Package with base classes for Buildings.Utilities.Diagnostics

Buildings.Utilities.Diagnostics.AssertEquality Buildings.Utilities.Diagnostics.AssertEquality

Assert when condition is violated

Buildings.Utilities.Diagnostics.AssertEquality

Information

Model that triggers an assert if |u1-u2| > threShold and t > t0.

Extends from BaseClasses.PartialInputCheck (Assert when condition is violated).

Parameters

TypeNameDefaultDescription
TimestartTime0Start time for activating the assert [s]
RealthreShold1E-2Threshold for equality comparison
Stringmessage"Inputs differ by more than ... 

Connectors

TypeNameDescription
input RealInputu1Value to check
input RealInputu2Value to check

Modelica definition

block AssertEquality "Assert when condition is violated" extends BaseClasses.PartialInputCheck(message="Inputs differ by more than threShold"); equation if noEvent(time > t0) then assert(noEvent(abs(u1 - u2) < threShold), message + "\n" + " time = " + String(time) + "\n" + " u1 = " + String(u1) + "\n" + " u2 = " + String(u2) + "\n" + " abs(u1-u2) = " + String(abs(u1 - u2)) + "\n" + " threShold = " + String(threShold)); end if; end AssertEquality;

Buildings.Utilities.Diagnostics.AssertInequality Buildings.Utilities.Diagnostics.AssertInequality

Assert when condition is violated

Buildings.Utilities.Diagnostics.AssertInequality

Information

Model that triggers an assert if u1 > u2 - threShold and t > t0.

Extends from BaseClasses.PartialInputCheck (Assert when condition is violated).

Parameters

TypeNameDefaultDescription
TimestartTime0Start time for activating the assert [s]
RealthreShold0Threshold for equality comparison
Stringmessage"Inputs differ by more than ... 

Connectors

TypeNameDescription
input RealInputu1Value to check
input RealInputu2Value to check

Modelica definition

block AssertInequality "Assert when condition is violated" extends BaseClasses.PartialInputCheck(message="Inputs differ by more than threShold", threShold=0); equation if noEvent(time > t0) then assert(noEvent(u1 > u2 - threShold), message + "\n" + " time = " + String(time) + "\n" + " u1 = " + String(u1) + "\n" + " u2 = " + String(u2) + "\n" + " abs(u1-u2) = " + String(abs(u1 - u2)) + "\n" + " threShold = " + String(threShold)); end if; end AssertInequality;

Buildings.Utilities.Diagnostics.CheckEquality Buildings.Utilities.Diagnostics.CheckEquality

Check equality between inputs up to a threshold

Buildings.Utilities.Diagnostics.CheckEquality

Information

Block that outputs 0 if the difference |u1-u2| < threShold, or else it outputs u2-u1.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
RealthreShold1e-2Threshold for equality comparison

Connectors

TypeNameDescription
input RealInputu1Value to check
input RealInputu2Value to check
output RealOutputyError

Modelica definition

block CheckEquality "Check equality between inputs up to a threshold" extends Modelica.Blocks.Icons.Block; parameter Real threShold(min=0) = 1e-2 "Threshold for equality comparison"; Modelica.Blocks.Interfaces.RealInput u1 "Value to check"; Modelica.Blocks.Interfaces.RealInput u2 "Value to check"; Modelica.Blocks.Interfaces.RealOutput y "Error"; equation y = noEvent(if abs(u2 - u1) < threShold then 0 else u2 - u1); end CheckEquality;