Merge branch 'release/v1.0.4'

This commit is contained in:
unknown 2020-08-05 14:41:45 -04:00
commit 8ba59e7a54
4 changed files with 19678 additions and 9 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1307,8 +1307,11 @@ def test_trnbuild_from_simple_idf(config):
window_file = "W74-lib.dat" window_file = "W74-lib.dat"
template_dir = os.path.join("translater", "ressources") template_dir = os.path.join("translater", "ressources")
window_filepath = os.path.join(template_dir, window_file) window_filepath = os.path.join(template_dir, window_file)
# weather_file = os.path.join(
# "tests", "input_data", "CAN_QC_Montreal-McTavish.716120_CWEC2016.epw"
# )
weather_file = os.path.join( weather_file = os.path.join(
"tests", "input_data", "CAN_QC_Montreal-McTavish.716120_CWEC2016.epw" "tests", "input_data", "USA_NY_Buffalo.Niagara.Intl.AP.725280_TMY3.epw"
) )
# prepare args (key=value)f or EnergyPlus version to use, windows parameters,etc. # prepare args (key=value)f or EnergyPlus version to use, windows parameters,etc.
@ -1325,7 +1328,8 @@ def test_trnbuild_from_simple_idf(config):
} }
# Path to IDF file # Path to IDF file
file = os.path.join("tests", "input_data", "trnsys", "simple_2_zone.idf") # file = os.path.join("tests", "input_data", "trnsys", "simple_2_zone.idf")
file = os.path.join("tests", "input_data", "ASHRAE90.1_OfficeLarge_STD2016_Buffalo.idf")
# Converts IDF to BUI # Converts IDF to BUI
convert_idf_to_trnbuild( convert_idf_to_trnbuild(
@ -1334,6 +1338,6 @@ def test_trnbuild_from_simple_idf(config):
window_lib=window_filepath, window_lib=window_filepath,
template="tests/input_data/trnsys/NewFileTemplate.d18", template="tests/input_data/trnsys/NewFileTemplate.d18",
trnsidf_exe="docker/trnsidf/trnsidf.exe", trnsidf_exe="docker/trnsidf/trnsidf.exe",
schedule_as_input=False, schedule_as_input=True,
**kwargs_dict **kwargs_dict
) )

View File

@ -6,13 +6,13 @@
################################################################################ ################################################################################
# Version of the package # Version of the package
__version__ = "1.0.3" __version__ = "1.0.4"
# warn if a newer version of translater is available # warn if a newer version of translater is available
from outdated import warn_if_outdated from outdated import warn_if_outdated
from .utils import warn_if_not_compatible from .utils import warn_if_not_compatible
# warn_if_outdated("translater", __version__) warn_if_outdated("translater", __version__)
warn_if_not_compatible() warn_if_not_compatible()
from .utils import * from .utils import *

View File

@ -448,6 +448,10 @@ def convert_idf_to_trnbuild(
# T initial to b18 # T initial to b18
t_initial_to_b18(b18_lines, zones, schedules) t_initial_to_b18(b18_lines, zones, schedules)
if schedule_as_input:
# Reduce number of schedules written as Inputs
reduce_schedule(b18_lines, lines, schedule_names)
# Save B18 file at output_folder # Save B18 file at output_folder
if output_folder is None: if output_folder is None:
# User did not provide an output folder path. We use the default setting # User did not provide an output folder path. We use the default setting
@ -462,6 +466,40 @@ def convert_idf_to_trnbuild(
return return_path return return_path
def reduce_schedule(b18_lines, lines, schedule_names):
name_to_delete = []
count = checkStr(b18_lines, "INPUTS_DESCRIPTION")
# Search schedule names that are not used in the b18 file
for name in schedule_names:
bool_list = [name in line for line in b18_lines[count:]]
if not any(bool_list):
name_to_delete.append(name)
# Delete the unused schedule names from the "INPUTS" line (in the T3D lines)
input_count = checkStr(lines, "I n p u t s")
input_descr_count = checkStr(lines, "INPUTS_DESCRIPTION")
input_lines = lines[input_count + 1 : input_descr_count-1]
for idx, line in enumerate(input_lines):
removed = []
for name in name_to_delete:
if name in line:
input_lines[idx] = line.replace(name, "")
removed.append(name)
for rmv_name in removed:
name_to_delete.remove(rmv_name)
# Remove "INPUTS" line from b18_lines and insert the "input_lines" from T3D file
# From where we just deleted the unused schedule names
del b18_lines[count - 2]
input_lines.reverse()
for line in input_lines:
line = line.replace(" ", " ")
line = line.replace(" ;", ";")
line = line.replace("!-", "")
b18_lines.insert(count - 2, line)
def t_initial_to_b18(b18_lines, zones, schedules): def t_initial_to_b18(b18_lines, zones, schedules):
for zone in zones: for zone in zones:
t_ini = schedules["sch_h_setpoint_" + zone.Name]["all values"][0] t_ini = schedules["sch_h_setpoint_" + zone.Name]["all values"][0]
@ -1778,7 +1816,7 @@ def _write_zone_buildingSurf_fenestrationSurf(
# surface # surface
_relative_to_absolute(fenestrationSurf, incrX, incrY, incrZ) _relative_to_absolute(fenestrationSurf, incrX, incrY, incrZ)
# Round vertex to 4 decimal digit max # Round vertex to 2 decimal digit max
_round_vertex(fenestrationSurf) _round_vertex(fenestrationSurf)
# Polygon from vector's window surface # Polygon from vector's window surface
@ -1860,7 +1898,7 @@ def _write_zone_buildingSurf_fenestrationSurf(
) )
raise NotImplementedError(msg) raise NotImplementedError(msg)
# Round vertex to 4 decimal digit max # Round vertex to 2 decimal digit max
_round_vertex(buildingSurf) _round_vertex(buildingSurf)
# Makes sure idf object key is not all upper string # Makes sure idf object key is not all upper string
@ -1968,7 +2006,7 @@ def _inverse_vertices_surf(buildingSurf, idf, outside_bound_surf, idfobject_key)
] = buildingSurf["Vertex_" + str(k) + "_Zcoordinate"] ] = buildingSurf["Vertex_" + str(k) + "_Zcoordinate"]
def _round_vertex(surface, nbr_decimal=4): def _round_vertex(surface, nbr_decimal=2):
"""Round vertex to the number of decimal (nbr_decimal) wanted """Round vertex to the number of decimal (nbr_decimal) wanted
Args: Args: