diff --git a/honeybee_grasshopper_ph/src/HBPH - Calc Air Layer HB Material.py b/honeybee_grasshopper_ph/src/HBPH - Calc Air Layer HB Material.py new file mode 100644 index 0000000..2b62a65 --- /dev/null +++ b/honeybee_grasshopper_ph/src/HBPH - Calc Air Layer HB Material.py @@ -0,0 +1,81 @@ +# +# Honeybee-PH: A Plugin for adding Passive-House data to LadybugTools Honeybee-Energy Models +# +# This component is part of the PH-Tools toolkit . +# +# Copyright (c) 2022, PH-Tools and bldgtyp, llc +# Honeybee-PH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# Honeybee-PH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License +# see . +# +# @license GPL-3.0+ +# +""" +Create a new Honeybee-Energy "Air-Layer" material. This calculator will +determine an equivalent conductivity based on the parameters input. The +procedue implemented here follows the PHPP v9/10 which closely matches the +ISO-6946-2017, Appendix D method. This material can be used in Honeybee +Constructions to approiximate the insulating effect of closed air-layers +such as service caviies. +- +Note: This "Air-Layer" is only suitable for CLOSED air layers which +are have a length AND width at least 10x the thickness, and which have less +thank 5 deg-K temperature change accross the layer. +- +EM April 1, 2023 + Args: + _heat_flow_direction: Input either - +"1-Upwards" +"2-Horizontal" +"3-Downwards" + + _thickness: (mm) The thickness of the Air Layer + + _srfc_1_emissivity: (%) Default=0.9 + + _srfc_2_emissivity: (%) Default=0.9 + + Returns: + marterial_: The new Honeybee-Energy Material. +""" + +import scriptcontext as sc +import Rhino as rh +import rhinoscriptsyntax as rs +import ghpythonlib.components as ghc +import Grasshopper as gh + +from honeybee_ph_rhino import gh_compo_io, gh_io + +# ------------------------------------------------------------------------------ +import honeybee_ph_rhino._component_info_ +reload(honeybee_ph_rhino._component_info_) +ghenv.Component.Name = "HBPH - Calc Air Layer HB Material" +DEV = honeybee_ph_rhino._component_info_.set_component_params(ghenv, dev=False) +if DEV: + from honeybee_ph_rhino.gh_compo_io import assmbly_create_air_layer_mat as gh_compo_io + reload(gh_compo_io) + +# ------------------------------------------------------------------------------ +# -- GH Interface +IGH = gh_io.IGH( ghdoc, ghenv, sc, rh, rs, ghc, gh ) + +# ------------------------------------------------------------------------------ +gh_compo_interface = gh_compo_io.GHCompo_AirLayerMaterial( + IGH, + _display_name, + _heat_flow_direction, + _thickness, + _srfc_1_emissivity, + _srfc_1_emissivity + ) +material_ = gh_compo_interface.run() \ No newline at end of file diff --git a/honeybee_grasshopper_ph/src/HBPH - Create Custom Collection.py b/honeybee_grasshopper_ph/src/HBPH - Create Custom Collection.py new file mode 100644 index 0000000..2ff11f7 --- /dev/null +++ b/honeybee_grasshopper_ph/src/HBPH - Create Custom Collection.py @@ -0,0 +1,74 @@ +# +# Honeybee-PH: A Plugin for adding Passive-House data to LadybugTools Honeybee-Energy Models +# +# This component is part of the PH-Tools toolkit . +# +# Copyright (c) 2022, PH-Tools and bldgtyp, llc +# Honeybee-PH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# Honeybee-PH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License +# see . +# +# @license GPL-3.0+ +# +""" +Create a new custom "Collection" of items. This collection works just like +a normal python 'Dictionary' and allows for item set and get using the typical +square bracket notation (ie: collection["my_key"] = my_value, etc.) + +If provided, the collection will use the "_key_name" as the dictionary "key", +for all items and if left blank will use the items 'id()' as the key +- +EM April 1, 2023 + Args: + _name: (str) An optional display_name for the collection. + + _key_name: (str): Default='id(item)'. Provide the name of the item's + 'key' atribute you would like to use when storing the item + to a dictionary. Be sure all items have this attribute. + + _items: (Collection) An iterable collection of items you would + like to add to the new CustomCollection object. + + Returns: + collection_: The new CustomCollection object with the items stored + according to their 'key' (or 'id' by default). +""" + +import scriptcontext as sc +import Rhino as rh +import rhinoscriptsyntax as rs +import ghpythonlib.components as ghc +import Grasshopper as gh + +from honeybee_ph_rhino import gh_compo_io, gh_io + +# ------------------------------------------------------------------------------ +import honeybee_ph_rhino._component_info_ +reload(honeybee_ph_rhino._component_info_) +ghenv.Component.Name = "HBPH - Create Custom Collection" +DEV = honeybee_ph_rhino._component_info_.set_component_params(ghenv, dev=False) +if DEV: + from honeybee_ph_rhino.gh_compo_io import util_create_collection as gh_compo_io + reload(gh_compo_io) + +# ------------------------------------------------------------------------------ +# -- GH Interface +IGH = gh_io.IGH( ghdoc, ghenv, sc, rh, rs, ghc, gh ) + +# ------------------------------------------------------------------------------ +gh_compo_interface = gh_compo_io.GHCompo_CreateCustomCollection( + IGH, + _name, + _key_name, + _items, + ) +collection_ = gh_compo_interface.run() \ No newline at end of file diff --git a/honeybee_grasshopper_ph/src/HBPH - Create Detailed Constructions.py b/honeybee_grasshopper_ph/src/HBPH - Create Detailed Constructions.py new file mode 100644 index 0000000..ab51b30 --- /dev/null +++ b/honeybee_grasshopper_ph/src/HBPH - Create Detailed Constructions.py @@ -0,0 +1,79 @@ +# +# Honeybee-PH: A Plugin for adding Passive-House data to LadybugTools Honeybee-Energy Models +# +# This component is part of the PH-Tools toolkit . +# +# Copyright (c) 2022, PH-Tools and bldgtyp, llc +# Honeybee-PH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# Honeybee-PH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License +# see . +# +# @license GPL-3.0+ +# +""" +Create new Honeybee-Energy Constructions based on a JSON file and a set of +Honeybee-Energy Materials. Note that the input JSON describing the construction +should be a normal HB JSON, except that this component also allows for an optional +"thickness" attribute which will set the thickness of each material layer as +the new construction is built. For example - + +"W1 - Below Grade Conc. Wall": { + "type": "OpaqueConstructionAbridged", + "identifier": "W1 - Below Grade Conc. Wall", + "materials": ["Concrete (Heavily Reinforced) [R-0.05/in]", "XPS [R-5.0/in]"], + "thicknesses": ["8in", "6in"] +} + +Will create a new construction and set the thicknesses of the layers as indicated (8in, then 6in). + +- +EM April 1, 2023 + Args: + _materials (List[EnergyMaterials]): A list of the Honeybee-Energy materials + that you would like to use to create the Honeybee Constructions. + + _path: (str) The path (or paths) to the .JSON file which describes the + Honeybee-Constructions. + + Returns: + constructions_: The new Honeybee-Energy Constructions, built from the + Honeybee-Energy Materials input. +""" + +import scriptcontext as sc +import Rhino as rh +import rhinoscriptsyntax as rs +import ghpythonlib.components as ghc +import Grasshopper as gh + +from honeybee_ph_rhino import gh_compo_io, gh_io + +# ------------------------------------------------------------------------------ +import honeybee_ph_rhino._component_info_ +reload(honeybee_ph_rhino._component_info_) +ghenv.Component.Name = "HBPH - Create Detailed Constructions" +DEV = honeybee_ph_rhino._component_info_.set_component_params(ghenv, dev=False) +if DEV: + from honeybee_ph_rhino.gh_compo_io import assmbly_create_detailed_const as gh_compo_io + reload(gh_compo_io) + +# ------------------------------------------------------------------------------ +# -- GH Interface +IGH = gh_io.IGH( ghdoc, ghenv, sc, rh, rs, ghc, gh ) + +# ------------------------------------------------------------------------------ +gh_compo_interface = gh_compo_io.GHCompo_CreateDetailedConstructions( + IGH, + _path, + _materials, + ) +constructions_ = gh_compo_interface.run() \ No newline at end of file diff --git a/honeybee_grasshopper_ph/src/HBPH - Get Brep Subface Materials.py b/honeybee_grasshopper_ph/src/HBPH - Get Brep Subface Materials.py new file mode 100644 index 0000000..5d2ef9a --- /dev/null +++ b/honeybee_grasshopper_ph/src/HBPH - Get Brep Subface Materials.py @@ -0,0 +1,64 @@ +# +# Honeybee-PH: A Plugin for adding Passive-House data to LadybugTools Honeybee-Energy Models +# +# This component is part of the PH-Tools toolkit . +# +# Copyright (c) 2022, PH-Tools and bldgtyp, llc +# Honeybee-PH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# Honeybee-PH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License +# see . +# +# @license GPL-3.0+ +# +""" +Get all of the Rhino Material Names for the subfaces of a closed Brep. This is +useful wheh using Materials as the 'key' for assigning things like constructions, +boundary-conditions or other sub-face specific values. +- +EM April 1, 2023 + Args: + _breps: (List[Guid]) A List of Brep Guid values. + + Returns: + subface_geometry_: The subface surfaces of the input Brep. + + material_names_: The names of the Materials assigned to the + subface surfaces of the input Breps. +""" + +import scriptcontext as sc +import Rhino as rh +import rhinoscriptsyntax as rs +import ghpythonlib.components as ghc +import Grasshopper as gh + +from honeybee_ph_rhino import gh_compo_io, gh_io + +# ------------------------------------------------------------------------------ +import honeybee_ph_rhino._component_info_ +reload(honeybee_ph_rhino._component_info_) +ghenv.Component.Name = "HBPH - Get Brep Subface Materials" +DEV = honeybee_ph_rhino._component_info_.set_component_params(ghenv, dev=False) +if DEV: + from honeybee_ph_rhino.gh_compo_io import util_get_brep_subface_mats as gh_compo_io + reload(gh_compo_io) + +# ------------------------------------------------------------------------------ +# -- GH Interface +IGH = gh_io.IGH( ghdoc, ghenv, sc, rh, rs, ghc, gh ) + +# ------------------------------------------------------------------------------ +gh_compo_interface = gh_compo_io.GHCompo_GetSubFaceMaterials( + IGH, + _breps + ) +subface_geometry_, material_names_ = gh_compo_interface.run() \ No newline at end of file diff --git a/honeybee_grasshopper_ph/src/HBPH - Get From Custom Collection.py b/honeybee_grasshopper_ph/src/HBPH - Get From Custom Collection.py new file mode 100644 index 0000000..29d87ba --- /dev/null +++ b/honeybee_grasshopper_ph/src/HBPH - Get From Custom Collection.py @@ -0,0 +1,64 @@ +# +# Honeybee-PH: A Plugin for adding Passive-House data to LadybugTools Honeybee-Energy Models +# +# This component is part of the PH-Tools toolkit . +# +# Copyright (c) 2022, PH-Tools and bldgtyp, llc +# Honeybee-PH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# Honeybee-PH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License +# see . +# +# @license GPL-3.0+ +# +""" +Get all of the Rhino Material Names for the subfaces of a closed Brep. This is +useful wheh using Materials as the 'key' for assigning things like constructions, +boundary-conditions or other sub-face specific values. +- +EM April 1, 2023 + Args: + _collection: (List[Guid]) A CustomCollection to get items from. + + _keys: (List[str]) A list of the keys to 'get' from the collection + + Returns: + values_: The items found, or None if not found. +""" + +import scriptcontext as sc +import Rhino as rh +import rhinoscriptsyntax as rs +import ghpythonlib.components as ghc +import Grasshopper as gh + +from honeybee_ph_rhino import gh_compo_io, gh_io + +# ------------------------------------------------------------------------------ +import honeybee_ph_rhino._component_info_ +reload(honeybee_ph_rhino._component_info_) +ghenv.Component.Name = "HBPH - Get From Custom Collection" +DEV = honeybee_ph_rhino._component_info_.set_component_params(ghenv, dev=False) +if DEV: + from honeybee_ph_rhino.gh_compo_io import util_get_from_collection as gh_compo_io + reload(gh_compo_io) + +# ------------------------------------------------------------------------------ +# -- GH Interface +IGH = gh_io.IGH( ghdoc, ghenv, sc, rh, rs, ghc, gh ) + +# ------------------------------------------------------------------------------ +gh_compo_interface = gh_compo_io.GHCompo_GetFromCustomCollection( + IGH, + _collection, + _keys, + ) +values_ = gh_compo_interface.run() \ No newline at end of file diff --git a/honeybee_grasshopper_ph/src/HBPH - Import Flixo Materials.py b/honeybee_grasshopper_ph/src/HBPH - Import Flixo Materials.py new file mode 100644 index 0000000..7c6a6a1 --- /dev/null +++ b/honeybee_grasshopper_ph/src/HBPH - Import Flixo Materials.py @@ -0,0 +1,62 @@ +# +# Honeybee-PH: A Plugin for adding Passive-House data to LadybugTools Honeybee-Energy Models +# +# This component is part of the PH-Tools toolkit . +# +# Copyright (c) 2022, PH-Tools and bldgtyp, llc +# Honeybee-PH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# Honeybee-PH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License +# see . +# +# @license GPL-3.0+ +# +""" +Import "Infomind Flixo" material .csv files as Honeybee-Energy Materials. This is +useful if you are trying to load materials from Flixo for use in your energy model. +- +EM March 31, 2023 + Args: + _path: (str) The path (or paths) to the Flixo .csv files you would like + to import as Honeybee-Energy Materials. + + Returns: + materials_: The new Honeybee-Energy materials which were created from the + Flixo .csv files. +""" + +import scriptcontext as sc +import Rhino as rh +import rhinoscriptsyntax as rs +import ghpythonlib.components as ghc +import Grasshopper as gh + +from honeybee_ph_rhino import gh_compo_io, gh_io + +# ------------------------------------------------------------------------------ +import honeybee_ph_rhino._component_info_ +reload(honeybee_ph_rhino._component_info_) +ghenv.Component.Name = "HBPH - Import Flixo Materials" +DEV = honeybee_ph_rhino._component_info_.set_component_params(ghenv, dev=False) +if DEV: + from honeybee_ph_rhino.gh_compo_io import assmbly_import_flixo_mats as gh_compo_io + reload(gh_compo_io) + +# ------------------------------------------------------------------------------ +# -- GH Interface +IGH = gh_io.IGH( ghdoc, ghenv, sc, rh, rs, ghc, gh ) + +# ------------------------------------------------------------------------------ +gh_compo_interface = gh_compo_io.GHCompo_ImportFlixoMaterials( + IGH, + _path + ) +materials_ = gh_compo_interface.run() \ No newline at end of file diff --git a/honeybee_grasshopper_ph/user_objects/HBPH - Calc Air Layer HB Material.ghuser b/honeybee_grasshopper_ph/user_objects/HBPH - Calc Air Layer HB Material.ghuser new file mode 100644 index 0000000..1e8c88a Binary files /dev/null and b/honeybee_grasshopper_ph/user_objects/HBPH - Calc Air Layer HB Material.ghuser differ diff --git a/honeybee_grasshopper_ph/user_objects/HBPH - Create Custom Collection.ghuser b/honeybee_grasshopper_ph/user_objects/HBPH - Create Custom Collection.ghuser new file mode 100644 index 0000000..274d602 Binary files /dev/null and b/honeybee_grasshopper_ph/user_objects/HBPH - Create Custom Collection.ghuser differ diff --git a/honeybee_grasshopper_ph/user_objects/HBPH - Create Detailed Constructions.ghuser b/honeybee_grasshopper_ph/user_objects/HBPH - Create Detailed Constructions.ghuser new file mode 100644 index 0000000..d172fbe Binary files /dev/null and b/honeybee_grasshopper_ph/user_objects/HBPH - Create Detailed Constructions.ghuser differ diff --git a/honeybee_grasshopper_ph/user_objects/HBPH - Get Brep Subface Materials.ghuser b/honeybee_grasshopper_ph/user_objects/HBPH - Get Brep Subface Materials.ghuser new file mode 100644 index 0000000..6b2ccaf Binary files /dev/null and b/honeybee_grasshopper_ph/user_objects/HBPH - Get Brep Subface Materials.ghuser differ diff --git a/honeybee_grasshopper_ph/user_objects/HBPH - Get From Custom Collection.ghuser b/honeybee_grasshopper_ph/user_objects/HBPH - Get From Custom Collection.ghuser new file mode 100644 index 0000000..a40b869 Binary files /dev/null and b/honeybee_grasshopper_ph/user_objects/HBPH - Get From Custom Collection.ghuser differ diff --git a/honeybee_grasshopper_ph/user_objects/HBPH - Import Flixo Materials.ghuser b/honeybee_grasshopper_ph/user_objects/HBPH - Import Flixo Materials.ghuser new file mode 100644 index 0000000..1d6edf6 Binary files /dev/null and b/honeybee_grasshopper_ph/user_objects/HBPH - Import Flixo Materials.ghuser differ diff --git a/honeybee_ph_rhino/_component_info_.py b/honeybee_ph_rhino/_component_info_.py index ead8cae..702103e 100644 --- a/honeybee_ph_rhino/_component_info_.py +++ b/honeybee_ph_rhino/_component_info_.py @@ -5,7 +5,7 @@ These are called when the component is instantiated within the Grasshopper canvas. """ -RELEASE_VERSION = "Honeybee-PH v1.0.28" +RELEASE_VERSION = "Honeybee-PH v1.0.29" CATEGORY = "HB-PH" SUB_CATEGORIES = { 0: "00 | Utils", @@ -336,6 +336,24 @@ "Category": CATEGORY, "SubCategory": 1, }, + "HBPH - Import Flixo Materials": { + "NickName": "Import Flixo Mats.", + "Message": RELEASE_VERSION, + "Category": CATEGORY, + "SubCategory": 1, + }, + "HBPH - Create Detailed Constructions": { + "NickName": "Create Detailed Constructions", + "Message": RELEASE_VERSION, + "Category": CATEGORY, + "SubCategory": 1, + }, + "HBPH - Calc Air Layer HB Material": { + "NickName": "Create Air Layer Mat", + "Message": RELEASE_VERSION, + "Category": CATEGORY, + "SubCategory": 1, + }, # -- Shading "HBPH - Create Building Shading": { "NickName": "Create Shading", @@ -418,6 +436,25 @@ "Category": CATEGORY, "SubCategory": 4, }, + # -- Utility + "HBPH - Get Brep Subface Materials": { + "NickName": "Get Subface Mats", + "Message": RELEASE_VERSION, + "Category": CATEGORY, + "SubCategory": 4, + }, + "HBPH - Create Custom Collection": { + "NickName": "Create Collection", + "Message": RELEASE_VERSION, + "Category": CATEGORY, + "SubCategory": 4, + }, + "HBPH - Get From Custom Collection": { + "NickName": "Get From Collection", + "Message": RELEASE_VERSION, + "Category": CATEGORY, + "SubCategory": 4, + }, } diff --git a/honeybee_ph_rhino/gh_compo_io/__init__.py b/honeybee_ph_rhino/gh_compo_io/__init__.py index 7fad946..4db4f3c 100644 --- a/honeybee_ph_rhino/gh_compo_io/__init__.py +++ b/honeybee_ph_rhino/gh_compo_io/__init__.py @@ -25,6 +25,9 @@ # -- Envelope from honeybee_ph_rhino.gh_compo_io.assmbly_create_sd_const import GHCompo_CreateSDConstructions from honeybee_ph_rhino.gh_compo_io.assmbly_create_mixed_mat import GHCompo_CreateMixedHBMaterial +from honeybee_ph_rhino.gh_compo_io.assmbly_import_flixo_mats import GHCompo_ImportFlixoMaterials +from honeybee_ph_rhino.gh_compo_io.assmbly_create_detailed_const import GHCompo_CreateDetailedConstructions +from honeybee_ph_rhino.gh_compo_io.assmbly_create_air_layer_mat import GHCompo_AirLayerMaterial from honeybee_ph_rhino.gh_compo_io.set_spec_heat_cap import GHCompo_SetRoomSpecHeatCaps # -- Mech from honeybee_ph_rhino.gh_compo_io.mech_create_vent_sys import GHCompo_CreateVentSystem @@ -68,4 +71,8 @@ from honeybee_ph_rhino.gh_compo_io.write_PHPP import GHCompo_WriteToPHPP # -- Foundations from honeybee_ph_rhino.gh_compo_io.foundations_add import GHCompo_AddFoundations -from honeybee_ph_rhino.gh_compo_io.foundations_create import GHCompo_CreateFoundations \ No newline at end of file +from honeybee_ph_rhino.gh_compo_io.foundations_create import GHCompo_CreateFoundations +# -- Utility +from honeybee_ph_rhino.gh_compo_io.util_create_collection import GHCompo_CreateCustomCollection +from honeybee_ph_rhino.gh_compo_io.util_get_from_collection import GHCompo_GetFromCustomCollection +from honeybee_ph_rhino.gh_compo_io.util_get_brep_subface_mats import GHCompo_GetSubFaceMaterials \ No newline at end of file diff --git a/honeybee_ph_rhino/gh_compo_io/assmbly_create_air_layer_mat.py b/honeybee_ph_rhino/gh_compo_io/assmbly_create_air_layer_mat.py new file mode 100644 index 0000000..d34199b --- /dev/null +++ b/honeybee_ph_rhino/gh_compo_io/assmbly_create_air_layer_mat.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- +# -*- Python Version: 2.7 -*- + +"""GHCompo Interface: HBPH - Calc Air Layer HB Material.""" + +try: + from typing import Optional +except ImportError: + pass # IronPython 2.7 + +from honeybee.typing import clean_ep_string +from honeybee_energy.material.opaque import EnergyMaterial + +try: + from honeybee_ph_rhino import gh_io + from honeybee_ph_rhino.gh_compo_io import ghio_validators +except ImportError as e: + raise ImportError('\nFailed to import honeybee_ph_rhino:\n\t{}'.format(e)) + +try: + from honeybee_ph_utils.input_tools import input_to_int +except: + raise ImportError('\nFailed to import honeybee_ph_utils:\n\t{}'.format(e)) + +class GHCompo_AirLayerMaterial(object): + """Equivalent Thermal Conductivity of Still Air Layers according to PHPP method. + + Applicable to assembly air-layers which are up to 300m thick (12in) AND where + the width and length of the layer are BOTH >10x the thickness of the layer. + This method is similar to the ISO-6946-2017, Appendix D method but not identical. + """ + + display_name = ghio_validators.HBName("display_name") + thickness = ghio_validators.UnitM("thickness") + e_1 = ghio_validators.FloatPercentage("e_1") + e_2 = ghio_validators.FloatPercentage("e_2") + + def __init__(self, _IGH, _name, _hf_direction, _thickness, _e1, _e2): + # type: (gh_io.IGH, str, str, float, float, float) -> None + self.IGH = _IGH + self.hf_direction = input_to_int(_hf_direction, 2) + self.thickness = _thickness or 0.000 + self.e_1 = _e1 or 0.9 + self.e_2 = _e2 or 0.9 + self.display_name = _name or "PH_AirLayer_({:.3f}m_{})".format(self.thickness, self.orientation) + + @property + def h_r(self): + # type: () -> float + """Radiative Coefficient (W/m2-K)""" + return 5.1 / ( 1 / self.e_1 + 1 / self.e_2 - 1) + + @property + def alpha(self): + # type: () -> int + """Surface normal direction in degrees. 0=up, 180=down""" + if self.hf_direction == 1: + return 0 # Upwards + elif self.hf_direction == 2: + return 90 # Horizontal + elif self.hf_direction == 3: + return 180 + else: + raise Exception("Error: Surface orientation not allowed.") + + @property + def orientation(self): + # type: () -> str + """Surface normal direction description""" + if self.hf_direction == 1: + return "Upwards Heat Flow" + elif self.hf_direction == 2: + return "Horizontal Heat Flow" + elif self.hf_direction == 3: + return "Downwards Heat Flow" + else: + raise Exception("Error: Surface orientation not allowed.") + + @property + def h_a(self): + # type: () -> float + """Conduction / Convection Coefficient (W/m2-K) + + h a is determined by conduction in still air for narrow airspaces and + by convection in wide cavities. For calculations in accordance with + ISO-6946-2017, it is the larger of 0.025/d and the value of h_a obtained from + Table D.1 or Table D.2. In Tables D.1 and D.2, d is the thickness of the + airspace in the direction of heat flow, in metres, and ΔT is the temperature + difference across the airspace, in kelvins. Table D.1 should be used when + the temperature difference across the airspace is less than or equal to 5K. + """ + + if self.alpha == 0: + # Upwards + return max(1.95, 0.025/self.thickness) + elif self.alpha == 90: + # Horizontal + return max(1.25, 0.025/self.thickness) + elif self.alpha == 180: + # Downwards + return max(0.12 * (self.thickness**-0.44), 0.025/self.thickness) + else: + raise Exception("Error: Surface orientation not") + + @property + def thermal_conductivity(self): + # type: () -> float + """W/mK""" + return self.thickness * (self.h_a + self.h_r) + + def create_new_HB_Material(self): + # type: () -> EnergyMaterial + return EnergyMaterial( + identifier = self.display_name, + thickness = self.thickness, + conductivity= self.thermal_conductivity, + density = 999.999, + specific_heat = 999.999, + roughness = 'MediumRough', + thermal_absorptance = 0.9, + solar_absorptance = 0.7, + visible_absorptance = None + ) + + def run(self): + # type: () -> Optional[EnergyMaterial] + if not self.thickness or not self.hf_direction: + return None + + return self.create_new_HB_Material() \ No newline at end of file diff --git a/honeybee_ph_rhino/gh_compo_io/assmbly_create_detailed_const.py b/honeybee_ph_rhino/gh_compo_io/assmbly_create_detailed_const.py new file mode 100644 index 0000000..4ba53e3 --- /dev/null +++ b/honeybee_ph_rhino/gh_compo_io/assmbly_create_detailed_const.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +# -*- Python Version: 2.7 -*- + +"""GHCompo Interface: HBPH - Create Detailed Constructions.""" + +try: + from typing import List, Optional, Dict, Any +except ImportError: + pass # IronPython 2.7 + +import os +import json + +from honeybee_energy.material.opaque import EnergyMaterial +from honeybee_energy.construction.opaque import OpaqueConstruction +from honeybee.typing import clean_ep_string + +from ph_units.parser import parse_input +from ph_units.converter import convert + +from honeybee_ph_rhino import gh_io + +class GHCompo_CreateDetailedConstructions(object): + + def __init__(self, _IGH, _path, _materials): + # type: (gh_io.IGH, str, List[EnergyMaterial]) -> None + self.IGH = _IGH + self._path = str(_path) + self.materials = _materials + + @property + def path(self): + # type: () -> Optional[str] + if not os.path.exists(self._path): + return None + + file_extension = str(os.path.splitext(self._path)[1]).upper() + if not file_extension == ".JSON": + msg = "Error: please input only .JSON files." + self.IGH.warning(msg) + return None + + return self._path + + def create_materials(self, _const_data): + # type: (Dict[str, Any]) -> List[EnergyMaterial] + + # -- Turn the materials into a dict + materials = {m.display_name:m for m in self.materials} + + materials_ = [] + for i, mat_name in enumerate(_const_data["materials"]): + + base_mat = materials[mat_name] + + # -- If thicknesses are provided, try and set the thickness + try: + value, unit = parse_input(_const_data["thicknesses"][i]) + thickness = convert(value, unit, "M") + except: + thickness = base_mat.thickness + + # -- build the new material + new_mat = base_mat.duplicate() + new_mat.identifier = "{}_{:.3f}m".format(base_mat.display_name, thickness) + new_mat.thickness = thickness + new_mat.lock() + + materials_.append(new_mat) + + return materials_ + + def run(self): + # type: () -> List[OpaqueConstruction] + if not self.path or not self.materials: + return [] + + # Load the file + with open(self.path) as json_file: + input_data = json.load(json_file) + + constructions_ = [] + for const_data in input_data.values(): + new_const = OpaqueConstruction( + identifier=clean_ep_string(const_data["identifier"]), + materials = self.create_materials(const_data) + ) + constructions_.append(new_const) + + return constructions_ \ No newline at end of file diff --git a/honeybee_ph_rhino/gh_compo_io/assmbly_import_flixo_mats.py b/honeybee_ph_rhino/gh_compo_io/assmbly_import_flixo_mats.py new file mode 100644 index 0000000..2cccdb7 --- /dev/null +++ b/honeybee_ph_rhino/gh_compo_io/assmbly_import_flixo_mats.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- +# -*- Python Version: 2.7 -*- + +"""GHCompo Interface: HBPH - Import Flixo Materials.""" + +try: + from typing import Optional, List +except ImportError: + pass # IronPython 2.7 + +from itertools import izip +import os +from io import open as io_open + +from honeybee.typing import clean_ep_string +from honeybee_energy.material.opaque import EnergyMaterial +from honeybee_ph_rhino import gh_io + +class FlixoDataItem(object): + + def __init__(self, *args, **kwargs): + for k, v in kwargs.items(): + setattr(self, str(k), str(v)) + + @property + def display_name(self): + # type: () -> str + return getattr(self, "Name", "") + + @property + def conductivity(self): + # type: () -> Optional[float] + try: + return float(getattr(self, "LambdaHor")) + except: + return None + + def __str__(self): + # type: () -> str + return "{}(display_name={})".format(self.__class__.__name__, self.display_name) + + def __repr__(self): + return str(self) + + def ToString(self): + return str(self) + + +class GHCompo_ImportFlixoMaterials(object): + THICKNESS = 1.0 #m + DENSITY = 999.9999 + SPEC_HEAT = 999.999 + ROUGHNESS = "Rough" + THERM_ABS = 0.9 + SOL_ABS = 0.7 + VIS_ABS = 0.7 + + def __init__(self, _IGH, _path): + # type: (gh_io.IGH, str) -> None + self.IGH = _IGH + self._path = str(_path) + + @property + def path(self): + # type: () -> Optional[str] + if not os.path.exists(self._path): + return None + + file_extension = str(os.path.splitext(self._path)[1]).upper() + if not file_extension == ".CSV": + msg = "Error: please input only .CSV files." + self.IGH.warning(msg) + return None + + return self._path + + def build_headers(self, _headers): + # type: (str) -> List[str] + headers_list = _headers.split(";") + + headers_ = [] + for header_name in headers_list: + + counter = len([header_name for h in headers_ if "{}_".format(header_name) in h or header_name in h]) + if counter != 0: + header_name = "{}_{}".format(header_name, counter) + headers_.append(header_name) + + return headers_ + + def build_flixo_data_from_inputs(self, _data): + # type: (List[str]) -> List[FlixoDataItem] + flixo_data_items = [] + headers = self.build_headers(_data[1]) + for item in _data[2:]: + flixo_data_items.append( + FlixoDataItem( + **{k:v for k, v in izip(headers, item.split(";")[1:])} + ) + ) + return flixo_data_items + + def build_hb_materials(self, _flixo_data_items): + # type: (List[FlixoDataItem]) -> List[EnergyMaterial] + materials_ = [] + for fl in sorted(_flixo_data_items, key=lambda f: f.display_name): + if not fl.display_name: + continue + + hb_mat = EnergyMaterial( + clean_ep_string(fl.display_name), self.THICKNESS, fl.conductivity, self.DENSITY, + self.SPEC_HEAT, self.ROUGHNESS, self.THERM_ABS, self.SOL_ABS, self.VIS_ABS) + materials_.append(hb_mat) + return materials_ + + def run(self): + # type: () -> List[EnergyMaterial] + if not self.path: + return [] + + # -- Get the file data + with io_open(self.path) as f: + data = f.readlines() + + flixo_data_items = self.build_flixo_data_from_inputs(data) + return self.build_hb_materials(flixo_data_items) diff --git a/honeybee_ph_rhino/gh_compo_io/util_create_collection.py b/honeybee_ph_rhino/gh_compo_io/util_create_collection.py new file mode 100644 index 0000000..2aed76d --- /dev/null +++ b/honeybee_ph_rhino/gh_compo_io/util_create_collection.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# -*- Python Version: 2.7 -*- + +"""GHCompo Interface: HBPH - Create Custom Collection.""" + +try: + from typing import Collection, TypeVar, ValuesView, KeysView, ItemsView, Dict, List, Optional + T = TypeVar("T") +except ImportError: + pass #IronPython 2.7 + +try: + from honeybee_ph_rhino import gh_io +except ImportError as e: + raise ImportError('\nFailed to import honeybee_ph_rhino:\n\t{}'.format(e)) + + +class CustomCollection(object): + + """A custom 'Collection' class which works like a Python Dictionary.""" + + def __init__(self, _display_name="", *args, **kwargs): + # type: (str, List, Dict) -> None + self.display_name = _display_name or "" + self._storage = {} + + def keys(self): + # type: () -> KeysView[str] + return self._storage.keys() + + def items(self): + # type: () -> ItemsView[str, T] + return self._storage.items() + + def values(self): + # type: () -> ValuesView[T] + return self._storage.values() + + def __setitem__(self, k, v): + # type: (str, T) -> None + self._storage[k] = v + + def __getitem__(self, k): + # type: (str) -> T + return self._storage[k] + + def get(self, k, default): + # type: (str, T) -> Optional[T] + return self._storage.get(k, default) + + def __str__(self): + # type: () -> str + return '{} {} ({} items)\n{}'.format( + self.__class__.__name__, + self.display_name, + len(self._storage), + "\n".join([ + "\t - Key: {} = {}...".format(k, str(v)[:25].replace("\n", "")) + for k, v in self.items() + ] + ) + ) + + def __repr__(self): + return str(self) + + def ToString(self): + return str(self) + +class GHCompo_CreateCustomCollection(object): + + def __init__(self, _IGH, _name, _key_name, _items, *args, **kwargs): + # type: (gh_io.IGH, str, str, Collection, List, Dict) -> None + self.IGH = _IGH + self.name = _name + self.key_name = _key_name + self.items = _items + + def key(self, _item): + # type: (T) -> str + """Return the Key to use when storing the value. Returns id(item) by default.""" + if self.key_name: + return str(getattr(_item, self.key_name)) + else: + return str(id(_item)) + + def run(self): + # type: () -> CustomCollection + collection_ = CustomCollection(self.name) + + for item in self.items: + collection_[self.key(item)] = item + + return collection_ \ No newline at end of file diff --git a/honeybee_ph_rhino/gh_compo_io/util_get_brep_subface_mats.py b/honeybee_ph_rhino/gh_compo_io/util_get_brep_subface_mats.py new file mode 100644 index 0000000..28e62bc --- /dev/null +++ b/honeybee_ph_rhino/gh_compo_io/util_get_brep_subface_mats.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# -*- Python Version: 2.7 -*- + +"""GHCompo Interface: HBPH - Get Brep Subface Materials.""" + +try: + from typing import Dict, List, Tuple, Any +except ImportError: + pass #IronPython 2.7 + +try: + from Grasshopper import DataTree # type: ignore + from Grasshopper.Kernel.Data import GH_Path # type: ignore + from System import Object # type: ignore +except: + pass # outside Rhino / Grasshopper + +try: + from honeybee_ph_rhino import gh_io +except ImportError as e: + raise ImportError('\nFailed to import honeybee_ph_rhino:\n\t{}'.format(e)) + + +class GHCompo_GetSubFaceMaterials(object): + + def __init__(self, _IGH, _brep_guids, *args, **kwargs): + # type: (gh_io.IGH, List, List, Dict) -> None + self.IGH = _IGH + self.brep_guids = _brep_guids + + def get_brep_face_data(self, _brep_guid): + # type: (Any, Any) -> Tuple[List, List] + geo_ = [] + names_ = [] + brep = self.IGH.rs.coercebrep(_brep_guid) + for face in brep.Faces: + # -- Add the face geometry to the output set + geo_.append(face) + + # -- Get the BrepFace's Material Name and add to the output + compo_index = self.IGH.Rhino.Geometry.ComponentIndex( + self.IGH.Rhino.Geometry.ComponentIndexType.BrepFace, + face.FaceIndex + ) + brep_obj = self.IGH.Rhino.RhinoDoc.ActiveDoc.Objects.FindId(_brep_guid) + mat_name = self.IGH.Rhino.DocObjects.RhinoObject.GetMaterial(brep_obj, compo_index).Name + names_.append(mat_name) + + return geo_, names_ + + def run(self): + subface_geo_ = DataTree[Object]() + mat_names_ = DataTree[Object]() + + with self.IGH.context_rh_doc(): + for i, brep_guid in enumerate(self.brep_guids): + faces, mats = self.get_brep_face_data(brep_guid) + subface_geo_.AddRange(faces, GH_Path(i)) + mat_names_.AddRange(mats, GH_Path(i)) + + return subface_geo_, mat_names_ \ No newline at end of file diff --git a/honeybee_ph_rhino/gh_compo_io/util_get_from_collection.py b/honeybee_ph_rhino/gh_compo_io/util_get_from_collection.py new file mode 100644 index 0000000..3baf009 --- /dev/null +++ b/honeybee_ph_rhino/gh_compo_io/util_get_from_collection.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# -*- Python Version: 2.7 -*- + +"""GHCompo Interface: HBPH - Get From Custom Collection.""" + +try: + from typing import Dict, List +except ImportError: + pass #IronPython 2.7 + +try: + from honeybee_ph_rhino import gh_io +except ImportError as e: + raise ImportError('\nFailed to import honeybee_ph_rhino:\n\t{}'.format(e)) + +from honeybee_ph_rhino.gh_compo_io.util_create_collection import CustomCollection + +class GHCompo_GetFromCustomCollection(object): + + def __init__(self, _IGH, _collection, _keys, *args, **kwargs): + # type: (gh_io.IGH, CustomCollection, List[str], List, Dict) -> None + self.IGH = _IGH + self.collection = _collection + self.keys = _keys + + def run(self): + # type: () -> List + if not self.collection or not self.keys: + return [] + + return [self.collection.get(key, None) for key in self.keys] \ No newline at end of file diff --git a/honeybee_ph_rhino/gh_io.py b/honeybee_ph_rhino/gh_io.py index 974ec23..70dc692 100644 --- a/honeybee_ph_rhino/gh_io.py +++ b/honeybee_ph_rhino/gh_io.py @@ -77,6 +77,11 @@ def __init__(self, _ghdoc, _ghenv, _sc, _rh, _rs, _ghc, _gh): self.ghpythonlib_components = _ghc self.Grasshopper = _gh + @property + def rs(self): + """Convenience Attribute Alias.""" + return self.rhinoscriptsyntax + def gh_compo_find_input_index_by_name(self, _input_name): # type: (str) -> int """