Skip to content

Commit

Permalink
Upgraded to Spawn 0.4.3
Browse files Browse the repository at this point in the history
This integrates #3209, #3481, and #3487 which corrects the heat capacitance multiplier
  • Loading branch information
mwetter committed Aug 29, 2023
1 parent fe949ea commit d8c44b4
Show file tree
Hide file tree
Showing 12 changed files with 2,084 additions and 22 deletions.

Large diffs are not rendered by default.

Git LFS file not shown
Git LFS file not shown
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
last-generated=2023-08-29
statistics-simulation=
{
"linear": "0, 0",
"nonlinear": " ",
"number of continuous time states": "6",
"numerical Jacobians": "0"
}
time=[0e+00, 4.32e+05]
defCap.zon.TAir=[2.931499938964844e+02, 2.851262817382812e+02, 2.829358520507812e+02, 2.810980224609375e+02, 2.794590148925781e+02, 2.779721069335938e+02, 2.765988159179688e+02, 2.768757934570312e+02, 2.784107055664062e+02, 2.797267456054688e+02, 2.80322998046875e+02, 2.804461975097656e+02, 2.806386413574219e+02, 2.802711486816406e+02, 2.796155395507812e+02, 2.789898986816406e+02, 2.783244018554688e+02, 2.7788671875e+02, 2.773622436523438e+02, 2.768299560546875e+02, 2.763008422851562e+02, 2.761153869628906e+02, 2.758070678710938e+02, 2.753749389648438e+02, 2.752128295898438e+02, 2.750193481445312e+02, 2.753028869628906e+02, 2.767030334472656e+02, 2.776649475097656e+02, 2.786033325195312e+02, 2.796157531738281e+02, 2.804749145507812e+02, 2.810079345703125e+02, 2.8121044921875e+02, 2.809478759765625e+02, 2.798797912597656e+02, 2.788085632324219e+02, 2.785285339355469e+02, 2.783365173339844e+02, 2.779616394042969e+02, 2.775796813964844e+02, 2.772979736328125e+02, 2.770599975585938e+02, 2.768825378417969e+02, 2.765175170898438e+02, 2.760656433105469e+02, 2.759440612792969e+02, 2.774949035644531e+02, 2.782390441894531e+02, 2.790961303710938e+02, 2.798348083496094e+02, 2.804661560058594e+02, 2.810580749511719e+02, 2.812132568359375e+02, 2.806531982421875e+02, 2.794320678710938e+02, 2.780961303710938e+02, 2.775421447753906e+02, 2.770378112792969e+02, 2.765709228515625e+02, 2.761454467773438e+02, 2.757478942871094e+02, 2.753711547851562e+02, 2.749943542480469e+02, 2.746211242675781e+02, 2.7430029296875e+02, 2.744634399414062e+02, 2.760703735351562e+02, 2.76943359375e+02, 2.779093322753906e+02, 2.78795166015625e+02, 2.795382080078125e+02, 2.801758117675781e+02, 2.803643188476562e+02, 2.79830810546875e+02, 2.784895935058594e+02, 2.769479064941406e+02, 2.763331604003906e+02, 2.75794189453125e+02, 2.750719299316406e+02, 2.742784729003906e+02, 2.736675109863281e+02, 2.731570739746094e+02, 2.724647521972656e+02, 2.714243469238281e+02, 2.702768859863281e+02, 2.697936096191406e+02, 2.719630432128906e+02, 2.743087463378906e+02, 2.765023498535156e+02, 2.783991394042969e+02, 2.80380126953125e+02, 2.822745056152344e+02, 2.826520690917969e+02, 2.818184814453125e+02, 2.803402404785156e+02, 2.78725341796875e+02, 2.776202697753906e+02, 2.765147094726562e+02, 2.754969482421875e+02, 2.74457275390625e+02]
mulCap.zon.TAir=[2.931499938964844e+02, 2.901801452636719e+02, 2.878099060058594e+02, 2.858500061035156e+02, 2.841411743164062e+02, 2.82617919921875e+02, 2.812156677246094e+02, 2.802545776367188e+02, 2.802074279785156e+02, 2.806913757324219e+02, 2.811638793945312e+02, 2.813619079589844e+02, 2.81478271484375e+02, 2.814356079101562e+02, 2.811454467773438e+02, 2.807387084960938e+02, 2.802452392578125e+02, 2.797724304199219e+02, 2.793012084960938e+02, 2.788330993652344e+02, 2.783436584472656e+02, 2.779898681640625e+02, 2.7761181640625e+02, 2.77216796875e+02, 2.768719787597656e+02, 2.765925598144531e+02, 2.763144836425781e+02, 2.765950012207031e+02, 2.771602478027344e+02, 2.777705383300781e+02, 2.784269409179688e+02, 2.790382080078125e+02, 2.796630249023438e+02, 2.801434326171875e+02, 2.804087524414062e+02, 2.801987609863281e+02, 2.796959838867188e+02, 2.793279724121094e+02, 2.790463562011719e+02, 2.787887268066406e+02, 2.784790344238281e+02, 2.781929626464844e+02, 2.779309997558594e+02, 2.777093200683594e+02, 2.774600830078125e+02, 2.771562194824219e+02, 2.767743530273438e+02, 2.769820861816406e+02, 2.77444580078125e+02, 2.779723510742188e+02, 2.785379333496094e+02, 2.79044189453125e+02, 2.796152038574219e+02, 2.800380554199219e+02, 2.802044372558594e+02, 2.7988330078125e+02, 2.792446594238281e+02, 2.787008056640625e+02, 2.782141723632812e+02, 2.777630004882812e+02, 2.773437194824219e+02, 2.769508972167969e+02, 2.765784912109375e+02, 2.762223510742188e+02, 2.7586669921875e+02, 2.755321350097656e+02, 2.752040710449219e+02, 2.754908142089844e+02, 2.760677795410156e+02, 2.766786193847656e+02, 2.773230895996094e+02, 2.779150390625e+02, 2.785517578125e+02, 2.790576782226562e+02, 2.792750244140625e+02, 2.789417114257812e+02, 2.782402954101562e+02, 2.776216125488281e+02, 2.770839233398438e+02, 2.765354919433594e+02, 2.759389038085938e+02, 2.753435363769531e+02, 2.748053894042969e+02, 2.742614440917969e+02, 2.736067199707031e+02, 2.728003540039062e+02, 2.719323425292969e+02, 2.719732666015625e+02, 2.729637145996094e+02, 2.744046325683594e+02, 2.758733825683594e+02, 2.773244934082031e+02, 2.789284973144531e+02, 2.800907897949219e+02, 2.804609985351562e+02, 2.801529846191406e+02, 2.7941064453125e+02, 2.786497497558594e+02, 2.778502197265625e+02, 2.770368347167969e+02, 2.762350158691406e+02]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
simulateModel("Buildings.ThermalZones.EnergyPlus_9_6_0.Validation.ThermalZone.ZoneCapacitanceMultiplier", stopTime=432000, method="Cvode", tolerance=1e-06, resultFile="ZoneCapacitanceMultiplier");
createPlot(id=1,
position={55, 55, 592, 371},
y={"defCap.zon.TAir", "mulCap.zon.TAir"},
range={0.0, 450000.0, -5.0, 25.0},
grid=true,
colors={{28,108,200}, {238,46,47}},
timeUnit="s",
displayUnits={"degC", "degC"});

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compareVars :=
{
"defCap.zon.TAir",
"mulCap.zon.TAir"
};
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def print_output(typ, stream):
def run_test(pathVariable):
# List of files to be moved
fileMoves = [
{"src": os.path.abspath(os.path.join("Buildings", "Resources", "bin", "spawn-0.3.0-0fa49be497", "linux64")),
{"src": os.path.abspath(os.path.join("Buildings", "Resources", "bin", "spawn-0.4.3-7048a72798", "linux64")),
"des": "my-bin"},
{"src": os.path.abspath(os.path.join("Buildings", "Resources", "weatherdata")),
"des": "some_weather_directory_that_the_fmu_does_not_know_about"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ void generateFMU(FMUBuilding* bui, const char* spawnFullPath, const char* modeli
/* Generate the FMU */
char* optionFlags;
char* outputFlag;
char* createFlag;
char* fulCmd;
int retVal;
size_t len;
Expand All @@ -545,12 +544,11 @@ void generateFMU(FMUBuilding* bui, const char* spawnFullPath, const char* modeli
SpawnFormatError("Requested to use json file '%s' which does not exist.", modelicaBuildingsJsonFile);
}

optionFlags = " --no-compress "; /* Flag for command */
outputFlag = " --output-path "; /* Flag for command */
createFlag = " --create "; /* Flag for command */
optionFlags = " energyplus create-fmu "; /* Flag for command */
outputFlag = " --output-path "; /* Flag for command */
len = strlen("\"") + strlen(spawnFullPath) + strlen("\"") + strlen(optionFlags)
+ strlen(outputFlag) + strlen("\"") + strlen(bui->fmuAbsPat) + strlen("\"")
+ strlen(createFlag) + strlen("\"") + strlen(modelicaBuildingsJsonFile) + strlen("\"")
+ strlen(outputFlag) + strlen("\"") + strlen(bui->fmuAbsPat) + strlen("\" ")
+ strlen("\"") + strlen(modelicaBuildingsJsonFile) + strlen("\"")
+ 1;
#ifdef _WIN32 /* Win32 or Win64 */
/* Windows needs double quotes in the system call, see https://stackoverflow.com/questions/2642551/windows-c-system-call-with-spaces-in-command */
Expand All @@ -572,8 +570,7 @@ void generateFMU(FMUBuilding* bui, const char* spawnFullPath, const char* modeli
strcat(fulCmd, outputFlag);
strcat(fulCmd, "\"");
strcat(fulCmd, bui->fmuAbsPat);
strcat(fulCmd, "\"");
strcat(fulCmd, createFlag);
strcat(fulCmd, "\" ");
strcat(fulCmd, "\"");
strcat(fulCmd, modelicaBuildingsJsonFile);
strcat(fulCmd, "\"");
Expand Down
18 changes: 9 additions & 9 deletions Buildings/Resources/src/ThermalZones/EnergyPlus_9_6_0/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# List of all spawn versions and commits that are supported
# by the Buildings library
spawn_dists = [
{"version": "0.3.0",
"commit": "0fa49be49715a5acc87f078ba583e369d435cdf9"}
{"version": "0.4.3",
"commit": "7048a72798"}
]
###########################################################################

Expand Down Expand Up @@ -95,7 +95,7 @@ def delete_installers(dis):
tar_fil = os.path.basename(dis["src"])
os.remove(tar_fil)

def get_vars_as_json(spawnFlag, spawn_dir, spawn_exe):
def get_vars_as_json(spawnFlags, spawn_dir, spawn_exe):
"""Return a json structure that contains the output variables supported by spawn"""
import os
import subprocess
Expand All @@ -104,9 +104,9 @@ def get_vars_as_json(spawnFlag, spawn_dir, spawn_exe):
bin_dir = get_bin_directory()
spawn = os.path.join(bin_dir, spawn_dir, "linux64", "bin", spawn_exe)

ret = subprocess.run([spawn, spawnFlag], stdout=subprocess.PIPE, check=True)
ret = subprocess.run([spawn] + spawnFlags.split(' '), stdout=subprocess.PIPE, check=True)
vars = json.loads(ret.stdout)
if spawnFlag == "--output-vars":
if spawnFlags == "energyplus list-output-variables":
vars = sorted(vars, key = lambda i: i['name'])
else:
vars = sorted(vars, key = lambda i: (i['componentType'], i['controlType']))
Expand Down Expand Up @@ -220,20 +220,20 @@ def update_version_in_modelica_files(spawn_dir, spawn_exe):
def update_actuator_output_tables(spawn_dir, spawn_exe):
vars = [
{
"spawnFlag": "--output-vars",
"spawnFlags": "energyplus list-output-variables",
"htmlTemplate": "output_vars_template.html",
"varType": "output variables",
"moFile": "OutputVariable.mo"
},
{
"spawnFlag": "--actuators",
"spawnFlags": "energyplus list-actuators",
"htmlTemplate": "actuators_template.html",
"varType": "actuators",
"moFile": "Actuator.mo"
},
]
for v in vars:
js = get_vars_as_json(v["spawnFlag"], spawn_dir, spawn_exe)
js = get_vars_as_json(v["spawnFlags"], spawn_dir, spawn_exe)
html = get_html_table(js, v["htmlTemplate"])
replace_table_in_mo(html, v["varType"], v["moFile"], spawn_dir)

Expand Down Expand Up @@ -313,7 +313,7 @@ def update_actuator_output_tables(spawn_dir, spawn_exe):
}
)

p = Pool(2)
p = Pool(len(dists))
p.map(download_distribution, dists)
for dist in dists:
install_distribution_inside_buildings_library(dist)
Expand Down
4 changes: 2 additions & 2 deletions Buildings/ThermalZones/EnergyPlus_9_6_0/Building.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ model Building
"Model that declares a building to which EnergyPlus objects belong to"
extends Modelica.Blocks.Icons.Block;

constant String spawnExe="spawn-0.3.0-0fa49be497"
"Name of the spawn executable, without extension, such as spawn-0.3.0-0fa49be497aaa"
constant String spawnExe="spawn-0.4.3-7048a72798"
"Name of the spawn executable, without extension, such as spawn-0.4.3-7048a72798aaa"
annotation (HideResult=true);

constant String idfVersion = "9_6_0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
within Buildings.ThermalZones.EnergyPlus_9_6_0.Validation.ThermalZone;
model ZoneCapacitanceMultiplier
"Validation model for zone capacitance multiplier in Spawn"
extends Modelica.Icons.Example;
Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Unconditioned defCap
"Default capacitance"
annotation (Placement(transformation(extent={{-10,20},{10,40}})));
Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Unconditioned mulCap(
building(
idfName=Modelica.Utilities.Files.loadResource(
"modelica://Buildings/Resources/Data/ThermalZones/EnergyPlus_9_6_0/Examples/SingleFamilyHouse_TwoSpeed_ZoneAirBalance/SingleFamilyHouse_TwoSpeed_ZoneAirBalance_zoneCapacitanceMultiplier.idf")))
"Capacitance with a multiplier of 10"
annotation (Placement(transformation(extent={{-10,-40},{10,-20}})));
annotation (
Documentation(
info="<html>
<p>
This validation case simulates two instances of
<a href=\"modelica://Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Unconditioned\">
Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.Unconditioned</a>.
In the instance <code>mulCap</code>, the case is modified by adding
the following snippet to the idf file:
</p>
<pre>
ZoneCapacitanceMultiplier:ResearchSpecial,
Living zone heat capacitance multiplier, !- Name
LIVING ZONE, !- Zone or ZoneList Name
10, !- Temperature Capacity Multiplier
, !- Humidity Capacity Multiplier
, !- Carbon Dioxide Capacity Multiplier
; !- Generic Contaminant Capacity Multiplier
</pre>
<p>
This model is to validate that this leads to a difference in the simulation
results as expected.
</p>
</html>",
revisions="<html>
<ul>
<li>
August 23, 2023, by Hongxiang Fu:<br/>
First implementation. This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3481\">#3481</a>.
</li>
</ul>
</html>"),
__Dymola_Commands(
file="modelica://Buildings/Resources/Scripts/Dymola/ThermalZones/EnergyPlus_9_6_0/Validation/ThermalZone/ZoneCapacitanceMultiplier.mos" "Simulate and plot"),
experiment(
StopTime=432000,
Tolerance=1e-06));
end ZoneCapacitanceMultiplier;
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ OneZoneCompareZoneTemperatureOutput
OneZoneOneYear
RefBldgSmallOffice
TwoIdenticalZones
ZoneCapacitanceMultiplier
ZoneTemperatureInitialization

0 comments on commit d8c44b4

Please sign in to comment.