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

Setpoint manager on Chiller's outlet node in Ruby

asked 2019-04-28 12:20:04 -0500

handi gravatar image

updated 2019-04-29 07:34:19 -0500

[updated with an image]

I am trying to add a setpoint manager on the outlet node of a ChillerElectricEIR object in the supply side of a chilled water loop. I have followed the instruction as shown in here. However, it still gives me an error undefined method 'outletModelObject' for #.

I have also tried to rename the outlet node for the chiller using setChilledWaterOutletNodeName(<string>), yet the chiller's name is still in hex code when I call it with chilledWaterOutletNodeName Can anyone please help?

I am trying to create a measure for the following system image description

edit retag flag offensive close merge delete

Comments

1

Could you post the code you are using to call the ChillerElectricEIR object? It looks like it may be receiving an Optional

Luis Lara gravatar image Luis Lara  ( 2019-04-28 15:50:45 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2019-04-28 16:09:04 -0500

updated 2019-04-29 14:57:51 -0500

The example that you linked does not apply to your situation. The outletModelObject is only available from objects that inherit from the StraightComponent class, such as the DX:CoolingCoil.

Your ChillerElectricEIR object is a WaterToWaterComponent. From your description, I would say that you are trying to put a setpoint manager in the outlet node for the chilled water side of the chiller. Then you would need to use the following:

outlet_node_chw_side = my_chiller.supplyOutletModelObject.get.to_Node.get

You are getting the for # part of the error because you are not calling correctly the chiller. Try appending .get.to_ChillerElectricEIR.get to what you are using to select your Chiller.

EDIT: Added example to correctly call the chiller

Is the primaryChiller object initialized? If it is a new object you are creating (e.g. it is not already in your plantloop) you need to:

primary_chiller = Openstudio::Model::ChillerElectricEIR.new(model)

If it is a chiller that is already in your model, you need to somehow select it. A way of doing this is to add the following code to the appropriate sections of the measure:

## Arguments section

# select chiller
available_chillers = model.getChillerElectricEIRs
available_chillers_handle = OpenStudio::StringVector.new
available_chillers_display_name = OpenStudio::StringVector.new
available_chillers.each do |chiller|
  available_chillers_handle << chiller.handle.to_s
  available_chillers_display_name << chiller.name.to_s
end

# make an argument for selecting your chiller
selected_chiller = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("selected_chiller", available_chillers_handle , available_chillers_display_name ,false)
selected_chiller.setDisplayName("Select the chiller:")
args << selected_chiller

## Run Section

selected_chiller = runner.getOptionalWorkspaceObjectChoiceValue("selected_chiller",user_arguments,model)

# check the selected_chiller for reasonableness and get it
if selected_chiller.empty?
  runner.registerError("The selected chiller was not found in the model.")
  return false
else
  if not selected_chiller.get.to_ChillerElectricEIR.empty?
    primary_chiller = selected_chiller.get.to_ChillerElectricEIR.get
    runner.registerInfo("Using chiller #{primary_chiller.name}.")
  else
    runner.registerError("Script Error - argument not showing up as Chiller.")
    return false
  end
end
edit flag offensive delete link more

Comments

Right. I had the Optional not initialized error. The below code gives me an undefined method 'get' for # error

chilled_water_plant.addSupplyBranchForComponent(primaryChiller) primaryChiller.get.to_ChillerElectricEIR.get primarychiller_manager_scheduled.addToNode(primaryChiller.demandOutletModelObject.get.to_Node.get)

handi gravatar image handi  ( 2019-04-28 20:01:18 -0500 )edit
1

I think you are not correctly getting the chiller that you want. See my revised answer for some example code.

Luis Lara gravatar image Luis Lara  ( 2019-04-29 10:38:29 -0500 )edit

I think I have selected the chiller correctly since it prints out the chiller's name right before I am trying to add setpoint manager on its outlet node. I cannot type longer than 343 characters in the comment section, so, I am adding the code in the Answer section below.

handi gravatar image handi  ( 2019-04-29 11:07:29 -0500 )edit
1

answered 2019-04-29 11:09:11 -0500

handi gravatar image

updated 2019-04-29 17:09:26 -0500

The below code gives an error message Optional not initialized

EDITED with the correct answer

chiller = OpenStudio::Model::ChillerElectricEIR.new(model, clgCapFuncTempCurve, eirFuncTempCurve, eirFuncPlrCurve)
chiller.chiller.setName('primary chiller')
runner.registerInfo("Primary Chiller= '#{chiller.name}' ") #this line prints the chiller name
chilled_water_plant.addSupplyBranchForComponent(chiller)
primarychiller_manager_scheduled = OpenStudio::Model::SetpointManagerScheduled.new(model, chiller_setpoint_schedule)
primarychiller_manager_scheduled.addToNode(chiller.supplyOutletModelObject.get.to_Node.get)
edit flag offensive delete link more

Comments

Please upload your model and measure so I can look at it.

Luis Lara gravatar image Luis Lara  ( 2019-04-29 13:50:55 -0500 )edit
2

I'm pretty sure you want to call supplyOutletModelObject instead. The 'supply' or 'demand' is relative to the chiller, i.e. it 'supplies' to the plant (chilled water) loop, and 'demands' from the secondary (condenser water) loop. If you had already added the chiller as a demand component to a condenser loop, then demandOutletModelObject would get you to the condenser outlet node.

Eric Ringold gravatar image Eric Ringold  ( 2019-04-29 14:39:31 -0500 )edit
1

Erin, you are correct. I will update my answer.

Luis Lara gravatar image Luis Lara  ( 2019-04-29 14:56:01 -0500 )edit

Thank you, Luis and Eric. My measure works fine now after calling supplyOutletModelObject instead. Now, I have all three chillers and an ice tank with setpoint manager. To attach the setpoint manager to the icetank outlet node, I call outletModelObject

handi gravatar image handi  ( 2019-04-29 16:04:35 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

 

Question Tools

1 follower

Stats

Asked: 2019-04-28 12:20:04 -0500

Seen: 176 times

Last updated: Jun 08