Skip to content

Commit

Permalink
Option to export reference results
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusfuchs committed Dec 7, 2020
1 parent bca0fb2 commit 2cbf79b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
27 changes: 27 additions & 0 deletions teaser/data/output/aixlib_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,38 @@ def export_multizone(buildings, prj, path=None):
extra=None)

_copy_script_unit_tests(os.path.join(dir_scripts, "runUnitTests.py"))
_copy_reference_results(dir_resources, prj)

print("Exports can be found here:")
print(path)


def _copy_reference_results(dir_resources, prj):
"""Copy reference results to modelica output.
Parameters
----------
dir_resources : str
Resources directory of the modelica output
prj : teaser.project.Project
Project to be exported
"""

if prj.dir_reference_results is not None:
dir_ref_out = os.path.join(dir_resources, "ReferenceResults")
if not os.path.exists(dir_ref_out):
os.mkdir(dir_ref_out)
dir_ref_out_dymola = os.path.join(dir_ref_out, "Dymola")
if not os.path.exists(dir_ref_out_dymola):
os.mkdir(dir_ref_out_dymola)
for filename in os.listdir(prj.dir_reference_results):
if filename.endswith(".txt"):
shutil.copy2(
os.path.join(prj.dir_reference_results, filename),
os.path.join(dir_ref_out_dymola, filename)
)


def _help_test_script(bldg, dir_dymola, test_script_template):
"""Create a test script for regression testing with BuildingsPy
Expand Down
1 change: 1 addition & 0 deletions teaser/examples/e2_export_aixlib_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def example_export_aixlib():
# buildings to get this Project we rerun this example

prj = e1.example_generate_archetype()
prj.dir_reference_results = utilities.get_full_path("data/output/modelicatemplate")

# To make sure the export is using the desired parameters you should
# always set model settings in the Project.
Expand Down
6 changes: 6 additions & 0 deletions teaser/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class Project(object):
IBPSA)
used_library_calc : str
used library (AixLib and IBPSA are supported)
dir_reference_results : str
Path to reference results in BuildingsPy format. If not None, the results
will be copied into the model output directories so that the exported
models can be regression tested against these results with BuildingsPy.
"""

def __init__(self, load_data=False):
Expand Down Expand Up @@ -117,6 +121,8 @@ def __init__(self, load_data=False):
else:
self.data = None

self.dir_reference_results = None

@staticmethod
def instantiate_data_class():
"""Initialization of DataClass
Expand Down

0 comments on commit 2cbf79b

Please sign in to comment.