Skip to content

Commit

Permalink
fix(thermal_map): Perform extra check for units system
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Jan 12, 2023
1 parent a45347a commit b8cbd1f
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 9 deletions.
4 changes: 2 additions & 2 deletions honeybee_grasshopper_energy/json/HB_Adaptive_Comfort_Map.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.5.0",
"version": "1.5.1",
"nickname": "AdaptiveMap",
"outputs": [
[
Expand Down Expand Up @@ -141,7 +141,7 @@
}
],
"subcategory": "7 :: Thermal Map",
"code": "\ntry:\n from lbt_recipes.recipe import Recipe\nexcept ImportError as e:\n raise ImportError('\\nFailed to import lbt_recipes:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, recipe_result\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 # create the recipe and set the input arguments\n recipe = Recipe('adaptive_comfort_map')\n recipe.input_value_by_name('model', _model)\n recipe.input_value_by_name('epw', _epw)\n recipe.input_value_by_name('ddy', _ddy)\n recipe.input_value_by_name('north', north_)\n recipe.input_value_by_name('run-period', run_period_)\n recipe.input_value_by_name('additional-idf', add_str_)\n recipe.input_value_by_name('air-speed', _air_speed_)\n recipe.input_value_by_name('comfort-parameters', comfort_par_)\n recipe.input_value_by_name('solarcal-parameters', solar_body_par_)\n recipe.input_value_by_name('radiance-parameters', radiance_par_)\n\n # run the recipe\n silent = True if _run > 1 else False\n project_folder = recipe.run(\n run_settings_, radiance_check=True, openstudio_check=True, silent=silent)\n\n # load the results\n try:\n env_conds = recipe_result(recipe.output_value_by_name('environmental-conditions', project_folder))\n op_temp = recipe_result(recipe.output_value_by_name('temperature', project_folder))\n condition = recipe_result(recipe.output_value_by_name('condition', project_folder))\n deg_neut = recipe_result(recipe.output_value_by_name('degrees-from-neutral', project_folder))\n TCP = recipe_result(recipe.output_value_by_name('tcp', project_folder))\n HSP = recipe_result(recipe.output_value_by_name('hsp', project_folder))\n CSP = recipe_result(recipe.output_value_by_name('csp', project_folder))\n except Exception:\n raise Exception(recipe.failure_message(project_folder))\n",
"code": "\ntry:\n from lbt_recipes.recipe import Recipe\n from honeybee.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import lbt_recipes:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import units_system\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, recipe_result\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 # create the recipe and set the input arguments\n recipe = Recipe('adaptive_comfort_map')\n recipe.input_value_by_name('model', _model)\n recipe.input_value_by_name('epw', _epw)\n recipe.input_value_by_name('ddy', _ddy)\n recipe.input_value_by_name('north', north_)\n recipe.input_value_by_name('run-period', run_period_)\n recipe.input_value_by_name('additional-idf', add_str_)\n recipe.input_value_by_name('air-speed', _air_speed_)\n recipe.input_value_by_name('comfort-parameters', comfort_par_)\n recipe.input_value_by_name('solarcal-parameters', solar_body_par_)\n recipe.input_value_by_name('radiance-parameters', radiance_par_)\n\n # perform an extra check for units because many people forget to check them\n if isinstance(_model, Model):\n check_model = _model\n if check_model.units != 'Meters':\n check_model = _model.duplicate()\n check_model.convert_to_units('Meters')\n # remove degenerate geometry within native E+ tolerance of 0.01 meters\n for room in check_model.rooms:\n try:\n room.remove_colinear_vertices_envelope(\n tolerance=0.01, delete_degenerate=True)\n except AssertionError as e: # room removed; likely wrong units\n error = 'Your Model units system is: {}. ' \\\n 'Is this correct?\\n{}'.format(_model.units, e)\n raise ValueError(error)\n\n # run the recipe\n silent = True if _run > 1 else False\n project_folder = recipe.run(\n run_settings_, radiance_check=True, openstudio_check=True, silent=silent)\n\n # load the results\n try:\n env_conds = recipe_result(recipe.output_value_by_name('environmental-conditions', project_folder))\n op_temp = recipe_result(recipe.output_value_by_name('temperature', project_folder))\n condition = recipe_result(recipe.output_value_by_name('condition', project_folder))\n deg_neut = recipe_result(recipe.output_value_by_name('degrees-from-neutral', project_folder))\n TCP = recipe_result(recipe.output_value_by_name('tcp', project_folder))\n HSP = recipe_result(recipe.output_value_by_name('hsp', project_folder))\n CSP = recipe_result(recipe.output_value_by_name('csp', project_folder))\n except Exception:\n raise Exception(recipe.failure_message(project_folder))\n",
"category": "HB-Energy",
"name": "HB Adaptive Comfort Map",
"description": "Compute spatially-resolved operative temperature and Adaptive thermal comfort from\na Honeybee model.\n_\nThis recipe uses EnergyPlus to obtain surface temperatures and indoor air\ntemperatures + humidities. Outdoor air temperatures, relative humidities, and\nair speeds are taken directly from the EPW. The energy properties of the model\ngeometry are what determine the outcome of the simulation, though the model's\nRadiance sensor grids are what determine where the comfort mapping occurs.\n_\nLongwave radiant temperatures are obtained by computing spherical view factors\nfrom each sensor to the Room surfaces of the model using Radiance. These view factors\nare then multiplied by the surface temperatures output by EnergyPlus to yield\nlongwave MRT at each sensor. All indoor shades (eg. those representing furniture)\nare assumed to be at the room-average MRT.\n_\nA Radiance-based enhanced 2-phase method is used for all shortwave MRT calculations,\nwhich precisely represents direct sun by tracing a ray from each sensor to the\nsolar position. To determine Thermal Comfort Percent (TCP), the occupancy schedules\nof the energy model are used. Any hour of the occupancy schedule that is 0.1 or\ngreater will be considered occupied. All hours of the outdoors are considered occupied.\n-"
Expand Down
4 changes: 2 additions & 2 deletions honeybee_grasshopper_energy/json/HB_PMV_Comfort_Map.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.5.0",
"version": "1.5.1",
"nickname": "PMVMap",
"outputs": [
[
Expand Down Expand Up @@ -162,7 +162,7 @@
}
],
"subcategory": "7 :: Thermal Map",
"code": "\ntry:\n from lbt_recipes.recipe import Recipe\nexcept ImportError as e:\n raise ImportError('\\nFailed to import lbt_recipes:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, recipe_result\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 # create the recipe and set the input arguments\n recipe = Recipe('pmv_comfort_map')\n recipe.input_value_by_name('model', _model)\n recipe.input_value_by_name('epw', _epw)\n recipe.input_value_by_name('ddy', _ddy)\n recipe.input_value_by_name('north', north_)\n recipe.input_value_by_name('run-period', run_period_)\n recipe.input_value_by_name('additional-idf', add_str_)\n recipe.input_value_by_name('write-set-map', write_set_map_)\n recipe.input_value_by_name('air-speed', _air_speed_)\n recipe.input_value_by_name('met-rate', _met_rate_)\n recipe.input_value_by_name('clo-value', _clo_value_)\n recipe.input_value_by_name('comfort-parameters', comfort_par_)\n recipe.input_value_by_name('solarcal-parameters', solar_body_par_)\n recipe.input_value_by_name('radiance-parameters', radiance_par_)\n\n # run the recipe\n silent = True if _run > 1 else False\n project_folder = recipe.run(\n run_settings_, radiance_check=True, openstudio_check=True, silent=silent)\n\n # load the results\n try:\n env_conds = recipe_result(recipe.output_value_by_name('environmental-conditions', project_folder))\n temperature = recipe_result(recipe.output_value_by_name('temperature', project_folder))\n condition = recipe_result(recipe.output_value_by_name('condition', project_folder))\n pmv = recipe_result(recipe.output_value_by_name('pmv', project_folder))\n TCP = recipe_result(recipe.output_value_by_name('tcp', project_folder))\n HSP = recipe_result(recipe.output_value_by_name('hsp', project_folder))\n CSP = recipe_result(recipe.output_value_by_name('csp', project_folder))\n except Exception:\n raise Exception(recipe.failure_message(project_folder))\n",
"code": "\ntry:\n from lbt_recipes.recipe import Recipe\n from honeybee.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import lbt_recipes:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import units_system\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, recipe_result\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 # create the recipe and set the input arguments\n recipe = Recipe('pmv_comfort_map')\n recipe.input_value_by_name('model', _model)\n recipe.input_value_by_name('epw', _epw)\n recipe.input_value_by_name('ddy', _ddy)\n recipe.input_value_by_name('north', north_)\n recipe.input_value_by_name('run-period', run_period_)\n recipe.input_value_by_name('additional-idf', add_str_)\n recipe.input_value_by_name('write-set-map', write_set_map_)\n recipe.input_value_by_name('air-speed', _air_speed_)\n recipe.input_value_by_name('met-rate', _met_rate_)\n recipe.input_value_by_name('clo-value', _clo_value_)\n recipe.input_value_by_name('comfort-parameters', comfort_par_)\n recipe.input_value_by_name('solarcal-parameters', solar_body_par_)\n recipe.input_value_by_name('radiance-parameters', radiance_par_)\n\n # perform an extra check for units because many people forget to check them\n if isinstance(_model, Model):\n check_model = _model\n if check_model.units != 'Meters':\n check_model = _model.duplicate()\n check_model.convert_to_units('Meters')\n # remove degenerate geometry within native E+ tolerance of 0.01 meters\n for room in check_model.rooms:\n try:\n room.remove_colinear_vertices_envelope(\n tolerance=0.01, delete_degenerate=True)\n except AssertionError as e: # room removed; likely wrong units\n error = 'Your Model units system is: {}. ' \\\n 'Is this correct?\\n{}'.format(_model.units, e)\n raise ValueError(error)\n\n # run the recipe\n silent = True if _run > 1 else False\n project_folder = recipe.run(\n run_settings_, radiance_check=True, openstudio_check=True, silent=silent)\n\n # load the results\n try:\n env_conds = recipe_result(recipe.output_value_by_name('environmental-conditions', project_folder))\n temperature = recipe_result(recipe.output_value_by_name('temperature', project_folder))\n condition = recipe_result(recipe.output_value_by_name('condition', project_folder))\n pmv = recipe_result(recipe.output_value_by_name('pmv', project_folder))\n TCP = recipe_result(recipe.output_value_by_name('tcp', project_folder))\n HSP = recipe_result(recipe.output_value_by_name('hsp', project_folder))\n CSP = recipe_result(recipe.output_value_by_name('csp', project_folder))\n except Exception:\n raise Exception(recipe.failure_message(project_folder))\n",
"category": "HB-Energy",
"name": "HB PMV Comfort Map",
"description": "Compute spatially-resolved operative temperature and Predicted Mean Vote (PMV)\nthermal comfort from a Honeybee model. This recipe can also (optionally)\ncompute Standard Effective Temperature (SET).\n_\nThis recipe uses EnergyPlus to obtain surface temperatures and indoor air\ntemperatures + humidities. Outdoor air temperatures, relative humidities, and\nair speeds are taken directly from the EPW. The energy properties of the model\ngeometry are what determine the outcome of the simulation, though the model's\nRadiance sensor grids are what determine where the comfort mapping occurs.\n_\nLongwave radiant temperatures are obtained by computing spherical view factors\nfrom each sensor to the Room surfaces of the model using Radiance. These view factors\nare then multiplied by the surface temperatures output by EnergyPlus to yield\nlongwave MRT at each sensor. All indoor shades (eg. those representing furniture)\nare assumed to be at the room-average MRT.\n_\nA Radiance-based enhanced 2-phase method is used for all shortwave MRT calculations,\nwhich precisely represents direct sun by tracing a ray from each sensor to the\nsolar position. To determine Thermal Comfort Percent (TCP), the occupancy schedules\nof the energy model are used. Any hour of the occupancy schedule that is 0.1 or\ngreater will be considered occupied. All hours of the outdoors are considered occupied.\n-"
Expand Down
4 changes: 2 additions & 2 deletions honeybee_grasshopper_energy/json/HB_UTCI_Comfort_Map.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.5.1",
"version": "1.5.2",
"nickname": "UTCIMap",
"outputs": [
[
Expand Down Expand Up @@ -134,7 +134,7 @@
}
],
"subcategory": "7 :: Thermal Map",
"code": "\nimport os\n\ntry:\n from lbt_recipes.recipe import Recipe\nexcept ImportError as e:\n raise ImportError('\\nFailed to import lbt_recipes:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, recipe_result\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 # create the recipe and set the input arguments\n recipe = Recipe('utci_comfort_map')\n recipe.input_value_by_name('model', _model)\n recipe.input_value_by_name('epw', _epw)\n recipe.input_value_by_name('ddy', ddy_)\n recipe.input_value_by_name('north', north_)\n recipe.input_value_by_name('run-period', run_period_)\n if isinstance(_wind_speed_, str) and os.path.isdir(_wind_speed_):\n recipe.input_value_by_name('air-speed-matrices', _wind_speed_)\n else:\n recipe.input_value_by_name('wind-speed', _wind_speed_)\n recipe.input_value_by_name('schedule', schedule_)\n recipe.input_value_by_name('solarcal-parameters', solar_body_par_)\n recipe.input_value_by_name('radiance-parameters', radiance_par_)\n\n # run the recipe\n silent = True if _run > 1 else False\n project_folder = recipe.run(\n run_settings_, radiance_check=True, openstudio_check=True, silent=silent)\n\n # load the results\n try:\n env_conds = recipe_result(recipe.output_value_by_name('environmental-conditions', project_folder))\n utci = recipe_result(recipe.output_value_by_name('utci', project_folder))\n condition = recipe_result(recipe.output_value_by_name('condition', project_folder))\n category = recipe_result(recipe.output_value_by_name('category', project_folder))\n TCP = recipe_result(recipe.output_value_by_name('tcp', project_folder))\n HSP = recipe_result(recipe.output_value_by_name('hsp', project_folder))\n CSP = recipe_result(recipe.output_value_by_name('csp', project_folder))\n except Exception:\n raise Exception(recipe.failure_message(project_folder))\n",
"code": "\nimport os\n\ntry:\n from lbt_recipes.recipe import Recipe\n from honeybee.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import lbt_recipes:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import units_system\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, recipe_result\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 # create the recipe and set the input arguments\n recipe = Recipe('utci_comfort_map')\n recipe.input_value_by_name('model', _model)\n recipe.input_value_by_name('epw', _epw)\n recipe.input_value_by_name('ddy', ddy_)\n recipe.input_value_by_name('north', north_)\n recipe.input_value_by_name('run-period', run_period_)\n if isinstance(_wind_speed_, str) and os.path.isdir(_wind_speed_):\n recipe.input_value_by_name('air-speed-matrices', _wind_speed_)\n else:\n recipe.input_value_by_name('wind-speed', _wind_speed_)\n recipe.input_value_by_name('schedule', schedule_)\n recipe.input_value_by_name('solarcal-parameters', solar_body_par_)\n recipe.input_value_by_name('radiance-parameters', radiance_par_)\n\n # perform an extra check for units because many people forget to check them\n if isinstance(_model, Model):\n check_model = _model\n if check_model.units != 'Meters':\n check_model = _model.duplicate()\n check_model.convert_to_units('Meters')\n # remove degenerate geometry within native E+ tolerance of 0.01 meters\n for room in check_model.rooms:\n try:\n room.remove_colinear_vertices_envelope(\n tolerance=0.01, delete_degenerate=True)\n except AssertionError as e: # room removed; likely wrong units\n error = 'Your Model units system is: {}. ' \\\n 'Is this correct?\\n{}'.format(_model.units, e)\n raise ValueError(error)\n\n # run the recipe\n silent = True if _run > 1 else False\n project_folder = recipe.run(\n run_settings_, radiance_check=True, openstudio_check=True, silent=silent)\n\n # load the results\n try:\n env_conds = recipe_result(recipe.output_value_by_name('environmental-conditions', project_folder))\n utci = recipe_result(recipe.output_value_by_name('utci', project_folder))\n condition = recipe_result(recipe.output_value_by_name('condition', project_folder))\n category = recipe_result(recipe.output_value_by_name('category', project_folder))\n TCP = recipe_result(recipe.output_value_by_name('tcp', project_folder))\n HSP = recipe_result(recipe.output_value_by_name('hsp', project_folder))\n CSP = recipe_result(recipe.output_value_by_name('csp', project_folder))\n except Exception:\n raise Exception(recipe.failure_message(project_folder))\n",
"category": "HB-Energy",
"name": "HB UTCI Comfort Map",
"description": "Compute spatially-resolved Universal Thermal Climate Index (UTCI) and heat/cold\nstress conditions an EPW and Honeybee model.\n_\nThis recipe uses EnergyPlus to obtain surface temperatures and indoor air\ntemperatures + humidities. Outdoor air temperatures, relative humidities, and\nair speeds are taken directly from the EPW. The energy properties of the model\ngeometry are what determine the outcome of the simulation, though the model's\nRadiance sensor grids are what determine where the comfort mapping occurs.\n_\nLongwave radiant temperatures are obtained by computing spherical view factors\nfrom each sensor to the Room surfaces of the model using Radiance. These view factors\nare then multiplied by the surface temperatures output by EnergyPlus to yield\nlongwave MRT at each sensor. For outdoor sensors, each sensor's sky view is multiplied\nby the EPW sky temperature to account for longwave radiant exchange with the sky.\nAll outdoor context shades and the ground are assumed to be at the EPW air\ntemperature unless they have been modeled as Honeybee rooms.\n_\nA Radiance-based enhanced 2-phase method is used for all shortwave MRT calculations,\nwhich precisely represents direct sun by tracing a ray from each sensor to the\nsolar position. To determine Thermal Comfort Percent (TCP), the occupancy schedules\nof the energy model are used for indoor sensors if no schedule_ is input. Any\nhour of the energy model occupancy schedule that is 0.1 or greater will be\nconsidered occupied. If no schedule_ is input, all hours of the outdoors are\nconsidered occupied.\n-"
Expand Down
Loading

0 comments on commit b8cbd1f

Please sign in to comment.