Skip to content

Commit

Permalink
fix(district): Expose support for holes in GHE geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Nov 21, 2024
1 parent cfc3870 commit 468fd18
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
Binary file modified dragonfly_grasshopper/icon/DF GHE Thermal Loop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions dragonfly_grasshopper/json/DF_GHE_Thermal_Loop.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.1",
"version": "1.8.2",
"nickname": "GHELoop",
"outputs": [
[
Expand All @@ -17,7 +17,7 @@
"access": "list",
"name": "_ghe_geo",
"description": "Horizontal Rhino surfaces representing the footprints of ground heat\nexchangers. These ground heat exchanging fields contain the\nboreholes that supply the loop with thermal capacity. Multiple\nborehole fields can be located along the loop created by the\n_connector_geo.",
"type": "Curve",
"type": "Brep",
"default": null
},
{
Expand Down Expand Up @@ -78,7 +78,7 @@
}
],
"subcategory": "5 :: District Thermal",
"code": "\nimport math\n\ntry: # import the core honeybee dependencies\n from honeybee.typing import clean_ep_string\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the core dragonfly_energy dependencies\n from dragonfly_energy.des.connector import ThermalConnector\n from dragonfly_energy.des.ghe import GroundHeatExchanger\n from dragonfly_energy.des.loop import {{PLGN}}EThermalLoop\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_polyline2d\n from ladybug_{{cad}}.togeometry import to_polygon2d\n from ladybug_{{cad}}.config import angle_tolerance, conversion_to_meters\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, give_warning\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component):\n # set a default name\n name = clean_ep_string(_name_) if _name_ is not None else 'unnamed'\n\n # create the {{PLGN}}E fields and the Thermal Connectors\n lines = []\n for geo in _connector_geo:\n lines.append(to_polyline2d(geo))\n connectors = []\n for i, lin in enumerate(lines):\n connectors.append(ThermalConnector('{}_ThermalConnector_{}'.format(name, i), lin))\n ghes, total_area = [], 0\n for i, geo in enumerate(_ghe_geo):\n gp = to_polygon2d(geo)\n total_area += gp.area * conversion_to_meters()\n if not gp.is_rectangle(math.radians(angle_tolerance)):\n msg = 'The ground heat exchanger with index {} is not a perfect rectangle ' \\\n 'but it will be approximated as such in the DES simulation.'.format(i)\n print(msg)\n give_warning(ghenv.Component, msg)\n ghes.append(GroundHeatExchanger('{}_{{PLGN}}E_{}'.format(name, i), gp))\n\n # create the loop\n des_loop = {{PLGN}}EThermalLoop(name, ghes, connectors, _clockwise_,\n _soil_, _fluid_, _pipe_, _borehole_, _design_)\n if _name_ is not None:\n des_loop.display_name = _name_\n\n # give a warning about RAM if the size of the borehole field is too large\n borehole_count = int(total_area / (des_loop.borehole_parameters.min_spacing ** 2))\n MAX_BOREHOLES = 8000\n if borehole_count > MAX_BOREHOLES:\n msg = 'The inputs suggest that there may be as many as {} boreholes in the ' \\\n '{{PLGN}}E field\\nand this can cause the {{PLGN}}E sizing routine to use ' \\\n 'more than 10GB of memory.\\nA smaller _ghe_geo or a larger '\\\n '_bore_spacing_ is recommended such that fewer\\nthan {} boreholes are ' \\\n 'generated.'.format(borehole_count, MAX_BOREHOLES)\n print(msg)\n give_warning(ghenv.Component, msg)\n",
"code": "\nimport math\n\ntry: # import the core honeybee dependencies\n from honeybee.typing import clean_ep_string\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the core dragonfly_energy dependencies\n from dragonfly_energy.des.connector import ThermalConnector\n from dragonfly_energy.des.ghe import GroundHeatExchanger\n from dragonfly_energy.des.loop import {{PLGN}}EThermalLoop\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_polyline2d\n from ladybug_{{cad}}.togeometry import to_face3d\n from ladybug_{{cad}}.config import angle_tolerance, conversion_to_meters\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, give_warning\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component):\n # set a default name\n name = clean_ep_string(_name_) if _name_ is not None else 'unnamed'\n\n # create the {{PLGN}}E fields and the Thermal Connectors\n lines = []\n for geo in _connector_geo:\n lines.append(to_polyline2d(geo))\n connectors = []\n for i, lin in enumerate(lines):\n connectors.append(ThermalConnector('{}_ThermalConnector_{}'.format(name, i), lin))\n ghes, total_area = [], 0\n for i, geo in enumerate(_ghe_geo):\n faces = to_face3d(geo)\n for gp in faces:\n print(gp)\n total_area += gp.area * conversion_to_meters()\n ghes.append(GroundHeatExchanger('{}_{{PLGN}}E_{}'.format(name, i), gp))\n\n # create the loop\n des_loop = {{PLGN}}EThermalLoop(name, ghes, connectors, _clockwise_,\n _soil_, _fluid_, _pipe_, _borehole_, _design_)\n if _name_ is not None:\n des_loop.display_name = _name_\n\n # give a warning about RAM if the size of the borehole field is too large\n borehole_count = int(total_area / (des_loop.borehole_parameters.min_spacing ** 2))\n MAX_BOREHOLES = 8000\n if borehole_count > MAX_BOREHOLES:\n msg = 'The inputs suggest that there may be as many as {} boreholes in the ' \\\n '{{PLGN}}E field\\nand this can cause the {{PLGN}}E sizing routine to use ' \\\n 'more than 10GB of memory.\\nA smaller _ghe_geo or a larger '\\\n '_bore_spacing_ is recommended such that fewer\\nthan {} boreholes are ' \\\n 'generated.'.format(borehole_count, MAX_BOREHOLES)\n print(msg)\n give_warning(ghenv.Component, msg)\n",
"category": "Dragonfly",
"name": "DF GHE Thermal Loop",
"description": "Create an Ground Heat Exchanger Thermal Loop, which represents all infrastructure\nfor a District Energy Simulation (DES) simulation.\n_\nThis includes a ground heat exchanger and all thermal connectors needed\nto connect these objects to Dragonfly Buildings.\n-"
Expand Down
17 changes: 7 additions & 10 deletions dragonfly_grasshopper/src/DF GHE Thermal Loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

ghenv.Component.Name = 'DF GHE Thermal Loop'
ghenv.Component.NickName = 'GHELoop'
ghenv.Component.Message = '1.8.1'
ghenv.Component.Message = '1.8.2'
ghenv.Component.Category = 'Dragonfly'
ghenv.Component.SubCategory = '5 :: District Thermal'
ghenv.Component.AdditionalHelpFromDocStrings = '2'
Expand All @@ -79,7 +79,7 @@

try:
from ladybug_rhino.togeometry import to_polyline2d
from ladybug_rhino.togeometry import to_polygon2d
from ladybug_rhino.togeometry import to_face3d
from ladybug_rhino.config import angle_tolerance, conversion_to_meters
from ladybug_rhino.grasshopper import all_required_inputs, give_warning
except ImportError as e:
Expand All @@ -99,14 +99,11 @@
connectors.append(ThermalConnector('{}_ThermalConnector_{}'.format(name, i), lin))
ghes, total_area = [], 0
for i, geo in enumerate(_ghe_geo):
gp = to_polygon2d(geo)
total_area += gp.area * conversion_to_meters()
if not gp.is_rectangle(math.radians(angle_tolerance)):
msg = 'The ground heat exchanger with index {} is not a perfect rectangle ' \
'but it will be approximated as such in the DES simulation.'.format(i)
print(msg)
give_warning(ghenv.Component, msg)
ghes.append(GroundHeatExchanger('{}_GHE_{}'.format(name, i), gp))
faces = to_face3d(geo)
for gp in faces:
print(gp)
total_area += gp.area * conversion_to_meters()
ghes.append(GroundHeatExchanger('{}_GHE_{}'.format(name, i), gp))

# create the loop
des_loop = GHEThermalLoop(name, ghes, connectors, _clockwise_,
Expand Down
Binary file modified dragonfly_grasshopper/user_objects/DF GHE Thermal Loop.ghuser
Binary file not shown.
Binary file modified samples/ghe_example.gh
Binary file not shown.

0 comments on commit 468fd18

Please sign in to comment.