Collection of models that validate the logical blocks of the CDL
Information
This package contains models that validate the blocks in
Buildings.Controls.OBC.CDL.Logical.
The examples plot various outputs, which have been verified against
analytical solutions. These model outputs are stored as reference data to
allow continuous validation whenever models in the library change.
Package Content
Name |
Description |
And
|
Validation model for the And block |
And3
|
Validation model for the And3 block |
Change
|
Validation model for the Change block. |
Edge
|
Validation model for the Edge block |
FallingEdge
|
Validation model for the falling edge block |
IntegerSwitch
|
Validation model for the IntegerSwitch block |
Latch
|
Validation model for the Latch block |
LogicalSwitch
|
Validation model for the LogicalSwitch block |
MultiAnd
|
Model to validate the application of MultiAnd block |
MultiOr
|
Model to validate the application of MultiOr block |
Nand
|
Validation model for the Nand block |
Nor
|
Validation model for the Nor block |
Not
|
Validation model for the Not block |
OnOffController
|
Validation model for the OnOffController block |
Or
|
Validation model for the Or block |
Or3
|
Validation model for the Or3 block |
Switch
|
Validation model for the Switch block |
Timer
|
Validation model for the Timer block |
Toggle
|
Validation model for the Toggle block |
TriggeredTrapezoid
|
Validation model for the TriggeredTrapezoid block |
TrueDelay
|
Validation model for the TrueDelay block |
TrueFalseHold
|
Validation model for the TrueFalseHold block |
TrueHoldWithReset
|
Validation model for the TrueHoldWithReset block |
Xor
|
Validation model for the Xor block |
ZeroCrossing
|
Validation model for the zero crossing block |
Validation model for the And block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.And.
Modelica definition
Validation model for the And3 block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.And3.
Modelica definition
Validation model for the Change block.
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Change.
Modelica definition
Validation model for the Edge block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Edge.
Modelica definition
Validation model for the falling edge block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.FallingEdge.
Modelica definition
Validation model for the IntegerSwitch block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.IntegerSwitch.
The input u2
is the switch input: If u2 = true
,
then output y = u1
;
else output y = u3
.
Modelica definition
model IntegerSwitch
Buildings.Controls.OBC.CDL.Logical.IntegerSwitch integerSwitch
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
width=0.7, period=1.5) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul2(
width=0.5, period=3)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul3(
width=0.5, period=5) ;
Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt(k=5) ;
Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt1(k=2) ;
protected
Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToInt
;
Buildings.Controls.OBC.CDL.Integers.Product proInt ;
Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToInt1
;
Buildings.Controls.OBC.CDL.Integers.Product proInt1 ;
equation
connect(booPul2.y,integerSwitch. u2);
connect(booPul1.y, booToInt.u);
connect(booPul3.y, booToInt1.u);
connect(conInt.y, proInt.u1);
connect(booToInt.y, proInt.u2);
connect(conInt1.y, proInt1.u1);
connect(booToInt1.y, proInt1.u2);
connect(proInt.y,integerSwitch. u1);
connect(proInt1.y,integerSwitch. u3);
end IntegerSwitch;
Validation model for the Latch block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Latch.
Modelica definition
model Latch
Buildings.Controls.OBC.CDL.Logical.Latch falCle
;
Buildings.Controls.OBC.CDL.Logical.Latch truCle(pre_y_start=true)
;
Buildings.Controls.OBC.CDL.Logical.Latch iniFalOut
;
Buildings.Controls.OBC.CDL.Logical.Latch iniTruOut(pre_y_start=true)
;
Buildings.Controls.OBC.CDL.Logical.Latch swiCleInp
;
Buildings.Controls.OBC.CDL.Logical.Latch swiCleInp1
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse cleInp(
final width=0.5,
final period=6) ;
Buildings.Controls.OBC.CDL.Logical.Not not1 ;
Buildings.Controls.OBC.CDL.Logical.Sources.Constant fal(
final k=false)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse latInp(
final width=0.5,
final period=2)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Constant tru(
final k=true)
;
equation
connect(cleInp.y, swiCleInp.clr);
connect(not1.u, cleInp.y);
connect(not1.y, swiCleInp1.clr);
connect(fal.y, falCle.clr);
connect(latInp.y, falCle.u);
connect(tru.y, truCle.clr);
connect(latInp.y, truCle.u);
connect(fal.y, iniFalOut.clr);
connect(fal.y,iniTruOut. clr);
connect(latInp.y, iniFalOut.u);
connect(latInp.y,iniTruOut. u);
connect(latInp.y, swiCleInp.u);
connect(latInp.y, swiCleInp1.u);
end Latch;
Validation model for the LogicalSwitch block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.LogicalSwitch.
The input u2
is the switch input: If u2 = true
,
then output y = u1
;
else output y = u3
.
Modelica definition
Model to validate the application of MultiAnd block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.MultiAnd.
The input signals are configured as follows:
- input u1 has a period of 1 s and a width of
0.5 s.
- input u2 has a period of 2 s and a width of
0.5 s.
- input u3 has a period of 3 s and a width of
0.5 s.
- input u4 has a period of 4 s and a width of
0.5 s.
- input u5 has a period of 5 s and a width of
0.5 s.
Modelica definition
model MultiAnd
Buildings.Controls.OBC.CDL.Logical.MultiAnd mulAnd0
;
Buildings.Controls.OBC.CDL.Logical.MultiAnd mulAnd1(nu=1)
;
Buildings.Controls.OBC.CDL.Logical.MultiAnd mulAnd2(nu=2)
;
Buildings.Controls.OBC.CDL.Logical.MultiAnd mulAnd5(nu=5)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
width=0.5, period=1) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul2(
width=0.5, period=2) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul3(
width=0.5, period=3) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul4(
width=0.5, period=4) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul5(
width=0.5, period=5) ;
equation
connect(booPul1.y, mulAnd5.u[1]);
connect(booPul2.y, mulAnd5.u[2]);
connect(booPul3.y, mulAnd5.u[3]);
connect(booPul4.y, mulAnd5.u[4]);
connect(booPul5.y, mulAnd5.u[5]);
connect(booPul1.y, mulAnd2.u[1]);
connect(booPul2.y, mulAnd2.u[2]);
connect(booPul1.y, mulAnd1.u[1]);
end MultiAnd;
Model to validate the application of MultiOr block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.MultiOr.
The input signals are configured as follows:
- input u1 has a period of 1 s and a width of
0.5 s.
- input u2 has a period of 2 s and a width of
0.5 s.
- input u3 has a period of 3 s and a width of
0.5 s.
- input u4 has a period of 4 s and a width of
0.5 s.
- input u5 has a period of 5 s and a width of
0.5 s.
Modelica definition
model MultiOr
Buildings.Controls.OBC.CDL.Logical.MultiOr mulOr0
;
Buildings.Controls.OBC.CDL.Logical.MultiOr mulOr1(nu=1)
;
Buildings.Controls.OBC.CDL.Logical.MultiOr mulOr2(nu=2)
;
Buildings.Controls.OBC.CDL.Logical.MultiOr mulOr5(nu=5)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
width=0.5, period=1) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul2(
width=0.5, period=2) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul3(
width=0.5, period=3) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul4(
width=0.5, period=4) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul5(
width=0.5, period=5) ;
equation
connect(booPul1.y, mulOr5.u[1]);
connect(booPul2.y, mulOr5.u[2]);
connect(booPul3.y, mulOr5.u[3]);
connect(booPul4.y, mulOr5.u[4]);
connect(booPul5.y, mulOr5.u[5]);
connect(booPul1.y, mulOr2.u[1]);
connect(booPul2.y, mulOr2.u[2]);
connect(booPul1.y, mulOr1.u[1]);
end MultiOr;
Validation model for the Nand block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Nand.
Modelica definition
Validation model for the Nor block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Nor.
Modelica definition
Validation model for the Not block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Not.
Modelica definition
Validation model for the OnOffController block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.OnOffController.
Modelica definition
Validation model for the Or block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Or.
Modelica definition
Validation model for the Or3 block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Or3.
Modelica definition
Validation model for the Switch block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Switch.
Modelica definition
Validation model for the Timer block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Timer.
Modelica definition
model Timer
Buildings.Controls.OBC.CDL.Logical.Timer resetTimer ;
Buildings.Controls.OBC.CDL.Logical.Timer accuTimer(
final accumulate=true)
;
Buildings.Controls.OBC.CDL.Logical.Timer accuTimer1(
final accumulate=true)
;
Buildings.Controls.OBC.CDL.Logical.Timer accuTimer2(
final accumulate=true)
;
Buildings.Controls.OBC.CDL.Logical.Timer accuTimer3(
final accumulate=true)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
final width=0.1,
final period=4)
;
Buildings.Controls.OBC.CDL.Continuous.GreaterEqualThreshold greEquThr(
final threshold=1.5) ;
Buildings.Controls.OBC.CDL.Logical.Pre pre
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul(
final width=0.5,
final period=2) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul2(
final width=0.5,
final period=2,
final startTime=0.5) ;
equation
connect(booPul.y, resetTimer.u);
connect(booPul.y, accuTimer.u);
connect(booPul1.y, accuTimer.reset);
connect(booPul.y,accuTimer3. u);
connect(accuTimer3.y, greEquThr.u);
connect(greEquThr.y, pre.u);
connect(pre.y,accuTimer3. reset);
connect(booPul.y, accuTimer1.u);
connect(booPul.y, accuTimer1.reset);
connect(booPul.y, accuTimer2.reset);
connect(booPul2.y, accuTimer2.u);
end Timer;
Validation model for the Toggle block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Toggle.
Modelica definition
model Toggle
Buildings.Controls.OBC.CDL.Logical.Toggle falCle
;
Buildings.Controls.OBC.CDL.Logical.Toggle truCle(pre_y_start=true)
;
Buildings.Controls.OBC.CDL.Logical.Toggle iniFalOut
;
Buildings.Controls.OBC.CDL.Logical.Toggle iniTruOut(pre_y_start=true)
;
Buildings.Controls.OBC.CDL.Logical.Toggle swiCleInp
;
Buildings.Controls.OBC.CDL.Logical.Toggle swiCleInp1
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse cleInp(
final width=0.5,
final period=6)
;
Buildings.Controls.OBC.CDL.Logical.Not not1 ;
Buildings.Controls.OBC.CDL.Logical.Sources.Constant fal(
final k=false)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse togInp(
final width=0.5,
final period=2)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Constant tru(
final k=true)
;
equation
connect(cleInp.y,swiCleInp. clr);
connect(not1.u,cleInp. y);
connect(not1.y,swiCleInp1. clr);
connect(fal.y,falCle. clr);
connect(togInp.y,falCle. u);
connect(tru.y,truCle. clr);
connect(togInp.y,truCle. u);
connect(fal.y,iniFalOut. clr);
connect(fal.y,iniTruOut. clr);
connect(togInp.y,iniFalOut. u);
connect(togInp.y,iniTruOut. u);
connect(togInp.y,swiCleInp. u);
connect(togInp.y,swiCleInp1. u);
end Toggle;
Validation model for the TriggeredTrapezoid block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.TriggeredTrapezoid.
Modelica definition
Validation model for the TrueDelay block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.TrueDelay.
Modelica definition
model TrueDelay
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay0(
final delayTime=0)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay1(
final delayTime=0.5)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay2(
final delayTime=0.8)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay4(
final delayTime=0)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay5(
final delayTime=0.5)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay6(
final delayTime=0.8)
;
Buildings.Controls.OBC.CDL.Logical.Not not1 ;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay3(
final delayTime=1.8)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay7(
final delayTime=1.8)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay00(
final delayTime=0,
final delayOnInit=true)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay11(
final delayTime=0.5,
final delayOnInit=true)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay22(
final delayTime=0.8,
final delayOnInit=true)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay44(
final delayTime=0,
final delayOnInit=true)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay55(
final delayTime=0.5,
final delayOnInit=true)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay66(
final delayTime=0.8,
final delayOnInit=true)
;
Buildings.Controls.OBC.CDL.Logical.Not not2 ;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay33(
final delayTime=1.8,
final delayOnInit=true)
;
Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay77(
final delayTime=1.8,
final delayOnInit=true)
;
protected
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul(
final width=0.5,
final period=1.5) ;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
final width=0.5,
final period=1.5) ;
equation
connect(booPul.y, not1.u);
connect(booPul.y, onDelay0.u);
connect(booPul.y, onDelay2.u);
connect(booPul.y, onDelay1.u);
connect(booPul.y, onDelay3.u);
connect(not1.y, onDelay4.u);
connect(not1.y, onDelay6.u);
connect(not1.y, onDelay5.u);
connect(not1.y, onDelay7.u);
connect(booPul1.y, not2.u);
connect(booPul1.y, onDelay00.u);
connect(booPul1.y, onDelay22.u);
connect(booPul1.y, onDelay11.u);
connect(booPul1.y, onDelay33.u);
connect(not2.y, onDelay44.u);
connect(not2.y, onDelay66.u);
connect(not2.y, onDelay55.u);
connect(not2.y, onDelay77.u);
end TrueDelay;
Validation model for the TrueFalseHold block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold.
The validation uses different instances to validate different hold trueHoldDurations, different lengths
of the input pulse, and different initial values for the input signal.
Modelica definition
model TrueFalseHold
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul(
startTime=0, period=1500) ;
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol(trueHoldDuration=1000)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
startTime=0,
period=1000,
width=0.25) ;
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol1(trueHoldDuration=1000)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul2(
startTime=0, period=1500) ;
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol2(trueHoldDuration=1000)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul3(
startTime=0,
period=1000,
width=0.25) ;
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol3(trueHoldDuration=1000)
;
Buildings.Controls.OBC.CDL.Logical.Not not1
;
Buildings.Controls.OBC.CDL.Logical.Not not3
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul4(
startTime=100, period=1500) ;
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol4(trueHoldDuration=1000)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul5(
startTime=100,
period=1000,
width=0.25) ;
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol5(trueHoldDuration=1000)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul6(
startTime=100, period=1500) ;
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol6(trueHoldDuration=1000)
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul7(
startTime=100,
period=1000,
width=0.25) ;
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol7(trueHoldDuration=1000)
;
Buildings.Controls.OBC.CDL.Logical.Not not2
;
Buildings.Controls.OBC.CDL.Logical.Not not4
;
equation
connect(booPul.y, truFalHol.u);
connect(booPul1.y, truFalHol1.u);
connect(booPul2.y, not1.u);
connect(not1.y, truFalHol2.u);
connect(booPul3.y, not3.u);
connect(not3.y, truFalHol3.u);
connect(booPul4.y, truFalHol4.u);
connect(booPul5.y, truFalHol5.u);
connect(booPul6.y, not2.u);
connect(not2.y, truFalHol6.u);
connect(booPul7.y, not4.u);
connect(not4.y, truFalHol7.u);
end TrueFalseHold;
Validation model for the TrueHoldWithReset block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.TrueHoldWithReset.
The validation uses different instances to validate different hold durations, different lengths
of the input pulse, and different initial values for the input signal.
Modelica definition
Validation model for the Xor block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.Xor.
Modelica definition
Validation model for the zero crossing block
Information
Validation test for the block
Buildings.Controls.OBC.CDL.Logical.ZeroCrossing.
Modelica definition
model ZeroCrossing
Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp ramp1(
duration=5,
offset=0,
height=31.415926) ;
Buildings.Controls.OBC.CDL.Continuous.Sin sin1
;
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
width=0.15,
period=5) ;
Buildings.Controls.OBC.CDL.Logical.ZeroCrossing zeroCrossing
;
Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp ramp2(
duration=5,
offset=0,
height=31.415926) ;
Controls.OBC.CDL.Discrete.TriggeredSampler triggeredSampler ;
equation
connect(booPul1.y, zeroCrossing.enable);
connect(ramp1.y, sin1.u);
connect(sin1.y, zeroCrossing.u);
connect(ramp2.y, triggeredSampler.u);
connect(zeroCrossing.y, triggeredSampler.trigger);
end ZeroCrossing;