Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(energy): Expose the option to set ideal air availability schedules #259

Merged
merged 1 commit into from Jul 17, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified dragonfly_grasshopper/icon/DF IdealAir.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions dragonfly_grasshopper/json/DF_IdealAir.json
@@ -1,5 +1,5 @@
{
"version": "1.6.1",
"version": "1.6.2",
"nickname": "DFIdealAir",
"outputs": [
[
Expand Down Expand Up @@ -75,10 +75,24 @@
"description": "A number for the maximum cooling capacity in Watts. This\ncan also be the text 'autosize' to indicate that the capacity should\nbe determined during the EnergyPlus sizing calculation. This can also\nbe the text 'NoLimit' to indicate no upper limit to the cooling\ncapacity. Default: 'autosize'.",
"type": "System.Object",
"default": null
},
{
"access": "item",
"name": "heat_avail_",
"description": "An optional on/off schedule to set the availability of\nheating over the course of the simulation. This can also be the\nidentifier of an on/off schedule to be looked up in the schedule\nlibrary (Default: None).",
"type": "System.Object",
"default": null
},
{
"access": "item",
"name": "cool_avail_",
"description": "An optional on/off schedule to set the availability of\ncooling over the course of the simulation. This can also be the\nidentifier of an on/off schedule to be looked up in the schedule\nlibrary (Default: None).",
"type": "System.Object",
"default": null
}
],
"subcategory": "3 :: Energy",
"code": "\n\ntry: # import the honeybee extension\n from honeybee.altnumber import autosize, no_limit\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.hvac.idealair import IdealAirSystem\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# dictionary to get alterante number types\nalt_numbers = {\n 'nolimit': no_limit,\n 'NoLimit': no_limit,\n 'autosize': autosize,\n 'Autosize': autosize,\n None: autosize\n }\n\n\ndef extract_room2ds(obj):\n \"\"\"Get all of the Room2Ds assinged to a given dragonfly object.\"\"\"\n if isinstance(obj, Building):\n return obj.unique_room_2ds\n elif isinstance(obj, Story):\n return obj.room_2ds\n elif isinstance(obj, Room2D):\n return [obj]\n elif isinstance(obj, Model):\n return [room for bldg in obj.buildings for room in bldg.unique_room_2ds]\n else:\n raise ValueError(\n 'Expected Dragonfly Room2D, Story, Building, or Model. '\n 'Got {}.'.format(type(hb_obj)))\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 for df_obj in df_objs:\n for room in extract_room2ds(df_obj):\n if room.properties.energy.is_conditioned:\n # check to be sure the assigned HVAC system is an IdealAirSystem\n if not isinstance(room.properties.energy.hvac, IdealAirSystem):\n room.properties.energy.add_default_ideal_air()\n\n # create the customized ideal air system\n new_ideal_air = room.properties.energy.hvac.duplicate()\n if _economizer_ is not None:\n new_ideal_air.economizer_type = _economizer_\n if dcv_ is not None:\n new_ideal_air.demand_controlled_ventilation = dcv_\n if sensible_hr_ is not None:\n new_ideal_air.sensible_heat_recovery = sensible_hr_\n if latent_hr_ is not None:\n new_ideal_air.latent_heat_recovery = latent_hr_\n if _heat_temp_ is not None:\n new_ideal_air.heating_air_temperature = _heat_temp_\n if _cool_temp_ is not None:\n new_ideal_air.cooling_air_temperature = _cool_temp_\n try:\n new_ideal_air.heating_limit = alt_numbers[_heat_limit_]\n except KeyError:\n new_ideal_air.heating_limit = _heat_limit_\n try:\n new_ideal_air.cooling_limit = alt_numbers[_cool_limit_]\n except KeyError:\n new_ideal_air.cooling_limit = _cool_limit_\n\n # assign the HVAC to the Room\n room.properties.energy.hvac = new_ideal_air\n",
"code": "\n\ntry: # import the honeybee extension\n from honeybee.altnumber import autosize, no_limit\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.hvac.idealair import IdealAirSystem\n from honeybee_energy.lib.schedules import schedule_by_identifier\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# dictionary to get alterante number types\nalt_numbers = {\n 'nolimit': no_limit,\n 'NoLimit': no_limit,\n 'autosize': autosize,\n 'Autosize': autosize,\n None: autosize\n }\n\n\ndef extract_room2ds(obj):\n \"\"\"Get all of the Room2Ds assinged to a given dragonfly object.\"\"\"\n if isinstance(obj, Building):\n return obj.unique_room_2ds\n elif isinstance(obj, Story):\n return obj.room_2ds\n elif isinstance(obj, Room2D):\n return [obj]\n elif isinstance(obj, Model):\n return [room for bldg in obj.buildings for room in bldg.unique_room_2ds]\n else:\n raise ValueError(\n 'Expected Dragonfly Room2D, Story, Building, or Model. '\n 'Got {}.'.format(type(hb_obj)))\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 # get schedules by identifer if they are strings\n if isinstance(heat_avail_, str):\n heat_avail_ = schedule_by_identifier(heat_avail_)\n if isinstance(cool_avail_, str):\n cool_avail_ = schedule_by_identifier(cool_avail_)\n\n for df_obj in df_objs:\n for room in extract_room2ds(df_obj):\n if room.properties.energy.is_conditioned:\n # check to be sure the assigned HVAC system is an IdealAirSystem\n if not isinstance(room.properties.energy.hvac, IdealAirSystem):\n room.properties.energy.add_default_ideal_air()\n\n # create the customized ideal air system\n new_ideal_air = room.properties.energy.hvac.duplicate()\n if _economizer_ is not None:\n new_ideal_air.economizer_type = _economizer_\n if dcv_ is not None:\n new_ideal_air.demand_controlled_ventilation = dcv_\n if sensible_hr_ is not None:\n new_ideal_air.sensible_heat_recovery = sensible_hr_\n if latent_hr_ is not None:\n new_ideal_air.latent_heat_recovery = latent_hr_\n if _heat_temp_ is not None:\n new_ideal_air.heating_air_temperature = _heat_temp_\n if _cool_temp_ is not None:\n new_ideal_air.cooling_air_temperature = _cool_temp_\n try:\n new_ideal_air.heating_limit = alt_numbers[_heat_limit_]\n except KeyError:\n new_ideal_air.heating_limit = _heat_limit_\n try:\n new_ideal_air.cooling_limit = alt_numbers[_cool_limit_]\n except KeyError:\n new_ideal_air.cooling_limit = _cool_limit_\n if heat_avail_ is not None:\n new_ideal_air.heating_availability = heat_avail_\n if cool_avail_ is not None:\n new_ideal_air.cooling_availability = cool_avail_\n\n # assign the HVAC to the Room\n room.properties.energy.hvac = new_ideal_air\n",
"category": "Dragonfly",
"name": "DF IdealAir",
"description": "Apply a customized IdealAirSystem to Dragonfly Buildings, Stories or Room2Ds.\n-"
Expand Down
21 changes: 20 additions & 1 deletion dragonfly_grasshopper/src/DF IdealAir.py
Expand Up @@ -44,14 +44,22 @@
be determined during the EnergyPlus sizing calculation. This can also
be the text 'NoLimit' to indicate no upper limit to the cooling
capacity. Default: 'autosize'.
heat_avail_: An optional on/off schedule to set the availability of
heating over the course of the simulation. This can also be the
identifier of an on/off schedule to be looked up in the schedule
library (Default: None).
cool_avail_: An optional on/off schedule to set the availability of
cooling over the course of the simulation. This can also be the
identifier of an on/off schedule to be looked up in the schedule
library (Default: None).

Returns:
df_objs: The input Dragonfly object with the custom Ideal Air System assigned.
"""

ghenv.Component.Name = "DF IdealAir"
ghenv.Component.NickName = 'DFIdealAir'
ghenv.Component.Message = '1.6.1'
ghenv.Component.Message = '1.6.2'
ghenv.Component.Category = 'Dragonfly'
ghenv.Component.SubCategory = '3 :: Energy'
ghenv.Component.AdditionalHelpFromDocStrings = '3'
Expand All @@ -64,6 +72,7 @@

try: # import the honeybee-energy extension
from honeybee_energy.hvac.idealair import IdealAirSystem
from honeybee_energy.lib.schedules import schedule_by_identifier
except ImportError as e:
raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

Expand Down Expand Up @@ -115,6 +124,12 @@ def extract_room2ds(obj):
# duplicate the initial objects
df_objs = [obj.duplicate() for obj in _df_objs]

# get schedules by identifer if they are strings
if isinstance(heat_avail_, str):
heat_avail_ = schedule_by_identifier(heat_avail_)
if isinstance(cool_avail_, str):
cool_avail_ = schedule_by_identifier(cool_avail_)

for df_obj in df_objs:
for room in extract_room2ds(df_obj):
if room.properties.energy.is_conditioned:
Expand Down Expand Up @@ -144,6 +159,10 @@ def extract_room2ds(obj):
new_ideal_air.cooling_limit = alt_numbers[_cool_limit_]
except KeyError:
new_ideal_air.cooling_limit = _cool_limit_
if heat_avail_ is not None:
new_ideal_air.heating_availability = heat_avail_
if cool_avail_ is not None:
new_ideal_air.cooling_availability = cool_avail_

# assign the HVAC to the Room
room.properties.energy.hvac = new_ideal_air
Binary file modified dragonfly_grasshopper/user_objects/DF IdealAir.ghuser
Binary file not shown.