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

EMS routine doesn't work

asked 2019-10-25 02:24:27 -0500

Bambo's avatar

updated 2019-10-27 10:14:57 -0500

Hi all! I am writing to you to understand why the EMS routine I have implemented in the model doesn’t give output values. I've created all the sensors, then the actuators. In the program section I've added the routine and in the global variable I've put variables coming from the routine. In Output:variable I've created a variable with the schedule of the routine, but after that analysis ends in the excel file in the column of the schedule result are 0. The EMS code is the following:

!-   ===========  ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:SENSOR ===========

EnergyManagementSystem:Sensor,
   Tout,                    !- Name
   Environment,             !- Output:Variable or Output:Meter Index Key Name
   Site Outdoor Air Drybulb Temperature;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
   RHout,                   !- Name
   Environment,             !- Output:Variable or Output:Meter Index Key Name
   Site Outdoor Air Relative Humidity;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
   WS,                      !- Name
   Environment,             !- Output:Variable or Output:Meter Index Key Name
   Site Wind Speed;         !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
   Rain,                    !- Name
   Environment,             !- Output:Variable or Output:Meter Index Key Name
   Site Rain Status;        !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
   Tin_KXS1,                !- Name
   PianoSecondo:KXS1,       !- Output:Variable or Output:Meter Index Key Name
   Zone Mean Air Temperature;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
   RHin_KXS1,               !- Name
   PianoSecondo:KXS1,       !- Output:Variable or Output:Meter Index Key Name
   Zone Air Relative Humidity;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
   OCC_KXS1,                !- Name
   PianoSecondo:KXS1,       !- Output:Variable or Output:Meter Index Key Name
   Zone People Occupant Count;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
   Tin_LM1,                 !- Name
   PianoSecondo:LM1,        !- Output:Variable or Output:Meter Index Key Name
   Zone Mean Air Temperature;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
    RHin_LM1,                !- Name
    PianoSecondo:LM1,        !- Output:Variable or Output:Meter Index Key Name
    Zone Air Relative Humidity;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
    OCC_LM1,                 !- Name
    PianoSecondo:LM1,        !- Output:Variable or Output:Meter Index Key Name
    Zone People Occupant Count;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
    Tin_LS1,                 !- Name
    PianoSecondo:LS1,        !- Output:Variable or Output:Meter Index Key Name
    Zone Mean Air Temperature;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
    RH_LS1,                  !- Name
    PianoSecondo:LS1,        !- Output:Variable or Output:Meter Index Key Name
    Zone Air Relative Humidity;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:Sensor,
    OCC_LS1,                 !- Name
    PianoSecondo:LS1,        !- Output:Variable or Output:Meter Index Key Name
    Zone People Occupant Count;  !- Output:Variable or Output:Meter Name


!-   ===========  ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:ACTUATOR ===========

EnergyManagementSystem:Actuator,
    Window1_S1_act,          !- Name
    BLDG_KXS1_WINDOW1_Jones_2017_SCH,  !- Actuated Component Unique Name
    Schedule:Compact,        !- Actuated Component Type
    Schedule Value;          !- Actuated Component Control Type

EnergyManagementSystem:Actuator,
    Window2_S1_act,          !- Name
    BLDG_KXS1_WINDOW2_Jones_2017_SCH,  !- Actuated Component Unique Name
    Schedule:Compact,        !- Actuated Component Type
    Schedule Value;          !- Actuated Component Control Type

EnergyManagementSystem:Actuator,
    Window_LM1_act,          !- Name
    BLDG_LM1_WINDOW_Jones_2017_SCH,  !- Actuated Component Unique Name
    Schedule:Compact,        !- Actuated Component Type
    Schedule Value;          !- Actuated Component Control Type

EnergyManagementSystem:Actuator,
    Window_LS1_act,          !- Name
    BLDG_LS1_WINDOW_Jones_2017_SCH,  !- Actuated Component Unique Name
    Schedule:Compact,        !- Actuated Component Type
    Schedule Value;          !- Actuated Component Control Type

!-   ===========  ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:PROGRAM ===========

EnergyManagementSystem ...
(more)
edit retag flag offensive close merge delete

Comments

How about you share your EMS code (+ Output:Variable) so we get a chance to see what's going on?

Julien Marrec's avatar Julien Marrec  ( 2019-10-25 04:37:34 -0500 )edit

I've edited the question in order to share the EMS code + Output:Variable.

Bambo's avatar Bambo  ( 2019-10-25 05:29:35 -0500 )edit
1

I formatted it as code and took the liberty of indenting your EMS program so that it's actually readable.

Julien Marrec's avatar Julien Marrec  ( 2019-10-25 07:10:06 -0500 )edit

Perfect! Thank you! The issue is related to the Output:Variable BLDG_KXS1_WINDOW1_Jones_2017_SCH. It seems that the code doesn't work even though I have created all the relevant sensors.

Bambo's avatar Bambo  ( 2019-10-25 07:33:33 -0500 )edit
1

This EMS code is only for the programs, could you also include the code lines where the sensors and actuators are defined? Also, are you sure that BLDG_KXS1_WINDOW1_Jones_2017_SCH is a schedule object created in the model?

Aaron Boranian's avatar Aaron Boranian  ( 2019-10-25 12:38:09 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2019-10-28 15:57:43 -0500

tl;dr -- You should replace "Window1_KXS1_act" with "Window1_S1_act".

I think the issue is that you have a mismatch of EMS:Actuator names. Here is what I have gathered from your EMS code:

  • The schedule that you are trying to change is named BLDG_KXS1_WINDOW1_Jones_2017_SCH
  • The EMS:Actuator object changing that schedule is named Window1_S1_act
  • Window1_S1_act only appears in Line 1 of the EMS:Program object named Window_Jones_2017 (set Wind_Cur_State=Window1_S1_act, !- Program Line 1).
  • Later lines in the same EMS:Program object are using if/else logic to set 0 or 1 to Window1_KXS1_act -- a slightly different name that has an extra "KX" compared to the original EMS:Actuator created.

In short, you are never actually overriding the schedule value because the EMS:Actuator name isn't entered correctly in EMS:Program lines. You should replace "Window1_KXS1_act" with "Window1_S1_act", and that should fix it.

edit flag offensive delete link more

Comments

Thank you for the answer, I really appreciate your interest! I've tried to change the name of the actuator, but unfortunately results are still equal to 0. I think that the problem should be the schedule value, because it is On/Off for all days until 24 through 12/31 equal to 0, so even if the program overrides the schedule value nothing will change. So the question is: is the variable the right one? Or maybe should I evaluate the action of the window through another variable?

Bambo's avatar Bambo  ( 2019-10-29 06:25:48 -0500 )edit

Yes, the schedule value output variable is the correct one to use. Even though the schedule is originally a constant 0, the actuator should override it. Looking at the EMS:Program, you want to set the schedule value to 1 depending on 3 variables: OCC_KXS1, handle and R. OCC_KXS1 is a sensor for zone people occupant count, which you already have an output variable for. I would recommend adding output variables for handle and R to confirm that they match your expectations. This will require EMS:OutputVariable objects for handle and R since they are local EMS:Program variables.

Aaron Boranian's avatar Aaron Boranian  ( 2019-10-29 10:21:46 -0500 )edit

Perfectly clear, I was doubting about the variable because I've tried to turn the schedule value from 0 to 1 and in the output all the results were 1. It seems that the routine does not consider the schedule.

Bambo's avatar Bambo  ( 2019-10-29 12:57:46 -0500 )edit
0

answered 2019-12-05 05:34:58 -0500

Here is the solution:

EnergyManagementSystem:Program,
Window_Jones_2017,       !- Name
if Window1_S1_act == Null,
set Wind_Cur_State = 0,
else,
set Wind_Cur_State = Window1_S1_act,
ENDIF,
if Wind_Cur_State == 0.0,  !- Program Line 2
  if OCC_KXS1>0,           !- A4
    set handle=A1+B1*Tin_KXS1+B2*RHin_KXS1-B3*Tout-B4*RHout+B5*WS+B6*Rain,  !- A5
    set handle=@Exp handle,  !- A6
    set handle=handle/(handle+1),  !- A7
    set R=@RandomUniform 0 1,!- A8
    if handle>R,             !- A9
      set Window1_S1_act=1,  !- A10
    endif,                   !- A11
  else,                    !- A12
    set Window1_S1_act=0,  !- A13
  endif,                   !- A14
endif,                   !- A15
if Wind_Cur_State == 1,  !- A16
  if OCC_KXS1>0,           !- A17
    set handle=A2+B7*Tin_KXS1+B8*RHin_KXS1+B9*Tout+B10*WS+B11*Rain,  !- A18
    set handle=@Exp handle,  !- A19
    set handle=handle/(handle+1),  !- A20
    set R=@RandomUniform 0 1,!- A21
    if handle>R,             !- A22
      set Window1_S1_act=0,  !- A23
    endif,                   !- A24
  else,                    !- A25
    set Window1_S1_act=0,  !- A26
  endif,                   !- A27
endif;                   !- A28
edit flag offensive delete link more

Your Answer

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

Add Answer

Careers

Question Tools

3 followers

Stats

Asked: 2019-10-25 02:24:27 -0500

Seen: 1,038 times

Last updated: Dec 05 '19