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 |
---|---|
VerifyDifferenceThreePeriods | Assert when condition is violated |
Buildings.ThermalZones.ReducedOrder.Validation.VDI6007.BaseClasses.VerifyDifferenceThreePeriods
Assert when condition is violated
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
.
Extends from Buildings.Utilities.Diagnostics.BaseClasses.PartialInputCheck (Assert when condition is violated).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Time | startTime | 0 | Start time for activating the assert [s] |
Real | threShold | 1E-2 | Threshold for equality comparison |
String | message | "Inputs differ by more than ... | |
Time | endTime | 0 | Start time for deactivating the assert (period one) [s] |
Time | startTime2 | 0 | Start time for activating the assert (period two) [s] |
Time | endTime2 | 0 | Start time for deactivating the assert (period two) [s] |
Time | startTime3 | 0 | Start time for activating the assert (period three) [s] |
Time | endTime3 | 0 | Start time for deactivating the assert (period three) [s] |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u1 | Value to check |
input RealInput | u2 | Value to check |
output BooleanOutput | satisfied | |
output RealOutput | diff | Difference u1-u2 |
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.SIunits.Time endTime=0
"Start time for deactivating the assert (period one)";
parameter Modelica.SIunits.Time startTime2=0
"Start time for activating the assert (period two)";
parameter Modelica.SIunits.Time endTime2=0
"Start time for deactivating the assert (period two)";
parameter Modelica.SIunits.Time startTime3=0
"Start time for activating the assert (period three)";
parameter Modelica.SIunits.Time endTime3=0
"Start time for deactivating the assert (period three)";
Modelica.Blocks.Interfaces.BooleanOutput satisfied(start=true, fixed=true);
Modelica.Blocks.Interfaces.RealOutput diff "Difference u1-u2";
protected
parameter Modelica.SIunits.Time t1(fixed=false)
"Simulation end time period one";
parameter Modelica.SIunits.Time t3(fixed=false)
"Simulation end time period two";
parameter Modelica.SIunits.Time t5(fixed=false)
"Simulation end time period three";
parameter Modelica.SIunits.Time t2(fixed=false)
"Simulation start time period two";
parameter Modelica.SIunits.Time t4(fixed=false)
"Simulation start time period three";
Integer nFai "Number of test violations";
initial equation
t1 = time + endTime;
t2 = time + startTime2;
t3 = time + endTime2;
t4 = time + startTime3;
t5 = time + endTime3;
nFai = 0;
equation
if (time >= t0) and (time <= t1) or (time >= t2) and (time <= t3) or (time >=
t4) and (time <= t5) then
diff = abs(u1 - u2);
else
diff = 0;
// Test is not needed in this time domain
end if;
// 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;