-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix #4240 (and more): add missing \ip-units gal/min
via a script
#4243
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
require 'openstudio' | ||
require 'optparse' | ||
|
||
# define the input parameters | ||
options = Hash.new | ||
|
||
optparse = OptionParser.new do |opts| | ||
|
||
opts.on("-f", "--[no-]fix", "Add the missing ipUnits to the OpenSutdio.idd (note: LOTS of whitespace changes...)") do |fix| | ||
options[:fix] = fix | ||
end | ||
|
||
opts.on( '-i', '--idd-path IDD_PATH', | ||
String, | ||
"Path to the OpenStudio.idd") do |iddPath| | ||
options[:iddPath] = iddPath | ||
end | ||
|
||
end | ||
|
||
# parse the input parameters | ||
optparse.parse! | ||
|
||
puts options | ||
|
||
|
||
iddWrapper = nil | ||
if options[:iddPath] | ||
IDD_PATH = options[:iddPath] | ||
else | ||
IDD_PATH = File.absolute_path(File.join(File.dirname(__FILE__), "../../resources/model/OpenStudio.idd")) | ||
#iddWrapper = OpenStudio::IddFileAndFactoryWrapper.new("OpenStudio".to_IddFileType) | ||
end | ||
|
||
if !File.exist?(IDD_PATH) | ||
puts "The OpenStudio.idd at '#{IDD_PATH}' does not exist. Pass it via `-i PATH`" | ||
puts "" | ||
puts optparse.help | ||
exit 1 | ||
end | ||
|
||
oIddFile = OpenStudio::IddFile::load(OpenStudio::toPath(IDD_PATH)) | ||
raise "Couldn't load #{IDD_PATH}" if oIddFile.empty? | ||
iddWrapper = oIddFile.get | ||
|
||
def apply_water_flow_rate(iddWrapper) | ||
|
||
puts "Looking for missing gal/min in Water Flow Rate fields" | ||
include_words = ['water', 'flow', 'rate'] | ||
exclude_words = ['ratio', 'fraction', 'curve', 'length', 'mass'] | ||
|
||
|
||
n_missing = 0 | ||
|
||
iddWrapper.objects.each do |iddObject| | ||
num_fields = iddObject.numFields | ||
for i in 0..num_fields-1 | ||
f = iddObject.getField(i).get | ||
f_name = f.name | ||
props = f.properties | ||
siUnits = props.units | ||
ipUnits = props.ipUnits | ||
if include_words.all? { |w| f_name.downcase.include?(w) } and exclude_words.none? { |w| f_name.downcase.include?(w) } | ||
if siUnits.empty? | ||
puts "#{iddObject.name} is missing units in field '#{f_name}'" | ||
elsif siUnits.get != "m3/s" | ||
puts "#{iddObject.name} has wrong units=#{siUnits.get} in field '#{f_name}'" | ||
elsif ipUnits.empty? | ||
puts "#{iddObject.name} is missing ipUnits in field '#{f_name}'" | ||
props.ipUnits = OpenStudio::OptionalString.new('gal/min') | ||
n_missing += 1 | ||
elsif ipUnits.get != "gal/min" | ||
puts "#{iddObject.name} has wrong ipUnits=#{ipUnits.get} in field '#{f_name}'" | ||
props.ipUnits = OpenStudio::OptionalString.new('gal/min') | ||
n_missing += 1 | ||
end | ||
end | ||
end | ||
end | ||
|
||
return n_missing | ||
end | ||
|
||
n_missing = 0 | ||
n_missing += apply_water_flow_rate(iddWrapper) | ||
|
||
if options[:fix] | ||
puts "Fixing in place at #{IDD_PATH}" | ||
# LOTS of whitespace changes | ||
iddWrapper.save(OpenStudio::toPath(IDD_PATH), true) | ||
else | ||
puts "Not fixing in place" | ||
end | ||
|
||
if n_missing > 0 | ||
exit 1 | ||
else | ||
exit 0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8176,12 +8176,14 @@ OS:Refrigeration:Condenser:WaterCooled, | |
N5, \field Water Design Flow Rate | ||
\type real | ||
\units m3/s | ||
\ip-units gal/min | ||
\minimum> 0.0 | ||
\note Note required units must be converted from L/s as specified in ARI 450-2007 | ||
\note Applicable only when loop flow type is Constant Flow. | ||
N6, \field Water Maximum Flow Rate | ||
\type real | ||
\units m3/s | ||
\ip-units gal/min | ||
\minimum> 0.0 | ||
N7, \field Water Maximum Water Outlet Temperature | ||
\type real | ||
|
@@ -10406,6 +10408,7 @@ OS:AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed, | |
\note If non-zero, then the heat recovery inlet and outlet node names must be entered. | ||
\note Used for heat recovery to an EnergyPlus plant loop. | ||
\units m3/s | ||
\ip-units gal/min | ||
\minimum 0.0 | ||
\required-field | ||
N7, \field Maximum Temperature for Heat Recovery | ||
|
@@ -11183,6 +11186,7 @@ OS:AirLoopHVAC:UnitarySystem, | |
N25, \field Design Heat Recovery Water Flow Rate | ||
\type real | ||
\units m3/s | ||
\ip-units gal/min | ||
\minimum 0.0 | ||
\default 0.0 | ||
\note If non-zero, then the heat recovery inlet and outlet node names must be entered. | ||
|
@@ -11810,6 +11814,7 @@ OS:AirTerminal:SingleDuct:ConstantVolume:CooledBeam, | |
N2, \field Maximum Total Chilled Water Volumetric Flow Rate | ||
\type real | ||
\units m3/s | ||
\ip-units gal/min | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the actual specific fix for #4240 |
||
\minimum 0.0 | ||
\autosizable | ||
\default autosize | ||
|
@@ -17686,6 +17691,7 @@ OS:Coil:WaterHeating:Desuperheater, | |
\required-field | ||
\type real | ||
\units m3/s | ||
\ip-units gal/min | ||
\minimum> 0 | ||
\note The operating water flow rate. | ||
N7, \field Water Pump Power | ||
|
@@ -18023,6 +18029,7 @@ OS:Coil:Heating:Water:Baseboard:Radiant, | |
\autosizable | ||
\type real | ||
\units m3/s | ||
\ip-units gal/min | ||
N7; \field Convergence Tolerance | ||
\required-field | ||
\type real | ||
|
@@ -18593,6 +18600,7 @@ OS:Coil:Heating:WaterToAirHeatPump:VariableSpeedEquationFit, | |
\required-field | ||
N4, \field Rated Water Flow Rate At Selected Nominal Speed Level | ||
\units m3/s | ||
\ip-units gal/min | ||
\type real | ||
\autosizable | ||
\required-field | ||
|
@@ -18633,6 +18641,7 @@ OS:Coil:Heating:WaterToAirHeatPump:VariableSpeedEquationFit:SpeedData, | |
\required-field | ||
N4, \field Reference Unit Rated Water Flow Rate | ||
\units m3/s | ||
\ip-units gal/min | ||
\type real | ||
\minimum 0 | ||
\required-field | ||
|
@@ -18720,6 +18729,7 @@ OS:Coil:Cooling:WaterToAirHeatPump:VariableSpeedEquationFit, | |
\required-field | ||
N4, \field Rated Water Flow Rate At Selected Nominal Speed Level | ||
\units m3/s | ||
\ip-units gal/min | ||
\type real | ||
\autosizable | ||
\required-field | ||
|
@@ -18780,6 +18790,7 @@ OS:Coil:Cooling:WaterToAirHeatPump:VariableSpeedEquationFit:SpeedData, | |
\required-field | ||
N5, \field Reference Unit Rated Water Flow Rate | ||
\units m3/s | ||
\ip-units gal/min | ||
\type real | ||
\minimum 0 | ||
\required-field | ||
|
@@ -27701,6 +27712,7 @@ OS:Coil:WaterHeating:AirToWaterHeatPump, | |
N8 , \field Rated Condenser Water Flow Rate | ||
\type real | ||
\units m3/s | ||
\ip-units gal/min | ||
\minimum> 0 | ||
\autosizable | ||
\required-field | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require running the "iddWrapper.save" once to do the whitespace changes once. I don't think it's really worth it here...