Skip to content

Commit

Permalink
fix(loads): Add better default daylight sensor position
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Mar 1, 2023
1 parent d9b81d3 commit 98fb811
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
Binary file modified honeybee_grasshopper_energy/icon/HB Apply Daylight Control.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.6.1",
"nickname": "DaylightControl",
"outputs": [
[
Expand Down Expand Up @@ -64,7 +64,7 @@
}
],
"subcategory": "3 :: Loads",
"code": "\ntry: # import the honeybee-energy extension\n from honeybee_energy.load.daylight import DaylightingControl\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_point3d\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, longest_list, \\\n 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 # duplicate the initial objects\n rooms = [room.duplicate() for room in _rooms]\n\n # set default values and perform checks\n dist_from_floor = 0.8 / conversion_to_meters()\n if len(_sensor_points_) != 0:\n assert len(_sensor_points_) == len(_rooms), 'Number of sensor points ({}) ' \\\n 'must align exactly with the number of rooms ({}).'.format(\n len(_sensor_points_), len(_rooms))\n _ill_setpoint_ = [300] if len(_ill_setpoint_) == 0 else _ill_setpoint_\n _control_fract_ = [1] if len(_control_fract_) == 0 else _control_fract_\n _min_power_in_ = [0.3] if len(_min_power_in_) == 0 else _min_power_in_\n _min_light_out_ = [0.2] if len(_min_light_out_) == 0 else _min_light_out_\n off_at_min_ = [False] if len(off_at_min_) == 0 else off_at_min_\n\n # loop through the rooms and assign daylight sensors\n unassigned_rooms = []\n if len(_sensor_points_) == 0:\n for i, room in enumerate(rooms):\n dl_control = room.properties.energy.add_daylight_control_to_center(\n dist_from_floor, longest_list(_ill_setpoint_, i),\n longest_list(_control_fract_, i), longest_list(_min_power_in_, i),\n longest_list(_min_light_out_, i), longest_list(off_at_min_, i))\n if dl_control is None:\n unassigned_rooms.append(room.display_name)\n else:\n for i, room in enumerate(rooms):\n sensor_pt = to_point3d(_sensor_points_[i])\n if room.geometry.is_point_inside(sensor_pt):\n dl_control = DaylightingControl(\n sensor_pt, longest_list(_ill_setpoint_, i),\n longest_list(_control_fract_, i), longest_list(_min_power_in_, i),\n longest_list(_min_light_out_, i), longest_list(off_at_min_, i))\n room.properties.energy.daylighting_control = dl_control\n else:\n unassigned_rooms.append(room.display_name)\n\n # give a warning about any rooms to which a sensor could not be assinged\n for room in unassigned_rooms:\n msg = 'Sensor point for room \"{}\" does not lie within the room volume.\\n' \\\n 'No daylight sensors have been added to this room.'.format(room)\n print(msg)\n give_warning(ghenv.Component, msg)\n",
"code": "\ntry: # import the honeybee-energy extension\n from honeybee_energy.load.daylight import DaylightingControl\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_point3d\n from ladybug_{{cad}}.config import conversion_to_meters, tolerance\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, longest_list, \\\n 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 # duplicate the initial objects\n rooms = [room.duplicate() for room in _rooms]\n\n # set default values and perform checks\n dist_from_floor = 0.8 / conversion_to_meters()\n if len(_sensor_points_) != 0:\n assert len(_sensor_points_) == len(_rooms), 'Number of sensor points ({}) ' \\\n 'must align exactly with the number of rooms ({}).'.format(\n len(_sensor_points_), len(_rooms))\n _ill_setpoint_ = [300] if len(_ill_setpoint_) == 0 else _ill_setpoint_\n _control_fract_ = [1] if len(_control_fract_) == 0 else _control_fract_\n _min_power_in_ = [0.3] if len(_min_power_in_) == 0 else _min_power_in_\n _min_light_out_ = [0.2] if len(_min_light_out_) == 0 else _min_light_out_\n off_at_min_ = [False] if len(off_at_min_) == 0 else off_at_min_\n\n # loop through the rooms and assign daylight sensors\n unassigned_rooms = []\n if len(_sensor_points_) == 0:\n for i, room in enumerate(rooms):\n dl_control = room.properties.energy.add_daylight_control_to_center(\n dist_from_floor, longest_list(_ill_setpoint_, i),\n longest_list(_control_fract_, i), longest_list(_min_power_in_, i),\n longest_list(_min_light_out_, i), longest_list(off_at_min_, i),\n tolerance)\n if dl_control is None:\n unassigned_rooms.append(room.display_name)\n else:\n for i, room in enumerate(rooms):\n sensor_pt = to_point3d(_sensor_points_[i])\n if room.geometry.is_point_inside(sensor_pt):\n dl_control = DaylightingControl(\n sensor_pt, longest_list(_ill_setpoint_, i),\n longest_list(_control_fract_, i), longest_list(_min_power_in_, i),\n longest_list(_min_light_out_, i), longest_list(off_at_min_, i))\n room.properties.energy.daylighting_control = dl_control\n else:\n unassigned_rooms.append(room.display_name)\n\n # give a warning about any rooms to which a sensor could not be assinged\n for room in unassigned_rooms:\n msg = 'Sensor point for room \"{}\" does not lie within the room volume.\\n' \\\n 'No daylight sensors have been added to this room.'.format(room)\n print(msg)\n give_warning(ghenv.Component, msg)\n",
"category": "HB-Energy",
"name": "HB Apply Daylight Control",
"description": "Apply simple daylight controls to Rooms.\n_\nSuch simple controls will dim the lights in the energy simulation according to\nwhether the illuminance at a sensor location is at a target illuminance setpoint.\nThe method used to estimate illuiminance is fairly simple and, for more detailed\ncontrol over the parameters used to compute illuminance, the \"HB Daylight Control\nSchedule\" component under HB-Radiance should be used.\n-"
Expand Down
7 changes: 4 additions & 3 deletions honeybee_grasshopper_energy/src/HB Apply Daylight Control.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

ghenv.Component.Name = 'HB Apply Daylight Control'
ghenv.Component.NickName = 'DaylightControl'
ghenv.Component.Message = '1.6.0'
ghenv.Component.Message = '1.6.1'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '3 :: Loads'
ghenv.Component.AdditionalHelpFromDocStrings = '2'
Expand All @@ -73,7 +73,7 @@

try:
from ladybug_rhino.togeometry import to_point3d
from ladybug_rhino.config import conversion_to_meters
from ladybug_rhino.config import conversion_to_meters, tolerance
from ladybug_rhino.grasshopper import all_required_inputs, longest_list, \
give_warning
except ImportError as e:
Expand Down Expand Up @@ -103,7 +103,8 @@
dl_control = room.properties.energy.add_daylight_control_to_center(
dist_from_floor, longest_list(_ill_setpoint_, i),
longest_list(_control_fract_, i), longest_list(_min_power_in_, i),
longest_list(_min_light_out_, i), longest_list(off_at_min_, i))
longest_list(_min_light_out_, i), longest_list(off_at_min_, i),
tolerance)
if dl_control is None:
unassigned_rooms.append(room.display_name)
else:
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 98fb811

Please sign in to comment.