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

How reset the UFactorTimesAreaValue of Heating Coil Water loop?

asked 2015-06-02 21:54:57 -0600

building_performance's avatar

updated 2017-08-05 13:24:43 -0600

I tried to reset the UFactorTimesArea value of the heating coil water loop. Along the inheritance diagram, i found the relevant objects. After i organize them together, by:

image description

The error shows up when i load the measure into OpenStudio:

image description

It says the assignment is dynamic. However, it is better to do it dynamically, because i do need the check of the heating coil for UFactorTimesAreaValueAutoSized().

My question is how to assign it statically? Or is it because my object inheritance is not right?

air_loops.each do |air_loop|
      supply_components = air_loop.supplyComponents

      #find coilheating on loop
      supply_components.each do |supply_component|
          heating_coil=supply_component.to_WaterToAirComponent.to_CoilHeatingWater
          if heating_coil.is_initialized         
               UFactorTimeArea= heating_coil.isUFactorTimesAreaValueAutoSized //here the error occurs
               if (UFactorTimeArea.isUFactorTimesAreaValueAutoSized)
                    UFactorTimeArea.setUFactorTimesAreaValue(user_input);
               else
                    UFactorTimeArea.setUFactorTimesAreaValue(user_input);
               end

            end
       end
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2015-06-03 11:03:31 -0600

updated 2015-06-03 11:25:34 -0600

I believe the problem is that your variable UFactorTimeArea begins with a capital letter and ruby treats that as a constant. Ruby does not allow you to make assignments to constants inside of methods, only within the class declaration. If you make the variable begin with a lower case letter I think you will be ok.

The very next line is troubling though. CoilHeatingWater::isUFactorTimesAreaValueAutoSized returns a bool so UFactortimeArea is going to be a bool, however you are trying to call the method isUFactorTimesAreaValueAutoSized on it. This method is going to be undefined for bool. Instead just say if( uFactortimeArea ) and then call heating_coil.setUFactorTimesAreaValue(foo).

Finally there is a simpler method of grabbing the hot water coils off the loop. Just do this...

air_loop.supply_components(OpenStudio::Model::CoilHeatingWater::iddObjectType) Thats going to give you only the hot water coils as generic ModelObjects. You will still need to cast them into heating coils, but it will save you a check to is_initialized. The full thing will probably look something like this....

air_loops.each do |air_loop|
  supply_components = air_loop.supplyComponents(OpenStudio::Model::CoilHeatingWater::iddObjectType)

  supply_components.each do |supply_component|
    heating_coil = supply_component.to_CoilHeatingWater.get # <-- this is safe because of how we called supplComps...
    uFactorTimeArea= heating_coil.isUFactorTimesAreaValueAutoSized

    if (uFactorTimeArea)
      heating_coil.setUFactorTimesAreaValue(user_input) # Or just leave autosized
    else
       # Or just leave the hardsized value that was already there
       heating_coil.setUFactorTimesAreaValue(some_other_user_input)
    end
  end

end

Alternatively if you wanted to get all of the heating coils in the model you could just do...

hot_water_coils = model.getCoilHeatingWaters

If you wanted to then go back and retrieve the air system you could do hotwatercoil.airLoopHVAC. I suspect you already know about this though since you probably had to do model.getAirLoopHVACs to fill your air_loops variable.

edit flag offensive delete link more

Comments

Thanks a lot! i am thinking about to learn more about the Measure writing. The problem in front of me are what methods should i use for some specific namespace layers. I come across several: ".get", ".set", ".get.to", ".to", etc. I know they are from Ruby syntax. I see there are many namespaces and methods: for instance, coilheatingwater=OpenStudio::Model:: CoilHeatingWater::iddObjectType. After i try coilheatingwater.setUFactorTimesAreaValue(0.1), i got error: NoMethodError or NoNameError, etc...
Sometimes, i can get AirLoopHVAC by simply: air_loops=model.getAirLoopHVACs

building_performance's avatar building_performance  ( 2015-06-03 20:58:28 -0600 )edit

Definitely start with the Measure Writing Guide. As for specific method by method, class by class documentation check out the API doc.

Kyle Benne's avatar Kyle Benne  ( 2015-06-03 21:18:29 -0600 )edit

Thanks. I tried above code corrections: But the error message tole me NoMethodError for the line: uFactorTimeArea= heatingcoil.isUFactorTimesAreaValueAutoSized. I guess the final object of coilheating_water is not right, but how to correct it?

building_performance's avatar building_performance  ( 2015-06-03 21:44:05 -0600 )edit

In the text you pasted back here in the comment you have heatingcoil as one word. Is that is not simply a typo in your comment then that will be a problem, based on the variable names I used above.

Kyle Benne's avatar Kyle Benne  ( 2015-06-04 09:24:11 -0600 )edit

Thanks. I tried just now. And it still told me the same error: "NoMethodError:, after importing the measure into OpenStudio. I copied your original code into mine. The error line is still: uFactorTimeArea= heatingcoil.isUFactorTimesAreaValueAutoSized. I have been debugging the whole morning, and still can not figure it out. I guess the line "heatingcoil = supplycomponent.toCoilHeatingWater.get" need some further modification. But i have no idea how to modify.

building_performance's avatar building_performance  ( 2015-06-04 11:04:46 -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-06-02 21:54:57 -0600

Seen: 197 times

Last updated: Jun 03 '15