lib/measures/ExteriorWallThermalPropertiesPercentChange/measure.rb in openstudio-calibration-0.9.0 vs lib/measures/ExteriorWallThermalPropertiesPercentChange/measure.rb in openstudio-calibration-0.10.0
- old
+ new
@@ -19,19 +19,20 @@
def modeler_description
'Change exterior walls by altering the thermal resistance, density, and solar absorptance of the wall constructions by a Percent Change'
end
# short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure
- def neat_numbers(number, roundto = 2) # round to 0 or 2)
+ # round to 0 or 2)
+ def neat_numbers(number, roundto = 2)
number = if roundto == 2
format '%.2f', number
else
number.round
end
# regex to add commas
number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\1,').reverse
- end # end def neat_numbers
+ end
# helper to make it easier to do unit conversions on the fly
def unit_helper(number, from_unit_string, to_unit_string)
OpenStudio.convert(OpenStudio::Quantity.new(number, OpenStudio.createUnit(from_unit_string).get), OpenStudio.createUnit(to_unit_string).get).get.value
end
@@ -55,11 +56,11 @@
thermal_mass_perc_change.setDisplayName('Exterior wall thermal mass Percentage Change')
thermal_mass_perc_change.setDefaultValue(0)
args << thermal_mass_perc_change
args
- end # end the arguments method
+ end
# define what happens when the measure is run
def run(model, runner, user_arguments)
super(model, runner, user_arguments)
@@ -77,10 +78,11 @@
surfaces = model.getSurfaces
exterior_surfaces = []
exterior_surface_constructions = []
surfaces.each do |surface|
next unless surface.outsideBoundaryCondition == 'Outdoors' && surface.surfaceType == 'Wall'
+
exterior_surfaces << surface
exterior_surface_const = surface.construction.get
# only add construction if it hasn't been added yet
unless exterior_surface_constructions.include?(exterior_surface_const)
exterior_surface_constructions << exterior_surface_const.to_Construction.get
@@ -143,10 +145,11 @@
desired_r_val[index1][index2] = initial_r_val[index1][index2] + initial_r_val[index1][index2] * r_value_perc_change * 0.01 if initial_r_val[index1][index2]
end
end
initial_sol_abs.each_index do |index1|
next unless initial_sol_abs[index1]
+
desired_sol_abs[index1] = initial_sol_abs[index1] + initial_sol_abs[index1] * solar_abs_perc_change * 0.01
if desired_sol_abs[index1] > 1
desired_sol_abs[index1] = 1
runner.registerWarning("Initial solar absorptance of '#{initial_layers[index1][0].name}' was #{initial_sol_abs[index1]}. A Percent Change of #{solar_abs_perc_change} results in a number greater than 1, which is outside the allowed range. The value is instead being set to #{desired_sol_abs[index1]}")
elsif desired_sol_abs[index1] < 0
@@ -214,10 +217,10 @@
# report desired condition
runner.registerFinalCondition("Applied R #{r_value_perc_change.round(1)} Solar #{solar_abs_perc_change.round(1)} Therm #{thermal_mass_perc_change.round(1)} Percent change")
true
- end # end the run method
-end # end the measure
+ end
+end
# this allows the measure to be used by the application
ExteriorWallThermalPropertiesPercentChange.new.registerWithApplication