lib/openstudio-standards/btap/measures.rb in openstudio-standards-0.1.15 vs lib/openstudio-standards/btap/measures.rb in openstudio-standards-0.2.0.rc1

- old
+ new

@@ -419,12 +419,12 @@ if not original_weather_file.empty? original_weather_file.get.clone(new_model) end # pull original design days over - new_model.getDesignDays.each { |designDay| designDay.remove } - model.getDesignDays.each { |designDay| designDay.clone(new_model) } + new_model.getDesignDays.sort.each { |designDay| designDay.remove } + model.getDesignDays.sort.each { |designDay| designDay.clone(new_model) } #swap underlying data in model with underlying data in newModel model.swap(new_model) runner.registerFinalCondition("Model replaced with alternative #{alternative_model_path}.") return true ? parent_method_is_true : false @@ -794,31 +794,31 @@ #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil. self.set_instance_variables(measure_values) log = "" unless model.getFanVariableVolumes.empty? log = "fan_variable_volume_name,fan_total_eff,fan_motor_eff\n" - model.getFanVariableVolumes.each do |fan| + model.getFanVariableVolumes.sort.each do |fan| fan.setFanEfficiency( @fan_total_eff ) unless @fan_total_eff.nil? fan.setMotorEfficiency( @fan_motor_eff ) unless @fan_motor_eff.nil? log << fan.name.get.to_s << ",#{fan.fanEfficiency},#{fan.motorEfficiency}\n" end end unless model.getFanConstantVolumes.empty? log = "fan_constant_volume_name,fan_total_eff,fan_motor_eff\n" - model.getFanConstantVolumes.each do |fan| + model.getFanConstantVolumes.sort.each do |fan| fan.setFanEfficiency( @fan_total_eff ) unless @fan_total_eff.nil? fan.setMotorEfficiency( @fan_motor_eff ) unless @fan_motor_eff.nil? log << fan.name.get.to_s << ",#{fan.fanEfficiency},#{fan.motorEfficiency}\n" end end case @fan_volume_type when "VariableVolume" - model.getFanConstantVolumes.each do |fan_const| + model.getFanConstantVolumes.sort.each do |fan_const| #check that this is indeed connected to an airloop. log << "Found Const Vol Fan #{fan_const.name.get.to_s}" unless fan_const.loop.empty? fan_variable = OpenStudio::Model::FanVariableVolume.new(model,fan_const.availabilitySchedule) #pass information from old fan as much as possible. @@ -841,11 +841,11 @@ fan_const.remove() log << "Replaced by Variable Vol Fan #{fan_variable.name.get.to_s}" end end when "ConstantVolume" - model.getFanVariableVolumes.each do |fan| + model.getFanVariableVolumes.sort.each do |fan| #check that this is indeed connected to an airloop. log << "Found Const Vol Fan #{fan.name.get.to_s}" unless fan.loop.empty? new_fan = OpenStudio::Model::FanConstantVolume.new(model,fan.availabilitySchedule) #pass information from constant speed fan as much as possible. @@ -880,29 +880,29 @@ #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil. self.set_instance_variables(measure_values) log = "" unless model.getPumpVariableSpeeds.empty? log = "pump_variable_speed_name,@pump_motor_eff\n" - model.getPumpVariableSpeeds.each do |pump| + model.getPumpVariableSpeeds.sort.each do |pump| pump.setMotorEfficiency( @pump_motor_eff.to_f ) unless @pump_motor_eff.nil? pump.setPumpControlType( @pump_control_type ) unless @pump_control_type.nil? log << pump.name.get.to_s << ",#{pump.motorEfficiency}\n" end end unless model.getPumpConstantSpeeds.empty? log << "pump_variable_speed_name,@pump_motor_eff\n" - model.getPumpConstantSpeeds.each do |pump| + model.getPumpConstantSpeeds.sort.each do |pump| pump.setMotorEfficiency( @pump_motor_eff.to_f ) unless @pump_motor_eff.nil? pump.setPumpControlType( @pump_control_type ) unless @pump_control_type.nil? log << pump.name.get.to_s << ",#{pump.motorEfficiency}\n" end end #set pump speed type based on existing pump. case @pump_speed_type when "VariableSpeed" - model.getPumpConstantSpeeds.each do |pump_const| + model.getPumpConstantSpeeds.sort.each do |pump_const| log << "Found Const Vol Fan #{pump_const.name.get.to_s}" #check that this is indeed connected to an plant loop. unless pump_const.plantLoop.empty? pump_variable = OpenStudio::Model::PumpVariableSpeed.new(model) #pass information from constant speed fan as much as possible. @@ -923,11 +923,11 @@ pump_variable.addToNode(hw_loop.supplyInletNode) log << "Replaced by Variable Vol Pump #{pump_variable.name.get.to_s}" end end #end loop PumpConstantSpeeds when "ConstantSpeed" - model.getPumpVariableSpeeds.each do |pump| + model.getPumpVariableSpeeds.sort.each do |pump| log << "Found Variable Speed Pump #{pump.name.get.to_s}" #check that this is indeed connected to an plant loop. unless pump.plantLoop.empty? new_pump = OpenStudio::Model::PumpVariableSpeed.new(model) #pass information from constant speed fan as much as possible. @@ -969,22 +969,22 @@ #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil. self.set_instance_variables(measure_values) unless model.getCoilCoolingDXSingleSpeeds.empty? log = "coil_cooling_dx_single_speed_name,cop\n" - model.getCoilCoolingDXSingleSpeeds.each do |cooling_coil| + model.getCoilCoolingDXSingleSpeeds.sort.each do |cooling_coil| cooling_coil.setRatedCOP( OpenStudio::OptionalDouble.new( @cop ) ) unless @cop.nil? cop = "NA" cop = cooling_coil.ratedCOP.get unless cooling_coil.ratedCOP.empty? log << cooling_coil.name.get.to_s << ",#{cop}\n" end end unless model.getCoilCoolingDXTwoSpeeds.empty? log << "coil_cooling_dx_two_speed_name,cop\n" - model.getCoilCoolingDXTwoSpeeds.each do |cooling_coil| + model.getCoilCoolingDXTwoSpeeds.sort.each do |cooling_coil| cooling_coil.setRatedHighSpeedCOP( @cop ) unless @cop.nil? cooling_coil.setRatedLowSpeedCOP( @cop ) unless @cop.nil? cop_high = "NA" cop_high = cooling_coil.ratedHighSpeedCOP.get unless cooling_coil.ratedHighSpeedCOP.empty? cop_low = "NA" @@ -1039,11 +1039,11 @@ model.getSizingParameters.setCoolingSizingFactor(@cooling_sizing_factor) unless @cooling_sizing_factor.nil? #SizingZone table << "handle,zone_heating_sizing_factor,zone_cooling_sizing_factor\n" - model.getSizingZones.each do |item| + model.getSizingZones.sort.each do |item| item.setZoneHeatingSizingFactor(@zone_heating_sizing_factor) unless @zone_heating_sizing_factor.nil? item.setZoneCoolingSizingFactor(@zone_cooling_sizing_factor) unless @zone_cooling_sizing_factor.nil? table << "#{item.handle},#{item.zoneHeatingSizingFactor.get},#{item.zoneCoolingSizingFactor.get}\n" end #Create sample csv file. @@ -1063,11 +1063,11 @@ #Create Schedule #schedule = BTAP::Resources::Schedules::create_annual_ruleset_schedule_detailed_json(model, @shw_setpoint_sched) unless @shw_setpoint_sched_name.nil? or @shw_setpoint_sched.nil? #iterate through water heaters. - model.getWaterHeaterMixeds.each do |item| + model.getWaterHeaterMixeds.sort.each do |item| unless @shw_setpoint_sched_name.nil? or @shw_setpoint_sched.nil? item.setSetpointTemperatureSchedule(schedule) end item.setHeaterFuelType(@shw_heater_fuel_type) unless @shw_heater_fuel_type.nil? item.setHeaterThermalEfficiency(@shw_thermal_eff) unless @shw_thermal_eff.nil? @@ -1091,11 +1091,11 @@ #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil. self.set_instance_variables(measure_values) table = "name,boiler_design_water_outlet_temperature,boiler_fuel_type,boiler_thermal_eff\n" - model.getPlantLoops.each do |iplantloop| + model.getPlantLoops.sort.each do |iplantloop| iplantloop.components.each do |icomponent| if icomponent.to_BoilerHotWater.is_initialized boiler = icomponent.to_BoilerHotWater.get #set design outlet temp @@ -1230,11 +1230,11 @@ raise("#{cooling_schedule_name} does not exist in #{library_file} library ") else cooling_schedule = lib.getScheduleRulesetByName(cooling_schedule_name).get.clone(model).to_ScheduleRuleset.get end end - model.getThermostatSetpointDualSetpoints.each do |dual_setpoint| + model.getThermostatSetpointDualSetpoints.sort.each do |dual_setpoint| unless heating_schedule_name.nil? raise ("Could not set heating Schedule") unless dual_setpoint.setHeatingSetpointTemperatureSchedule(heating_schedule) end unless cooling_schedule_name.nil? raise ("Could not set cooling Schedule") unless dual_setpoint.setCoolingSetpointTemperatureSchedule(cooling_schedule) @@ -1292,11 +1292,11 @@ @erv_economizer_lockout.to_bool ).each { |erv| log << erv.to_s } #Add setpoint manager to all OA object in airloops. - model.getHeatExchangerAirToAirSensibleAndLatents.each do |erv| + model.getHeatExchangerAirToAirSensibleAndLatents.sort.each do |erv| #needed to get the supply outlet node from the erv to place the setpoint manager. node = erv.primaryAirOutletModelObject.get.to_Node.get if erv.primaryAirOutletModelObject.is_initialized new_set_point_manager = OpenStudio::Model::SetpointManagerWarmest.new(model) raise ("Could not add setpoint manager") unless new_set_point_manager.addToNode(node) @@ -1341,11 +1341,11 @@ self.set_instance_variables(measure_values) BTAP::Resources::SpaceLoads::ScaleLoads::scale_lighting_loads( model, @lighting_scaling_factor ) unless @lighting_scaling_factor.nil? #Set lighting variables - model.getLightsDefinitions.each do |lightsdef| + model.getLightsDefinitions.sort.each do |lightsdef| lightsdef.setFractionRadiant(@lighting_fraction_radiant.to_f) lightsdef.setFractionVisible(@lighting_fraction_visible.to_f) lightsdef.setReturnAirFraction(@lighting_return_air_fraction.to_f) end return log @@ -1365,11 +1365,11 @@ BTAP::Resources::SpaceLoads::ScaleLoads::scale_electrical_loads( model, @elec_equipment_scaling_factor) unless @elec_equipment_scaling_factor.nil? #Set plug loads variables - model.getElectricEquipmentDefinitions.each do |elec_equip_def| + model.getElectricEquipmentDefinitions.sort.each do |elec_equip_def| elec_equip_def.setFractionRadiant(@elec_equipment_fraction_radiant.to_f) elec_equip_def.setFractionLatent(@elec_equipment_fraction_latent.to_f) elec_equip_def.setFractionLost(@elec_equipment_fraction_lost.to_f) end @@ -1386,11 +1386,11 @@ #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil. self.set_instance_variables(measure_values) if @cold_deck_reset_enabled.to_bool == true - model.getAirLoopHVACs.each do |iairloop| + model.getAirLoopHVACs.sort.each do |iairloop| cooling_present = false set_point_manager = nil iairloop.components.each do |icomponent| if icomponent.to_CoilCoolingDXSingleSpeed.is_initialized or icomponent.to_CoilCoolingDXTwoSpeed.is_initialized or @@ -1403,11 +1403,11 @@ cooling_present = true log << "found cooling." end end #check if setpoint manager is present at supply outlet. - model.getSetpointManagerSingleZoneReheats.each do |manager| + model.getSetpointManagerSingleZoneReheats.sort.each do |manager| if iairloop.supplyOutletNode == manager.setpointNode.get set_point_manager = manager end end @@ -1439,14 +1439,14 @@ #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil. self.set_instance_variables(measure_values) if @sat_reset_enabled.to_bool == true - model.getAirLoopHVACs.each do |iairloop| + model.getAirLoopHVACs.sort.each do |iairloop| #check if setpoint manager is present at supply outlet - model.getSetpointManagerSingleZoneReheats.each do |manager| + model.getSetpointManagerSingleZoneReheats.sort.each do |manager| if iairloop.supplyOutletNode == manager.setpointNode.get manager.disconnect end end @@ -1486,10 +1486,10 @@ @occ_stbck_tolerance.to_f, @occ_stbck_heat_setpoint.to_f, @occ_stbck_heat_setback.to_f, @occ_stbck_cool_setpoint.to_f, @occ_stbck_cool_setback.to_f) - model.getThermostatSetpointDualSetpoints.each do |dual_setpoint| + model.getThermostatSetpointDualSetpoints.sort.each do |dual_setpoint| raise ("Could not set setback heating Schedule") unless dual_setpoint.setHeatingSetpointTemperatureSchedule(heating_schedule) raise ("Could not set setback cooling Schedule") unless dual_setpoint.setCoolingSetpointTemperatureSchedule(cooling_schedule) log << "modified....#{dual_setpoint}" end end