Skip to content

Commit

Permalink
fix(output): Expose simulation outputs for unmet hours
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Dec 2, 2023
1 parent e61a434 commit 2225917
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 67 deletions.
Binary file modified honeybee_grasshopper_energy/icon/HB Custom Simulation Output.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 honeybee_grasshopper_energy/icon/HB Read Room Comfort Result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 25 additions & 18 deletions honeybee_grasshopper_energy/json/HB_Custom_Simulation_Output.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
{
"description": "Create a custom simulation output object by plugging in one or more names of\nEnergyPlus simulation ouputs.\nThe resulting object can be used to request output variables from EnergyPlus.\n-",
"version": "1.7.2",
"nickname": "CustomOutput",
"outputs": [
[
{
"type": null,
"access": "None",
"name": "sim_output",
"description": "A SimulationOutput object that can be connected to the\n\"HB Simulation Parameter\" component in order to specify which\ntypes of outputs should be written from EnergyPlus.",
"access": "None",
"type": null,
"default": null
}
]
],
"code": "\ntry:\n from honeybee_energy.simulation.output import SimulationOutput\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import turn_off_old_tag\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\nturn_off_old_tag(ghenv.Component)\n\n\n# set the starting sim_output\nsim_output = base_sim_output_.duplicate() if base_sim_output_ is not None \\\n else SimulationOutput()\n\n# set reporting frequency\nif _report_frequency_ is not None:\n sim_output.reporting_frequency = _report_frequency_.title()\n\n# add the _output names\nfor output_name in output_names_:\n sim_output.add_output(output_name)\n\n# add the summary_reports_\nfor rep in summary_reports_:\n sim_output.add_summary_report(rep)\n",
"name": "HB Custom Simulation Output",
"version": "1.7.1",
"category": "HB-Energy",
"subcategory": "5 :: Simulate",
"nickname": "CustomOutput",
"inputs": [
{
"type": "System.Object",
"access": "item",
"name": "base_sim_output_",
"description": "An optional simulation output object to serve as the\nstarting point for the sim_output object returned by this component.\nAll of the output names will simply be appended to this initial\nstarting object.",
"access": "item",
"type": "System.Object",
"default": null
},
{
"type": "string",
"access": "list",
"name": "output_names_",
"description": "A list of EnergyPlus output names as strings (eg.\n'Surface Window System Solar Transmittance'. These outputs will be\nrequested from the simulation.",
"access": "list",
"type": "string",
"default": null
},
{
"type": "string",
"access": "item",
"name": "_report_frequency_",
"description": "Text for the frequency at which the outputs\nare reported. Default: 'Hourly'.\nChoose from the following:\n* Annual\n* Monthly\n* Daily\n* Hourly\n* Timestep",
"access": "item",
"type": "string",
"default": null
},
{
"type": "string",
"access": "list",
"name": "summary_reports_",
"description": "An optional list of EnergyPlus summary report names as strings.\nIf None, only the 'AllSummary' report will be requested from the\nsimulation and will appear in the HTML report output by EnergyPlus.\nSee the Input Output Reference SummaryReports section for a full\nlist of all reports that can be requested. https://bigladdersoftware.com/\nepx/docs/9-1/input-output-reference/output-table-summaryreports.html",
"access": "list",
"type": "string",
"default": null
},
{
"access": "item",
"name": "x",
"description": "A number in degrees Celsius for the difference that the zone\nconditions must be from the thermostat setpoint in order\nfor the setpoint to be considered unmet. This will affect how unmet\nhours are reported in the output. ASHRAE 90.1 uses a tolerance of\n1.11C, which is equivalent to 1.8F. (Default: 1.11C).",
"type": "double",
"default": null
}
]
],
"subcategory": "5 :: Simulate",
"code": "\ntry:\n from honeybee_energy.simulation.output import SimulationOutput\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import turn_off_old_tag\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\nturn_off_old_tag(ghenv.Component)\n\n\n# set the starting sim_output\nsim_output = base_sim_output_.duplicate() if base_sim_output_ is not None \\\n else SimulationOutput()\n\n# set reporting frequency\nif _report_frequency_ is not None:\n sim_output.reporting_frequency = _report_frequency_.title()\n\n# add the _output names\nfor output_name in output_names_:\n sim_output.add_output(output_name)\n\n# add the summary_reports_\nfor rep in summary_reports_:\n sim_output.add_summary_report(rep)\n\n# add the unmet setpoint tolerance\nif _unmet_setpt_tol_ is not None:\n sim_output.unmet_setpoint_tolerance = _unmet_setpt_tol_\n",
"category": "HB-Energy",
"name": "HB Custom Simulation Output",
"description": "Create a custom simulation output object by plugging in one or more names of\nEnergyPlus simulation ouputs.\nThe resulting object can be used to request output variables from EnergyPlus.\n-"
}
48 changes: 31 additions & 17 deletions honeybee_grasshopper_energy/json/HB_Read_Room_Comfort_Result.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,64 @@
{
"name": "HB Read Room Comfort Result",
"subcategory": "6 :: Result",
"version": "1.7.1",
"description": "Parse all of the common Room-level comfort-related results from an SQL result\nfile that has been generated from an energy simulation.\n-",
"code": "\nimport os\nimport subprocess\nimport json\n\ntry:\n from ladybug.datacollection import HourlyContinuousCollection, \\\n MonthlyCollection, DailyCollection\n from ladybug.sql import SQLiteResult\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from honeybee.config import folders\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\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\ndef serialize_data(data_dicts):\n \"\"\"Reserialize a list of collection dictionaries.\"\"\"\n if len(data_dicts) == 0:\n return []\n elif data_dicts[0]['type'] == 'HourlyContinuous':\n return [HourlyContinuousCollection.from_dict(data) for data in data_dicts]\n elif data_dicts[0]['type'] == 'Monthly':\n return [MonthlyCollection.from_dict(data) for data in data_dicts]\n elif data_dicts[0]['type'] == 'Daily':\n return [DailyCollection.from_dict(data) for data in data_dicts]\n\n\n# List of all the output strings that will be requested\noper_temp_output = 'Zone Operative Temperature'\nair_temp_output = 'Zone Mean Air Temperature'\nrad_temp_output = 'Zone Mean Radiant Temperature'\nrel_humidity_output = 'Zone Air Relative Humidity'\nall_output = [oper_temp_output, air_temp_output, rad_temp_output, rel_humidity_output]\n\n\nif all_required_inputs(ghenv.Component):\n # check the size of the SQL file to see if we should use the CLI\n assert os.path.isfile(_sql), 'No sql file found at: {}.'.format(_sql)\n if os.name == 'nt' and os.path.getsize(_sql) < 1e8:\n # small file on windows; use IronPython like usual\n sql_obj = SQLiteResult(_sql) # create the SQL result parsing object\n # get all of the results\n oper_temp = sql_obj.data_collections_by_output_name(oper_temp_output)\n air_temp = sql_obj.data_collections_by_output_name(air_temp_output)\n rad_temp = sql_obj.data_collections_by_output_name(rad_temp_output)\n rel_humidity = sql_obj.data_collections_by_output_name(rel_humidity_output)\n\n else: # use the honeybee_energy CLI\n # sqlite3 module doesn't work in Mac IronPython\n # or the file's big and we know that the Python3 version scales better\n # Execute the honybee CLI to obtain the results via CPython\n cmds = [folders.python_exe_path, '-m', 'honeybee_energy', 'result',\n 'data-by-outputs', _sql] + all_output\n use_shell = True if os.name == 'nt' else False\n custom_env = os.environ.copy()\n custom_env['PYTHONHOME'] = ''\n process = subprocess.Popen(\n cmds, stdout=subprocess.PIPE, shell=use_shell, env=custom_env)\n stdout = process.communicate()\n data_coll_dicts = json.loads(stdout[0])\n # get all of the results\n oper_temp = serialize_data(data_coll_dicts[0])\n air_temp = serialize_data(data_coll_dicts[1])\n rad_temp = serialize_data(data_coll_dicts[2])\n rel_humidity = serialize_data(data_coll_dicts[3])\n",
"version": "1.7.2",
"nickname": "RoomComfortResult",
"outputs": [
[
{
"name": "oper_temp",
"access": "None",
"type": null,
"name": "oper_temp",
"description": "DataCollections for the mean operative temperature of each room (C).",
"type": null,
"default": null
},
{
"name": "air_temp",
"access": "None",
"type": null,
"name": "air_temp",
"description": "DataCollections for the mean air temperature of each room (C).",
"type": null,
"default": null
},
{
"name": "rad_temp",
"access": "None",
"type": null,
"name": "rad_temp",
"description": "DataCollections for the mean radiant temperature of each room (C).",
"type": null,
"default": null
},
{
"access": "None",
"name": "rel_humidity",
"description": "DataCollections for the relative humidity of each room (%).",
"type": null,
"default": null
},
{
"access": "None",
"name": "unmet_heat",
"description": "DataCollections for time that the heating setpoint is not met\nin each room (hours).",
"type": null,
"default": null
},
{
"access": "None",
"name": "unmet_cool",
"description": "DataCollections for time that the cooling setpoint is not met\nin each room (hours).",
"type": null,
"description": "DataCollections for the relative humidity of each room (%).",
"default": null
}
]
],
"category": "HB-Energy",
"nickname": "RoomComfortResult",
"inputs": [
{
"name": "_sql",
"access": "item",
"type": "string",
"name": "_sql",
"description": "The file path of the SQL result file that has been generated from\nan energy simulation.",
"type": "string",
"default": null
}
]
],
"subcategory": "6 :: Result",
"code": "\nimport os\nimport subprocess\nimport json\n\ntry:\n from ladybug.datacollection import HourlyContinuousCollection, \\\n MonthlyCollection, DailyCollection\n from ladybug.sql import SQLiteResult\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from honeybee.config import folders\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\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\ndef serialize_data(data_dicts):\n \"\"\"Reserialize a list of collection dictionaries.\"\"\"\n if len(data_dicts) == 0:\n return []\n elif data_dicts[0]['type'] == 'HourlyContinuous':\n return [HourlyContinuousCollection.from_dict(data) for data in data_dicts]\n elif data_dicts[0]['type'] == 'Monthly':\n return [MonthlyCollection.from_dict(data) for data in data_dicts]\n elif data_dicts[0]['type'] == 'Daily':\n return [DailyCollection.from_dict(data) for data in data_dicts]\n\n\n# List of all the output strings that will be requested\noper_temp_output = 'Zone Operative Temperature'\nair_temp_output = 'Zone Mean Air Temperature'\nrad_temp_output = 'Zone Mean Radiant Temperature'\nrel_humidity_output = 'Zone Air Relative Humidity'\nheat_setpt_output = 'Zone Heating Setpoint Not Met Time'\ncool_setpt_output = 'Zone Cooling Setpoint Not Met Time'\nall_output = [\n oper_temp_output, air_temp_output, rad_temp_output,\n rel_humidity_output, heat_setpt_output, cool_setpt_output\n]\n\n\nif all_required_inputs(ghenv.Component):\n # check the size of the SQL file to see if we should use the CLI\n assert os.path.isfile(_sql), 'No sql file found at: {}.'.format(_sql)\n if os.name == 'nt' and os.path.getsize(_sql) < 1e8:\n # small file on windows; use IronPython like usual\n sql_obj = SQLiteResult(_sql) # create the SQL result parsing object\n # get all of the results\n oper_temp = sql_obj.data_collections_by_output_name(oper_temp_output)\n air_temp = sql_obj.data_collections_by_output_name(air_temp_output)\n rad_temp = sql_obj.data_collections_by_output_name(rad_temp_output)\n rel_humidity = sql_obj.data_collections_by_output_name(rel_humidity_output)\n unmet_heat = sql_obj.data_collections_by_output_name(heat_setpt_output)\n unmet_cool = sql_obj.data_collections_by_output_name(cool_setpt_output)\n\n else: # use the honeybee_energy CLI\n # sqlite3 module doesn't work in Mac IronPython\n # or the file's big and we know that the Python3 version scales better\n # Execute the honybee CLI to obtain the results via CPython\n cmds = [folders.python_exe_path, '-m', 'honeybee_energy', 'result',\n 'data-by-outputs', _sql] + all_output\n use_shell = True if os.name == 'nt' else False\n custom_env = os.environ.copy()\n custom_env['PYTHONHOME'] = ''\n process = subprocess.Popen(\n cmds, stdout=subprocess.PIPE, shell=use_shell, env=custom_env)\n stdout = process.communicate()\n data_coll_dicts = json.loads(stdout[0])\n # get all of the results\n oper_temp = serialize_data(data_coll_dicts[0])\n air_temp = serialize_data(data_coll_dicts[1])\n rad_temp = serialize_data(data_coll_dicts[2])\n rel_humidity = serialize_data(data_coll_dicts[3])\n unmet_heat = serialize_data(data_coll_dicts[4])\n unmet_cool = serialize_data(data_coll_dicts[5])\n",
"category": "HB-Energy",
"name": "HB Read Room Comfort Result",
"description": "Parse all of the common Room-level comfort-related results from an SQL result\nfile that has been generated from an energy simulation.\n-"
}
Loading

0 comments on commit 2225917

Please sign in to comment.