Coverage for bim2sim/plugins/PluginTEASER/bim2sim_teaser/task/load_modelica_results.py: 0%
17 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
1import json
2import re
3from pathlib import Path
5from ebcpy import DymolaAPI
7import bim2sim
8from bim2sim.tasks.base import ITask
11class LoadModelicaResults(ITask):
12 """Load existing results, run() method holds detailed information."""
13 touches = ('bldg_names', 'sim_results_path')
15 def run(self):
16 """Loads existing Modelica results from a previous simulation.
18 The .mat file from a previous simulation is loaded and stored in the
19 playground state. The intended behaviour is that for the following
20 tasks with post-processing and plotting there should be no difference
21 if a total bim2sim plugin run is performed or the existing results are
22 loaded.
24 Returns:
25 bldg_names: list of building names
26 sim_results_path: path where to store the plots
27 """
28 teaser_mat_result_paths = {}
29 regex = re.compile("[^a-zA-z0-9]")
30 model_export_name = regex.sub("", self.prj_name)
31 model_dir = self.paths.export / 'TEASER' / 'Model' / model_export_name
32 sub_dirs = [item for item in model_dir.iterdir() if
33 item.is_dir() and item.name != "Resources"]
34 sim_results_path = (self.paths.export / 'TEASER' / 'SimResults' /
35 model_export_name)
36 # load bldg names via directory structure and store them
37 bldg_names = [sub_dir.name for sub_dir in sub_dirs]
38 return bldg_names, sim_results_path