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

How to add Cycle Fan to HVAC_Library.osm

asked 2015-01-31 16:10:57 -0600

MattStewart's avatar

updated 2015-01-31 19:29:13 -0600

Hi Folks, How does one add a PTAC to OS hvac_library? I am looking to control fan with Fan:OnOff and this seems to be an elegant solution. Thank you, Matt

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
8

answered 2015-02-05 14:19:05 -0600

updated 2015-02-07 08:18:01 -0600

I recently added a cycling PTAC to the hvac library in OpenStudio, along with several variations of fan coils. This will roll out with version 1.7.0. I thought I would share how I did this, because I think it will be useful to some people on this forum. @aparker's solution is good because it is simple and low overhead. But editing the hvac_library.osm file directly is tricky, and can potentially corrupt the library if there are large changes that add and remove objects. When we work with osm files at NREL we almost always use the API that many of you are using to write Measures as opposed to editing osm directly. Here is the Ruby code that I used to add to the hvac library. If you save this as a Ruby file and run it from the directory where the hvac library osm file is installed C:\Program Files\OpenStudio 1.6.0\share\openstudio-1.6.0\OSApp\hvaclibrary you will have a new PTAC and four new variations of fan coil in your model. If you are already writing OpenStudio Measures you will find this syntax natural and you can probably imagine adding other items to the library that you may want.

require 'openstudio'

# Load current library and bring up to current version
version_translator = OpenStudio::OSVersion::VersionTranslator.new
m = version_translator.loadModel('hvac_library.osm').get 

# Get the model's built in always on schedule
s = m.alwaysOnDiscreteSchedule

# ConstantFanVariableFlow

name = 'Fan Coil with Const Fan Var Fluid Flow'
fan = OpenStudio::Model::FanConstantVolume.new m
fan.setName name + ' - Fan'
heating_coil = OpenStudio::Model::CoilHeatingWater.new m
heating_coil.setName name + ' - Heating Coil'
cooling_coil = OpenStudio::Model::CoilCoolingWater.new m
cooling_coil.setName name + ' - Cooling Coil'

fan_coil = OpenStudio::Model::ZoneHVACFourPipeFanCoil.new m,s,fan,cooling_coil,heating_coil
fan_coil.setName name
fan_coil.setCapacityControlMethod('ConstantFanVariableFlow');

# CyclingFan

name = 'Fan Coil with Cycling Fan'
fan = OpenStudio::Model::FanOnOff.new m
fan.setName name + ' - Fan'
heating_coil = OpenStudio::Model::CoilHeatingWater.new m
heating_coil.setName name + ' - Heating Coil'
cooling_coil = OpenStudio::Model::CoilCoolingWater.new m
cooling_coil.setName name + ' - Cooling Coil'

fan_coil = OpenStudio::Model::ZoneHVACFourPipeFanCoil.new m,s,fan,cooling_coil,heating_coil
fan_coil.setName name
fan_coil.setCapacityControlMethod('CyclingFan');

# VariableFanVariableFlow

name = 'Fan Coil with Var Fan Var Fluid Flow'
fan = OpenStudio::Model::FanVariableVolume.new m
fan.setName name + ' - Fan'
heating_coil = OpenStudio::Model::CoilHeatingWater.new m
heating_coil.setName name + ' - Heating Coil'
cooling_coil = OpenStudio::Model::CoilCoolingWater.new m
cooling_coil.setName name + ' - Cooling Coil'

fan_coil = OpenStudio::Model::ZoneHVACFourPipeFanCoil.new m,s,fan,cooling_coil,heating_coil
fan_coil.setName name
fan_coil.setCapacityControlMethod('VariableFanVariableFlow');

# VariableFanConstantFlow

name = 'Fan Coil with Var Fan Const Fluid Flow'
fan = OpenStudio::Model::FanVariableVolume.new m
fan.setName name + ' - Fan'
heating_coil = OpenStudio::Model::CoilHeatingWater.new m
heating_coil.setName name + ' - Heating Coil'
cooling_coil = OpenStudio::Model::CoilCoolingWater.new m
cooling_coil.setName name + ' - Cooling Coil'

fan_coil = OpenStudio::Model::ZoneHVACFourPipeFanCoil.new m,s,fan,cooling_coil,heating_coil
fan_coil.setName name
fan_coil.setCapacityControlMethod('VariableFanConstantFlow');

# Cycling PTAC - Hot Water Heating

# Make an always-zero schedule for the PTAC fan
twenty_four_hrs = OpenStudio::Time.new(0,24,0,0)
ptac_fan_mode_sch = OpenStudio::Model::ScheduleRuleset.new(m)
ptac_fan_mode_sch ...
(more)
edit flag offensive delete link more

Comments

Dear Kyle, I saved the above code to: ...share/opentstudio-1.6.0/OSApp/hvaclibrary as an .rb file and tried to run it using RubyMine 7.0.4 and received multiple errors. Will this become a new Always Run measure and how do I "run it"? Sorry for my lack of understanding. Your help is appreciated.
Regards, Matt

MattStewart's avatar MattStewart  ( 2015-02-06 13:18:04 -0600 )edit

Sounds like you are doing things right. There are no concrete plans to turn this into a measure, but we have brainstormed possibilities for turning the HVAC library into a series of Mesasure(ish) files instead of the monolithic osm library file we have now. Again nothing concrete in the works right now. What are your errors? I can probably help you troubleshoot. Off hand, one possible source of error is that you don't have write permission to the library file. If you were able to save your script in the hvaclibrary directory then a permission problem is less likely.

Kyle Benne's avatar Kyle Benne  ( 2015-02-06 13:25:59 -0600 )edit

@MattStewart another possibility is that RubyMine's version of Ruby might be incompatible with the OpenStudio Ruby Module. If you are comfortable with cmd.exe you can type two commands to execute your script using OpenStudio's built in Ruby.

cd "C:\Program Files\OpenStudio 1.6.0\share\openstudio-1.6.0\OSApp\hvaclibrary"
"C:\Program Files\OpenStudio 1.6.0\ruby-install\ruby\bin\ruby" yourscript.rb
Kyle Benne's avatar Kyle Benne  ( 2015-02-06 13:55:28 -0600 )edit

Kyle, I saved the code as hvac2.rb in the hvaclibrary file folder alongside hvac_library.osm . Please see the message from command prompt. I do not believe this has executed properly.

Ruby photo OS Ruby_zpsx18dhyc1.jpg</a">link text

MattStewart's avatar MattStewart  ( 2015-02-06 16:51:14 -0600 )edit

That's just some noise from ruby about some deprecated features. Fire up OpenStudio or peek inside the library osm. Looks like your script was successful, you should have the new components.

Kyle Benne's avatar Kyle Benne  ( 2015-02-06 19:01:45 -0600 )edit
2

answered 2015-01-31 19:23:46 -0600

updated 2015-01-31 19:28:33 -0600

See @aparker's answer to this question where he provides the code to do this. It's a long answer so you'll have to expand it using the (more) link at the bottom which is easy to miss.

edit flag offensive delete link more

Comments

1

Matthew, Thank you for your reply. I have successfully followed @aparker's solution. The routine successfully added DX coils and HW heating. I was hoping to elicit a response that would advise me on how to follow up with gas and electric heating. @aparker said he was going to do but has not responded.

MattStewart's avatar MattStewart  ( 2015-02-01 13:12:31 -0600 )edit

@Neal Kruis FYI Kyle's answer is blocking/covering the right side bar on my display possibly because of the image in the comments.

MatthewSteen's avatar MatthewSteen  ( 2015-05-28 08:05:43 -0600 )edit

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2015-01-31 16:10:57 -0600

Seen: 658 times

Last updated: Feb 07 '15