Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues running EnergyPlus 9.0.1 models as FMUs (error while reading RUNPERIOD) #30

Closed
krzysztofarendt opened this issue Mar 18, 2019 · 19 comments · Fixed by #48
Closed

Comments

@krzysztofarendt
Copy link

When I try to run an FMU exported using EnergyPlus 9.0.1 I get the following error:

...
[INFO][Slave] [ok][FMU status:OK] done searching pattern .idd

Reading input and weather file for preprocessor program.
The IDF version found is :-38
The IDF version of the input file c:\users\krza\appdata\local\temp\JModelica.org\jm_tmp0wnda7\resources\flexstore.idf starts with -38
Successfully finish reading weather file.
=== Input Error ===
File c:\users\krza\appdata\local\temp\JModelica.org\jm_tmp0wnda7\resources\flexstore.idf, line 267: Expected a number, received 'Yes', while reading entry #12 according to dictionary descriptor 'ANNNNAAAAAA<N>AN' (at <>).

=== Error ===
IDF parsing error.
Error encountered while reading values for keyword 'RUNPERIOD', starting on line 255 of IDF file.

This is the Begin Month: 1
This is the Day of the Begin Month: 2
This is the End Month: 1
This is the Day of the End Month: 7
[ERROR][Slave] [error][FMU status:Error] fmiInitializeSlave: Could not create the input and weather file. Initialization of Slave failed.

It might be related with the new RunPeriod format, which also caused problems in #24. I run into the same issue as in #24 so I downloaded EnergyPlusToFMU-v2.1.0. The FMU generates fine now, but I still can't simulate.

@tsnouidui
Copy link
Member

Any error message which could indicate why the FMU cannot be simulated? Few details about your set-up would be heplful (Operating system, master algorithm, EnergyPlus version, Type of ExternalInterface objects used)

@krzysztofarendt
Copy link
Author

@tsnouidui, I think the hint is in this part of the above-cited error message (it is printed in the terminal):

=== Error ===
IDF parsing error.
Error encountered while reading values for keyword 'RUNPERIOD', starting on line 255 of IDF file.

The file Output_EPExport_Slave\output.log looks as follows:

=== Input Error ===
File c:\users\krza\appdata\local\temp\JModelica.org\jm_tmptto40o\resources\flexstore.idf, line 267: Expected a number, received 'Yes', while reading entry #12 according to dictionary descriptor 'ANNNNAAAAAA<N>AN' (at <>).

The RunPeriod object in the IDF looks as follows:

RunPeriod,
    Run Period 1,                                  != Name
    1,                                             != Begin Month
    1,                                             != Begin Day of Month
    2006,                                          != Begin Year
    12,                                            != End Month
    31,                                            != End Day of Month
    2006,                                          != End Year
    Sunday,                                        != Day of Week for Start Day
    No,                                            != Use Weather File Holidays and Special Days
    No,                                            != Use Weather File Daylight Saving Period
    No,                                            != Apply Weekend Holiday Rule
    Yes,                                           != Use Weather File Rain Indicators
    Yes;                                           != Use Weather File Snow Indicators

For comparison, a RunPeriod object in another model created using EnergyPlus 8.6:

RunPeriod,
    Run Period 1,                                  != Name
    3,                                             != Begin Month
    1,                                             != Begin Day of Month
    3,                                             != End Month
    31,                                            != End Day of Month
    Wednesday,                                     != Day of Week for Start Day
    No,                                            != Use Weather File Holidays and Special Days
    No,                                            != Use Weather File Daylight Saving Period
    No,                                            != Apply Weekend Holiday Rule
    Yes,                                           != Use Weather File Rain Indicators
    Yes,                                           != Use Weather File Snow Indicators
    1;                                             != Number of Times Runperiod to be Repeated

So it looks that a wrong IDD is used. E.g. the 12th field in the first one is "Yes" while it is "1" in the second one. It fits to the message Expected a number, received 'Yes' from output.log.

However, I use IDD from EnergyPlus 9.01 when calling EnergyPlusToFMU:

python .\\EnergyPlusToFMU-v2.1.0\\Scripts\\EnergyPlusToFMU.py -d -i C:\\EnergyPlusV9-0-1\\Energy+.idd -w .\\model\\final.epw .\\fmu\\flexstore.idf

I have older EnergyPlus versions installed on my computer, but I have only the path to EnergyPlus 9.0.1 installation directory in my environmental variables.

My set-up:

ExternalInterface,
    FunctionalMockupUnitExport;                    != Name of External Interface

ExternalInterface:FunctionalMockupUnitExport:From:Variable,
    hovedareal,                                    != Output:Variable Index Key Name
    Zone Mean Air Temperature,                     != Output:Variable Name
    Zone_Mean_Air_Temperature_hovedareal;          != FMU Variable Name

ExternalInterface:FunctionalMockupUnitExport:To:Schedule,
    bageovn schedule,                              != Schedule Name
    Fractional,                                    != Schedule Type Limits Names
    bageovn_schedule,                              != FMU Variable Name
    0;                                             != Initial Value

Since we couldn't make it working we switched from using FMU to using EnergyPlus CLI and Schedule:File objects instead (csv schedules). However, I can help with debugging this, so please let me know if you need any other details.

@tsnouidui
Copy link
Member

tsnouidui commented Mar 31, 2019

@krzysztofarendt The fact that you can compile but cannot run it is puzzling to me. I would have suspected a mismatch between the version used to create the FMU and the version used to run FMU. Could you share your IDF file?
Furthermore, the RunPeriod of the files included in the example folder of EnergyPlusToFMU (e.g. Examples\Schedule\_fmu-export-schedule.idf) is similar to yours and they do run with EnergyPlus 9.0.1.

RunPeriod,
  ,                        !- Name
  1,                       !- Begin Month
  1,                       !- Begin Day of Month
  ,                        !- Begin Year
  1,                       !- End Month
  2,                       !- End Day of Month
  ,                        !- End Year
  ,                        !- Day of Week for Start Day
  yes,                     !- Use Weather File Holidays and Special Days
  yes,                     !- Use Weather File Daylight Saving Period
  no,                      !- Apply Weekend Holiday Rule
  yes,                     !- Use Weather File Rain Indicators
  yes;                     !- Use Weather File Snow Indicators

@krzysztofarendt
Copy link
Author

@tsnouidui, I'm getting nervous that it might be some issue in my setup, although I didn't manage to find the culprit yet. I have EnergyPlus 9.0.1 in PATH and I used IDD from EnergyPlus 9.0.1 to create the FMU.

Here is the IDF with the external interface (three last objects): https://drive.google.com/open?id=1yyBF24seYEELm5RX-MkCgF089qthToD3

@kuzha
Copy link

kuzha commented Sep 14, 2019

I have encountered the same issue with EnergyPlus version 9.0 for my own idf but the given example Examples\Schedule_fmu-export-schedule.idf could run with v9.0...very strange
I switched to E+ version 8.9 and my own idf has no issue any more.

@dayjsun
Copy link

dayjsun commented Nov 26, 2019

Hello, @kuzha @krzysztofarendt, I'm encountering the same problem as you two with similar setups. I was able to successfully run the example file but one thing that I noticed that might help: when I used idf-editor to make changes in the example file, I ended up getting the same error, but when I made the same changes directly in the .txt file, everything worked fine.

It could have something to do with the way idf-editor compiles the txt file of models made with different versions of E+?

Were you able to find a solution to this?

Best,
David

@tsnouidui
Copy link
Member

@dayjsun This is a good hint as I have so far not used the editor idf-editor to modify the IDF-file. I will do some investigations to see the impact of the idf-editor on the IDF-file

@dayjsun
Copy link

dayjsun commented Nov 27, 2019

@tsnouidui great! Let me know if I can help in any way or provide more information on my setup that might be useful to you. In the meantime, I'll comment here if I am able to find a temporary workaround

@AlyElhefny
Copy link

I'm still experiencing the same problem with the EnergyPlusToFMU-v2.1.0, the FMU generates fine but I get the same errors presented above when I simulate.

@bba-afk
Copy link

bba-afk commented Apr 29, 2020

The issue seems to be related to the way the .idf is parsed:
EnergyPlusToFMU expects the first line to be

Version,9.0;!-Version Identifier

, no return, no blanks.

A lot of editors export the version info like this to the idf:

!- Linux Line endings 

Version,
    9.0;                      !- Version Identifier

@tomstesco
Copy link

The issue seems to be related to the way the .idf is parsed:
EnergyPlusToFMU expects the first line to be

Version,9.0;!-Version Identifier

, no return, no blanks.

A lot of editors export the version info like this to the idf:

!- Linux Line endings 

Version,
    9.0;                      !- Version Identifier

Thank you for sharing this. Changing the version line format does appear to resolve the issue across different EnergyPlus versions. I'm using this simple function as a final patch after exporting IDF files I generate using eppy.

def fix_idf_version_line(idf_path, ep_version):
    """
    Fix format of Version Identifier line in IDF file for EnergyPlusToFMU
    https://github.com/lbl-srg/EnergyPlusToFMU/issues/30#issuecomment-621353009
    """
    with open(idf_path, "r") as input:
        with open(idf_path + ".patch", "w") as output: 
            for line in input:
                if line == "Version,\n":
                    output.write(
                        line.replace("\n", "{};\n".format(ep_version))
                    )
                elif "!- Version Identifier" not in line:
                    output.write(line)

    shutil.move(idf_path + ".patch", idf_path)

@bsl546
Copy link

bsl546 commented May 12, 2020

We are still experiencing the issue, even with formatting as proposed by @tomstesco . It seems to be related to the script fmu-export-idf-data.cpp. There is a variable idfVer in this script that is used to read the runperiod in the .idf file.

We were using E+9.3 and it seems that idfVer was not set to a value bigger than 8. To test it, we added an hard fix to the code, setting manually idfVer to 9 in the related functions in fmu-export-idf-data.cpp (or any number higher than 9.0) and then it worked smoothly.

Therefore, apparently, there is a problem on some platforms (we are using windows 10) with the idfVer variable.

@alex-kolmakov
Copy link

alex-kolmakov commented May 17, 2020

Did all of the above - but what actually saved me from hacking into cpp files is

OutputControl:Table:Style,
    HTML,                     !- Column Separator
    JtoKWH;                   !- Unit Conversion

removing Conversion comment - seems like it very aggressively parsing for versions.
So check your idf file for possible culprits and try removing those to see if that helps!

@lymereJ
Copy link

lymereJ commented Jun 25, 2020

I had the same issue, what helped me was removing all comments.

@stef-papathan
Copy link

@tomstesco I try to run you script but I get the following error:

"NameError: name 'shutil' is not defined"

Do you have any idea why this is happening?

@sajithjay
Copy link

@bsl546 could you elaborate on the solution. I have the same issue in EP 9.3. Have there been other ways found to correct this error?

@bsl546
Copy link

bsl546 commented Oct 5, 2020

@sajithjay Yes, sure. It is not the nicest fix, but it works: Actually it seems that fmu-export-idf-data.cpp continues reading the file after having found the first entry for the idf version. So a hard fix that work is to modify fmu-export-idf-data.cpp in both SourceCode\v10\fmu-export-prep\ and SourceCode\v20\fmu-export-prep.
Add a line with _goodRead = false; within the while loop starting at line 1167, in getIDFVersion:

	if (inputKey.find(g_key_idfVer) != string::npos) {
		frIdf.getToken(",", IDF_COMMENT_CHARS, inputKey, inputKeyExt);
		capitalize(inputKey);
		//idfVer.assign(inputKeyExt);
		idfVersion = inputKeyExt[0] - '0';
		cout << "The IDF version found is :" << idfVersion << endl;
		_goodRead = false;

For us it works.
Otherwise, I guess removing comments with version in it might solve the issue as well, as proposed by Feanaur.

@tsnouidui
Copy link
Member

I have committed a fix on this branch https://github.com/lbl-srg/EnergyPlusToFMU/tree/issue30. You can pull it and try it out. I will do further testing prior to merging to the master.

@sajithjay
Copy link

The updated package by @tsnouidui worked for me to run FMUs created using EP 9.4.

@tsnouidui tsnouidui mentioned this issue Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.