lib/measures/RoofThermalPropertiesMultiplier/measure.rb in openstudio-calibration-0.9.0 vs lib/measures/RoofThermalPropertiesMultiplier/measure.rb in openstudio-calibration-0.10.0
- old
+ new
@@ -19,19 +19,20 @@
def modeler_description
'Change Roof by altering the thermal resistance, density, and solar absorptance of the wall constructions by a Multiplier'
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
@@ -62,11 +63,11 @@
thermal_mass_mult.setDisplayName('Roof thermal mass multiplier')
thermal_mass_mult.setDefaultValue(1)
args << thermal_mass_mult
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)
@@ -87,10 +88,11 @@
surfaces = model.getSurfaces
roof_surfaces = []
roof_surface_constructions = []
surfaces.each do |surface|
next unless surface.outsideBoundaryCondition == 'Outdoors' && surface.surfaceType == 'RoofCeiling'
+
roof_surfaces << surface
roof_surface_const = surface.construction.get
# only add construction if it hasn't been added yet
unless roof_surface_constructions.include?(roof_surface_const)
roof_surface_constructions << roof_surface_const.to_Construction.get
@@ -153,10 +155,11 @@
desired_r_val[index1][index2] = initial_r_val[index1][index2] * r_value_mult 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] * solar_abs_mult
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]}. Multiplying it by #{solar_abs_mult} 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
@@ -224,10 +227,10 @@
# report desired condition
runner.registerFinalCondition("Applied R #{r_value_mult.round(1)}x Solar #{solar_abs_mult.round(1)}x Therm #{thermal_mass_mult.round(1)}x change")
true
- end # end the run method
-end # end the measure
+ end
+end
# this allows the measure to be used by the application
RoofThermalPropertiesMultiplier.new.registerWithApplication