Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f5fdf9
commit 7aeaf08
Showing
25 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
openmodelica/requirements/TwoTanksExample/Design/Components/BaseController.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
within TwoTanksExample.Design.Components; | ||
|
||
partial model BaseController | ||
parameter Real K= 2; | ||
parameter Real T= 10; | ||
input Real ref= 0.25; | ||
Real error; | ||
Real outCtr; | ||
TwoTanksExample.Design.Interfaces.ReadSignalIn cIn annotation( | ||
Placement(visible = true, transformation(origin = {-78, 4}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-78, 4}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
Interfaces.ActSignalOut cOut annotation( | ||
Placement(visible = true, transformation(origin = {82, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {82, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
equation | ||
error = ref - cIn; | ||
cOut = outCtr; | ||
annotation( | ||
Diagram, | ||
Icon(graphics = {Rectangle(origin = {2, 10}, extent = {{-70, 52}, {70, -52}}), Line(origin = {3.51258, 14.8423}, points = {{-59.5126, -32.8423}, {-37.5126, 9.15768}, {14.4874, -36.8423}, {54.4874, 33.1577}, {62.4874, 15.1577}, {62.4874, 17.1577}, {62.4874, 17.1577}, {60.4874, 19.1577}})}));end BaseController; |
10 changes: 10 additions & 0 deletions
10
openmodelica/requirements/TwoTanksExample/Design/Components/PIContinuousController.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
within TwoTanksExample.Design.Components; | ||
|
||
model PIContinuousController | ||
extends TwoTanksExample.Design.Components.BaseController ; | ||
Real x; | ||
equation | ||
der(x) = error/T; | ||
outCtr = K*(error + x); | ||
|
||
end PIContinuousController; |
14 changes: 14 additions & 0 deletions
14
openmodelica/requirements/TwoTanksExample/Design/Components/Source.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
within TwoTanksExample.Design.Components; | ||
|
||
model Source | ||
|
||
input Real flowLevel= 0; | ||
TwoTanksExample.Design.Interfaces.LiquidFlowOut qOut annotation( | ||
Placement(visible = true, transformation(origin = {74, 12}, extent = {{-24, -24}, {24, 24}}, rotation = 0), iconTransformation(origin = {74, 12}, extent = {{-24, -24}, {24, 24}}, rotation = 0))); | ||
equation | ||
|
||
qOut = flowLevel; | ||
|
||
annotation( | ||
Diagram, | ||
Icon(graphics = {Ellipse(origin = {-14, 10}, fillColor = {82, 235, 205}, fillPattern = FillPattern.Sphere, extent = {{-64, 62}, {64, -62}}, endAngle = 360)}));end Source; |
33 changes: 33 additions & 0 deletions
33
openmodelica/requirements/TwoTanksExample/Design/Components/Tank.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
within TwoTanksExample.Design.Components; | ||
|
||
model Tank | ||
|
||
parameter Real flowGain= 0.05; | ||
parameter Real minV= 0; | ||
parameter Real maxV= 10; | ||
parameter Real area= 1; | ||
parameter Real height= 2; | ||
|
||
|
||
TwoTanksExample.Design.Interfaces.LiquidFlowIn qIn annotation( | ||
Placement(visible = true, transformation(origin = {-64, 20}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {-64, 20}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); | ||
TwoTanksExample.Design.Interfaces.LiquidFlowOut qOut annotation( | ||
Placement(visible = true, transformation(origin = {72, 18}, extent = {{-16, -16}, {16, 16}}, rotation = 0), iconTransformation(origin = {72, 18}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); | ||
TwoTanksExample.Design.Interfaces.ReadSignalOut tSensor annotation( | ||
Placement(visible = true, transformation(origin = {72, -36}, extent = {{-16, -16}, {16, 16}}, rotation = 0), iconTransformation(origin = {72, -36}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); | ||
TwoTanksExample.Design.Interfaces.ActSignalIn tActuator annotation( | ||
Placement(visible = true, transformation(origin = {-64, -36}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {-64, -36}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); | ||
|
||
public Real volume= area * height; | ||
public Real levelOfLiquid; | ||
|
||
equation | ||
// Mass balance equation | ||
der(levelOfLiquid) = (qIn - qOut)/area; qOut = | ||
TwoTanksExample.Design.Components.limitValue(minV, maxV, -flowGain*tActuator); | ||
|
||
tSensor = levelOfLiquid; | ||
|
||
annotation( | ||
Icon(graphics = {Rectangle(origin = {5, 36}, extent = {{-51, 16}, {51, -16}}), Rectangle(origin = {5, 4}, fillColor = {82, 235, 205}, fillPattern = FillPattern.VerticalCylinder, extent = {{-51, 16}, {51, -70}})})); | ||
end Tank; |
9 changes: 9 additions & 0 deletions
9
openmodelica/requirements/TwoTanksExample/Design/Components/limitValue.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
within TwoTanksExample.Design.Components; | ||
|
||
function limitValue | ||
input Real pMin; input Real pMax; | ||
input Real p; output Real pLim; protected | ||
algorithm | ||
pLim := if p>pMax then pMax | ||
else if p<pMin then pMin else p; | ||
end limitValue; |
5 changes: 5 additions & 0 deletions
5
openmodelica/requirements/TwoTanksExample/Design/Components/package.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
within TwoTanksExample.Design; | ||
|
||
package Components | ||
|
||
end Components; |
17 changes: 17 additions & 0 deletions
17
openmodelica/requirements/TwoTanksExample/Design/Interfaces/package.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
within TwoTanksExample.Design; | ||
|
||
package Interfaces | ||
|
||
connector ActSignalIn = Modelica.Blocks.Interfaces.RealInput; | ||
|
||
connector ActSignalOut = Modelica.Blocks.Interfaces.RealOutput; | ||
|
||
connector LiquidFlowIn = Modelica.Blocks.Interfaces.RealInput; | ||
|
||
connector LiquidFlowOut = Modelica.Blocks.Interfaces.RealOutput; | ||
|
||
connector ReadSignalIn = Modelica.Blocks.Interfaces.RealInput; | ||
|
||
connector ReadSignalOut = Modelica.Blocks.Interfaces.RealOutput; | ||
|
||
end Interfaces; |
31 changes: 31 additions & 0 deletions
31
openmodelica/requirements/TwoTanksExample/Design/TwoTanksDesign.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
within TwoTanksExample.Design; | ||
|
||
model TwoTanksDesign | ||
extends VVDRlib.Verification.Design; | ||
public TwoTanksExample.Design.Components.Tank tank1 annotation( | ||
Placement(visible = true, transformation(origin = {-25, 21}, extent = {{-29, -29}, {29, 29}}, rotation = 0))); | ||
public TwoTanksExample.Design.Components.Tank tank2 annotation( | ||
Placement(visible = true, transformation(origin = {47, 21}, extent = {{-29, -29}, {29, 29}}, rotation = 0))); | ||
TwoTanksExample.Design.Components.PIContinuousController pIContinuousController1 annotation( | ||
Placement(visible = true, transformation(origin = {-24, -50}, extent = {{22, -22}, {-22, 22}}, rotation = 0))); | ||
TwoTanksExample.Design.Components.PIContinuousController pIContinuousController2 annotation( | ||
Placement(visible = true, transformation(origin = {49, -51}, extent = {{25, -25}, {-25, 25}}, rotation = 0))); | ||
public TwoTanksExample.Design.Components.Source source annotation( | ||
Placement(visible = true, transformation(origin = {-88, 18}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
equation | ||
connect(pIContinuousController1.cOut, tank1.tActuator) annotation( | ||
Line(points = {{-42, -48}, {-56, -48}, {-56, 12}, {-44, 12}, {-44, 10}}, color = {0, 0, 127})); | ||
connect(tank1.tSensor, pIContinuousController1.cIn) annotation( | ||
Line(points = {{-4, 10}, {2, 10}, {2, -48}, {-6, -48}, {-6, -50}})); | ||
connect(pIContinuousController2.cOut, tank2.tActuator) annotation( | ||
Line(points = {{28, -48}, {20, -48}, {20, 10}, {28, 10}, {28, 10}}, color = {0, 0, 127})); | ||
connect(tank2.tSensor, pIContinuousController2.cIn) annotation( | ||
Line(points = {{68, 10}, {78, 10}, {78, -50}, {68, -50}, {68, -50}})); | ||
connect(tank1.qOut, tank2.qIn) annotation( | ||
Line(points = {{-4, 26}, {30, 26}, {30, 26}, {28, 26}})); | ||
connect(source.qOut, tank1.qIn) annotation( | ||
Line(points = {{-80, 20}, {-60, 20}, {-60, 28}, {-44, 28}, {-44, 26}}, color = {0, 0, 127})); | ||
|
||
|
||
|
||
end TwoTanksDesign; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
within TwoTanksExample; | ||
|
||
package Design | ||
|
||
end Design; |
7 changes: 7 additions & 0 deletions
7
openmodelica/requirements/TwoTanksExample/Mediators/package.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
within TwoTanksExample; | ||
|
||
package Mediators | ||
|
||
import VVDRlib.Bindings.Mediator; | ||
|
||
end Mediators; |
10 changes: 10 additions & 0 deletions
10
openmodelica/requirements/TwoTanksExample/Mediators/sourceFlowLevel.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
within TwoTanksExample.Mediators; | ||
|
||
record sourceFlowLevel | ||
extends Mediator(mType = "Real", | ||
clients = {Client(modelID = "TwoTanksExample.Design.Components.Source", component = "flowLevel")}, | ||
providers = {Provider(modelID = "TwoTanksExample.Scenarios.Normal_operation", | ||
template = "%getPath.flowLevel"), | ||
Provider(modelID = "TwoTanksExample.Scenarios.Overflow", | ||
template = "%getPath.flowLevel")}); | ||
end sourceFlowLevel; |
8 changes: 8 additions & 0 deletions
8
openmodelica/requirements/TwoTanksExample/Mediators/tankWaterLevel.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
within TwoTanksExample.Mediators; | ||
|
||
record tankWaterLevel | ||
extends Mediator(mType = "Real", | ||
clients = {Client(modelID = "TwoTanksExample.Requirements.LiquidLevel", component = "waterLevel")}, | ||
providers = {Provider(modelID = "TwoTanksExample.Design.Components.Tank", | ||
template = "%getPath.levelOfLiquid")}); | ||
end tankWaterLevel; |
8 changes: 8 additions & 0 deletions
8
openmodelica/requirements/TwoTanksExample/Mediators/volumeLevel.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
within TwoTanksExample.Mediators; | ||
|
||
record volumeLevel | ||
extends Mediator(mType = "Real", | ||
clients = {Client(modelID = "TwoTanksExample.Requirements.Volume_of_a_tank", component = "tankVolume")}, | ||
providers = {Provider(modelID = "TwoTanksExample.Design.Components.Tank", | ||
template = "%getPath.volume")}); | ||
end volumeLevel; |
9 changes: 9 additions & 0 deletions
9
openmodelica/requirements/TwoTanksExample/Requirements/LiquidLevel.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
within TwoTanksExample.Requirements; | ||
|
||
model LiquidLevel | ||
extends VVDRlib.Verification.Requirement; | ||
input Real waterLevel; | ||
equation | ||
status = if (waterLevel < 8) then | ||
VVDRlib.ReqStatus.NOT_VIOLATED else VVDRlib.ReqStatus.VIOLATED; | ||
end LiquidLevel; |
10 changes: 10 additions & 0 deletions
10
openmodelica/requirements/TwoTanksExample/Requirements/Volume_of_a_tank.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
within TwoTanksExample.Requirements; | ||
|
||
model Volume_of_a_tank "The volume of each tank shall be at least 2 m3. " | ||
extends VVDRlib.Verification.Requirement; | ||
input Real tankVolume; | ||
parameter Modelica.SIunits.Volume requiredVolume = 2; | ||
equation | ||
status = if tankVolume < requiredVolume | ||
then VVDRlib.ReqStatus.VIOLATED else VVDRlib.ReqStatus.NOT_VIOLATED; | ||
end Volume_of_a_tank; |
5 changes: 5 additions & 0 deletions
5
openmodelica/requirements/TwoTanksExample/Requirements/package.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
within TwoTanksExample; | ||
|
||
package Requirements | ||
|
||
end Requirements; |
7 changes: 7 additions & 0 deletions
7
openmodelica/requirements/TwoTanksExample/Scenarios/Normal_operation.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
within TwoTanksExample.Scenarios; | ||
model Normal_operation | ||
extends VVDRlib.Verification.Scenario; | ||
|
||
output Real flowLevel = 0.5; | ||
|
||
end Normal_operation; |
11 changes: 11 additions & 0 deletions
11
openmodelica/requirements/TwoTanksExample/Scenarios/Overflow.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
within TwoTanksExample.Scenarios; | ||
model Overflow | ||
extends VVDRlib.Verification.Scenario; | ||
output Real flowLevel(start = 0.5); | ||
|
||
equation | ||
when time > 5 then | ||
flowLevel = 1.5; | ||
end when; | ||
|
||
end Overflow ; |
5 changes: 5 additions & 0 deletions
5
openmodelica/requirements/TwoTanksExample/Scenarios/package.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
within TwoTanksExample; | ||
|
||
package Scenarios | ||
|
||
end Scenarios; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// script to test updating of bindings for a specific scenario | ||
|
||
loadFile("../package.mo"); | ||
getErrorString(); | ||
inferBindings(TwoTanksExample.UserDefinedVerificationModels.UDVModel1); | ||
getErrorString(); | ||
list(test.TestModel); | ||
getErrorString(); |
8 changes: 8 additions & 0 deletions
8
openmodelica/requirements/TwoTanksExample/Scripts/runScenarios.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// script to test updating of bindings for a specific scenario | ||
|
||
loadFile("../package.mo"); | ||
getErrorString(); | ||
generateVerificationScenarios(TwoTanksExample.VerificationModels); | ||
getErrorString(); | ||
list(TwoTanksExample.VerificationModels); | ||
getErrorString(); |
12 changes: 12 additions & 0 deletions
12
openmodelica/requirements/TwoTanksExample/UserDefinedVerificationModels/UDVModel1.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
within TwoTanksExample.UserDefinedVerificationModels; | ||
|
||
model UDVModel1 | ||
TwoTanksExample.Design.TwoTanksDesign twoTanksDesign1 annotation( | ||
Placement(visible = true, transformation(origin = {42, -28}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
TwoTanksExample.Requirements.Volume_of_a_tank volume_of_a_tank1 annotation( | ||
Placement(visible = true, transformation(origin = {-60, 34}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
TwoTanksExample.Requirements.LiquidLevel liquidLevel1 annotation( | ||
Placement(visible = true, transformation(origin = {-60, -26}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
TwoTanksExample.Scenarios.Overflow overflow1 annotation( | ||
Placement(visible = true, transformation(origin = {42, 28}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
end UDVModel1; |
5 changes: 5 additions & 0 deletions
5
openmodelica/requirements/TwoTanksExample/UserDefinedVerificationModels/package.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
within TwoTanksExample; | ||
|
||
package UserDefinedVerificationModels | ||
|
||
end UserDefinedVerificationModels; |
7 changes: 7 additions & 0 deletions
7
openmodelica/requirements/TwoTanksExample/VerificationModels/package.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
within TwoTanksExample; | ||
|
||
package VerificationModels | ||
|
||
|
||
|
||
end VerificationModels; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
within ; | ||
|
||
package TwoTanksExample | ||
end TwoTanksExample; |