From d11d7493032471dd355db636516085a36053171d Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Tue, 24 May 2022 16:26:09 -0700 Subject: [PATCH 1/3] Updated test for BOM (#3029) * Updated test for BOM This is for #3028 --- .github/workflows/formatting.yml | 10 +++++++--- .../ControllerChillerDXHeatingEconomizer.mos | 2 +- .../Dymola/Airflow/Multizone/Examples/TrickleVent.mos | 2 +- .../GroundTemperature/Examples/CorrectedConvection.mos | 2 +- .../GroundTemperature/Examples/CorrectedNFactors.mos | 2 +- .../Examples/UndisturbedSoilTemperature.mos | 2 +- .../AHUs/SingleZone/VAV/Validation/Controller.mos | 2 +- .../AHUs/SingleZone/VAV/Validation/CoolingCoil.mos | 2 +- .../AHUs/SingleZone/VAV/Validation/ZoneState.mos | 2 +- .../Validation/OptimalStartNoHeatingNoCooling.mos | 2 +- .../Examples/VAVReheat/Validation/TraceSubstance.mos | 2 +- .../Fluid/FixedResistances/Examples/PlugFlowPipe.mos | 2 +- .../BuriedPipes/Examples/DiscretizedBuriedPipe.mos | 2 +- .../BuriedPipes/Examples/SingleBuriedPipe.mos | 2 +- .../Geothermal/BuriedPipes/Examples/TwoBuriedPipes.mos | 2 +- .../Functions/Validation/EquivalentHeatCapacity.mos | 2 +- .../CoolingTowers/Examples/FixedApproachDryBulb.mos | 2 +- .../CoolingTowers/Validation/MerkelEnergyPlus.mos | 2 +- .../Validation/WetCoilEffectivenessNTU.mos | 2 +- .../Validation/WetCoilEffectivenessNTUCounterFlow.mos | 2 +- .../Validation/WetCoilEffectivenessNTUHeating.mos | 2 +- .../Dymola/Fluid/Sources/Examples/Outside_CpData.mos | 2 +- .../Fluid/Sources/Examples/Outside_CpData_Angles.mos | 2 +- .../Dymola/Media/Examples/SteamDerivativeCheck.mos | 2 +- .../Scripts/Dymola/Media/Examples/SteamProperties.mos | 2 +- .../Media/Examples/SteamSaturationConsistencyCheck.mos | 2 +- .../Examples/SteamTemperatureEnthalpyInversion.mos | 2 +- .../Examples/VAVReheat/Validation/VAVBranch.mos | 2 +- .../IO/SignalExchange/Examples/FirstOrder.mos | 2 +- 29 files changed, 35 insertions(+), 31 deletions(-) diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index f27461991b6..4936af0b8de 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -42,6 +42,13 @@ jobs: - name: "Install BuildingsPy" run: pip3 install git+https://github.com/lbl-srg/BuildingsPy@v4.0.0 + - name: Check for UTF-8 BOM + run : | + for ff in `grep -rlI --exclude="ffd.vcxproj" --exclude-dir="\.git" $'^\xEF\xBB\xBF' .`; do + echo "::error file=${ff}:: Found BOM in ${ff}." + done; + test -z "${ff}" + - name: "Test html syntax" run : ../bin/runUnitTests.py --validate-html-only @@ -75,9 +82,6 @@ jobs: python Buildings/Resources/src/Controls/OBC/UnitConversions/unit_converters.py git diff --exit-code Buildings - - name: Check for UTF-8 BOM - run: "! find . -name '*.mo' -print0 | xargs -0 grep -l $'^\\xEF\\xBB\\xBF' | grep ." - - name: Check for file permissions run : | set -o noglob diff --git a/Buildings/Resources/Scripts/Dymola/Air/Systems/SingleZone/VAV/BaseClasses/Validation/ControllerChillerDXHeatingEconomizer.mos b/Buildings/Resources/Scripts/Dymola/Air/Systems/SingleZone/VAV/BaseClasses/Validation/ControllerChillerDXHeatingEconomizer.mos index 58c1813444a..c18095e6333 100644 --- a/Buildings/Resources/Scripts/Dymola/Air/Systems/SingleZone/VAV/BaseClasses/Validation/ControllerChillerDXHeatingEconomizer.mos +++ b/Buildings/Resources/Scripts/Dymola/Air/Systems/SingleZone/VAV/BaseClasses/Validation/ControllerChillerDXHeatingEconomizer.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Air.Systems.SingleZone.VAV.BaseClasses.Validation.ControllerChillerDXHeatingEconomizer", stopTime=172800, tolerance=1e-06, resultFile="ControllerChillerDXHeatingEconomizer"); +simulateModel("Buildings.Air.Systems.SingleZone.VAV.BaseClasses.Validation.ControllerChillerDXHeatingEconomizer", stopTime=172800, tolerance=1e-06, resultFile="ControllerChillerDXHeatingEconomizer"); createPlot(id=1, position={0, 0, 1316, 720}, y={"con.TSetRooCoo", "con.TSetRooHea", "con.TRoo"}, range={0.0, 175000.0, 10.0, 35.0}, grid=true, colors={{28,108,200}, {238,46,47}, {0,140,72}}, displayUnits={"degC", "degC", "degC"}); createPlot(id=1, position={0, 0, 1316, 720}, y={"con.yFan", "con.yHea", "con.yCooCoiVal"}, range={0.0, 175000.0, -0.5, 1.5}, grid=true, subPlot=102, colors={{28,108,200}, {238,46,47}, {0,140,72}}, displayUnits={"1", "1", "1"}); createPlot(id=1, position={0, 0, 1316, 720}, y={"con.TSup", "con.TSetSupAir"}, range={0.0, 175000.0, 5.0, 25.0}, grid=true, subPlot=103, colors={{28,108,200}, {238,46,47}}, displayUnits={"degC", "degC"}); diff --git a/Buildings/Resources/Scripts/Dymola/Airflow/Multizone/Examples/TrickleVent.mos b/Buildings/Resources/Scripts/Dymola/Airflow/Multizone/Examples/TrickleVent.mos index 529f9f58b7e..e596bb128b6 100644 --- a/Buildings/Resources/Scripts/Dymola/Airflow/Multizone/Examples/TrickleVent.mos +++ b/Buildings/Resources/Scripts/Dymola/Airflow/Multizone/Examples/TrickleVent.mos @@ -1,3 +1,3 @@ -simulateModel("Buildings.Airflow.Multizone.Examples.TrickleVent", stopTime=2592000, numberOfIntervals=0, outputInterval=600, tolerance=1e-06, resultFile="TrickleVent"); +simulateModel("Buildings.Airflow.Multizone.Examples.TrickleVent", stopTime=2592000, numberOfIntervals=0, outputInterval=600, tolerance=1e-06, resultFile="TrickleVent"); createPlot(id=1, position={55, 55, 584, 361}, y={"tabDat_m_flow.m_flow", "tabDat_V_flow.V_flow"}, range={0.0, 2600000.0, -0.08, 0.039999999999999994}, grid=true, filename="TrickleVent.mat", colors={{28,108,200}, {0,0,0}}, displayUnits={"kg/s", "m3/s"}); createPlot(id=1, position={55, 55, 584, 361}, x="tabDat_m_flow.dp", y={"tabDat_V_flow.V_flow", "tabDat_m_flow.m_flow"}, range={-35.0, 45.0, -0.08, 0.039999999999999994}, grid=true, subPlot=102, colors={{238,46,47}, {28,108,200}}, patterns={LinePattern.None, LinePattern.None}, markers={MarkerStyle.Cross, MarkerStyle.Cross}, timeUnit="Pa", displayUnits={"m3/s", "kg/s"}); diff --git a/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/CorrectedConvection.mos b/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/CorrectedConvection.mos index ac8644d0b97..188909aa48e 100644 --- a/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/CorrectedConvection.mos +++ b/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/CorrectedConvection.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.BoundaryConditions.GroundTemperature.Examples.CorrectedConvection", tolerance=1e-6, stopTime=31536000, method="Cvode", resultFile="CorrectedConvection"); +simulateModel("Buildings.BoundaryConditions.GroundTemperature.Examples.CorrectedConvection", tolerance=1e-6, stopTime=31536000, method="Cvode", resultFile="CorrectedConvection"); createPlot(id=1, position={16, 11, 592, 372}, y={"TSoi[1].T", "TSoi[2].T", "TSoi[3].T", "TSoi[4].T"}, diff --git a/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/CorrectedNFactors.mos b/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/CorrectedNFactors.mos index f7969a92fa2..c1ca31d9e80 100644 --- a/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/CorrectedNFactors.mos +++ b/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/CorrectedNFactors.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.BoundaryConditions.GroundTemperature.Examples.CorrectedNFactors", tolerance=1e-6, stopTime=31536000, method="Cvode", resultFile="CorrectedNFactors"); +simulateModel("Buildings.BoundaryConditions.GroundTemperature.Examples.CorrectedNFactors", tolerance=1e-6, stopTime=31536000, method="Cvode", resultFile="CorrectedNFactors"); createPlot(id=1, position={16, 11, 592, 372}, y={"TSoi[1].T", "TSoi[2].T", "TSoi[3].T", "TSoi[4].T"}, diff --git a/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/UndisturbedSoilTemperature.mos b/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/UndisturbedSoilTemperature.mos index 0f2cb1bb4c6..688af4de632 100644 --- a/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/UndisturbedSoilTemperature.mos +++ b/Buildings/Resources/Scripts/Dymola/BoundaryConditions/GroundTemperature/Examples/UndisturbedSoilTemperature.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.BoundaryConditions.GroundTemperature.Examples.UndisturbedSoilTemperature", tolerance=1e-6, stopTime=31536000, method="Cvode", resultFile="UndisturbedSoilTemperature"); +simulateModel("Buildings.BoundaryConditions.GroundTemperature.Examples.UndisturbedSoilTemperature", tolerance=1e-6, stopTime=31536000, method="Cvode", resultFile="UndisturbedSoilTemperature"); createPlot(id=1, position={16, 11, 592, 372}, y={"TSoi[1].T", "TSoi[2].T", "TSoi[3].T", "TSoi[4].T"}, diff --git a/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/Controller.mos b/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/Controller.mos index 2a0b2bb4ddf..fa070fb2180 100644 --- a/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/Controller.mos +++ b/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/Controller.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation.Controller", method="Cvode", outputInterval=300, stopTime=86400, tolerance=1e-06, resultFile="conVAV"); +simulateModel("Buildings.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation.Controller", method="Cvode", outputInterval=300, stopTime=86400, tolerance=1e-06, resultFile="conVAV"); createPlot(id=1, position={35, 30, 592, 427}, y={"conVAV.TSup", "conVAV.setPoiVAV.TSupHeaEco", "conVAV.setPoiVAV.TSupCoo"}, range={0.0, 90000.0, 0.0, 40.0}, grid=true, colors={{0,140,72}, {162,29,33}, {244,125,35}}, displayUnits={"degC", "degC", "degC"}); createPlot(id=1, position={35, 30, 592, 104}, y={"conVAV.yRetDamPos", "conVAV.yOutDamPos", "conVAV.yFan","conVAV.yHeaCoi"}, range={0.0, 90000.0, -2.0, 2.0}, grid=true, subPlot=2, colors={{28,108,200}, {238,46,47}, {0,140,72}, {217,67,180}}); createPlot(id=1, position={35, 30, 592, 103}, y={"conVAV.uOcc"}, range={0.0, 90000.0, -2.0, 2.0}, grid=true, subPlot=3, colors={{28,108,200}}); diff --git a/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/CoolingCoil.mos b/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/CoolingCoil.mos index 25c63fc23da..f1d0ec451cf 100644 --- a/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/CoolingCoil.mos +++ b/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/CoolingCoil.mos @@ -1,3 +1,3 @@ -simulateModel("Buildings.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation.CoolingCoil", method="Cvode", outputInterval=300, stopTime=28000, tolerance=1e-06, resultFile="CoolingCoil"); +simulateModel("Buildings.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation.CoolingCoil", method="Cvode", outputInterval=300, stopTime=28000, tolerance=1e-06, resultFile="CoolingCoil"); createPlot(id=1, position={0, 0, 1532, 791}, y={"cooCoi.yCooCoi"}, range={0.0, 28000.0, -0.2, 1.2000000000000002}, grid=true, colors={{28,108,200}}); createPlot(id=1, position={0, 0, 1532, 393}, y={"TSupSet", "TSup.y"}, range={0.0, 28000.0, 15.5, 20.0}, grid=true, subPlot=2, colors={{28,108,200}, {238,46,47}}, displayUnits={"degC", "degC"}); diff --git a/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/ZoneState.mos b/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/ZoneState.mos index c5817ae33d7..44bca3a1f9b 100644 --- a/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/ZoneState.mos +++ b/Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36_PR1/AHUs/SingleZone/VAV/Validation/ZoneState.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation.ZoneState", method="Cvode", stopTime=3, tolerance=1e-06, resultFile="ZoneStatePoints"); +simulateModel("Buildings.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation.ZoneState", method="Cvode", stopTime=3, tolerance=1e-06, resultFile="ZoneStatePoints"); createPlot(id=1, position={55, 50, 592, 427}, y={"zonSta.yZonSta"}, range={0.0, 3.0, 0.0, 4.0}, grid=true, colors={{28,108,200}}); createPlot(id=1, position={55, 50, 592, 211}, y={"zonSta.uHea", "zonSta.uCoo"}, range={0.0, 3.0, -0.5, 1.5}, grid=true, subPlot=2, colors={{28,108,200}, {238,46,47}}); diff --git a/Buildings/Resources/Scripts/Dymola/Controls/OBC/Utilities/Validation/OptimalStartNoHeatingNoCooling.mos b/Buildings/Resources/Scripts/Dymola/Controls/OBC/Utilities/Validation/OptimalStartNoHeatingNoCooling.mos index b9714090d49..50838781ad6 100644 --- a/Buildings/Resources/Scripts/Dymola/Controls/OBC/Utilities/Validation/OptimalStartNoHeatingNoCooling.mos +++ b/Buildings/Resources/Scripts/Dymola/Controls/OBC/Utilities/Validation/OptimalStartNoHeatingNoCooling.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Controls.OBC.Utilities.Validation.OptimalStartNoHeatingNoCooling", stopTime=2419200, method="Cvode", tolerance=1e-06, resultFile="OptimalStartNoHeatingNoCooling"); +simulateModel("Buildings.Controls.OBC.Utilities.Validation.OptimalStartNoHeatingNoCooling", stopTime=2419200, method="Cvode", tolerance=1e-06, resultFile="OptimalStartNoHeatingNoCooling"); createPlot(id=1, position={10, 9, 1161, 1054},subPlot=1, y={"optSta.tOpt"}, range={0.0, 28.0, -1.5, 1.5}, grid=true, colors={{28,108,200}}); createPlot(id=1, position={10, 9, 1161, 346},subPlot=2, y={"optSta.optOn"}, range={0.0, 2500000.0, -1.5, 1.5}, grid=true, colors={{28,108,200}}); createPlot(id=1, position={10, 9, 1161, 346},subPlot=3, y={"TSetHea.y","TSetCoo.y","optSta.TZon"}, range={0.0, 2500000.0, 10.0, 35.0}, grid=true, colors={{238,46,47},{0,140,72},{28,108,200}}); diff --git a/Buildings/Resources/Scripts/Dymola/Examples/VAVReheat/Validation/TraceSubstance.mos b/Buildings/Resources/Scripts/Dymola/Examples/VAVReheat/Validation/TraceSubstance.mos index 1207ed174cd..28264c0e87a 100644 --- a/Buildings/Resources/Scripts/Dymola/Examples/VAVReheat/Validation/TraceSubstance.mos +++ b/Buildings/Resources/Scripts/Dymola/Examples/VAVReheat/Validation/TraceSubstance.mos @@ -1,3 +1,3 @@ -simulateModel("Buildings.Examples.VAVReheat.Validation.TraceSubstance", startTime=4492800, stopTime=4665600, numberOfIntervals=0, outputInterval=900, method="Cvode", tolerance=1e-06, resultFile="TraceSubstance"); +simulateModel("Buildings.Examples.VAVReheat.Validation.TraceSubstance", startTime=4492800, stopTime=4665600, numberOfIntervals=0, outputInterval=900, method="Cvode", tolerance=1e-06, resultFile="TraceSubstance"); createPlot(id=1, position={0, 0, 1537, 628}, y={"hvac.VOut1.V_flow", "hvac.senSupFlo.V_flow"}, range={3500000.0, 4650000.0, -0.5, 3.0}, grid=true, colors={{28,108,200}, {238,46,47}}, displayUnits={"m3/s", "m3/s"}); createPlot(id=1, position={0, 0, 1537, 628}, y={"flo.cor.air.vol.C[1]", "flo.sou.air.vol.C[1]", "flo.eas.air.vol.C[1]", "flo.nor.air.vol.C[1]", "flo.wes.air.vol.C[1]"}, range={3500000.0, 4650000.0, -0.0005, 0.0015}, grid=true, subPlot=102, colors={{28,108,200}, {238,46,47}, {0,140,72}, {217,67,180}, {0,0,0}}); diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/FixedResistances/Examples/PlugFlowPipe.mos b/Buildings/Resources/Scripts/Dymola/Fluid/FixedResistances/Examples/PlugFlowPipe.mos index 87a4293a463..663c653891e 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/FixedResistances/Examples/PlugFlowPipe.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/FixedResistances/Examples/PlugFlowPipe.mos @@ -1,3 +1,3 @@ -translateModel("Buildings.Fluid.FixedResistances.Examples.PlugFlowPipe"); +translateModel("Buildings.Fluid.FixedResistances.Examples.PlugFlowPipe"); simulateModel("Buildings.Fluid.FixedResistances.Examples.PlugFlowPipe", stopTime=1000, method="CVode", tolerance=1e-006, resultFile="PlugFlowPipe"); createPlot(id=1, position={15, 10, 584, 397}, y={"senTemIn.T", "senTemInNoMix.T", "senTemOutNoMix.T", "senTemOut.T"}, range={0.0, 1000.0, 45.0, 75.0}, grid=true, colors={{28,108,200}, {0,140,72}, {217,67,180}, {238,46,47}}, timeUnit="s", displayUnits={"degC", "degC", "degC", "degC"}); diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/DiscretizedBuriedPipe.mos b/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/DiscretizedBuriedPipe.mos index 753173987e6..b73f4de3c82 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/DiscretizedBuriedPipe.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/DiscretizedBuriedPipe.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.Geothermal.BuriedPipes.Examples.DiscretizedBuriedPipe", stopTime=63072000, method="Cvode", tolerance=1e-06, resultFile="DiscretizedBuriedPipe"); +simulateModel("Buildings.Fluid.Geothermal.BuriedPipes.Examples.DiscretizedBuriedPipe", stopTime=63072000, method="Cvode", tolerance=1e-06, resultFile="DiscretizedBuriedPipe"); createPlot( id=1, position={55, 55, 1192, 772}, diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/SingleBuriedPipe.mos b/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/SingleBuriedPipe.mos index 8bd2a34c96c..36fd8e967f8 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/SingleBuriedPipe.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/SingleBuriedPipe.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.Geothermal.BuriedPipes.Examples.SingleBuriedPipe", stopTime=63072000, method="Cvode", tolerance=1e-06, resultFile="SingleBuriedPipe"); +simulateModel("Buildings.Fluid.Geothermal.BuriedPipes.Examples.SingleBuriedPipe", stopTime=63072000, method="Cvode", tolerance=1e-06, resultFile="SingleBuriedPipe"); createPlot( id=1, position={55, 55, 1192, 772}, diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/TwoBuriedPipes.mos b/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/TwoBuriedPipes.mos index 7b0d36eb31b..4534480e665 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/TwoBuriedPipes.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/Geothermal/BuriedPipes/Examples/TwoBuriedPipes.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.Geothermal.BuriedPipes.Examples.TwoBuriedPipes", stopTime=63072000, method="Cvode", tolerance=1e-06, resultFile="TwoBuriedPipes"); +simulateModel("Buildings.Fluid.Geothermal.BuriedPipes.Examples.TwoBuriedPipes", stopTime=63072000, method="Cvode", tolerance=1e-06, resultFile="TwoBuriedPipes"); createPlot(id=1, position={0, 0, 1534, 469}, y={"senTemChWIn.T", "senTemChWOut.T", "senTemHotWIn.T", "senTemHotWOut.T", "gro.soi.T"}, diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/BaseClasses/Functions/Validation/EquivalentHeatCapacity.mos b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/BaseClasses/Functions/Validation/EquivalentHeatCapacity.mos index ddd11b48188..a2db2ccd165 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/BaseClasses/Functions/Validation/EquivalentHeatCapacity.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/BaseClasses/Functions/Validation/EquivalentHeatCapacity.mos @@ -1,4 +1,4 @@ -// Simulate +// Simulate simulateModel("Buildings.Fluid.HeatExchangers.CoolingTowers.BaseClasses.Functions.Validation.EquivalentHeatCapacity", startTime=10, stopTime=20, method="CVode", tolerance=1e-6, resultFile="EquivalentHeatCapacity"); // Plot commands removePlots(false); diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/Examples/FixedApproachDryBulb.mos b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/Examples/FixedApproachDryBulb.mos index 0c62f61ce47..9ea9c890e12 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/Examples/FixedApproachDryBulb.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/Examples/FixedApproachDryBulb.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.HeatExchangers.CoolingTowers.Examples.FixedApproachDryBulb", +simulateModel("Buildings.Fluid.HeatExchangers.CoolingTowers.Examples.FixedApproachDryBulb", startTime=15552000, stopTime=15984000, tolerance=1e-06, method="CVode", resultFile="FixedApproachDryBulb"); removePlots(); diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/Validation/MerkelEnergyPlus.mos b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/Validation/MerkelEnergyPlus.mos index 6f1faa65c03..badf1825819 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/Validation/MerkelEnergyPlus.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/CoolingTowers/Validation/MerkelEnergyPlus.mos @@ -1,4 +1,4 @@ -// Simulate +// Simulate simulateModel("Buildings.Fluid.HeatExchangers.CoolingTowers.Validation.MerkelEnergyPlus", stopTime=172800, tolerance=1E-6, method="CVode", resultFile="MerkelEnergyPlus"); // Plot commands removePlots(false); diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTU.mos b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTU.mos index cc9bb662a65..69c0775c985 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTU.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTU.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.HeatExchangers.Validation.WetCoilEffectivenessNTU", +simulateModel("Buildings.Fluid.HeatExchangers.Validation.WetCoilEffectivenessNTU", stopTime=1000, method="cvode", tolerance=1e-6, diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTUCounterFlow.mos b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTUCounterFlow.mos index c03b527c5bd..f2db3a97fed 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTUCounterFlow.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTUCounterFlow.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.HeatExchangers.Validation.WetCoilEffectivenessNTUCounterFlow", +simulateModel("Buildings.Fluid.HeatExchangers.Validation.WetCoilEffectivenessNTUCounterFlow", stopTime=1000, method="cvode", tolerance=1e-6, diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTUHeating.mos b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTUHeating.mos index 4a5ce5b8a41..8f2b59a8259 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTUHeating.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/HeatExchangers/Validation/WetCoilEffectivenessNTUHeating.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.HeatExchangers.Validation.WetCoilEffectivenessNTUHeating", +simulateModel("Buildings.Fluid.HeatExchangers.Validation.WetCoilEffectivenessNTUHeating", stopTime=1000, method="cvode", tolerance=1e-6, diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/Sources/Examples/Outside_CpData.mos b/Buildings/Resources/Scripts/Dymola/Fluid/Sources/Examples/Outside_CpData.mos index 28dde3e1d69..8406e9dc096 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/Sources/Examples/Outside_CpData.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/Sources/Examples/Outside_CpData.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.Sources.Examples.Outside_CpData", startTime=1.728e+07, stopTime=1.78848e+07, method="CVode", tolerance=1e-6, resultFile="Outside_CpData"); +simulateModel("Buildings.Fluid.Sources.Examples.Outside_CpData", startTime=1.728e+07, stopTime=1.78848e+07, method="CVode", tolerance=1e-6, resultFile="Outside_CpData"); createPlot(id = 3, position = {55, 24, 679, 513}, y = {"weaDat.weaBus.winDir"}, diff --git a/Buildings/Resources/Scripts/Dymola/Fluid/Sources/Examples/Outside_CpData_Angles.mos b/Buildings/Resources/Scripts/Dymola/Fluid/Sources/Examples/Outside_CpData_Angles.mos index 5b4a43fac0f..75cf10452ce 100644 --- a/Buildings/Resources/Scripts/Dymola/Fluid/Sources/Examples/Outside_CpData_Angles.mos +++ b/Buildings/Resources/Scripts/Dymola/Fluid/Sources/Examples/Outside_CpData_Angles.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Fluid.Sources.Examples.Outside_CpData_Angles", startTime=0, stopTime=20, method="CVode", tolerance=1e-6, resultFile="Outside_CpData_Angles"); +simulateModel("Buildings.Fluid.Sources.Examples.Outside_CpData_Angles", startTime=0, stopTime=20, method="CVode", tolerance=1e-6, resultFile="Outside_CpData_Angles"); createPlot(id = 3, position = {55, 24, 679, 513}, y = {"weaDat.weaBus.winDir"}, diff --git a/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamDerivativeCheck.mos b/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamDerivativeCheck.mos index ec4d77616f7..48e6a6c360d 100644 --- a/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamDerivativeCheck.mos +++ b/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamDerivativeCheck.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Media.Examples.SteamDerivativeCheck", startTime=0, stopTime=1, tolerance=1E-10, method="dassl", resultFile="MediaExamplesSteamDerivativeCheck"); +simulateModel("Buildings.Media.Examples.SteamDerivativeCheck", startTime=0, stopTime=1, tolerance=1E-10, method="dassl", resultFile="MediaExamplesSteamDerivativeCheck"); createPlot(id=1, position={34, 26, 626, 458}, y={"der(hVapSym)", "der(hVapCod)"}, diff --git a/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamProperties.mos b/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamProperties.mos index 514d3c50aa4..c46dc11efff 100644 --- a/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamProperties.mos +++ b/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamProperties.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Media.Examples.SteamProperties", method="dassl", startTime=0, stopTime=1.0, tolerance=1e-06, resultFile="SteamProperties"); +simulateModel("Buildings.Media.Examples.SteamProperties", method="dassl", startTime=0, stopTime=1.0, tolerance=1e-06, resultFile="SteamProperties"); createPlot( id = 1, x = "T_degC", diff --git a/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamSaturationConsistencyCheck.mos b/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamSaturationConsistencyCheck.mos index 60030a85a68..f86235c6245 100644 --- a/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamSaturationConsistencyCheck.mos +++ b/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamSaturationConsistencyCheck.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Media.Examples.SteamSaturationConsistencyCheck", method="dassl", startTime=0, stopTime=1.0, tolerance=1e-06, resultFile="SteamSaturationConsistencyCheck"); +simulateModel("Buildings.Media.Examples.SteamSaturationConsistencyCheck", method="dassl", startTime=0, stopTime=1.0, tolerance=1e-06, resultFile="SteamSaturationConsistencyCheck"); createPlot(id=1, position={15, 10, 498, 544}, x="TSat_degC", y={"TSat0", "TSat"}, diff --git a/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamTemperatureEnthalpyInversion.mos b/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamTemperatureEnthalpyInversion.mos index 02aa6846247..5d09eb78a5b 100644 --- a/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamTemperatureEnthalpyInversion.mos +++ b/Buildings/Resources/Scripts/Dymola/Media/Examples/SteamTemperatureEnthalpyInversion.mos @@ -1,4 +1,4 @@ -simulateModel("Buildings.Media.Examples.SteamTemperatureEnthalpyInversion", method="dassl", tolerance=1e-6, stopTime=1.0, resultFile="MediaExamplesSteamTemperatureEnthalpyInversion"); +simulateModel("Buildings.Media.Examples.SteamTemperatureEnthalpyInversion", method="dassl", tolerance=1e-6, stopTime=1.0, resultFile="MediaExamplesSteamTemperatureEnthalpyInversion"); createPlot(id = 1, position = {31, 30, 400, 280}, y = {"T"}, diff --git a/Buildings/Resources/Scripts/Dymola/Obsolete/Examples/VAVReheat/Validation/VAVBranch.mos b/Buildings/Resources/Scripts/Dymola/Obsolete/Examples/VAVReheat/Validation/VAVBranch.mos index 4902a3f31e1..07d237295f4 100644 --- a/Buildings/Resources/Scripts/Dymola/Obsolete/Examples/VAVReheat/Validation/VAVBranch.mos +++ b/Buildings/Resources/Scripts/Dymola/Obsolete/Examples/VAVReheat/Validation/VAVBranch.mos @@ -1,4 +1,4 @@ -// Script generated by Dymola Fri Feb 12 13:47:08 2021 +// Script generated by Dymola Fri Feb 12 13:47:08 2021 // Simulate commands simulateModel("Buildings.Obsolete.Examples.VAVReheat.Validation.VAVBranch", stopTime=25200, method="Cvode", tolerance=1e-06, resultFile="VAVBranch"); // Plot commands diff --git a/Buildings/Resources/Scripts/Dymola/Utilities/IO/SignalExchange/Examples/FirstOrder.mos b/Buildings/Resources/Scripts/Dymola/Utilities/IO/SignalExchange/Examples/FirstOrder.mos index 6abb6c4d9ae..4ec916c3160 100644 --- a/Buildings/Resources/Scripts/Dymola/Utilities/IO/SignalExchange/Examples/FirstOrder.mos +++ b/Buildings/Resources/Scripts/Dymola/Utilities/IO/SignalExchange/Examples/FirstOrder.mos @@ -1,3 +1,3 @@ -simulateModel("Buildings.Utilities.IO.SignalExchange.Examples.FirstOrder", stopTime=150, tolerance=1e-6, method="CVode", resultFile="FirstOrder"); +simulateModel("Buildings.Utilities.IO.SignalExchange.Examples.FirstOrder", stopTime=150, tolerance=1e-6, method="CVode", resultFile="FirstOrder"); createPlot(id=1, position={55, 50, 592, 427}, y={"expMod.oveWriSet_u", "expMod.oveWriAct_u", "expMod.rea"}, range={0.0, 150.0, -2.0, 4.0}, grid=true, colors={{28,108,200}, {238,46,47}, {0,140,72}}); createPlot(id=1, position={55, 50, 592, 211}, y={"expMod.oveWriSet_activate", "expMod.oveWriAct_activate"}, range={0.0, 150.0, -0.5, 1.5}, grid=true, subPlot=2, colors={{28,108,200}, {28,108,200}}); From 0a7bbd1d9e34a4d9e243abb9adca5b3ea5fa3b72 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Tue, 24 May 2022 19:32:12 -0700 Subject: [PATCH 2/3] Merge IBPSA (#3035) * Merged IBPSA --- Buildings/Fluid/Examples/ResistanceVolumeFlowReversal.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Buildings/Fluid/Examples/ResistanceVolumeFlowReversal.mo b/Buildings/Fluid/Examples/ResistanceVolumeFlowReversal.mo index e0ca764f8ac..69cd099c359 100644 --- a/Buildings/Fluid/Examples/ResistanceVolumeFlowReversal.mo +++ b/Buildings/Fluid/Examples/ResistanceVolumeFlowReversal.mo @@ -89,10 +89,10 @@ equation points={{40,-20},{56,-20}}, color={0,127,255})); connect(res[i].port_b, vol[i].ports[1]) annotation (Line( - points={{76,-20},{80,-20},{80,-70},{52,-70},{52,-66}}, + points={{76,-20},{80,-20},{80,-70},{51,-70},{51,-66}}, color={0,127,255})); connect(vol[i].ports[2], val.port_3) annotation (Line( - points={{48,-66},{48,-70},{0,-70},{0,-30}}, + points={{49,-66},{49,-70},{0,-70},{0,-30}}, color={0,127,255})); end for; annotation (experiment( From afda6ac8bc4ff89830089b4d6b52ae4cf7362595 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Tue, 24 May 2022 22:32:00 -0700 Subject: [PATCH 3/3] Issue3022 cdl continuos derivative (#3023) * Implementation of CDL.Continuous.Derivative For #3022 --- .../Controls/OBC/CDL/Continuous/Derivative.mo | 121 +++++++++++++ Buildings/Controls/OBC/CDL/Continuous/PID.mo | 169 ++---------------- .../OBC/CDL/Continuous/PIDWithReset.mo | 159 ++-------------- .../CDL/Continuous/Validation/Derivative.mo | 124 +++++++++++++ .../CDL/Continuous/Validation/package.order | 1 + .../Controls/OBC/CDL/Continuous/package.order | 1 + ...C_CDL_Continuous_Validation_Derivative.txt | 13 ++ .../CDL/Continuous/Validation/Derivative.mos | 3 + ...C.CDL.Continuous.Validation.Derivative.mos | 7 + Buildings/package.mo | 12 +- 10 files changed, 314 insertions(+), 296 deletions(-) create mode 100644 Buildings/Controls/OBC/CDL/Continuous/Derivative.mo create mode 100644 Buildings/Controls/OBC/CDL/Continuous/Validation/Derivative.mo create mode 100644 Buildings/Resources/ReferenceResults/Dymola/Buildings_Controls_OBC_CDL_Continuous_Validation_Derivative.txt create mode 100644 Buildings/Resources/Scripts/Dymola/Controls/OBC/CDL/Continuous/Validation/Derivative.mos create mode 100644 Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.Controls.OBC.CDL.Continuous.Validation.Derivative.mos diff --git a/Buildings/Controls/OBC/CDL/Continuous/Derivative.mo b/Buildings/Controls/OBC/CDL/Continuous/Derivative.mo new file mode 100644 index 00000000000..5ac07e449ba --- /dev/null +++ b/Buildings/Controls/OBC/CDL/Continuous/Derivative.mo @@ -0,0 +1,121 @@ +within Buildings.Controls.OBC.CDL.Continuous; +block Derivative + "Block that approximates the derivative of the input" + parameter Real y_start=0 + "Initial value of output (= state)" + annotation (Dialog(group="Initialization")); + + Buildings.Controls.OBC.CDL.Interfaces.RealInput k + "Connector for gain signal" + annotation (Placement(transformation(extent={{-140,60},{-100,100}}))); + Buildings.Controls.OBC.CDL.Interfaces.RealInput T( + final quantity="Time", + final unit="s", + min=100*Buildings.Controls.OBC.CDL.Constants.eps) + "Time constant (T>0 required; T=0 is ideal derivative block)" + annotation (Placement(transformation(extent={{-140,20},{-100,60}}))); + Buildings.Controls.OBC.CDL.Interfaces.RealInput u + "Input to be differentiated" + annotation (Placement(transformation(extent={{-140,-20},{-100,20}}))); + Buildings.Controls.OBC.CDL.Interfaces.RealOutput y + "Approximation of derivative du/dt" + annotation (Placement(transformation(extent={{100,-20},{140,20}}))); +protected + Real T_nonZero(final unit="s") "Non-zero value for T"; + + output Real x + "State of block"; + +initial equation + x= if abs(k) < Buildings.Controls.OBC.CDL.Constants.eps then u else u - T*y_start/k; + +equation + T_nonZero = max(T, 100*Buildings.Controls.OBC.CDL.Constants.eps); + der(x) = (u-x)/T_nonZero; + y = (k/T_nonZero)*(u-x); + + annotation ( + defaultComponentName="der", + Documentation( + info=" +

+This blocks defines the transfer function between the +input u and the output y +as approximated derivative: +

+
+                s
+  y = k * ------------ * u
+            T * s + 1
+
+

+If k=0, the block reduces to y=0. +

+", + revisions=" +
    +
  • +May 20, 2022, by Michael Wetter:
    +First implementation.
    +This is for +issue 3022. +
  • +
+"), + Icon( + coordinateSystem( + extent={{-100.0,-100.0},{100.0,100.0}}), + graphics={ + Rectangle( + extent={{-100,-100},{100,100}}, + lineColor={0,0,127}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Line( + points={{-56,78},{-56,-90}}, + color={192,192,192}), + Polygon( + lineColor={192,192,192}, + fillColor={192,192,192}, + fillPattern=FillPattern.Solid, + points={{-56,90},{-64,68},{-48,68},{-56,90}}), + Line( + points={{-64,-80},{82,-80}}, + color={192,192,192}), + Polygon( + lineColor={192,192,192}, + fillColor={192,192,192}, + fillPattern=FillPattern.Solid, + points={{90.0,-80.0},{68.0,-72.0},{68.0,-88.0},{90.0,-80.0}}), + Line( + origin={-24.667,-27.333}, + points={{-31.333,89.333},{-19.333,-40.667},{86.667,-52.667}}, + color={0,0,127}, + smooth=Smooth.Bezier), + Text( + extent={{-150,150},{150,110}}, + textString="%name", + textColor={0,0,255}), + Text( + extent={{226,60},{106,10}}, + textColor={0,0,0}, + textString=DynamicSelect("",String(y, + leftJustified=false, + significantDigits=3))), + Text( + extent={{-106,14},{-62,-12}}, + textColor={0,0,0}, + textString="u"), + Text( + extent={{46,14},{90,-12}}, + textColor={0,0,0}, + textString="y=du/dt"), + Text( + extent={{-108,94},{-64,68}}, + textColor={0,0,0}, + textString="k"), + Text( + extent={{-108,54},{-64,28}}, + textColor={0,0,0}, + textString="T")})); +end Derivative; diff --git a/Buildings/Controls/OBC/CDL/Continuous/PID.mo b/Buildings/Controls/OBC/CDL/Continuous/PID.mo index 8744a2af46c..41bd1e82446 100644 --- a/Buildings/Controls/OBC/CDL/Continuous/PID.mo +++ b/Buildings/Controls/OBC/CDL/Continuous/PID.mo @@ -63,9 +63,7 @@ block PID final y_start=xi_start) if with_I "Integral term" annotation (Placement(transformation(extent={{-50,-10},{-30,10}}))); - Derivative D( - final k=k*Td, - final T=Td/Nd, + Buildings.Controls.OBC.CDL.Continuous.Derivative D( final y_start=yd_start) if with_D "Derivative term" annotation (Placement(transformation(extent={{-50,60},{-30,80}}))); @@ -100,6 +98,12 @@ protected final parameter Boolean with_D=controllerType == Buildings.Controls.OBC.CDL.Types.SimpleController.PD or controllerType == Buildings.Controls.OBC.CDL.Types.SimpleController.PID "Boolean flag to enable derivative action" annotation (Evaluate=true,HideResult=true); + Sources.Constant kDer(k=k*Td) if with_D + "Gain for derivative block" + annotation (Placement(transformation(extent={{-100,110},{-80,130}}))); + Sources.Constant TDer(k=Td/Nd) if with_D + "Time constant for approximation in derivative block" + annotation (Placement(transformation(extent={{-100,80},{-80,100}}))); Buildings.Controls.OBC.CDL.Continuous.Sources.Constant Dzero( final k=0) if not with_D "Zero input signal" @@ -144,152 +148,6 @@ protected "Constant false" annotation (Placement(transformation(extent={{-100,-90},{-80,-70}}))); - block Derivative - "Block that approximates the derivative of the input" - parameter Real k( - unit="1")=1 - "Gains"; - parameter Real T( - final quantity="Time", - final unit="s", - min=1E-60)=0.01 - "Time constant (T>0 required)"; - parameter Real y_start=0 - "Initial value of output (= state)" - annotation (Dialog(group="Initialization")); - Interfaces.RealInput u - "Connector of Real input signal" - annotation (Placement(transformation(extent={{-140,-20},{-100,20}}))); - Interfaces.RealOutput y - "Connector of Real output signal" - annotation (Placement(transformation(extent={{100,-20},{140,20}}))); - output Real x - "State of block"; - - protected - parameter Boolean zeroGain=abs(k) < 1E-17 - "= true, if gain equals to zero"; - - initial equation - if zeroGain then - x=u; - else - x=u-T*y_start/k; - end if; - - equation - der(x)= - if zeroGain then - 0 - else - (u-x)/T; - y=if zeroGain then - 0 - else - (k/T)*(u-x); - annotation ( - defaultComponentName="der", - Documentation( - info=" -

-This blocks defines the transfer function between the -input u and the output y -as approximated derivative: -

-
-             k * s
-     y = ------------ * u
-            T * s + 1
-
-

-If k=0, the block reduces to y=0. -

-", - revisions=" -
    -
  • -April 30, 2021, by Michael Wetter:
    -Refactored implementation to have separate blocks that show the P, I and D contribution, -each with the control gain applied.
    -This is for -issue 2475. -
  • -
  • -November 12, 2020, by Michael Wetter:
    -Reformulated to remove dependency to Modelica.Units.SI.
    -This is for -issue 2243. -
  • -
  • -August 7, 2020, by Michael Wetter:
    -Moved to protected block in PID controller because the derivative block is no longer part of CDL. -
  • -
  • -April 21, 2020, by Michael Wetter:
    -Removed option to not set the initialization method or to set the initial state. -The new implementation only allows to set the initial output, from which -the initial state is computed. -
    -This is for -issue 1887. -
  • -
  • -March 2, 2020, by Michael Wetter:
    -Changed icon to display dynamically the output value. -
  • -
  • -March 24, 2017, by Jianjun Hu:
    -First implementation, based on the implementation of the -Modelica Standard Library. -
  • -
-"), - Icon( - coordinateSystem( - preserveAspectRatio=true, - extent={{-100.0,-100.0},{100.0,100.0}}), - graphics={ - Rectangle( - extent={{-100,-100},{100,100}}, - lineColor={0,0,127}, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid), - Line( - points={{-80.0,78.0},{-80.0,-90.0}}, - color={192,192,192}), - Polygon( - lineColor={192,192,192}, - fillColor={192,192,192}, - fillPattern=FillPattern.Solid, - points={{-80.0,90.0},{-88.0,68.0},{-72.0,68.0},{-80.0,90.0}}), - Line( - points={{-90.0,-80.0},{82.0,-80.0}}, - color={192,192,192}), - Polygon( - lineColor={192,192,192}, - fillColor={192,192,192}, - fillPattern=FillPattern.Solid, - points={{90.0,-80.0},{68.0,-72.0},{68.0,-88.0},{90.0,-80.0}}), - Line( - origin={-24.667,-27.333}, - points={{-55.333,87.333},{-19.333,-40.667},{86.667,-52.667}}, - color={0,0,127}, - smooth=Smooth.Bezier), - Text( - extent={{-150.0,-150.0},{150.0,-110.0}}, - textString="k=%k"), - Text( - extent={{-150,150},{150,110}}, - textString="%name", - textColor={0,0,255}), - Text( - extent={{226,60},{106,10}}, - textColor={0,0,0}, - textString=DynamicSelect("",String(y, - leftJustified=false, - significantDigits=3)))})); - end Derivative; - equation connect(u_s,uS_revAct.u) annotation (Line(points={{-240,0},{-212,0},{-212,40},{-202,40}},color={0,0,127})); @@ -352,8 +210,11 @@ equation connect(uMea_revAct.y, errI1.u2) annotation (Line(points={{-158,-40},{-150, -40},{-150,-6},{-142,-6}}, color={0,0,127})); connect(antWinGai.y, errI2.u2) annotation (Line(points={{158,-20},{-100,-20}, - {-100,-6},{-92,-6}}, - color={0,0,127})); + {-100,-6},{-92,-6}}, color={0,0,127})); + connect(kDer.y, D.k) annotation (Line(points={{-78,120},{-58,120},{-58,78},{ + -52,78}}, color={0,0,127})); + connect(TDer.y, D.T) annotation (Line(points={{-78,90},{-60,90},{-60,74},{-52, + 74}}, color={0,0,127})); annotation ( defaultComponentName="conPID", Icon( @@ -619,6 +480,12 @@ American Society of Heating Refrigerating and Air-Conditioning Engineers Inc. At revisions="
  • +May 20, 2022, by Michael Wetter:
    +Refactored implementation to use new derivative block from CDL package.
    +This is for +issue 3022. +
  • +
  • May 6, 2022, by Michael Wetter:
    Corrected wrong documentation in how the derivative of the control error is approximated.
    This is for diff --git a/Buildings/Controls/OBC/CDL/Continuous/PIDWithReset.mo b/Buildings/Controls/OBC/CDL/Continuous/PIDWithReset.mo index 861f70a4272..7cb8d02a2ca 100644 --- a/Buildings/Controls/OBC/CDL/Continuous/PIDWithReset.mo +++ b/Buildings/Controls/OBC/CDL/Continuous/PIDWithReset.mo @@ -69,9 +69,7 @@ block PIDWithReset final y_start=xi_start) if with_I "Integral term" annotation (Placement(transformation(extent={{-50,-10},{-30,10}}))); - Derivative D( - final k=k*Td, - final T=Td/Nd, + Buildings.Controls.OBC.CDL.Continuous.Derivative D( final y_start=yd_start) if with_D "Derivative term" annotation (Placement(transformation(extent={{-50,60},{-30,80}}))); @@ -105,6 +103,12 @@ protected final parameter Boolean with_D=controllerType == Buildings.Controls.OBC.CDL.Types.SimpleController.PD or controllerType == Buildings.Controls.OBC.CDL.Types.SimpleController.PID "Boolean flag to enable derivative action" annotation (Evaluate=true,HideResult=true); + Sources.Constant kDer(k=k*Td) if with_D + "Gain for derivative block" + annotation (Placement(transformation(extent={{-100,110},{-80,130}}))); + Sources.Constant TDer(k=Td/Nd) if with_D + "Time constant for approximation in derivative block" + annotation (Placement(transformation(extent={{-100,80},{-80,100}}))); Buildings.Controls.OBC.CDL.Continuous.Sources.Constant Dzero( final k=0) if not with_D "Zero input signal" @@ -151,145 +155,6 @@ protected "Assertion on yMin and yMax" annotation (Placement(transformation(extent={{160,-160},{180,-140}}))); - block Derivative - "Block that approximates the derivative of the input" - parameter Real k( - unit="1")=1 - "Gains"; - parameter Real T( - final quantity="Time", - final unit="s", - min=1E-60)=0.01 - "Time constant (T>0 required)"; - parameter Real y_start=0 - "Initial value of output (= state)" - annotation (Dialog(group="Initialization")); - Interfaces.RealInput u - "Connector of Real input signal" - annotation (Placement(transformation(extent={{-140,-20},{-100,20}}))); - Interfaces.RealOutput y - "Connector of Real output signal" - annotation (Placement(transformation(extent={{100,-20},{140,20}}))); - output Real x - "State of block"; - - protected - parameter Boolean zeroGain=abs(k) < 1E-17 - "= true, if gain equals to zero"; - - initial equation - if zeroGain then - x=u; - else - x=u-T*y_start/k; - end if; - - equation - der(x)= - if zeroGain then - 0 - else - (u-x)/T; - y=if zeroGain then - 0 - else - (k/T)*(u-x); - annotation ( - defaultComponentName="der", - Documentation( - info=" -

    -This blocks defines the transfer function between the -input u and the output y -as approximated derivative: -

    -
    -             k * s
    -     y = ------------ * u
    -            T * s + 1
    -
    -

    -If k=0, the block reduces to y=0. -

    -", - revisions=" -
      -
    • -November 12, 2020, by Michael Wetter:
      -Reformulated to remove dependency to Modelica.Units.SI.
      -This is for -issue 2243. -
    • -
    • -August 7, 2020, by Michael Wetter:
      -Moved to protected block in PID controller because the derivative block is no longer part of CDL. -
    • -
    • -April 21, 2020, by Michael Wetter:
      -Removed option to not set the initialization method or to set the initial state. -The new implementation only allows to set the initial output, from which -the initial state is computed. -
      -This is for -issue 1887. -
    • -
    • -March 2, 2020, by Michael Wetter:
      -Changed icon to display dynamically the output value. -
    • -
    • -March 24, 2017, by Jianjun Hu:
      -First implementation, based on the implementation of the -Modelica Standard Library. -
    • -
    -"), - Icon( - coordinateSystem( - preserveAspectRatio=true, - extent={{-100.0,-100.0},{100.0,100.0}}), - graphics={ - Rectangle( - extent={{-100,-100},{100,100}}, - lineColor={0,0,127}, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid), - Line( - points={{-80.0,78.0},{-80.0,-90.0}}, - color={192,192,192}), - Polygon( - lineColor={192,192,192}, - fillColor={192,192,192}, - fillPattern=FillPattern.Solid, - points={{-80.0,90.0},{-88.0,68.0},{-72.0,68.0},{-80.0,90.0}}), - Line( - points={{-90.0,-80.0},{82.0,-80.0}}, - color={192,192,192}), - Polygon( - lineColor={192,192,192}, - fillColor={192,192,192}, - fillPattern=FillPattern.Solid, - points={{90.0,-80.0},{68.0,-72.0},{68.0,-88.0},{90.0,-80.0}}), - Line( - origin={-24.667,-27.333}, - points={{-55.333,87.333},{-19.333,-40.667},{86.667,-52.667}}, - color={0,0,127}, - smooth=Smooth.Bezier), - Text( - extent={{-150.0,-150.0},{150.0,-110.0}}, - textString="k=%k"), - Text( - extent={{-150,150},{150,110}}, - textString="%name", - textColor={0,0,255}), - Text( - extent={{226,60},{106,10}}, - textColor={0,0,0}, - textString=DynamicSelect("",String(y, - leftJustified=false, - significantDigits=3)))})); - end Derivative; - equation connect(trigger,I.trigger) annotation (Line(points={{-160,-220},{-160,-140},{-40,-140},{-40,-12}},color={255,0,255})); @@ -353,6 +218,10 @@ equation -100,-6},{-92,-6}}, color={0,0,127})); connect(addPD.y, addRes.u2) annotation (Line(points={{42,126},{60,126},{60,-100}, {-110,-100},{-110,-86},{-102,-86}}, color={0,0,127})); + connect(kDer.y, D.k) annotation (Line(points={{-78,120},{-58,120},{-58,78},{ + -52,78}}, color={0,0,127})); + connect(TDer.y, D.T) annotation (Line(points={{-78,90},{-60,90},{-60,74},{-52, + 74}}, color={0,0,127})); annotation ( defaultComponentName="conPID", @@ -611,6 +480,12 @@ American Society of Heating Refrigerating and Air-Conditioning Engineers Inc. At revisions="
    • +May 20, 2022, by Michael Wetter:
      +Refactored implementation to use new derivative block from CDL package.
      +This is for +issue 3022. +
    • +
    • May 6, 2022, by Michael Wetter:
      Corrected wrong documentation in how the derivative of the control error is approximated.
      This is for diff --git a/Buildings/Controls/OBC/CDL/Continuous/Validation/Derivative.mo b/Buildings/Controls/OBC/CDL/Continuous/Validation/Derivative.mo new file mode 100644 index 00000000000..9c523004f63 --- /dev/null +++ b/Buildings/Controls/OBC/CDL/Continuous/Validation/Derivative.mo @@ -0,0 +1,124 @@ +within Buildings.Controls.OBC.CDL.Continuous.Validation; +model Derivative + "Test model for the derivative block" + Buildings.Controls.OBC.CDL.Continuous.Derivative der1(y_start=1) + "Derivative block with input gains" + annotation (Placement(transformation(extent={{40,40},{60,60}}))); + Sources.Constant con(k=1) "Outputs 1" + annotation (Placement(transformation(extent={{-80,70},{-60,90}}))); + Sources.Ramp ram( + height=0.09, + duration=10, + offset=0.01, + startTime=5) "Ramp for time constant used in approximating derivative" + annotation (Placement(transformation(extent={{-80,40},{-60,60}}))); + Sources.ModelTime modTim "Model time" + annotation (Placement(transformation(extent={{-80,0},{-60,20}}))); + Buildings.Controls.OBC.CDL.Continuous.IntegratorWithReset intWitRes(y_start=1) + "Integration of input" + annotation (Placement(transformation(extent={{0,0},{20,20}}))); + Logical.Sources.Constant booSig(k=false) "Contant boolean signal" + annotation (Placement(transformation(extent={{-40,-30},{-20,-10}}))); + Buildings.Controls.OBC.CDL.Continuous.Cos cos "Cosine of model time" + annotation (Placement(transformation(extent={{-40,0},{-20,20}}))); + Buildings.Controls.OBC.CDL.Continuous.Derivative der2(y_start=0) + "Derivative block with input gains" + annotation (Placement(transformation(extent={{40,-80},{60,-60}}))); + Sources.Constant con2(k=2) "Outputs 2" + annotation (Placement(transformation(extent={{-40,-72},{-20,-52}}))); + Sources.Constant T(k=0.1) "Time constant for derivative approximation" + annotation (Placement(transformation(extent={{0,-90},{20,-70}}))); + Utilities.Assert assMes(message="Differentiated value differs more than threshold") + "Issue an error if results differ more than a threshold" + annotation (Placement(transformation(extent={{170,26},{190,46}}))); + Buildings.Controls.OBC.CDL.Continuous.Subtract sub + "Difference between original signal, and differentiated integral of that signal" + annotation (Placement(transformation(extent={{80,26},{100,46}}))); + Buildings.Controls.OBC.CDL.Continuous.Abs abs "Absolute difference" + annotation (Placement(transformation(extent={{110,26},{130,46}}))); + Buildings.Controls.OBC.CDL.Continuous.LessThreshold lesThr(t=0.1, h=0.01) + "Output true if difference is within expected accuracy" + annotation (Placement(transformation(extent={{140,26},{160,46}}))); +equation + connect(con.y, der1.k) annotation (Line(points={{-58,80},{-10,80},{-10,58},{38, + 58}}, color={0,0,127})); + connect(ram.y, der1.T) annotation (Line(points={{-58,50},{-20,50},{-20,54},{38, + 54}}, color={0,0,127})); + connect(intWitRes.y, der1.u) annotation (Line(points={{22,10},{30,10},{30,50}, + {38,50}}, color={0,0,127})); + connect(booSig.y, intWitRes.trigger) + annotation (Line(points={{-18,-20},{10,-20},{10,-2}}, color={255,0,255})); + connect(modTim.y, cos.u) + annotation (Line(points={{-58,10},{-42,10}}, color={0,0,127})); + connect(intWitRes.u, cos.y) + annotation (Line(points={{-2,10},{-18,10}}, color={0,0,127})); + connect(intWitRes.y_reset_in, cos.y) annotation (Line(points={{-2,2},{-10,2},{ + -10,10},{-18,10}}, color={0,0,127})); + connect(intWitRes.y, der2.u) annotation (Line(points={{22,10},{30,10},{30,-70}, + {38,-70}}, color={0,0,127})); + connect(con2.y, der2.k) annotation (Line(points={{-18,-62},{38,-62}}, + color={0,0,127})); + connect(T.y, der2.T) annotation (Line(points={{22,-80},{34,-80},{34,-66},{38,-66}}, + color={0,0,127})); + connect(der1.y, sub.u1) annotation (Line(points={{62,50},{70,50},{70,42},{78,42}}, + color={0,0,127})); + connect(cos.y, sub.u2) annotation (Line(points={{-18,10},{-10,10},{-10,30},{78, + 30}}, color={0,0,127})); + connect(sub.y, abs.u) + annotation (Line(points={{102,36},{108,36}}, color={0,0,127})); + connect(abs.y, lesThr.u) + annotation (Line(points={{132,36},{138,36}}, color={0,0,127})); + connect(lesThr.y, assMes.u) + annotation (Line(points={{162,36},{168,36}}, color={255,0,255})); + annotation ( + experiment( + StopTime=10.0, + Tolerance=1e-06), + __Dymola_Commands( + file="modelica://Buildings/Resources/Scripts/Dymola/Controls/OBC/CDL/Continuous/Validation/Derivative.mos" "Simulate and plot"), + Documentation( + info=" +

      +Validation test for the block + +Buildings.Controls.OBC.Continuous.Derivative. +The model integrates a time varying signal, and the differentiates this integrated signal. +Hence, the output der1.y matches the non-integrated signal intWitRes.u, +within a small approximation tolerance. +

      +

      +The instance der1 uses a varying input for T which controls the accuracy of +the derivative approximation. At the start of the simulation, T is small and hence +the output der1.y matches the signal intWitRes.u well. +As expected, the approximation error increases with increasing der1.T. +

      +

      +The instance der2 uses a gain of 2, and it initializes the output to 0. +Hence, there is a fast transient at the beginning, and afterwards the output matches der1.y = der2.y / 2. +

      +", + revisions=" +
        +
      • +May 20, 2022, by Michael Wetter:
        +First implementation.
        +This is for +issue 3022. +
      • +
      +"), + Icon(coordinateSystem(extent={{-100,-100},{100,100}}), + graphics={ + Ellipse( + lineColor={75,138,73}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + extent={{-100,-100},{100,100}}), + Polygon( + lineColor={0,0,255}, + fillColor={75,138,73}, + pattern=LinePattern.None, + fillPattern=FillPattern.Solid, + points={{-36,60},{64,0},{-36,-60},{-36,60}})}), + Diagram(coordinateSystem(extent={{-100,-100},{200,100}}))); +end Derivative; diff --git a/Buildings/Controls/OBC/CDL/Continuous/Validation/package.order b/Buildings/Controls/OBC/CDL/Continuous/Validation/package.order index 7125fbad6af..e6c61b3a278 100644 --- a/Buildings/Controls/OBC/CDL/Continuous/Validation/package.order +++ b/Buildings/Controls/OBC/CDL/Continuous/Validation/package.order @@ -7,6 +7,7 @@ Atan Atan2 Average Cos +Derivative Divide Exp Greater diff --git a/Buildings/Controls/OBC/CDL/Continuous/package.order b/Buildings/Controls/OBC/CDL/Continuous/package.order index 1e7094411df..f649f4b5046 100644 --- a/Buildings/Controls/OBC/CDL/Continuous/package.order +++ b/Buildings/Controls/OBC/CDL/Continuous/package.order @@ -7,6 +7,7 @@ Atan Atan2 Average Cos +Derivative Divide Exp Greater diff --git a/Buildings/Resources/ReferenceResults/Dymola/Buildings_Controls_OBC_CDL_Continuous_Validation_Derivative.txt b/Buildings/Resources/ReferenceResults/Dymola/Buildings_Controls_OBC_CDL_Continuous_Validation_Derivative.txt new file mode 100644 index 00000000000..b9a3545f919 --- /dev/null +++ b/Buildings/Resources/ReferenceResults/Dymola/Buildings_Controls_OBC_CDL_Continuous_Validation_Derivative.txt @@ -0,0 +1,13 @@ +last-generated=2022-05-20 +statistics-simulation= +{ + "linear": " ", + "nonlinear": " ", + "number of continuous time states": "3", + "numerical Jacobians": "0" +} +time=[0e+00, 1e+01] +der1.y=[1e+00, 9.959029556511609e-01, 9.819550519556391e-01, 9.581958684484828e-01, 9.248626850300768e-01, 8.822885751724243e-01, 8.30898953628209e-01, 7.712072057226549e-01, 7.038098657516486e-01, 6.293802670651683e-01, 5.486621260643005e-01, 4.624618800139957e-01, 3.716409647245125e-01, 2.771066563849755e-01, 1.798036310580985e-01, 8.070407062768936e-02, -1.920184158046432e-02, -1.189159127963956e-01, -2.174419330967812e-01, -3.137952016887199e-01, -4.070131480693817e-01, -4.961644042161528e-01, -5.803579297043112e-01, -6.587530730082903e-01, -7.305657205554266e-01, -7.950791716575623e-01, -8.516484990565701e-01, -8.997080113724476e-01, -9.387783567888033e-01, -9.684685818090535e-01, -9.884820580482483e-01, -9.986192623683261e-01, -9.987782854266829e-01, -9.889578744061039e-01, -9.692564831869036e-01, -9.398701190948486e-01, -9.010930831438654e-01, -8.533128744477044e-01, -7.970061606496592e-01, -7.327364132949056e-01, -6.611453890800476e-01, -5.829479510096971e-01, -4.989262647112701e-01, -4.09919911937772e-01, -3.168170459464936e-01, -2.205488979816437e-01, -1.220770201207359e-01, -2.238532456495748e-02, 7.752944871904387e-02, 1.766701294498562e-01, 2.740455567836761e-01, 3.647369715837641e-01, 4.541292356760653e-01, 5.390563217309452e-01, 6.186908342098586e-01, 6.922511458396912e-01, 7.590085863035372e-01, 8.18328723111548e-01, 8.695972243976067e-01, 9.123040659984764e-01, 9.460864067077637e-01, 9.706299484706904e-01, 9.856043035907927e-01, 9.90764973244493e-01, 9.861068211072925e-01, 9.719277620315552e-01, 9.487461176595129e-01, 9.167966128197123e-01, 8.754043848803944e-01, 8.233377283138972e-01, 7.642217874526978e-01, 6.983578125948424e-01, 6.251760460266708e-01, 5.463333493766307e-01, 4.618678915654968e-01, 3.729592263698578e-01, 2.801976792615047e-01, 1.848035996633204e-01, 8.759840603750702e-02, -1.049217160290172e-02, -1.083637103438377e-01, -2.052910824015185e-01, -3.002698708977171e-01, -3.91973234009087e-01, -4.799867564454556e-01, -5.636404156684875e-01, -6.412348865837442e-01, -7.126053668389487e-01, -7.773599638878428e-01, -8.341422861606459e-01, -8.825868964195251e-01, -9.228221561659524e-01, -9.538763041802545e-01, -9.751025696440143e-01, -9.874415635948937e-01, -9.895004034042358e-01, -9.821841542465688e-01, -9.650942245336657e-01, -9.386583541746063e-01, -9.028355694160464e-01, -8.582535982131958e-01] +intWitRes.u=[1e+00, 9.950041772274343e-01, 9.800665980245303e-01, 9.553365145438573e-01, 9.210609816323642e-01, 8.775825500488281e-01, 8.253356350982572e-01, 7.648422044298272e-01, 6.967067207138525e-01, 6.216099670055213e-01, 5.403022766113281e-01, 4.535961362508291e-01, 3.623578097032607e-01, 2.674987749498673e-01, 1.699671211937806e-01, 7.073719799518585e-02, -2.919949815154311e-02, -1.288444522436861e-01, -2.27202133965785e-01, -3.232895956755755e-01, -4.16146844625473e-01, -5.048461778740929e-01, -5.885010569415869e-01, -6.662760729310033e-01, -7.373936717231064e-01, -8.011435866355896e-01, -8.56888819398808e-01, -9.040721446803646e-01, -9.422223723193646e-01, -9.709581495340331e-01, -9.899924993515015e-01, -9.99135139616729e-01, -9.982947730248974e-01, -9.87479738349513e-01, -9.667982097489808e-01, -9.364566802978516e-01, -8.967583941020099e-01, -8.481000314388562e-01, -7.909676733146686e-01, -7.259323649847195e-01, -6.536436080932617e-01, -5.748238969829167e-01, -4.902606424960932e-01, -4.00799359006494e-01, -3.07332963797166e-01, -2.107958048582077e-01, -1.121524294260055e-01, -1.238847263511822e-02, 8.749879507316261e-02, 1.865122720715352e-01, 2.836621999740601e-01, 3.779778167700255e-01, 4.685168452190177e-01, 5.543741774070742e-01, 6.346927734317522e-01, 7.086697816848755e-01, 7.755659221144813e-01, 8.347129067995939e-01, 8.8551941424842e-01, 9.274783961174866e-01, 9.601702690124512e-01, 9.832684562031929e-01, 9.965421100845466e-01, 9.99858619082603e-01, 9.931849342926949e-01, 9.765876531600952e-01, 9.502325347879425e-01, 9.143830940304652e-01, 8.69397553994733e-01, 8.157251425022263e-01, 7.539022564888e-01, 6.845465792878729e-01, 6.083511376956182e-01, 5.260776701202705e-01, 4.385473984970318e-01, 3.466353118419647e-01, 2.512597410327659e-01, 1.533736785150569e-01, 5.395561119328425e-02, -4.600203192608105e-02, -1.455000340938568e-01, -2.435437755393855e-01, -3.391550480850473e-01, -4.313766717615178e-01, -5.192889830890152e-01, -6.020119190216064e-01, -6.787197742961457e-01, -7.486467419480308e-01, -8.110929192590418e-01, -8.654353708546059e-01, -9.111302495002747e-01, -9.477214752024828e-01, -9.748436619040397e-01, -9.922253233210268e-01, -9.996930417158711e-01, -9.971721768379211e-01, -9.846879275182084e-01, -9.62364798763793e-01, -9.304263676910163e-01, -8.891909727528647e-01, -8.3907151222229e-01] +der2.y=[0e+00, 1.261453378077789e+00, 1.711985579762048e+00, 1.851723304784845e+00, 1.8649318228344e+00, 1.819409608840942e+00, 1.741235396466365e+00, 1.640323983164534e+00, 1.521138563864111e+00, 1.385840858450008e+00, 1.236459612846375e+00, 1.074675599661087e+00, 9.021037466422734e-01, 7.204945987609972e-01, 5.316998500144678e-01, 3.375990986824036e-01, 1.401166345747656e-01, -5.877177615111972e-02, -2.570807979435709e-01, -4.528207643842859e-01, -6.440265774726868e-01, -8.287988234296156e-01, -1.005272663720355e+00, -1.171703772383937e+00, -1.326428866705305e+00, -1.467910289764404e+00, -1.594728224227986e+00, -1.705613325007856e+00, -1.799453655807933e+00, -1.875312501455989e+00, -1.932432532310486e+00, -1.970247055097071e+00, -1.988376254940529e+00, -1.986639373937913e+00, -1.965052155963148e+00, -1.923829436302185e+00, -1.863383701581305e+00, -1.784320634047713e+00, -1.687428542529866e+00, -1.573677773699383e+00, -1.44420313835144e+00, -1.300297473009185e+00, -1.143399879428372e+00, -9.750786733517046e-01, -7.970133366981652e-01, -6.109854578971863e-01, -4.188526797724627e-01, -2.225346663600015e-01, -2.399422550722351e-02, 1.747871682408452e-01, 3.718221187591553e-01, 5.651411440248939e-01, 7.528148216330167e-01, 9.329657760524905e-01, 1.103795607868809e+00, 1.263595938682556e+00, 1.410771144811192e+00, 1.54385089688162e+00, 1.661504533404948e+00, 1.762557059138344e+00, 1.845999121665955e+00, 1.910996965054258e+00, 1.956899946646507e+00, 1.983249152278825e+00, 1.989781977103009e+00, 1.976433753967285e+00, 1.943338709054005e+00, 1.890826937774475e+00, 1.819422872169441e+00, 1.729839059498406e+00, 1.622971773147583e+00, 1.499888055528566e+00, 1.361817676606696e+00, 1.210141242532985e+00, 1.046372693272172e+00, 8.721489906311035e-01, 6.892110706629077e-01, 4.993868660900383e-01, 3.04573701802227e-01, 1.067162634506809e-01, -9.220686554908752e-02, -2.902076174171313e-01, -4.853108918603731e-01, -6.755633943582912e-01, -8.590675254257364e-01, -1.033986449241638e+00, -1.198574290085948e+00, -1.351187862856297e+00, -1.490299328107224e+00, -1.614521464250162e+00, -1.722610592842102e+00, -1.813488283117332e+00, -1.886246798608269e+00, -1.94015804056491e+00, -1.974684205913325e+00, -1.989479660987854e+00, -1.984397103446325e+00, -1.959486891339804e+00, -1.914998511744664e+00, -1.851375413559421e+00, -1.769254684448242e+00] +der1.T=[9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 9.999999776482582e-03, 1.090000096857395e-02, 1.180000216066532e-02, 1.269999812990733e-02, 1.359999932199426e-02, 1.449999958276749e-02, 1.54000007748633e-02, 1.63000019669591e-02, 1.719999886750592e-02, 1.810000005960173e-02, 1.899999938905239e-02, 1.99000005811482e-02, 2.080000177324401e-02, 2.169999867379083e-02, 2.259999986588664e-02, 2.34999991953373e-02, 2.440000038743311e-02, 2.530000157952891e-02, 2.619999848007574e-02, 2.709999967217154e-02, 2.800000086426735e-02, 2.890000019371801e-02, 2.980000138581381e-02, 3.069999828636064e-02, 3.159999761582018e-02, 3.24999988079071e-02, 3.34000000000118e-02, 3.430000119211649e-02, 3.519999809266331e-02, 3.609999928475023e-02, 3.700000047683716e-02, 3.789999737743031e-02, 3.880000286097008e-02, 3.969999976159875e-02, 4.060000524510302e-02, 4.149999842047691e-02, 4.239999532114111e-02, 4.330000080464536e-02, 4.419999770527405e-02, 4.510000318874277e-02, 4.600000008940697e-02, 4.689999699007116e-02, 4.78000024735399e-02, 4.869999937416857e-02, 4.960000485767281e-02, 5.050000175833702e-02, 5.139999493371092e-02, 5.230000041721517e-02, 5.319999731784385e-02, 5.410000280138363e-02, 5.499999970197678e-02] diff --git a/Buildings/Resources/Scripts/Dymola/Controls/OBC/CDL/Continuous/Validation/Derivative.mos b/Buildings/Resources/Scripts/Dymola/Controls/OBC/CDL/Continuous/Validation/Derivative.mos new file mode 100644 index 00000000000..89f9a9be598 --- /dev/null +++ b/Buildings/Resources/Scripts/Dymola/Controls/OBC/CDL/Continuous/Validation/Derivative.mos @@ -0,0 +1,3 @@ +simulateModel("Buildings.Controls.OBC.CDL.Continuous.Validation.Derivative", stopTime=10, method="Cvode", tolerance=1e-06, resultFile="Derivative"); +createPlot(id=1, position={15, 15, 761, 628}, y={"der1.y", "intWitRes.u", "der2.y"}, range={0.0, 20.0, -3.0, 3.0}, grid=true, subPlot=102, colors={{238,46,47}, {28,108,200}, {0,140,72}}, timeUnit="s"); +createPlot(id=1, position={15, 15, 761, 628}, y={"der1.T"}, range={0.0, 20.0, 0.0, 0.12}, grid=true, subPlot=101, colors={{28,108,200}}, timeUnit="s"); diff --git a/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.Controls.OBC.CDL.Continuous.Validation.Derivative.mos b/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.Controls.OBC.CDL.Continuous.Validation.Derivative.mos new file mode 100644 index 00000000000..5aeeaa9c03a --- /dev/null +++ b/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.Controls.OBC.CDL.Continuous.Validation.Derivative.mos @@ -0,0 +1,7 @@ +compareVars := + { + "der1.y", + "intWitRes.u", + "der2.y", + "der1.T" + }; diff --git a/Buildings/package.mo b/Buildings/package.mo index c82a4e57de6..3860b4a137d 100644 --- a/Buildings/package.mo +++ b/Buildings/package.mo @@ -298,9 +298,15 @@ to existing libraries: This is for #2865. -Buildings.Controls.OBC.CDL.Integers.AddParameter +Buildings.Controls.OBC.CDL.Continuous.Derivative - New block based on the discussion from ASHRAE Standard 231P Committee.
      + Created new block which is required for PID controller with gain scheduling.
      + This is for #3022. + + + Buildings.Controls.OBC.CDL.Integers.AddParameter + + Created new block based on the discussion from ASHRAE Standard 231P Committee.
      This is for #2876. @@ -10994,4 +11000,4 @@ requirements definition or providing feedback regarding the model applicability to solve specific problems.

      ")); -end Buildings; +end Buildings; \ No newline at end of file