NREL / openstudio-standards

Other
83 stars 58 forks source link

Calling model_apply_hvac_efficiency_standard for PTAC and PTHP systems fails when system size is small #1469

Closed chriswmackey closed 1 year ago

chriswmackey commented 1 year ago

I have been experiencing an error that only seems to affect PTAC/HP systems when the model_run_sizing_run causes the system to be small. This is the complete traceback that I get when trying to run model_apply_hvac_efficiency_standard on this type of system:

undefined method `*' for nil:NilClass
    :/ruby/2.7.0/gems/openstudio-standards-0.3.0/lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb:140:in `coil_heating_dx_single_speed_standard_minimum_cop'
    :/ruby/2.7.0/gems/openstudio-standards-0.3.0/lib/openstudio-standards/standards/Standards.CoilHeatingDXSingleSpeed.rb:253:in `coil_heating_dx_single_speed_apply_efficiency_and_curves'
    :/ruby/2.7.0/gems/openstudio-standards-0.3.0/lib/openstudio-standards/standards/Standards.Model.rb:2305:in `block in model_apply_hvac_efficiency_standard'
    :/ruby/2.7.0/gems/openstudio-standards-0.3.0/lib/openstudio-standards/standards/Standards.Model.rb:2305:in `each'
    :/ruby/2.7.0/gems/openstudio-standards-0.3.0/lib/openstudio-standards/standards/Standards.Model.rb:2305:in `model_apply_hvac_efficiency_standard'
    C:/Program Files/ladybug_tools/resources/measures/honeybee_openstudio_gem/lib/measures/from_honeybee_model/measure.rb:188:in `run'
    :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:517:in `apply_measure'
    :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:114:in `block in apply_measures'
    :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:67:in `each_index'
    :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:67:in `apply_measures'
    :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/jobs/run_os_measures.rb:70:in `perform'
    :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:291:in `step'
    :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:233:in `run'
    :/openstudio_cli.rb:1174:in `execute'
    :/openstudio_cli.rb:804:in `execute'
    :/openstudio_cli.rb:1973:in `<main>'
    eval:188:in `eval'
    eval:188:in `require_embedded_absolute'
    eval:173:in `block in require_embedded'
    eval:167:in `each'
    eval:167:in `require_embedded'
    eval:126:in `require'
    eval:3:in `<main>'

I tried many things to address the error but the only thing that could really get it to go away is if I somehow increased the loads during the sizing run so that the system became larger.

I think you should be able to recreate the error using the following simple single-zone model: https://drive.google.com/file/d/1o30QydyJK8y6iCC5GmEd97eet7k8q9wC/view?usp=sharing

... and you can run the following Standards gem routine to do a sizing run and then try to apply the efficiency standard:

require 'openstudio-standards'

building = model.getBuilding
standard_id = building.standardsTemplate.get
standard = Standard.build(standard_id)
# Set the heating and cooling sizing parameters
standard.model_apply_prm_sizing_parameters(model)
# Perform a sizing run
if standard.model_run_sizing_run(model, "#{Dir.pwd}/SR1") == false
  log_messages_to_runner(runner, debug = true)
  return false
end
# If there are any multizone systems, reset damper positions
# to achieve a 60% ventilation effectiveness minimum for the system
# following the ventilation rate procedure from 62.1
standard.model_apply_multizone_vav_outdoor_air_sizing(model)
# get the climate zone  
climate_zone_obj = model.getClimateZones.getClimateZone('ASHRAE', 2006)
if climate_zone_obj.empty
  climate_zone_obj = model.getClimateZones.getClimateZone('ASHRAE', 2013)
end
climate_zone = climate_zone_obj.value
# get the building type
bldg_type = nil
unless building.standardsBuildingType.empty?
  bldg_type = building.standardsBuildingType.get
end
# Apply the prototype HVAC assumptions
standard.model_apply_prototype_hvac_assumptions(model, bldg_type, climate_zone)
# Apply the HVAC efficiency standard
standard.model_apply_hvac_efficiency_standard(model, climate_zone)

This is effectively the same routine that runs in the "create typical building" measure.

mdahlhausen commented 1 year ago

Thanks @chriswmackey. What version of OpenStudio was this?

chriswmackey commented 1 year ago

Hey @mdahlhausen ,

This issue is happening with the latest stable release of OpenStudio (3.5.1).

mdahlhausen commented 1 year ago

Fixed with #1501