How to add Cycle Fan to HVAC_Library.osm
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
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 ...
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
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.
@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, 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.
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.
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.
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.
@Neal Kruis FYI Kyle's answer is blocking/covering the right side bar on my display possibly because of the image in the comments.