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

Not to run a program if there is no inputs in the model, CO2 Control

asked 2020-03-19 04:39:33 -0600

Pablo-SO gravatar image

updated 2020-03-20 05:25:25 -0600

Hello Everyone,

I'm writing a script to control CO2 concentration through natural ventilation. There are different kind of spaces with different levels of CO2 allowed, which I want to use in all my projects. That’s why I need the script to have all the options, but not to run the options that are not in the model. The thing is that when I run a model with spaces that are not defined in the EMS, the following error occurs:

** Severe  ** IP: IDF line~5428 Error detected in Object=ENERGYMANAGEMENTSYSTEM:PROGRAM, name=CO2WINDOWCONTROLIDA1

   **   ~~~   ** Field [Program Line 1] is required but was blank

   ** Severe  ** IP: Blank "required" fields found in input

   ** Severe  ** IP: Out of "range" values and/or blank required fields found in input

   **  Fatal  ** IP: Errors occurred on processing IDF file. Preceding condition(s) cause termination.

The script I Used i that:

<ForAllWindows> {ZoneIDFName=IDA1;Tag=CO2}
   Zone Air CO2 Concentration;

   AirFlow Network Window/Door Opening,
   Venting Opening Factor;

! extra outputs for viewing in the results viewer
<If BuildingAttribute HourlyOutput = 1 Then>
Output:Variable, *, Zone Air CO2 Concentration, hourly; 
<If BuildingAttribute TimesteplyOutput = 1 Then>
Output:Variable, *, Zone Air CO2 Concentration, timestep; 

   CO2 Window Control IDA1,

! programa per a IDA1
<ForAllWindows> {ZoneIDFName=IDA1;Tag=CO2}
If <LoopWindowVariableName>Air_CO2_Concentration_IDA1 <> Null,
   ! Proportional control of window opening
   ! CO2 levels in zone for this window
   SET ZoneCO2 = <LoopWindowVariableName>Air_CO2_Concentration_IDA1,
   ! CO2 level giving rise to lowest opening factor
   SET ZoneCO2Min = 650,
   ! Lowest opening factor
   SET OpenFactZoneCO2Min = 0,
   ! CO2 level giving rise to highest opening factor
   SET ZoneCO2Max = 750,   
   ! Highest opening factor
   SET OpenFactZoneCO2Max = 0.1,
   IF ZoneCO2 <= ZoneCO2Min,
      SET OpenFact = OpenFactZoneCO2Min,
   ELSEIF ZoneCO2 >= ZoneCO2Max,
      SET OpenFact = OpenFactZoneCO2Max,
      SET m = (OpenFactZoneCO2Max - OpenFactZoneCO2Min) / (ZoneCO2Max - ZoneCO2Min),      
      SET C = (OpenFactZoneCO2Min + OpenFactZoneCO2Max - m * (ZoneCO2Min + ZoneCO2Max)) / 2,
      SET OpenFact = m * ZoneCO2 + C,
   SET Venting_Opening_Factor_IDA1<LoopWindowVariableName> = OpenFact,

I used If <LoopWindowVariableName>Air_CO2_Concentration_IDA1 <> Null, before running the program but seems it didn't work,

Any help wouyld be great,

Thank you!

IDF in the link

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-03-19 11:24:20 -0600

updated 2020-03-19 11:31:37 -0600

"Null" should only be used to deactivate actuators to not change the model anymore -- they should not be used with sensors. If you want to check if the zone air CO2 concentration sensors are not equal to zero, that should be written as:

If <loopwindowvariablename>Air_CO2_Concentration_IDA1 <> 0,

I believe that EMS is checking this first IF statement, not able to evaluate it, and as a result skipping over the remaining lines of your loop. The IDF you attached has the EMS program created below from this code.

! programa per a IDA1

As you can see, only the first "Name" input field is set, and no EMS code is generated. This is what the severe error message in your error file indicates as well.

It looks like you are using DesignBuilder to write this EMS code, since you are able to use loops and other features that "native" EnergyPlus IDF files can't use. If DesignBuilder has an <if> check function, then you can use that before the EMS program lines in order to not create the entire program under certain conditions. What you are doing now is always creating the program, the only adding it's EMS code under certain conditions.

On another note, I believe that your first loop over all windows to create the sensors is incorrect. Zone Air CO2 Concentration is an output variable for each zone in the model -- not for each window in the model. So, if multiple windows are attached to the same zone, the sensors created with your current loop are essentially copies of each other with the same CO2 concentration value. If you want to open windows for natural ventilation, then using a loop over all windows in the model to create actuators for Venting Opening Factor is correct.

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

Training Workshops

Question Tools


Asked: 2020-03-19 04:39:33 -0600

Seen: 68 times

Last updated: Mar 19 '20