Skip to content

Commit

Permalink
Order horizontal piping correctly between buildings (#679)
Browse files Browse the repository at this point in the history
* WIP: start putting pipe lengths in loop order

* put horizontal pipes in the correct loop order

* add comment and error message for users

* round result to 3 places when converting ft to m

* fix identifiers in test sys-param file

* update test cli geojson files to build loop order properly

* increase default central pump head for 5G systems
  • Loading branch information
vtnate authored Nov 26, 2024
1 parent f70eadb commit f4f0129
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 1,299 deletions.
49 changes: 34 additions & 15 deletions geojson_modelica_translator/model_connectors/districts/district.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class District:

def __init__(self, root_dir, project_name, system_parameters, coupling_graph, geojson_file=None):
self._scaffold = Scaffold(root_dir, project_name)
self.system_parameters = system_parameters
self.gj = geojson_file
self._coupling_graph = coupling_graph
self.system_parameters = system_parameters # SystemParameters object
self.gj = geojson_file # UrbanOptGeoJson object
self._coupling_graph = coupling_graph # CouplingGraph object
self.district_model_filepath = None
# Modelica can't handle spaces in project name or path
if (len(str(root_dir).split()) > 1) or (len(str(project_name).split()) > 1):
Expand Down Expand Up @@ -105,18 +105,37 @@ def to_modelica(self):
"data": loop_order,
}

if self.gj:
# get horizontal pipe lengths from geojson, starting from the outlet of the (first) ghe
# TODO: only check for total_length if type==ThermalConnector
# I thought this was the right syntax, but not quite: .properties[?type=ThermalConnector].total_length
# TODO: make sure the list of lengths is starting from the outlet of the ghe
list_of_pipe_lengths = self.gj.get_feature("$.features.[*].properties.total_length")
for i in range(len(list_of_pipe_lengths)):
list_of_pipe_lengths[i] = convert_ft_to_m(list_of_pipe_lengths[i])
common_template_params["globals"]["lDis"] = (
str(list_of_pipe_lengths[:-1]).replace("[", "{").replace("]", "}")
)
common_template_params["globals"]["lEnd"] = list_of_pipe_lengths[-1]
# This indent level requires the District to include a GHE, because the only way we get a loop_order
# is by running ThermalNetwork for sizing.
# TODO: determine loop order some other way, so thermal networks without GHEs can have horizontal piping
# or: Ensure TN is used for all networks, so loop order is generated that way.
if self.gj:
# get horizontal pipe lengths from geojson, starting from the beginning of the loop
feature_properties = self.gj.get_feature("$.features.[*].properties")
dict_of_pipe_lengths = {
feature_prop.get("startFeatureId"): feature_prop["total_length"]
for feature_prop in feature_properties
if feature_prop["type"] == "ThermalConnector"
}
ordered_feature_list = []
ordered_pipe_list = []
for loop in loop_order:
ordered_feature_list.extend(loop["list_bldg_ids_in_group"])
ordered_feature_list.extend(loop["list_ghe_ids_in_group"])

for feature in ordered_feature_list:
for dict_feature, pipe_length in dict_of_pipe_lengths.items():
if dict_feature == feature:
ordered_pipe_list.append(pipe_length)

for i in range(len(ordered_pipe_list)):
ordered_pipe_list[i] = convert_ft_to_m(ordered_pipe_list[i])
common_template_params["globals"]["lDis"] = (
str(ordered_pipe_list[:-1]).replace("[", "{").replace("]", "}")
)
common_template_params["globals"]["lEnd"] = ordered_pipe_list[-1]
else:
raise SystemExit("No geojson file provided, unable to determine thermal network loop order")

# render each coupling
load_num = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
]
},
"central_pump_parameters": {
"pump_design_head": 60000,
"pump_design_head": 200000,
"pump_flow_rate": 0.01
}
}
Expand Down
4 changes: 2 additions & 2 deletions geojson_modelica_translator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def convert_ft_to_m(f):
"""Converts a length in foot to meter
:param f: float, length in ft
:return: float, length in meter
:return: float, length in meters, to 3 decimal places
"""
return 0.3048 * f
return round(0.3048 * f, 3)


def linecount(filename: Path) -> int:
Expand Down
Loading

0 comments on commit f4f0129

Please sign in to comment.