Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified dragonfly_grasshopper/icon/DF SHW System.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 31 additions & 31 deletions dragonfly_grasshopper/json/DF_SHW_System.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
{
"version": "1.10.0",
"nickname": "SHW",
"subcategory": "3 :: Energy",
"description": "Apply a template Service Hot Water (SHW) system to Dragonfly Buildings, Stories\nor Room2Ds.\n-",
"outputs": [
[
{
"access": "None",
"default": null,
"name": "report",
"description": "Script variable OSHVACSystems",
"type": null,
"default": null
"access": "None",
"type": null
},
{
"access": "None",
"default": null,
"name": "df_objs",
"description": "The input Rooms with a Service Hot Water system applied.",
"type": null,
"default": null
"access": "None",
"type": null
}
]
],
"inputs": [
{
"access": "list",
"default": null,
"name": "_df_objs",
"description": "Dragonfly Buildings, Stories or Room2Ds to which the input template\nsystem will be assigned. This can also be a Honeybee Model for\nwhich all Rooms will be assigned the SHW system.",
"type": "System.Object",
"default": null
"access": "list",
"type": "System.Object"
},
{
"access": "item",
"default": null,
"name": "_system_type",
"description": "Text for the specific type of service hot water system and equipment.\nThe \"HB SHW Templates\" component has a full list of the supported\nsystem templates.",
"type": "string",
"default": null
"access": "item",
"type": "string"
},
{
"access": "item",
"default": null,
"name": "_name_",
"description": "Text to set the name for the Service Hot Water system and to be\nincorporated into unique system identifier. If the name is not\nprovided, a random name will be assigned.",
"type": "string",
"default": null
"access": "item",
"type": "string"
},
{
"access": "item",
"default": null,
"name": "_efficiency_",
"description": "A number for the efficiency of the heater within the system.\nFor Gas systems, this is the efficiency of the burner. For HeatPump\nsystems, this is the rated COP of the system. For electric systems,\nthis should usually be set to 1. If unspecified this value will\nautomatically be set based on the equipment_type. See below for\nthe default value for each equipment type:\n* Gas_WaterHeater - 0.8\n* Electric_WaterHeater - 1.0\n* HeatPump_WaterHeater - 3.5\n* Gas_TanklessHeater - 0.8\n* Electric_TanklessHeater - 1.0",
"type": "double",
"default": null
"description": "A number for the efficiency of the heater within the system.\nFor Gas systems, this is the efficiency of the burner. For HeatPump\nsystems, this is the rated COP of the system. For electric systems,\nthis should usually be set to 1. If unspecified this value will\nautomatically be set based on the equipment_type. See below for\nthe default value for each equipment type:\n* Gas_WaterHeater - 0.8\n* Electric_WaterHeater - 1.0\n* HeatPump_WaterHeater - 3.5\n* Gas_TanklessHeater - 0.8\n* Electric_TanklessHeater - 1.0\n* District_WaterHeater - 1.0\n* District_TanklessHeater - 1.0",
"access": "item",
"type": "double"
},
{
"access": "item",
"default": null,
"name": "_condition_",
"description": "A number for the ambient temperature in which the hot water tank\nis located [C]. This can also be a Room2D in which the tank is\nlocated. (Default: 22).",
"type": "System.Object",
"default": null
"description": "A number for the ambient temperature in which the hot water tank\nis located [C]. This can also be a Room2D in which the tank is\nlocated. (Default: 22, unless the _system_type is HeatPump_WaterHeater\nand the input _df_objs are Buildings or a Model, in which case the\ntank is placed in the largest room on the first floor of the Building).",
"access": "item",
"type": "System.Object"
},
{
"access": "item",
"default": null,
"name": "_loss_coeff_",
"description": "A number for the loss of heat from the water heater tank to the\nsurrounding ambient conditions [W/K]. (Default: 6 W/K).",
"type": "double",
"default": null
"access": "item",
"type": "double"
}
],
"subcategory": "3 :: Energy",
"code": "\ntry: # import the honeybee extension\n from honeybee.typing import clean_and_id_ep_string, clean_ep_string\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the honeybee-energy extension\n from honeybee_energy.shw import SHWSystem\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry: # import the core dragonfly dependencies\n from dragonfly.model import Model\n from dragonfly.building import Building\n from dragonfly.story import Story\n from dragonfly.room2d import Room2D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry: # import the dragonfly-energy extension\n import dragonfly_energy\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly_energy energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\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 # duplicate the initial objects\n df_objs = [obj.duplicate() for obj in _df_objs]\n\n # set default value for the inputs\n name = clean_and_id_ep_string('SHW System') if _name_ is None \\\n else clean_ep_string(_name_)\n if _condition_ is None:\n _condition_ = 22\n elif isinstance(_condition_, Room2D):\n _condition_ = _condition_.identifier\n else:\n try:\n _condition_ = float(_condition_)\n except Exception:\n raise ValueError(\n 'Input _condition_ must be a Room2D in which the system is located '\n 'or a number\\nfor the ambient temperature in which the hot water '\n 'tank is located [C].\\nGot {}.'.format(type(_condition_))\n )\n _loss_coeff_ = 6 if _loss_coeff_ is None else _loss_coeff_\n\n # create the SHW System\n shw = SHWSystem(name, _system_type, _efficiency_, _condition_, _loss_coeff_)\n if _name_ is not None:\n shw.display_name = _name_\n\n # apply the HVAC system to the objects\n for obj in df_objs:\n if isinstance(obj, (Building, Story)):\n obj.properties.energy.set_all_room_2d_shw(shw)\n elif isinstance(obj, Room2D) and obj.properties.energy.is_conditioned:\n obj.properties.energy.shw = shw\n elif isinstance(obj, Model):\n for bldg in obj.buildings:\n bldg.properties.energy.set_all_room_2d_shw(shw)\n else:\n raise ValueError(\n 'Expected Dragonfly Room2D, Story, Building, or Model. '\n 'Got {}.'.format(type(hb_obj)))\n",
"category": "Dragonfly",
"name": "DF SHW System",
"description": "Apply a template Service Hot Water (SHW) system to Dragonfly Buildings, Stories\nor Room2Ds.\n-"
"code": "\ntry: # import the honeybee extension\n from honeybee.typing import clean_and_id_ep_string, clean_ep_string\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the honeybee-energy extension\n from honeybee_energy.shw import SHWSystem\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry: # import the core dragonfly dependencies\n from dragonfly.model import Model\n from dragonfly.building import Building\n from dragonfly.story import Story\n from dragonfly.room2d import Room2D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry: # import the dragonfly-energy extension\n import dragonfly_energy\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly_energy energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\ndef best_room_for_heater(building):\n \"\"\"Get the ID of the Room2D that is best suited for a water heater in a Building.\"\"\"\n try:\n lowest_floor = building.unique_stories[0]\n except IndexError: # Building of 3D rooms\n return sorted(building.room_3ds, key=lambda x: x.floor_area)[-1].identifier\n return sorted(lowest_floor.room_2ds, key=lambda x: x.floor_area)[-1].identifier\n\n\nif all_required_inputs(ghenv.Component):\n # duplicate the initial objects\n df_objs = [obj.duplicate() for obj in _df_objs]\n\n # set default value for the inputs\n name = clean_and_id_ep_string('SHW System') if _name_ is None \\\n else clean_ep_string(_name_)\n _loss_coeff_ = 6 if _loss_coeff_ is None else _loss_coeff_\n if _condition_ is None:\n if _system_type == 'HeatPump_WaterHeater' and \\\n all(isinstance(dfo, (Building, Model)) for dfo in df_objs):\n _condition_ = []\n for obj in df_objs:\n if isinstance(obj, Building):\n _condition_.append(best_room_for_heater(obj))\n else:\n for bldg in obj.buildings:\n _condition_.append(best_room_for_heater(bldg))\n else:\n _condition_ = 22\n elif isinstance(_condition_, Room2D):\n _condition_ = _condition_.identifier\n else:\n try:\n _condition_ = float(_condition_)\n except Exception:\n raise ValueError(\n 'Input _condition_ must be a Room2D in which the system is located '\n 'or a number\\nfor the ambient temperature in which the hot water '\n 'tank is located [C].\\nGot {}.'.format(type(_condition_))\n )\n\n # create the SHW System\n if isinstance(_condition_, list):\n shw = [SHWSystem(name, _system_type, _efficiency_, con, _loss_coeff_)\n for con in _condition_]\n else:\n shw = SHWSystem(name, _system_type, _efficiency_, _condition_, _loss_coeff_)\n if _name_ is not None:\n shw.display_name = _name_\n\n # apply the HVAC system to the objects\n shw_count = 0\n for obj in df_objs:\n if isinstance(obj, (Building, Story)):\n if isinstance(shw, list):\n obj.properties.energy.set_all_room_2d_shw(shw[shw_count])\n shw_count += 1\n else:\n obj.properties.energy.set_all_room_2d_shw(shw)\n elif isinstance(obj, Room2D) and obj.properties.energy.is_conditioned:\n obj.properties.energy.shw = shw\n elif isinstance(obj, Model):\n for bldg in obj.buildings:\n if isinstance(shw, list):\n bldg.properties.energy.set_all_room_2d_shw(shw[shw_count])\n shw_count += 1\n else:\n bldg.properties.energy.set_all_room_2d_shw(shw)\n else:\n raise ValueError(\n 'Expected Dragonfly Room2D, Story, Building, or Model. '\n 'Got {}.'.format(type(hb_obj)))\n",
"version": "1.10.1",
"category": "Dragonfly"
}
50 changes: 43 additions & 7 deletions dragonfly_grasshopper/src/DF SHW System.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
* HeatPump_WaterHeater - 3.5
* Gas_TanklessHeater - 0.8
* Electric_TanklessHeater - 1.0
* District_WaterHeater - 1.0
* District_TanklessHeater - 1.0
_condition_: A number for the ambient temperature in which the hot water tank
is located [C]. This can also be a Room2D in which the tank is
located. (Default: 22).
located. (Default: 22, unless the _system_type is HeatPump_WaterHeater
and the input _df_objs are Buildings or a Model, in which case the
tank is placed in the largest room on the first floor of the Building).
_loss_coeff_: A number for the loss of heat from the water heater tank to the
surrounding ambient conditions [W/K]. (Default: 6 W/K).

Expand All @@ -45,7 +49,7 @@

ghenv.Component.Name = "DF SHW System"
ghenv.Component.NickName = 'SHW'
ghenv.Component.Message = '1.10.0'
ghenv.Component.Message = '1.10.1'
ghenv.Component.Category = 'Dragonfly'
ghenv.Component.SubCategory = '3 :: Energy'
ghenv.Component.AdditionalHelpFromDocStrings = '3'
Expand Down Expand Up @@ -79,15 +83,35 @@
raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


def best_room_for_heater(building):
"""Get the ID of the Room2D that is best suited for a water heater in a Building."""
try:
lowest_floor = building.unique_stories[0]
except IndexError: # Building of 3D rooms
return sorted(building.room_3ds, key=lambda x: x.floor_area)[-1].identifier
return sorted(lowest_floor.room_2ds, key=lambda x: x.floor_area)[-1].identifier


if all_required_inputs(ghenv.Component):
# duplicate the initial objects
df_objs = [obj.duplicate() for obj in _df_objs]

# set default value for the inputs
name = clean_and_id_ep_string('SHW System') if _name_ is None \
else clean_ep_string(_name_)
_loss_coeff_ = 6 if _loss_coeff_ is None else _loss_coeff_
if _condition_ is None:
_condition_ = 22
if _system_type == 'HeatPump_WaterHeater' and \
all(isinstance(dfo, (Building, Model)) for dfo in df_objs):
_condition_ = []
for obj in df_objs:
if isinstance(obj, Building):
_condition_.append(best_room_for_heater(obj))
else:
for bldg in obj.buildings:
_condition_.append(best_room_for_heater(bldg))
else:
_condition_ = 22
elif isinstance(_condition_, Room2D):
_condition_ = _condition_.identifier
else:
Expand All @@ -99,22 +123,34 @@
'or a number\nfor the ambient temperature in which the hot water '
'tank is located [C].\nGot {}.'.format(type(_condition_))
)
_loss_coeff_ = 6 if _loss_coeff_ is None else _loss_coeff_

# create the SHW System
shw = SHWSystem(name, _system_type, _efficiency_, _condition_, _loss_coeff_)
if isinstance(_condition_, list):
shw = [SHWSystem(name, _system_type, _efficiency_, con, _loss_coeff_)
for con in _condition_]
else:
shw = SHWSystem(name, _system_type, _efficiency_, _condition_, _loss_coeff_)
if _name_ is not None:
shw.display_name = _name_

# apply the HVAC system to the objects
shw_count = 0
for obj in df_objs:
if isinstance(obj, (Building, Story)):
obj.properties.energy.set_all_room_2d_shw(shw)
if isinstance(shw, list):
obj.properties.energy.set_all_room_2d_shw(shw[shw_count])
shw_count += 1
else:
obj.properties.energy.set_all_room_2d_shw(shw)
elif isinstance(obj, Room2D) and obj.properties.energy.is_conditioned:
obj.properties.energy.shw = shw
elif isinstance(obj, Model):
for bldg in obj.buildings:
bldg.properties.energy.set_all_room_2d_shw(shw)
if isinstance(shw, list):
bldg.properties.energy.set_all_room_2d_shw(shw[shw_count])
shw_count += 1
else:
bldg.properties.energy.set_all_room_2d_shw(shw)
else:
raise ValueError(
'Expected Dragonfly Room2D, Story, Building, or Model. '
Expand Down
Binary file modified dragonfly_grasshopper/user_objects/DF Room2D Attributes.ghuser
Binary file not shown.
Binary file modified dragonfly_grasshopper/user_objects/DF SHW System.ghuser
Binary file not shown.
Binary file modified samples/des_comparison_example.gh
Binary file not shown.
Binary file modified samples/des_gen4_example.gh
Binary file not shown.
Binary file modified samples/des_gen5_example.gh
Binary file not shown.
Binary file modified samples/des_ghe_example.gh
Binary file not shown.
Binary file modified samples/des_ghe_example_custom_loads.gh
Binary file not shown.
Binary file removed samples/des_ghe_example_large.gh
Binary file not shown.
Binary file added samples/des_modelica_gen4.gh
Binary file not shown.
Binary file added samples/des_modelica_ghe.gh
Binary file not shown.