1

Design Builder Control for natural ventilation - EMS code problem [closed]

Hi everybody,

I modified an EMS control script in DesignBuilder to control the opening of external windows to provide free cooling on spaces which are too hot. I only want the occupants to open the windows when zone is occupied. The first part of the code works fine. But I want to do another thing: To prevent overheat, when people arrive in the morning (7 am), during the summer, they always open the window until 9am, to cool the space in prevention (use of thermal inertia of the space). So, I tried to add some boolean expression to do this, but it don't works. I don't know if I can nest boolean expression, or if there is an easier way to do what I want.

<ForAllExternalWindows>
EnergyManagementSystem:Sensor,
   Zone_People_Occupant_Count_<LoopWindowVariableName>,
   <LoopWindowZoneIDFName>,
   Zone People Occupant Count;
<LoopNextWindow>

<ForAllExternalWindows>
EnergyManagementSystem:Actuator,
      Venting_Opening_Factor_<LoopWindowVariableName>,
      <LoopWindowIDFName>,
      AirFlow Network Window/Door Opening,
      Venting Opening Factor;
<LoopNextWindow>

EnergyManagementSystem:ProgramCallingManager,
   Natural ventilation,
   BeginTimestepBeforePredictor,
   NatVent;

EnergyManagementSystem:Program,
   NatVent,
    <ForAllExternalWindows>
    IF Zone_People_Occupant_Count_<LoopWindowVariableName> == 0,        
        SET Venting_Opening_Factor_<LoopWindowVariableName> = 0,
    ELSEIF (Zone_People_Occupant_Count_<LoopWindowVariableName> > 0),
    <IF LoopWindowAttribute Month >=5 Then>
    <IF LoopWindowAttribute Month <=9 Then>
    <IF LoopWindowAttribute Hour >=7 Then>
    <IF LoopWindowAttribute Hour <=9 Then>
        SET Venting_Opening_Factor_<LoopWindowVariableName> = 1,
    <endif>
    <endif>
    <endif>
    <endif>
    ELSE,
        SET Venting_Opening_Factor_<LoopWindowVariableName> = null,
    ENDIF,
<LoopNextWindow>
;

Blockquote

Thanks a lot!

Julien THIRIFAYS's avatar
77
Julien THIRIFAYS
asked 2021-08-25 07:29:38 -0500
Aaron Boranian's avatar
14.1k
Aaron Boranian
updated 2021-08-25 09:47:18 -0500
edit flag offensive 0 remove flag reopen merge delete

Closed for the following reason "the question is answered, right answer was accepted" by Julien THIRIFAYS 2021-08-25 09:57:40 -0500

Comments

add a comment see more comments

1 Answer

1

It sounds like you want to use the logical "and" operator: &&. You can read more about operators available for EMS in the Expressions section of the EMS Application Guide.

Also, I don't believe you need LoopWindowAttribute, as the Month and Hour variables are already built in to EMS and not "attached" to specific EnergyPlus objects like windows. You can read more about built-in variables for EMS.

Using && and removing LoopWindowAttribute, your EMS program would look like this:

EnergyManagementSystem:Program,
 NatVent,
 <ForAllExternalWindows>
 IF Zone_People_Occupant_Count_<LoopWindowVariableName> == 0,        
    SET Venting_Opening_Factor_<LoopWindowVariableName> = 0,
 ELSEIF (Zone_People_Occupant_Count_<LoopWindowVariableName> > 0),
    IF Month >=5 && Month <=9 && Hour >=7 && Hour <=9,
      SET Venting_Opening_Factor_<LoopWindowVariableName> = 1,
   ELSE,
      SET Venting_Opening_Factor_<LoopWindowVariableName> = null,
   ENDIF,
 ENDIF,
<LoopNextWindow>
;

You also needed a second ENDIF statement, since you have two IF statements.

Aaron Boranian's avatar
14.1k
Aaron Boranian
answered 2021-08-25 09:45:01 -0500
edit flag offensive 0 remove flag delete link

Comments

Thanks a lot Aaron! It works fine!

Julien THIRIFAYS's avatar Julien THIRIFAYS (2021-08-25 09:57:01 -0500) edit
add a comment see more comments