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

feat(create): Add new component to support new plenum generation #313

Merged
merged 1 commit into from
Jan 30, 2025
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 Model To Honeybee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dragonfly_grasshopper/icon/DF Model To geoJSON.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dragonfly_grasshopper/icon/DF Set Plenums.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_Model_To_Honeybee.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.0",
"version": "1.8.1",
"nickname": "ToHoneybee",
"outputs": [
[
Expand Down Expand Up @@ -37,7 +37,7 @@
{
"access": "item",
"name": "add_plenum_",
"description": "Boolean to indicate whether ceiling/floor plenums should\nbe auto-generated for the Rooms. The height of ceiling plenums\nwill be autocalculated as the difference between the Room2D\nceiling height and Story ceiling height. The height of the floor\nplenum will be autocalculated as the difference between the Room2D\nfloor height and Story floor height. (Default: False).",
"description": "Boolean to indicate whether ceiling/floor plenum depths\nassigned to Room2Ds should be ignored during translation. This\nresults in each Room2D translating to a single Honeybee Room at\nthe full floor-to-ceiling height instead of a base Room with (a)\nplenum Room(s). (Default: False).",
"type": "bool",
"default": null
},
Expand Down Expand Up @@ -71,7 +71,7 @@
}
],
"subcategory": "2 :: Serialize",
"code": "\n\ntry: # import the core dragonfly dependencies\n from dragonfly.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_vector2d\n from ladybug_{{cad}}.config import tolerance\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) and _run:\n # set default inputs if not specified\n use_multiplier_ = use_multiplier_ if use_multiplier_ is not None else True\n add_plenum_ = add_plenum_ if add_plenum_ is not None else False\n _obj_per_model_ = 'Building' if _obj_per_model_ is None else _obj_per_model_\n ceil_adjacency_ = ceil_adjacency_ if ceil_adjacency_ is not None else False\n\n # check the _model input\n assert isinstance(_model, Model), \\\n 'Expected Dragonfly Model object. Got {}.'.format(type(_model))\n\n # create the model objects\n hb_models = _model.to_honeybee(\n _obj_per_model_, shade_dist_, use_multiplier_, add_plenum_, cap_shades_,\n ceil_adjacency_, tolerance=tolerance)\n",
"code": "\n\ntry: # import the core dragonfly dependencies\n from dragonfly.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_vector2d\n from ladybug_{{cad}}.config import tolerance\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) and _run:\n # set default inputs if not specified\n use_multiplier_ = use_multiplier_ if use_multiplier_ is not None else True\n no_plenum_ = no_plenum_ if no_plenum_ is not None else False\n _obj_per_model_ = 'Building' if _obj_per_model_ is None else _obj_per_model_\n ceil_adjacency_ = ceil_adjacency_ if ceil_adjacency_ is not None else False\n\n # check the _model input\n assert isinstance(_model, Model), \\\n 'Expected Dragonfly Model object. Got {}.'.format(type(_model))\n\n # create the model objects\n hb_models = _model.to_honeybee(\n _obj_per_model_, shade_dist_, use_multiplier_, no_plenum_, cap_shades_,\n ceil_adjacency_, tolerance=tolerance)\n",
"category": "Dragonfly",
"name": "DF Model To Honeybee",
"description": "Convert a Dragonfly Model into a series of Honeybee Models.\n-"
Expand Down
10 changes: 5 additions & 5 deletions dragonfly_grasshopper/json/DF_Model_To_geoJSON.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.1",
"version": "1.8.2",
"nickname": "ToGeoJSON",
"outputs": [
[
Expand Down Expand Up @@ -58,14 +58,14 @@
{
"access": "item",
"name": "use_multiplier_",
"description": "If True, the multipliers on each Building's Stories will be\npassed along to the generated Honeybee Room objects, indicating the\nsimulation will be run once for each unique room and then results\nwill be multiplied. If False, full geometry objects will be written\nfor each and every story in the building such that all resulting\nmultipliers will be 1. Default: True.",
"description": "If True, the multipliers on each Building's Stories will be\npassed along to the generated Honeybee Room objects, indicating the\nsimulation will be run once for each unique room and then results\nwill be multiplied. If False, full geometry objects will be written\nfor each and every story in the building such that all resulting\nmultipliers will be 1. (Default: True).",
"type": "bool",
"default": null
},
{
"access": "item",
"name": "add_plenum_",
"description": "Boolean to indicate whether ceiling/floor plenums should\nbe auto-generated for the Rooms. The height of ceiling plenums\nwill be autocalculated as the difference between the Room2D\nceiling height and Story ceiling height. The height of the floor\nplenum will be autocalculated as the difference between the Room2D\nfloor height and Story floor height. (Default: False).",
"description": "Boolean to indicate whether ceiling/floor plenum depths\nassigned to Room2Ds should be ignored during translation. This\nresults in each Room2D translating to a single Honeybee Room at\nthe full floor-to-ceiling height instead of a base Room with (a)\nplenum Room(s). (Default: False).",
"type": "bool",
"default": null
},
Expand Down Expand Up @@ -114,13 +114,13 @@
{
"access": "item",
"name": "_write",
"description": "Set to \"True\" to have the Dragonfly Model translated to an\nURBANopt-compatible geoJSON. This input can also be the integer \"2\",\nwhich will only create the geojson file but not create any honeybee\nModel json files that are linked to it (note that a geojson produced\nthis way is not compatible with URBANopt).",
"description": "Set to \"True\" to have the Dragonfly Model translated to an URBANopt-\ncompatible geoJSON. This input can also be the integer \"2\",\nwhich will only create the geojson file but not create any honeybee\nModel json files that are linked to it (note that a geojson produced\nthis way is not compatible with URBANopt).",
"type": "int",
"default": null
}
],
"subcategory": "2 :: Serialize",
"code": "\nimport os\nimport json\n\ntry: # import the ladybug_geometry dependencies\n from ladybug_geometry.geometry2d.pointvector import Point2D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_geometry:\\n\\t{}'.format(e))\n\ntry: # import the ladybug dependencies\n from ladybug.location import Location\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry: # import the core dragonfly dependencies\n from dragonfly.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry: # import the dragonfly_energy dependencies\n from dragonfly_energy.opendss.network import ElectricalNetwork, RoadNetwork\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_point2d\n from ladybug_{{cad}}.config import tolerance\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) and _write:\n # check the _model and _location input\n assert isinstance(_model, Model), \\\n 'Expected Dragonfly Model object. Got {}.'.format(type(_model))\n assert isinstance(_location, Location), \\\n 'Expected Ladybug Location object. Got {}.'.format(type(_location))\n\n # set default inputs if not specified\n point = to_point2d(_point_) if _point_ is not None else Point2D(0, 0)\n use_multiplier_ = use_multiplier_ if use_multiplier_ is not None else True\n add_plenum_ = add_plenum_ if add_plenum_ is not None else False\n ceil_adjacency_ = ceil_adjacency_ if ceil_adjacency_ is not None else False\n\n if _write == 2:\n geojson = _model.to_geojson(_location, point, _folder_, tolerance)\n else:\n # process any input electrical or road networks\n if network_ is None:\n elec_network, road_network = None, None\n elif isinstance(network_, ElectricalNetwork):\n elec_network, road_network = network_, None\n elif isinstance(network_, RoadNetwork):\n elec_network, road_network = None, network_\n # create the geoJSON and honeybee Model JSONs\n geojson, hb_jsons, hb_models = _model.to.urbanopt(\n _model, _location, point, shade_dist_, use_multiplier_,\n add_plenum_, ceil_adjacency_, des_loop=des_loop_,\n electrical_network=elec_network, road_network=road_network,\n ground_pv=ground_pv_, folder=_folder_, tolerance=tolerance)\n # write the network to a JSON so that it can be loaded in the future\n if network_ is not None:\n proj_folder = os.path.dirname(geojson)\n net_json = os.path.join(proj_folder, 'network.json')\n with open(net_json, 'w') as nj:\n json.dump(network_.to_dict(), nj)\n",
"code": "\nimport os\nimport json\n\ntry: # import the ladybug_geometry dependencies\n from ladybug_geometry.geometry2d.pointvector import Point2D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_geometry:\\n\\t{}'.format(e))\n\ntry: # import the ladybug dependencies\n from ladybug.location import Location\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry: # import the core dragonfly dependencies\n from dragonfly.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry: # import the dragonfly_energy dependencies\n from dragonfly_energy.opendss.network import ElectricalNetwork, RoadNetwork\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_point2d\n from ladybug_{{cad}}.config import tolerance\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) and _write:\n # check the _model and _location input\n assert isinstance(_model, Model), \\\n 'Expected Dragonfly Model object. Got {}.'.format(type(_model))\n assert isinstance(_location, Location), \\\n 'Expected Ladybug Location object. Got {}.'.format(type(_location))\n\n # set default inputs if not specified\n point = to_point2d(_point_) if _point_ is not None else Point2D(0, 0)\n use_multiplier_ = use_multiplier_ if use_multiplier_ is not None else True\n no_plenum_ = no_plenum_ if no_plenum_ is not None else False\n ceil_adjacency_ = ceil_adjacency_ if ceil_adjacency_ is not None else False\n\n if _write == 2:\n geojson = _model.to_geojson(_location, point, _folder_, tolerance)\n else:\n # process any input electrical or road networks\n if network_ is None:\n elec_network, road_network = None, None\n elif isinstance(network_, ElectricalNetwork):\n elec_network, road_network = network_, None\n elif isinstance(network_, RoadNetwork):\n elec_network, road_network = None, network_\n # create the geoJSON and honeybee Model JSONs\n geojson, hb_jsons, hb_models = _model.to.urbanopt(\n _model, _location, point, shade_dist_, use_multiplier_,\n no_plenum_, ceil_adjacency_, des_loop=des_loop_,\n electrical_network=elec_network, road_network=road_network,\n ground_pv=ground_pv_, folder=_folder_, tolerance=tolerance)\n # write the network to a JSON so that it can be loaded in the future\n if network_ is not None:\n proj_folder = os.path.dirname(geojson)\n net_json = os.path.join(proj_folder, 'network.json')\n with open(net_json, 'w') as nj:\n json.dump(network_.to_dict(), nj)\n",
"category": "Dragonfly",
"name": "DF Model To geoJSON",
"description": "Convert a Dragonfly Model into an URBANopt-compatible geoJSON with linked Honeybee\nModel JSONs. Honeybee Model JSONs will be referenced using the \"detailed_model_filename\"\nkey in the geoJSON.\n-"
Expand Down
43 changes: 43 additions & 0 deletions dragonfly_grasshopper/json/DF_Set_Plenums.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"version": "1.8.0",
"nickname": "SetPlenums",
"outputs": [
[
{
"access": "None",
"name": "df_obj",
"description": "The input Dragonfly object with ceiling or floor plenum depths set.",
"type": null,
"default": null
}
]
],
"inputs": [
{
"access": "list",
"name": "_df_obj",
"description": "A Dragonfly Model, Building, Story or Room2D to have plenum depths\nassigned to it.",
"type": "System.Object",
"default": null
},
{
"access": "item",
"name": "ceil_plenum_",
"description": "A number for the depth that ceiling plenums extend into rooms.\nSetting this to a positive value will result in a separate plenum\nroom being split off of the Room2D volume during translation from\nDragonfly to Honeybee.",
"type": "double",
"default": null
},
{
"access": "item",
"name": "floor_plenum_",
"description": "A number for the depth that floor plenums extend into rooms.\nSetting this to a positive value will result in a separate plenum\nroom being split off of the Room2D volume during translation from\nDragonfly to Honeybee.",
"type": "double",
"default": null
}
],
"subcategory": "0 :: Create",
"code": "\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:\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_obj = [obj.duplicate() for obj in _df_obj]\n\n # extract rooms from inputs\n in_rooms = []\n for df_o in df_obj:\n if isinstance(df_o, Model):\n in_rooms.extend(df_o.room_2ds)\n elif isinstance(df_o, Building):\n in_rooms.extend(df_o.unique_room_2ds)\n elif isinstance(df_o, Story):\n in_rooms.extend(df_o.room_2ds)\n elif isinstance(df_o, Room2D):\n in_rooms.append(df_o)\n\n # set the plenum depths\n if ceil_plenum_ is not None:\n for rm in in_rooms:\n rm.ceiling_plenum_depth = ceil_plenum_\n if floor_plenum_ is not None:\n for rm in in_rooms:\n rm.floor_plenum_depth = floor_plenum_\n",
"category": "Dragonfly",
"name": "DF Set Plenums",
"description": "Set the ceiling plenum and/or floor plenum depth of rooms for any Dragonfly\nobject (Room2Ds, Stories, Buildings, Model).\n-"
}
17 changes: 8 additions & 9 deletions dragonfly_grasshopper/src/DF Model To Honeybee.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
will be multiplied. If False, full geometry objects will be written
for each and every story in the building such that all resulting
multipliers will be 1. (Default: True).
add_plenum_: Boolean to indicate whether ceiling/floor plenums should
be auto-generated for the Rooms. The height of ceiling plenums
will be autocalculated as the difference between the Room2D
ceiling height and Story ceiling height. The height of the floor
plenum will be autocalculated as the difference between the Room2D
floor height and Story floor height. (Default: False).
no_plenum_: Boolean to indicate whether ceiling/floor plenum depths
assigned to Room2Ds should be ignored during translation. This
results in each Room2D translating to a single Honeybee Room at
the full floor-to-ceiling height instead of a base Room with (a)
plenum Room(s). (Default: False).
ceil_adjacency_: Boolean to note whether adjacencies should be solved between
interior stories when Room2Ds perfectly match one another in
their floor plate. This ensures that Surface boundary conditions
Expand Down Expand Up @@ -67,7 +66,7 @@

ghenv.Component.Name = 'DF Model To Honeybee'
ghenv.Component.NickName = 'ToHoneybee'
ghenv.Component.Message = '1.8.0'
ghenv.Component.Message = '1.8.1'
ghenv.Component.Category = 'Dragonfly'
ghenv.Component.SubCategory = '2 :: Serialize'
ghenv.Component.AdditionalHelpFromDocStrings = '3'
Expand All @@ -89,7 +88,7 @@
if all_required_inputs(ghenv.Component) and _run:
# set default inputs if not specified
use_multiplier_ = use_multiplier_ if use_multiplier_ is not None else True
add_plenum_ = add_plenum_ if add_plenum_ is not None else False
no_plenum_ = no_plenum_ if no_plenum_ is not None else False
_obj_per_model_ = 'Building' if _obj_per_model_ is None else _obj_per_model_
ceil_adjacency_ = ceil_adjacency_ if ceil_adjacency_ is not None else False

Expand All @@ -99,5 +98,5 @@

# create the model objects
hb_models = _model.to_honeybee(
_obj_per_model_, shade_dist_, use_multiplier_, add_plenum_, cap_shades_,
_obj_per_model_, shade_dist_, use_multiplier_, no_plenum_, cap_shades_,
ceil_adjacency_, tolerance=tolerance)
Loading