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

Fixes to Scouts Loads Summary Measure #133

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
81bbed5
fixes to the load summary measure
mdahlhausen Oct 31, 2023
a71e0a4
Merge branch 'main' into fix/scout_loads_summary
mdahlhausen Mar 6, 2024
13925a6
switch to space lookup for enduse meters
mdahlhausen Mar 6, 2024
e082ddc
remove tests from ci
eringold Mar 12, 2024
940d7cc
Merge branch 'main' into fix/scout_loads_summary
mdahlhausen Mar 13, 2024
a6f472e
Merge branch 'fix/scout_loads_summary' of https://github.com/NREL/Com…
mdahlhausen Mar 13, 2024
6bd0b70
test model updates
eringold Jul 11, 2024
19f98f8
add debug support to test
eringold Jul 12, 2024
1ec6ab3
use nonsolar RTS
eringold Jul 12, 2024
f472716
window transmitted solar uses space name
eringold Jul 12, 2024
8e02107
use energy variables
eringold Jul 12, 2024
df82e74
fix internal mass not being subtracted
eringold Jul 12, 2024
1fafc9b
is redistribution happening correctly?
eringold Jul 12, 2024
6ce0ba9
temp debug helpers
eringold Jul 12, 2024
0361e23
marginal performance improvements
eringold Jul 16, 2024
6096a0a
test troubleshooting switches
eringold Jul 16, 2024
50e4306
add internal surface gains to external surfaces, dont subtract
eringold Jul 16, 2024
074f2a9
Merge branch 'main' of https://github.com/NREL/ComStock into fix/scou…
eringold Jul 16, 2024
7bc2899
postprocess load components data
eringold Jul 24, 2024
4a46d10
Energy meter updates
mdahlhausen Jul 24, 2024
44b9057
add gas equipment
mdahlhausen Jul 24, 2024
635b0bf
Merge branch 'fix/scout_loads_summary' of https://github.com/NREL/Com…
eringold Jul 25, 2024
ca5c7a6
add natural gas equipment meters
mdahlhausen Jul 25, 2024
b2d2563
add supply gas quipment
eringold Jul 26, 2024
8c4bd4c
add weighted load component cols to long
eringold Jul 26, 2024
ed81200
test flags
eringold Jul 31, 2024
77fa214
avoid double counting by apportioning load based on total heating+coo…
eringold Jul 31, 2024
92836a3
Merge branch 'fix/scout_loads_summary' of https://github.com/NREL/Com…
eringold Jul 31, 2024
2d6edd0
add comstock measure tests
eringold Aug 4, 2024
7ffeeeb
enable district heating fuel metering
eringold Aug 14, 2024
092becc
minor update to loads reporting
eringold Sep 23, 2024
d59f147
generalize dview formatting of output
eringold Oct 7, 2024
1a84612
add missing window IR and shade convective gain, reorganize delayed r…
eringold Dec 17, 2024
3d2ebdb
add generated_files/, reports/, run/, and out.osw to .gitignore
bonnema Jan 17, 2025
a922b8d
first commit of python plugin load summary; all handles returning -1
bonnema Jan 17, 2025
fd70056
simple test using openstudio workflow
bonnema Jan 17, 2025
fe9d0b7
Merge branch 'fix/scout_loads_summary' of github.com:NREL/ComStock in…
bonnema Jan 17, 2025
4dd555c
use ERB template for python, code is still very much in a testing phase
bonnema Jan 23, 2025
1e1c616
add in.py to .gitignore
bonnema Jan 23, 2025
3388bfb
convert to E+ measure until OS 3.10, 1-model test works, next step calcs
bonnema Jan 27, 2025
fa585f1
assign out vars to py var, add full list of py vars, add py vars by mode
bonnema Feb 28, 2025
6b1c1dd
add zone name dict, add lists by py var and op mode, sum to make globals
bonnema Feb 28, 2025
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ lib/
/sampling/truth_data
*.pyc
report.xml
generated_files/
reports/
run/
out.osw
in.py
232 changes: 232 additions & 0 deletions measures/python_plugin_load_summary/measure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# ComStock, Copyright (c) 2025 Alliance for Sustainable Energy, LLC. All rights reserved.
# See top level LICENSE.txt file for license terms.

require 'erb'

# start the measure
class PythonPluginLoadSummary < OpenStudio::Measure::EnergyPlusMeasure

# human readable name
def name
return 'Python Plugin Loads Summary'
end

# human readable description
def description
return 'Breaks out the building load and HVAC energy by end-use'
end

# human readable description of modeling approach
def modeler_description
return 'Python plugin to report building load and HVAC energy by component'
end

# define the arguments that the user will input
def arguments(ws)

# create empty argument vector to add arguments to
args = OpenStudio::Measure::OSArgumentVector.new

return args
end

# define what happens when the measure is run
def run(ws, runner, usr_args)

# call the parent class method
super(ws, runner, usr_args)

# use the built-in error checking
return false unless runner.validateUserArguments(arguments(ws), usr_args)

# define necessary energyplus output variables
out_vars = [
# internal gains, convective
['Zone People Convective Heating Energy', 'people_gain'],
['Zone Lights Convective Heating Energy', 'lighting_gain'],
['Zone Electric Equipment Convective Heating Energy', 'equipment_gain'],
['Zone Gas Equipment Convective Heating Energy', 'equipment_gain'],
['Zone Hot Water Equipment Convective Heating Energy', 'equipment_gain'],
['Zone Other Equipment Convective Heating Energy', 'equipment_gain'],
# internal gains, radiant
['Zone People Radiant Heating Energy', 'people_gain'],
['Zone Lights Radiant Heating Energy', 'lighting_gain'],
['Zone Electric Equipment Radiant Heating Energy', 'equipment_gain'],
['Zone Gas Equipment Radiant Heating Energy', 'equipment_gain'],
['Zone Hot Water Equipment Radiant Heating Energy', 'equipment_gain'],
['Zone Other Equipment Radiant Heating Energy', 'equipment_gain'],
# refrigeration
['Refrigeration Zone Case and Walk In Total Sensible Cooling Energy', 'equipment_gain'],
# infiltration gain/loss
['Zone Infiltration Sensible Heat Gain Energy', 'infiltration'],
['Zone Infiltration Sensible Heat Loss Energy', 'infiltration'],
# ventilation gain/loss
['Zone Mechanical Ventilation Heating Load Increase Energy', 'ventilation'],
['Zone Mechanical Ventilation Cooling Load Decrease Energy', 'ventilation'],
# air transfer
['Zone Air Heat Balance Interzone Air Transfer Rate', ''],
['Zone Exhaust Air Sensible Heat Transfer Rate', ''],
['Zone Exfiltration Sensible Heat Transfer Rate', ''],
# surface convection
['Surface Inside Face Convection Heat Gain Energy', ''],
# windows
['Zone Windows Total Heat Gain Energy', 'windows_conduction'],
['Zone Windows Total Transmitted Solar Radiation Energy', 'windows_solar'],
['Zone Windows Total Heat Loss Energy', 'windows_conduction'],
# zone air heat balance
['Zone Air Heat Balance Internal Convective Heat Gain Rate', ''],
['Zone Air Heat Balance Surface Convection Rate', ''],
['Zone Air Heat Balance Interzone Air Transfer Rate', ''],
['Zone Air Heat Balance Outdoor Air Transfer Rate', ''],
['Zone Air Heat Balance Air Energy Storage Rate', ''],
['Zone Air Heat Balance System Air Transfer Rate', ''],
['Zone Air Heat Balance System Convective Heat Gain Rate', ''],
# zone total gains
['Zone Total Internal Radiant Heating Rate', ''],
['Zone Total Internal Convective Heating Rate', ''],
['Zone Total Internal Latent Gain Rate', ''],
['Zone Total Internal Total Heating Rate', '']
]

# define building operating modes
op_modes = ['heating', 'cooling', 'floating']

# define python plugin global variables
py_vars = [
'people_gain',
'lighting_gain',
'equipment_gain',
'wall',
'foundation_wall',
'roof',
'floor',
'ground',
'windows_conduction',
'doors_conduction',
'windows_solar',
'infiltration',
'ventilation',
]

# populate array of zone names
zone_names = []
ot = 'Zone'
ws.getObjectsByType(ot.to_IddObjectType).each do |o|
zone_names << o.getString(0, false).get
end

# add outputs, fix frequency at runperiod
# python plugin just needs variable to exist in the idf
# setting to minimum frequency reduces runtime overhead
out_vars.each do |ov|
zone_names.each do |zn|
ot = 'Output_Variable'
no = OpenStudio::IdfObject.new(ot.to_IddObjectType)
no.setString(0, zn)
no.setString(1, ov[0])
no.setString(2, 'RunPeriod')
ws.addObject(no)
end
end

# define resources path
rsrcs = "#{File.dirname(__FILE__)}/resources"

# define template path
temp_path = "#{rsrcs}/python_plugin.py.erb"

# read in template
template = ''
File.open(temp_path, 'r') do |f|
template = f.read
end

# configure template with variable values
renderer = ERB.new(template, trim_mode: '-')
py_out = renderer.result(binding)

# write python plugin script to resources directory
File.open("#{rsrcs}/in.py", 'w') do |f|
f << py_out
# make sure data is written to the disk one way or the other
begin
f.fsync
rescue StandardError
f.flush
end
end

# define python site packages base on ruby platform
pckg = ''
if (RUBY_PLATFORM =~ /linux/) != nil
pckg = '/usr/local/lib/python3.8/dist-packages'
elsif (RUBY_PLATFORM =~ /darwin/) != nil
lib = '/Library/Frameworks/Python.framework/Versions'
pckg = "#{lib}/3.8/lib/python3.8/site-packages"
elsif (RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/) != nil
home = ENV['USERPROFILE'].to_s.gsub('\\', '/')
lib = '/AppData/Local/Programs/Python/'
pckg = "#{home}/#{lib}/Python38/Lib/site-packages"
end

# add python plugin search paths
ot = 'PythonPlugin_SearchPaths'
no = OpenStudio::IdfObject.new(ot.to_IddObjectType)
no.setString(0, 'Python Plugin Search Paths')
no.setString(1, 'Yes')
no.setString(2, 'Yes')
no.setString(3, 'No')
no.setString(4, pckg)
no.setString(5, rsrcs)
ws.addObject(no)

# add python plugin instance
ot = 'PythonPlugin_Instance'
no = OpenStudio::IdfObject.new(ot.to_IddObjectType)
no.setString(0, 'Load Summary')
no.setString(1, 'No')
no.setString(2, 'in')
no.setString(3, 'LoadSummary')
ws.addObject(no)

# add python plugin global variables
ot = 'PythonPlugin_Variables'
no = OpenStudio::IdfObject.new(ot.to_IddObjectType)
no.setString(0, 'Python Plugin Variables')
i = 1
op_modes.each do |om|
py_vars.each do |pv|
no.setString(i, "#{om}_#{pv}")
i+=1
end
end
ws.addObject(no)

# add python plugin output variable
op_modes.each do |om|
py_vars.each do |pv|
ot = 'PythonPlugin_OutputVariable'
no = OpenStudio::IdfObject.new(ot.to_IddObjectType)
no.setString(0, "#{om}_#{pv}")
no.setString(1, "#{om}_#{pv}")
no.setString(2, 'Averaged')
no.setString(3, 'SystemTimestep')
no.setString(4, '')
ws.addObject(no)
# add corresponding energyplus output variable
ot = 'Output_Variable'
no = OpenStudio::IdfObject.new(ot.to_IddObjectType)
no.setString(0, "#{om}_#{pv}")
no.setString(1, 'PythonPlugin:OutputVariable')
no.setString(2, 'Timestep')
ws.addObject(no)
end
end

return true
end

end

# this allows the measure to be use by the application
PythonPluginLoadSummary.new.registerWithApplication
62 changes: 62 additions & 0 deletions measures/python_plugin_load_summary/measure.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.1</schema_version>
<name>python_plugin_load_summary</name>
<uid>43529957-d29b-4f5a-9ea2-8ca171569220</uid>
<version_id>aa0cc1ce-6ebb-4a06-86a6-75c06443a2c2</version_id>
<version_modified>2025-01-27T20:28:46Z</version_modified>
<xml_checksum>85664254</xml_checksum>
<class_name>PythonPluginLoadSummary</class_name>
<display_name>Python Plugin Loads Summary</display_name>
<description>Breaks out the building load and HVAC energy by end-use</description>
<modeler_description>Python plugin to report building load and HVAC energy by component</modeler_description>
<arguments />
<outputs />
<provenances />
<tags>
<tag>HVAC</tag>
</tags>
<attributes>
<attribute>
<name>Measure Type</name>
<value>EnergyPlusMeasure</value>
<datatype>string</datatype>
</attribute>
<attribute>
<name>Intended Software Tool</name>
<value>ComStock</value>
<datatype>string</datatype>
</attribute>
</attributes>
<files>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>2.3.0</identifier>
<min_compatible>2.3.0</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>029A6D8B</checksum>
</file>
<file>
<filename>__pycache__/in.cpython-38.pyc</filename>
<filetype>pyc</filetype>
<usage_type>resource</usage_type>
<checksum>3C20A3D7</checksum>
</file>
<file>
<filename>in.py</filename>
<filetype>py</filetype>
<usage_type>resource</usage_type>
<checksum>7C5815A2</checksum>
</file>
<file>
<filename>python_plugin.py.erb</filename>
<filetype>erb</filetype>
<usage_type>resource</usage_type>
<checksum>4B85EDF3</checksum>
</file>
</files>
</measure>
Loading