From 39457d348ea447bbeaa748c77605523cb1da3612 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Mon, 26 Feb 2024 07:52:05 -0800 Subject: [PATCH 01/39] Added radiant heat port to EnergyPlus thermal zone (#3662) * Added radiant heat port to EnergyPlus thermal zone This is for #3659 * Reverted changes in userguide * Changed script setting to avoid numerical Jacobian This is required for the CI tests to pass, else BuildingsPy issues a warning because of the numerical Jacobian * Changed connection layout --- ..._0_Examples_SingleFamilyHouse_Radiator.txt | 18 ++ .../Examples/SingleFamilyHouse/Radiator.mos | 10 + ..._0.Examples.SingleFamilyHouse.Radiator.mos | 7 + .../BaseClasses/ThermalZoneAdapter.mo | 13 +- .../Examples/SingleFamilyHouse/Radiator.mo | 229 ++++++++++++++++++ .../Examples/SingleFamilyHouse/package.order | 1 + .../EnergyPlus_9_6_0/ThermalZone.mo | 150 ++++++++---- .../EnergyPlus_9_6_0/UsersGuide.mo | 20 +- 8 files changed, 395 insertions(+), 53 deletions(-) create mode 100644 Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_EnergyPlus_9_6_0_Examples_SingleFamilyHouse_Radiator.txt create mode 100644 Buildings/Resources/Scripts/Dymola/ThermalZones/EnergyPlus_9_6_0/Examples/SingleFamilyHouse/Radiator.mos create mode 100644 Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Radiator.mos create mode 100644 Buildings/ThermalZones/EnergyPlus_9_6_0/Examples/SingleFamilyHouse/Radiator.mo diff --git a/Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_EnergyPlus_9_6_0_Examples_SingleFamilyHouse_Radiator.txt b/Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_EnergyPlus_9_6_0_Examples_SingleFamilyHouse_Radiator.txt new file mode 100644 index 00000000000..0d462f34b7c --- /dev/null +++ b/Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_EnergyPlus_9_6_0_Examples_SingleFamilyHouse_Radiator.txt @@ -0,0 +1,18 @@ +last-generated=2024-02-15 +statistics-initialization= +{ + "nonlinear": "5, 1", + "numerical Jacobians": "0" +} +statistics-simulation= +{ + "linear": "0, 0, 0, 0, 0, 0", + "nonlinear": " ", + "number of continuous time states": "9", + "numerical Jacobians": "0" +} +time=[0e+00, 2.592e+05] +zon.TAir=[2.931499938964844e+02, 2.885162963867188e+02, 2.890038452148438e+02, 2.89100830078125e+02, 2.891073913574219e+02, 2.891145324707031e+02, 2.891228332519531e+02, 2.891190795898438e+02, 2.891273498535156e+02, 2.940575561523438e+02, 2.951323852539062e+02, 2.953233032226562e+02, 2.952467651367188e+02, 2.952141723632812e+02, 2.952002258300781e+02, 2.951759033203125e+02, 2.951660461425781e+02, 2.951304321289062e+02, 2.951582946777344e+02, 2.951387023925781e+02, 2.951582641601562e+02, 2.951255187988281e+02, 2.951250305175781e+02, 2.95108154296875e+02, 2.951278076171875e+02, 2.951482849121094e+02, 2.907836608886719e+02, 2.888636169433594e+02, 2.887982482910156e+02, 2.890688171386719e+02, 2.890606689453125e+02, 2.890933837890625e+02, 2.891238708496094e+02, 2.89104736328125e+02, 2.891547241210938e+02, 2.891677856445312e+02, 2.890784912109375e+02, 2.891388854980469e+02, 2.891366577148438e+02, 2.891101989746094e+02, 2.890399780273438e+02, 2.890972900390625e+02, 2.919660034179688e+02, 2.930552368164062e+02, 2.941284790039062e+02, 2.950075988769531e+02, 2.95282958984375e+02, 2.952221069335938e+02, 2.95188720703125e+02, 2.952179870605469e+02, 2.952081604003906e+02, 2.952047729492188e+02, 2.951769104003906e+02, 2.951874389648438e+02, 2.951422119140625e+02, 2.951116943359375e+02, 2.950827941894531e+02, 2.950376281738281e+02, 2.951556396484375e+02, 2.919762878417969e+02, 2.896281127929688e+02, 2.886056823730469e+02, 2.8899365234375e+02, 2.890379028320312e+02, 2.890559692382812e+02, 2.892391052246094e+02, 2.891265258789062e+02, 2.891060791015625e+02, 2.891162719726562e+02, 2.891158142089844e+02, 2.891070556640625e+02, 2.890746154785156e+02, 2.891533813476562e+02, 2.892048950195312e+02, 2.891974487304688e+02, 2.891836853027344e+02, 2.934359130859375e+02, 2.948109741210938e+02, 2.955402526855469e+02, 2.952570190429688e+02, 2.952168884277344e+02, 2.951921997070312e+02, 2.951782836914062e+02, 2.951735534667969e+02, 2.951912841796875e+02, 2.952297973632812e+02, 2.951537170410156e+02, 2.951480712890625e+02, 2.951318359375e+02, 2.950791625976562e+02, 2.951258850097656e+02, 2.951843872070312e+02, 2.932949829101562e+02, 2.89701904296875e+02, 2.885221862792969e+02, 2.890930480957031e+02, 2.890812683105469e+02, 2.8910498046875e+02, 2.891055908203125e+02, 2.891153564453125e+02, 2.891221313476562e+02] +building.weaBus.TDryBul=[2.609500122070312e+02, 2.608753967285156e+02, 2.61153564453125e+02, 2.615419921875e+02, 2.619866027832031e+02, 2.620587158203125e+02, 2.62211181640625e+02, 2.625499877929688e+02, 2.625499877929688e+02, 2.625499877929688e+02, 2.625875549316406e+02, 2.630865173339844e+02, 2.637460632324219e+02, 2.650023803710938e+02, 2.665859985351562e+02, 2.678099975585938e+02, 2.690339965820312e+02, 2.701971740722656e+02, 2.709069213867188e+02, 2.718607788085938e+02, 2.720499877929688e+02, 2.720499877929688e+02, 2.720499877929688e+02, 2.720499877929688e+02, 2.719675598144531e+02, 2.714500122070312e+02, 2.71072998046875e+02, 2.71330810546875e+02, 2.720211181640625e+02, 2.714658508300781e+02, 2.718775329589844e+02, 2.719024353027344e+02, 2.714362182617188e+02, 2.714799194335938e+02, 2.704067077636719e+02, 2.693314514160156e+02, 2.703369750976562e+02, 2.699765930175781e+02, 2.69929931640625e+02, 2.7044189453125e+02, 2.718394165039062e+02, 2.720597534179688e+02, 2.721641845703125e+02, 2.725382080078125e+02, 2.72480224609375e+02, 2.727900085449219e+02, 2.732219848632812e+02, 2.736539916992188e+02, 2.744635620117188e+02, 2.748500061035156e+02, 2.748500061035156e+02, 2.748500061035156e+02, 2.742786560058594e+02, 2.729716186523438e+02, 2.725348205566406e+02, 2.732835083007812e+02, 2.73848876953125e+02, 2.737291564941406e+02, 2.726629028320312e+02, 2.730917358398438e+02, 2.738507690429688e+02, 2.742042541503906e+02, 2.746334838867188e+02, 2.75053955078125e+02, 2.753359069824219e+02, 2.733910522460938e+02, 2.731499938964844e+02, 2.731499938964844e+02, 2.731499938964844e+02, 2.731499938964844e+02, 2.733664245605469e+02, 2.737350158691406e+02, 2.733141784667969e+02, 2.725339965820312e+02, 2.717420043945312e+02, 2.709500122070312e+02, 2.701579895019531e+02, 2.697578430175781e+02, 2.697198181152344e+02, 2.688186950683594e+02, 2.686510009765625e+02, 2.688980407714844e+02, 2.692734069824219e+02, 2.697075805664062e+02, 2.701607055664062e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02, 2.703500061035156e+02] +TSet.y=[2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.951499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02, 2.891499938964844e+02] +val.y=[0e+00, 5.328106284141541e-01, 5.427585244178772e-01, 5.813263654708862e-01, 6.176857948303223e-01, 6.515731811523438e-01, 6.75459086894989e-01, 7.038198113441467e-01, 7.234554886817932e-01, 1e+00, 9.996036887168884e-01, 8.581473827362061e-01, 7.536557912826538e-01, 6.896372437477112e-01, 6.528612971305847e-01, 6.162166595458984e-01, 5.968593955039978e-01, 6.195003986358643e-01, 6.24418318271637e-01, 6.361110806465149e-01, 6.397660970687866e-01, 6.589826345443726e-01, 6.896765828132629e-01, 7.24882960319519e-01, 7.419304251670837e-01, 7.469165325164795e-01, 0e+00, 9.521432220935822e-02, 5.492333173751831e-01, 5.926982760429382e-01, 6.57970130443573e-01, 7.21432626247406e-01, 7.484580278396606e-01, 7.801234126091003e-01, 7.514259815216064e-01, 7.17662513256073e-01, 7.679747343063354e-01, 7.94197678565979e-01, 8.002633452415466e-01, 8.285678625106812e-01, 9.048248529434204e-01, 9.756938219070435e-01, 1e+00, 1e+00, 1e+00, 1e+00, 9.154705405235291e-01, 8.268867135047913e-01, 7.845022082328796e-01, 7.403280138969421e-01, 6.82828426361084e-01, 6.43625020980835e-01, 5.978256464004517e-01, 5.667576193809509e-01, 5.605658292770386e-01, 5.857276916503906e-01, 6.447668671607971e-01, 6.902087926864624e-01, 7.210708260536194e-01, 0e+00, 0e+00, 2.947166264057159e-01, 6.067448258399963e-01, 7.054827809333801e-01, 7.894452214241028e-01, 7.74444580078125e-01, 7.524481415748596e-01, 7.924646735191345e-01, 8.231828808784485e-01, 8.537617325782776e-01, 8.853533267974854e-01, 9.514594674110413e-01, 9.692603349685669e-01, 9.287818670272827e-01, 8.831746578216553e-01, 8.518074750900269e-01, 1e+00, 1e+00, 8.335460424423218e-01, 7.443306446075439e-01, 6.778441667556763e-01, 6.384000778198242e-01, 6.112334728240967e-01, 5.90678334236145e-01, 5.801072120666504e-01, 5.407183170318604e-01, 5.404146909713745e-01, 5.379185676574707e-01, 5.497285127639771e-01, 5.75802743434906e-01, 6.210174560546875e-01, 6.712750792503357e-01, 0e+00, 0e+00, 3.788963556289673e-01, 5.395563244819641e-01, 6.111312508583069e-01, 6.552678346633911e-01, 6.954297423362732e-01, 7.27879524230957e-01, 7.543732523918152e-01] diff --git a/Buildings/Resources/Scripts/Dymola/ThermalZones/EnergyPlus_9_6_0/Examples/SingleFamilyHouse/Radiator.mos b/Buildings/Resources/Scripts/Dymola/ThermalZones/EnergyPlus_9_6_0/Examples/SingleFamilyHouse/Radiator.mos new file mode 100644 index 00000000000..75da8392542 --- /dev/null +++ b/Buildings/Resources/Scripts/Dymola/ThermalZones/EnergyPlus_9_6_0/Examples/SingleFamilyHouse/Radiator.mos @@ -0,0 +1,10 @@ +// Change the setting for automatic differentiation. +// Without this change, the model has a numerical Jacobian, +// and BuildingsPy flags this as a problem in the CI test, +// which causes them to fail. +ori = Advanced.AllowNumericDifferentiation; +Advanced.AllowNumericDifferentiation = true; +simulateModel("Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Radiator", stopTime=259200, method="Cvode", tolerance=1e-06, resultFile="Radiator"); +createPlot(id=1, position={44, 37, 1046, 619}, y={"zon.TAir", "building.weaBus.TDryBul", "TSet.y"}, range={0.0, 260000.0, -15.0, 25.0}, grid=true, subPlot=101, colors={{28,108,200}, {238,46,47}, {0,140,72}}, timeUnit="s", displayUnits={"degC", "degC", "degC"}); +createPlot(id=1, position={44, 37, 1046, 619}, y={"val.y"}, range={0.0, 260000.0, -0.2, 1.2}, grid=true, subPlot=102, colors={{28,108,200}}, timeUnit="s"); +Advanced.AllowNumericDifferentiation = ori; diff --git a/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Radiator.mos b/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Radiator.mos new file mode 100644 index 00000000000..c1693a3b7f9 --- /dev/null +++ b/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Radiator.mos @@ -0,0 +1,7 @@ +compareVars := + { + "zon.TAir", + "building.weaBus.TDryBul", + "TSet.y", + "val.y" + }; diff --git a/Buildings/ThermalZones/EnergyPlus_9_6_0/BaseClasses/ThermalZoneAdapter.mo b/Buildings/ThermalZones/EnergyPlus_9_6_0/BaseClasses/ThermalZoneAdapter.mo index 11adba28047..ac79939929b 100644 --- a/Buildings/ThermalZones/EnergyPlus_9_6_0/BaseClasses/ThermalZoneAdapter.mo +++ b/Buildings/ThermalZones/EnergyPlus_9_6_0/BaseClasses/ThermalZoneAdapter.mo @@ -150,7 +150,9 @@ protected "Last time of data exchange"; discrete Modelica.Units.SI.Time dtLast "Time step since the last synchronization"; - discrete Modelica.Units.SI.MassFlowRate mInlet_flow + discrete Modelica.Units.SI.MassFlowRate mInlet_flow( + start=0, + fixed=true) "Time averaged inlet mass flow rate"; discrete Modelica.Units.SI.Temperature TAveInlet "Time averaged inlet temperature"; @@ -231,7 +233,7 @@ equation adapter=adapter, initialCall=false, nY=nY, - u={T,X_w/(1.-X_w),mInlet_flow,TAveInlet,QGaiRad_flow,round(time,1E-3)}, + u={T,X_w/(1.-X_w),pre(mInlet_flow),TAveInlet,pre(QGaiRad_flow),round(time,1E-3)}, dummy=AFlo); TRad=yEP[1]; QConLast_flow=yEP[2]; @@ -264,6 +266,13 @@ of its class adapter, of EnergyPlus. revisions="