1

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
Alosius Thomas's avatar
21
Alosius Thomas
asked 2023-05-30 08:20:58 -0500
Julien Marrec's avatar
29.7k
Julien Marrec
updated 2023-05-30 13:23:38 -0500
edit flag offensive 0 remove flag close merge delete

Comments

A few questions:

  • Why hardwire the plant loop identifier ('Hot Water Plant Loop')? Even if it were for internal use only, the measure could only modify a loop named as such (future projects). In any case, safer to check if get...ByName returns an .empty? (before .get)
  • Also safer to check the return Bool value of methods like setReference...; check if they return false.
  • Does the OSM hold the new cogen objects? The generated IDF as well? If so, any related errors in the eplusout.err file?
Denis Bourgeois's avatar Denis Bourgeois (2023-05-30 09:25:51 -0500) edit
add a comment see more comments

1 Answer

2

You should make sure you're creating or connecting everything that EnergyPlus needs to have the Generator:MicroTurbine operate in the model. See, for instance, the part:

The ElectricLoadCenter:Generators and ElectricLoadCenter:Distribution objects are used to define the availability and control of all electric generators included in the simulation.

ericringold's avatar
10.6k
ericringold
answered 2023-05-30 09:56:30 -0500, updated 2023-05-30 10:03:38 -0500
edit flag offensive 0 remove flag delete link

Comments

I definitely have a measure somewherethat does this. But anyways, you can find some good example code you can adapt in this regression test: https://github.com/NREL/OpenStudio-re...

Julien Marrec's avatar Julien Marrec (2023-05-30 13:28:44 -0500) edit
add a comment see more comments