Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create DOE Prototype Building measure is incompatible with OpenStudio 2.6.0 #392

Closed
mldichter opened this issue Jul 16, 2018 · 3 comments
Closed

Comments

@mldichter
Copy link

Error: undefined method create_prototype_building' for #OpenStudio::Model::Model:0x0001719bce65e0`

BCL link

capture0
capture1

@asparke2
Copy link
Member

asparke2 commented Aug 2, 2018

I believe you are using a now-outdated version of the measure. The version currently on BCL works with 2.6.0

@asparke2 asparke2 closed this as completed Aug 2, 2018
@mldichter
Copy link
Author

mldichter commented Aug 2, 2018

The updated measure still isn't working, but you were right about there being an updated measure in the BCL. I updated to the latest BCL version.

updated_bcl

The error generated with the updated version of the measure looks the same

bcl_error

To try and diagnose the error a little further, I decided to duplicate the measure and make a copy.

copy_measure

But the error is the same.

copy_error

Could you please send me the ruby code of the working measure. I've had problems with Openstudio not updating internal copies of measures before, so that's probably it.

I have copy-pasted the measure ruby code of the BCL copy that Openstudio made for me to edit in case that's useful. (Kind of a kluge, I know, but I couldn't figure out how to attach a text file to this response.

# Start the measure
class CreateDOEPrototypeBuildingCopy < OpenStudio::Ruleset::ModelUserScript
  
  require 'openstudio-standards'
  
  # Define the name of the Measure.
  def name
    return "Create DOE Prototype Building Copy"
  end

  # Human readable description
  def description
    return "Creates the DOE Reference Building Models as starting points for other analyses."
  end

  # Human readable description of modeling approach
  def modeler_description
    return ""
  end

  # Define the arguments that the user will input.
  def arguments(model)
    args = OpenStudio::Ruleset::OSArgumentVector.new

    # Make an argument for the building type
    building_type_chs = OpenStudio::StringVector.new
    building_type_chs << 'SecondarySchool'
    building_type_chs << 'PrimarySchool'
    building_type_chs << 'SmallOffice'
    building_type_chs << 'MediumOffice'
    building_type_chs << 'LargeOffice'
    building_type_chs << 'SmallHotel'
    building_type_chs << 'LargeHotel'
    building_type_chs << 'Warehouse'
    building_type_chs << 'RetailStandalone'
    building_type_chs << 'RetailStripmall'
    building_type_chs << 'QuickServiceRestaurant'
    building_type_chs << 'FullServiceRestaurant'
    building_type_chs << 'MidriseApartment'
    building_type_chs << 'HighriseApartment'
    building_type_chs << 'Hospital'
    building_type_chs << 'Outpatient'
    building_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('building_type', building_type_chs, true)
    building_type.setDisplayName('Building Type.')
    building_type.setDefaultValue('SmallOffice')
    args << building_type

    # Make an argument for the template
    template_chs = OpenStudio::StringVector.new
    template_chs << 'DOE Ref Pre-1980'
    template_chs << 'DOE Ref 1980-2004'
    template_chs << '90.1-2004'
    template_chs << '90.1-2007'
    #template_chs << '189.1-2009'
    template_chs << '90.1-2010'
    template_chs << '90.1-2013'
    template_chs << 'NECB 2011'
    template = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('template', template_chs, true)
    template.setDisplayName('Template.')
    template.setDefaultValue('90.1-2010')
    args << template

    # Make an argument for the climate zone
    climate_zone_chs = OpenStudio::StringVector.new
    climate_zone_chs << 'ASHRAE 169-2006-1A'
    #climate_zone_chs << 'ASHRAE 169-2006-1B'
    climate_zone_chs << 'ASHRAE 169-2006-2A'
    climate_zone_chs << 'ASHRAE 169-2006-2B'
    climate_zone_chs << 'ASHRAE 169-2006-3A'
    climate_zone_chs << 'ASHRAE 169-2006-3B'
    climate_zone_chs << 'ASHRAE 169-2006-3C'
    climate_zone_chs << 'ASHRAE 169-2006-4A'
    climate_zone_chs << 'ASHRAE 169-2006-4B'
    climate_zone_chs << 'ASHRAE 169-2006-4C'
    climate_zone_chs << 'ASHRAE 169-2006-5A'
    climate_zone_chs << 'ASHRAE 169-2006-5B'
    #climate_zone_chs << 'ASHRAE 169-2006-5C'
    climate_zone_chs << 'ASHRAE 169-2006-6A'
    climate_zone_chs << 'ASHRAE 169-2006-6B'
    climate_zone_chs << 'ASHRAE 169-2006-7A'
    #climate_zone_chs << 'ASHRAE 169-2006-7B'
    climate_zone_chs << 'ASHRAE 169-2006-8A'
    #climate_zone_chs << 'ASHRAE 169-2006-8B'
    climate_zone_chs << 'NECB HDD Method'
    climate_zone = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('climate_zone', climate_zone_chs, true)
    climate_zone.setDisplayName('Climate Zone.')
    climate_zone.setDefaultValue('ASHRAE 169-2006-2A')
    args << climate_zone

    #Drop down selector for Canadian weather files. 
    epw_files = OpenStudio::StringVector.new
    epw_files << 'Not Applicable'
    BTAP::Environment::get_canadian_weather_file_names().each {|file| epw_files << file }
    epw_file = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('epw_file', epw_files, true)
    epw_file.setDisplayName('Climate File (NECB only)')
    epw_file.setDefaultValue('Not Applicable')
    args << epw_file
   
    return args
  end

  # Define what happens when the measure is run.
  def run(model, runner, user_arguments)
    super(model, runner, user_arguments)

    # Use the built-in error checking
    if not runner.validateUserArguments(arguments(model), user_arguments)
      return false
    end

    # Assign the user inputs to variables that can be accessed across the measure
    building_type = runner.getStringArgumentValue('building_type',user_arguments)
    template = runner.getStringArgumentValue('template',user_arguments)
    climate_zone = runner.getStringArgumentValue('climate_zone',user_arguments)
    epw_file = runner.getStringArgumentValue('epw_file',user_arguments)

    # Turn debugging output on/off
    @debug = false    
    
    # Open a channel to log info/warning/error messages
    @msg_log = OpenStudio::StringStreamLogSink.new
    if @debug
      @msg_log.setLogLevel(OpenStudio::Debug)
    else
      @msg_log.setLogLevel(OpenStudio::Info)
    end
    @start_time = Time.new
    @runner = runner

    # Make a directory to save the resulting models for debugging
    build_dir = "#{Dir.pwd}/output"
    if !Dir.exists?(build_dir)
      Dir.mkdir(build_dir)
    end

	#Set OSM folder
	osm_directory = ""
	if template == 'NECB 2011'
    osm_directory = "#{build_dir}/#{building_type}-#{template}-#{climate_zone}-#{epw_file}"
	else
	osm_directory = "#{build_dir}/#{building_type}-#{template}-#{climate_zone}"
	end
    if !Dir.exists?(osm_directory)
      Dir.mkdir(osm_directory)
    end

    model.create_prototype_building(building_type,
									template,
									climate_zone,
									epw_file,
									osm_directory,
									@debug)
    
    log_msgs
    return true

  end #end the run method

  # Get all the log messages and put into output
  # for users to see.
  def log_msgs
    @msg_log.logMessages.each do |msg|
      # DLM: you can filter on log channel here for now
      if /openstudio.*/.match(msg.logChannel) #/openstudio\.model\..*/
        # Skip certain messages that are irrelevant/misleading
        next if msg.logMessage.include?("Skipping layer") || # Annoying/bogus "Skipping layer" warnings
            msg.logChannel.include?("runmanager") || # RunManager messages
            msg.logChannel.include?("setFileExtension") || # .ddy extension unexpected
            msg.logChannel.include?("Translator") || # Forward translator and geometry translator
            msg.logMessage.include?("UseWeatherFile") # 'UseWeatherFile' is not yet a supported option for YearDescription
            
        # Report the message in the correct way
        if msg.logLevel == OpenStudio::Info
          @runner.registerInfo(msg.logMessage)
        elsif msg.logLevel == OpenStudio::Warn
          @runner.registerWarning("[#{msg.logChannel}] #{msg.logMessage}")
        elsif msg.logLevel == OpenStudio::Error
          @runner.registerError("[#{msg.logChannel}] #{msg.logMessage}")
        elsif msg.logLevel == OpenStudio::Debug && @debug
          @runner.registerInfo("DEBUG - #{msg.logMessage}")
        end
      end
    end
    @runner.registerInfo("Total Time = #{(Time.new - @start_time).round}sec.")
  end

end #end the measure

#this allows the measure to be use by the application
CreateDOEPrototypeBuildingCopy.new.registerWithApplication

@mldichter
Copy link
Author

You were right. I had a older version of the file leftover in C:\Users\your_user_name\BCL that was being used instead of the updated measure that was added after updating the measure in openstudio. So I deleted everything in the BCL directory, redownloaded, and now it runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants