openergy / opyplus

A package to work with EnergyPlus in python
Mozilla Public License 2.0
38 stars 13 forks source link

[BUG]: On/Off Schedule Type Limits Name not supported by opyplus? #58

Open AlejandroCN7 opened 2 years ago

AlejandroCN7 commented 2 years ago

Describe the bug I am trying to load a building IDF file with opyplus, but apparently it does not have support for the On/Off Schedule Type Limits Name.

To Reproduce Steps to reproduce the behavior:

  1. Download warehouse IDF from ASHRAE9012016_Warehouse_Denver.zip
  2. Extract IDF file
  3. Use opyplus to load from IDF:
from opyplus import Epm
import os

building = Epm.from_idf(
            'ASHRAE9012016_Warehouse_Denver.idf',
            check_length=False)

Expected behavior building should be an Epm object, but the next Traceback happens:

opyplus.exceptions.FieldValidationError: No object found with any of given references : (('ScheduleTypeLimitsNames', 'on/off'),). Table: Schedule:Compact, index: 1, ref: schedule_type_limits_name, value: on/off.

With Energyplus 9.5.0 this type (On/Off) is a valid type. The lines in the IDF that cause the error are as follows:

Schedule:Compact,
    ALWAYS_OFF,              !- Name
    On/Off,                  !- Schedule Type Limits Name
    Through: 12/31,          !- Field 1
    For: AllDays,            !- Field 2
    Until: 24:00,0;          !- Field 3

  Schedule:Compact,
    ALWAYS_ON,               !- Name
    On/Off,                  !- Schedule Type Limits Name
    Through: 12/31,          !- Field 1
    For: AllDays,            !- Field 2
    Until: 24:00,1;          !- Field 3

If On/Off is changed to Any Number value, for example, The Epm.from_idf() function is executed successfully.

thomascerbelaud commented 2 years ago

Hello @AlejandroCN7, thanks for using opyplus, and reporting this bug back to us !

Indeed it seems there is a contradiction between how EPLaunch works and the Energy+.idd file that indicates only ScheduleTypeLimits objects can be referenced. (See below)

Schedule:Compact,
  A1 , \field Name
       \required-field
       \type alpha
       \reference ScheduleNames
  A2 , \field Schedule Type Limits Name
       \type object-list
       \object-list ScheduleTypeLimitsNames

Under the hood, opyplus corrects several bugs in IDD files, so I think this is the way to go about this bug. I made a quick test by modifying the IDD and was able to load the IDF file without any error raised.

Schedule:Compact,
  A1 , \field Name
       \required-field
       \type alpha
       \reference ScheduleNames
  A2 , \field Schedule Type Limits Name
       \type choice
       \key On/Off
       \object-list ScheduleTypeLimitsNames

I still have to validate this fix and if it works properly, I will make a PR to fix this next week. Until then, modifying the schedule type limit to "Any Number" (present in the IDF file) should do the trick.

geoffroy-destaintot commented 2 years ago

Hello @AlejandroCN7, thanks for reporting this bug. Hello @thomascerbelaud , thanks for the fix.

Energy+ seems to behave as if a pre-existing ScheduleTypeLimits named On/Off had been defined (even though not declared in idf). The proposed fix changed the field type to a choice, rather than an object-list. This breaks the way opyplus manages reference fields (opyplus will think that the field "Schedule Type Limits Name" is a string, rather than a link to other records). => I think we need to implement a new concept of "pre-existing" records. We could define an On/Off ScheduleTypeLimits at each new Idf creation, but this record would be registered as "pre-existing" or "virtual" and would never be written to a .idf file and always stay in-memory. Moreover, it would be interesting to find an explanation in Energy+ documentation (and maybe find out that other records are pre-defined?).