Buildings.ThermalZones.ReducedOrder.Validation.VDI6007.BaseClasses

Base classes for VDI 6007 validation cases

Information

This package contains base classes that are used to construct the models in Buildings.ThermalZones.ReducedOrder.Validation.VDI6007.

Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).

Package Content

Name Description
Buildings.ThermalZones.ReducedOrder.Validation.VDI6007.BaseClasses.VerifyDifferenceThreePeriods VerifyDifferenceThreePeriods Assert when condition is violated

Buildings.ThermalZones.ReducedOrder.Validation.VDI6007.BaseClasses.VerifyDifferenceThreePeriods Buildings.ThermalZones.ReducedOrder.Validation.VDI6007.BaseClasses.VerifyDifferenceThreePeriods

Assert when condition is violated

Buildings.ThermalZones.ReducedOrder.Validation.VDI6007.BaseClasses.VerifyDifferenceThreePeriods

Information

Block that outputs satisfied = false if abs(u1-u2) > threShold within the prescribed time intervals, or satisfied = true otherwise.

Implementation

The test uses a hysteresis of plus/minus 1% in order to avoid chattering if abs(u1-u2) is near threShold.

The difference abs(u1-u2) is filtered with a first order filter with time constant tau. This guards against rounding errors in event handling by upstream signal-generating blocks.

Extends from Buildings.Utilities.Diagnostics.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 ... 
TimeendTime0Start time for deactivating the assert (period one) [s]
TimestartTime20Start time for activating the assert (period two) [s]
TimeendTime20Start time for deactivating the assert (period two) [s]
TimestartTime30Start time for activating the assert (period three) [s]
TimeendTime30Start time for deactivating the assert (period three) [s]
Timetau60Time constant for filtering signal [s]

Connectors

TypeNameDescription
input RealInputu1Value to check
input RealInputu2Value to check
output BooleanOutputsatisfied 
output RealOutputdiffDifference abs(u1-u2) after filtering

Modelica definition

block VerifyDifferenceThreePeriods "Assert when condition is violated" extends Buildings.Utilities.Diagnostics.BaseClasses.PartialInputCheck( message="Inputs differ by more than threShold.\n Check output 'satisfied' for when violation(s) happened."); parameter Modelica.Units.SI.Time endTime=0 "Start time for deactivating the assert (period one)"; parameter Modelica.Units.SI.Time startTime2=0 "Start time for activating the assert (period two)"; parameter Modelica.Units.SI.Time endTime2=0 "Start time for deactivating the assert (period two)"; parameter Modelica.Units.SI.Time startTime3=0 "Start time for activating the assert (period three)"; parameter Modelica.Units.SI.Time endTime3=0 "Start time for deactivating the assert (period three)"; parameter Modelica.Units.SI.Time tau(min=1) = 60 "Time constant for filtering signal"; Modelica.Blocks.Interfaces.BooleanOutput satisfied(start=true, fixed=true); Modelica.Blocks.Interfaces.RealOutput diff "Difference abs(u1-u2) after filtering"; protected parameter Modelica.Units.SI.Time t1(fixed=false) "Simulation end time period one"; parameter Modelica.Units.SI.Time t3(fixed=false) "Simulation end time period two"; parameter Modelica.Units.SI.Time t5(fixed=false) "Simulation end time period three"; parameter Modelica.Units.SI.Time t2(fixed=false) "Simulation start time period two"; parameter Modelica.Units.SI.Time t4(fixed=false) "Simulation start time period three"; Integer nFai "Number of test violations"; Real diffExa "Exact, non-filtered value of the difference between the inputs"; initial equation t1 = time + endTime; t2 = time + startTime2; t3 = time + endTime2; t4 = time + startTime3; t5 = time + endTime3; nFai = 0; diff = if (time >= t0) and (time < t1) or (time >= t2) and (time < t3) or (time >= t4) and (time < t5) then abs(u1 - u2) else 0; equation if (time >= t0) and (time < t1) or (time >= t2) and (time < t3) or (time >= t4) and (time < t5) then diffExa = abs(u1 - u2); else diffExa = 0; // Test is not needed in this time domain end if; der(diff) = (diffExa-diff)/tau; // Output whether test is satisfied, using a small hysteresis that is scaled using threShold satisfied = not ( (pre(satisfied) and diff > 1.01*threShold) or (not pre(satisfied) and diff >= 0.99*threShold)); // Count the number of failures and raise an assertion in the terminal section. // This ensures that if the model is in an FMU, no asserts are triggered during // the solver iterations. when not satisfied then nFai = pre(nFai) + 1; end when; when terminal() then assert(nFai == 0, message); end when; end VerifyDifferenceThreePeriods;