Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

Why measures are not applied to the model in openstudio?

I have been working on adding measures like geothermal and co-generation systems for a project in OpenStudio application. However, after running the program, I understood that the measures are not effectively applied on the project model as the energy use values remained the same. Below is the ruby code for cogeneration:

start the measure

class CogenerationMeasure < OpenStudio::Measure::ModelMeasure # Define the name and description of the measure def name return 'Cogeneration Measure' end

def description return 'Upon running the measure, the cogeneration system is created using a micro generator object within the OpenStudio model. The user-defined capacity and efficiency values are assigned to the cogeneration system. The measure then adds the cogeneration system to the primary plant loop of the model, ensuring it becomes part of the overall HVAC system.' end

def modeler_description return "By applying the Cogeneration Measure, users can assess the impact of integrating a cogeneration system on their model's energy performance. This measure facilitates the evaluation of the combined electricity and heat generation potential, enabling users to analyze metrics such as energy consumption, demand, and cost savings. The measure serves as a valuable tool for energy efficiency analysis and decision-making regarding the implementation of cogeneration systems in OpenStudio models." end

# Define the measure inputs def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new

# set capacity
capacity = OpenStudio::Measure::OSArgument.makeDoubleArgument('capacity', true)
capacity.setDisplayName('Cogeneration System Capacity')
capacity.setUnits('kW')
capacity.setDefaultValue(150.0)
args << capacity

# set efficiency
efficiency = OpenStudio::Measure::OSArgument.makeDoubleArgument('efficiency', true)
efficiency.setDisplayName('Cogeneration System Efficiency')
efficiency.setUnits('fraction')
efficiency.setDefaultValue(0.8)
args << efficiency

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 !runner.validateUserArguments(arguments(model), user_arguments)
  return false
end

# assign the user inputs to variables
args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model))
if !args then return false end

# Get the user inputs
capacity = runner.getDoubleArgumentValue('capacity', user_arguments)
efficiency = runner.getDoubleArgumentValue('efficiency', user_arguments)

# Check if the capacity is valid
if capacity <= 0.0
  runner.registerError('Cogeneration system capacity must be a positive value.')
  return false
end

# Check if the efficiency is valid
if efficiency <= 0.0 || efficiency > 1.0
  runner.registerError('Cogeneration system efficiency must be between 0 and 1.')
  return false
end

# Create a cogeneration system object
cogeneration = OpenStudio::Model::GeneratorMicroTurbine.new(model)
cogen = OpenStudio::Model::GeneratorMicroTurbineHeatRecovery.new(model, cogeneration)
cogeneration.setReferenceElectricalPowerOutput(capacity)
cogeneration.setReferenceElectricalEfficiencyUsingLowerHeatingValue(efficiency)

# Add the cogeneration system to the primary plant loop
loop = model.getPlantLoopByName('Hot Water Plant Loop').get
loop.addSupplyBranchForComponent(cogen)

# Report the success of the measure runner.registerInfo('Cogeneration system has been added to the model.')

return true

end end

Register the measure with the OpenStudio MeasureManager

CogenerationMeasure.new.registerWithApplication

Why measures are not applied to the model in openstudio?

I have been working on adding measures like geothermal and co-generation systems for a project in OpenStudio application. However, after running the program, I understood that the measures are not effectively applied on the project model as the energy use values remained the same. Below is the ruby code for cogeneration:

# start the measure

measure class CogenerationMeasure < OpenStudio::Measure::ModelMeasure # Define the name and description of the measure def name return 'Cogeneration Measure' end

end def description return 'Upon running the measure, the cogeneration system is created using a micro generator object within the OpenStudio model. The user-defined capacity and efficiency values are assigned to the cogeneration system. The measure then adds the cogeneration system to the primary plant loop of the model, ensuring it becomes part of the overall HVAC system.' end

end def modeler_description return "By applying the Cogeneration Measure, users can assess the impact of integrating a cogeneration system on their model's energy performance. This measure facilitates the evaluation of the combined electricity and heat generation potential, enabling users to analyze metrics such as energy consumption, demand, and cost savings. The measure serves as a valuable tool for energy efficiency analysis and decision-making regarding the implementation of cogeneration systems in OpenStudio models." end

end # Define the measure inputs def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new

OpenStudio::Measure::OSArgumentVector.new

    # set capacity
 capacity = OpenStudio::Measure::OSArgument.makeDoubleArgument('capacity', true)
 capacity.setDisplayName('Cogeneration System Capacity')
 capacity.setUnits('kW')
 capacity.setDefaultValue(150.0)
 args << capacity

 # set efficiency
 efficiency = OpenStudio::Measure::OSArgument.makeDoubleArgument('efficiency', true)
 efficiency.setDisplayName('Cogeneration System Efficiency')
 efficiency.setUnits('fraction')
 efficiency.setDefaultValue(0.8)
 args << efficiency

 return args

end

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

user_arguments)

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

    end

    # assign the user inputs to variables
 args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model))
 if !args then return false end

 # Get the user inputs
 capacity = runner.getDoubleArgumentValue('capacity', user_arguments)
 efficiency = runner.getDoubleArgumentValue('efficiency', user_arguments)

 # Check if the capacity is valid
 if capacity <= 0.0
   runner.registerError('Cogeneration system capacity must be a positive value.')
   return false
end

    end

    # Check if the efficiency is valid
 if efficiency <= 0.0 || efficiency > 1.0
   runner.registerError('Cogeneration system efficiency must be between 0 and 1.')
   return false
end

    end

    # Create a cogeneration system object
 cogeneration = OpenStudio::Model::GeneratorMicroTurbine.new(model)
 cogen = OpenStudio::Model::GeneratorMicroTurbineHeatRecovery.new(model, cogeneration)
 cogeneration.setReferenceElectricalPowerOutput(capacity)
 cogeneration.setReferenceElectricalEfficiencyUsingLowerHeatingValue(efficiency)

 # Add the cogeneration system to the primary plant loop
 loop = model.getPlantLoopByName('Hot Water Plant Loop').get
 loop.addSupplyBranchForComponent(cogen)

# Report the success of the measure runner.registerInfo('Cogeneration system has been added to the model.')

model.')

    return true
  end
end

# Register the measure with the OpenStudio MeasureManager
CogenerationMeasure.new.registerWithApplication

end end

Register the measure with the OpenStudio MeasureManager

CogenerationMeasure.new.registerWithApplication