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

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

asked 2021-08-25 07:29:38 -0600

Julien THIRIFAYS's avatar

updated 2021-08-25 09:47:18 -0600

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!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Julien THIRIFAYS
close date 2021-08-25 09:57:40.689657

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-08-25 09:45:01 -0600

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.

edit flag offensive delete link more

Comments

Thanks a lot Aaron! It works fine!

Julien THIRIFAYS's avatar Julien THIRIFAYS  ( 2021-08-25 09:57:01 -0600 )edit

Training Workshops

Careers

Question Tools

2 followers

Stats

Asked: 2021-08-25 07:29:38 -0600

Seen: 463 times

Last updated: Aug 25 '21