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

Can't tell if EnergyPlusToFMU Examples are working

asked 2020-03-23 07:34:29 -0500

Deniz Erbilgin's avatar

updated 2020-03-24 08:56:37 -0500

Hi,

I've been having some trouble with running EnergyPlus as an FMU. Hi,

For some reason I haven't been able to install PyFMI on my system, and have been trying to using FMPy. After some initial trouble, I've managed to run the examples that come with EnergyPlusToFMU.

My issue now, is that setting the input variables does not seem to change the simulation output at all. Since none of the examples provide all the files necessary to generate the FMU or document the expected output from running them, I have no idea what the results should be.

Has anyone else successfully run the examples? If so, what .epw did you use, and how does changing the input variables to the examples change the outputs?

Edit: Here's the python code I'm using to run the example.

#!/usr/bin/python3
import fmpy

# FMU compiled with:
# - E+ v9.0.1
# - EnergyPlusToFMU v2.1.0
# - EnergyPlusToFMU-v2.1.0/Examples/Actuator/_fmu-export-actuator.idf
# - EnergyPlus-9-0-1/WeatherData/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw
fmu = '_fmu_export_actuator.fmu'

# prints a description of the FMU.
fmpy.dump(fmu)

# Runs the model.
# Needs this patch to be applied:
# https://github.com/CATIA-Systems/FMPy/commit/75fb978a55fdae5a800b80cde54118a2e274d2e2
result = fmpy.simulate_fmu(
    filename=fmu,
    start_time=0,
    stop_time=86400,
    output_interval=600,
    start_values={"yShade":2}
)

fmpy.util.plot_result(result)

And this is the output I get, regardless of what yShade is set to. image description

edit retag flag offensive close merge delete

Comments

Why couldn't you install PyFMI on your machine? Was it on Windows or on Linux. PyFMI has pre-compiled binaries that allows it to be easily installed (https://anaconda.org/chria/pyfmi).

What do you mean by been able to run the examples? The examples have one input and one output so you should be able to query the output and see what comes out. You could also modify one of the examples (e.g. Schedule) and add an output variable that tracks the input. You could then set the input and see whether the output is what you are expecting.

Thierry Nouidui's avatar Thierry Nouidui  ( 2020-03-23 13:39:38 -0500 )edit

@Deniz Erbilgin, are you running into the same issue as me? https://github.com/lbl-srg/EnergyPlus...

Jeremy's avatar Jeremy  ( 2020-03-23 16:57:19 -0500 )edit

@Thierry, I'm running Fedora 31. I'm not really sure why I couldn't get PyFMI to work, I ran into some pretty bizarre issues and so gave up in the end (I did try the anaconda package as well). I can run all three examples in FMPy, but: a) adjusting the the inputs does not seem to effect the outputs. b) in the absence of a more complete example, I don't know if (a) is because of a problem in the software, or because of the particular .epw I've chosen or what (I assume it's a bug but you never know).

@Jeremy that does looks similar to my problem. How did you read back yShade?

Deniz Erbilgin's avatar Deniz Erbilgin  ( 2020-03-24 05:48:25 -0500 )edit

Could you share the code you are using to run the example in FMPy? I unfortunately have no experience with it though.

Thierry Nouidui's avatar Thierry Nouidui  ( 2020-03-24 08:13:58 -0500 )edit

I've added the code and the output to the original question.

Deniz Erbilgin's avatar Deniz Erbilgin  ( 2020-03-24 08:52:01 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
2

answered 2020-03-25 08:06:51 -0500

Deniz Erbilgin's avatar

updated 2020-03-25 08:10:14 -0500

After much faffing, I finally got it all working.

The key points were:

  • FMPy doesn't work with EnergyPlusToFMU
  • The PyFMI on the chria channel is not being maintained. The one on conda-forge seems to be the best place to get the binary package.
  • The _fmu-export-actuator.idf simulation is in fact three days long, and differences are only visible on the third day!
  • Initialising yShade is not enough, you must pass it in to the input parameter of simulate().

I've added my final python file to a gist (with graphs of the output) as it's pretty long and I can only upload images here. The important bit is this though:

# ...

# Setup the input array.
step_size = seconds_in_hour / idf_steps_per_hour
shade_val = np.array([(i*step_size, yShade) for i in range(ncp)])
shade_val = ('yShade', shade_val)

# Set initial value of yShade
model.set(shade_val[0], shade_val[1][0][1])

res = model.simulate(start_time=0,
                     final_time=final_time,
                     input=shade_val,  # This must be passed in!
                     options=opts)

# ...

And here's a couple of graphs so that people know what to look for:

yShade = 0:

yShade=0

yShade = 7:

yShade=7

edit flag offensive delete link more

Comments

I am glad that it works.

Thierry Nouidui's avatar Thierry Nouidui  ( 2020-03-25 08:31:20 -0500 )edit
2

answered 2020-03-24 11:21:43 -0500

updated 2020-03-24 11:32:55 -0500

I am not familiar with FMPy but based on what I am seeing, I suggest to use the primitive functions setReal(), getReal(), doStep(similar to what is done https://github.com/CATIA-Systems/FMPy...) so you can set time-dependent inputs.

Please note that that example is for FMI 2.0 so you need to adapt it and call the corresponding FMI 1.0 functions.

Currently, it seems like you are only setting the initial value of yShade but EnergyPlus FMU will be updated based on the input values set during the time stepping.

If the simulate_fmu() function you have used in your example accepts a time-dependent input object, it may be easier to control your input that way.

P.S. Looking at https://github.com/CATIA-Systems/FMPy... it seems like the simulate_fmu() does accept an input object, see line 33 of that example. You may be able to change your input that way as well. Best will be to read the documentation of fmpy to see how to set-up such object.

edit flag offensive delete link more

Comments

1

You can pass simulate_fmu an array of step times and values. It doesn't seem to change anything though.

Deniz Erbilgin's avatar Deniz Erbilgin  ( 2020-03-24 11:41:04 -0500 )edit

Did you try to use the primitives setReal(), getReal(), doStep()?

Thierry Nouidui's avatar Thierry Nouidui  ( 2020-03-24 12:07:31 -0500 )edit
1

Yes, still no change. Before getting into a debugging black-hole, when you personally run these examples with your own usual setup, do you see a change in the output if you change the inputs? There's been too many occasions I've spent days debugging a component of a system, only to realise the problem was elsewhere, so I'd really like some reassurance that the E+/E+ToFMU side of things is behaving as expected. Anyway, thank you for putting so much time into this.

Deniz Erbilgin's avatar Deniz Erbilgin  ( 2020-03-24 13:03:53 -0500 )edit

I have been running E+FMU with PyFMI, Dymola, C-code and OpenModelica without issues. I am not set-up to run them with fmpy, so can confirm whether it will work or not. Could you try to run the FMU using a different master algorithm? If you are familiar with the BCVTB you may try with it. It is a pity that PyFMI is not working for you. I could install it on Ubuntu 18 with conda without any issues.

Thierry Nouidui's avatar Thierry Nouidui  ( 2020-03-25 01:53:06 -0500 )edit
0

answered 2021-08-18 07:17:36 -0500

xavfa's avatar

Hi, I am giving updates on this subject on which I struggled the last few days. I encountered the same issues with PyFMI, thus using FMI++ as an alternative on windows. It worked great with FMU1.0, but on Linux, I didn't manage to install correctly FMI++ (sundials' issue). I found a way out with FMPy with FMU2.0 of building model in energyplus. Worked great from now (10 FMUs in a row without issue, more lead to crash my virtual Linux machine (I guess the 4Gb of RAM is not enough for so many FMUs) ! But I manage to make 30 FMUs in a row on my windows machine (32Gb of RAM) using FMI++. Before make all the changes to have same packages working on Linux and windows, Is there any known issue for FMU2.0 on energyplus ? (I still have warnings form strcpy() function in C while making the FMUs but it runs perfectly afterwards, and the warning might come form gcc ?) Looking forward,

edit flag offensive delete link more

Comments

Could you please clarify what works and what doesn't work? e.g.

  • Windows + 30 FMUs 2.0 + FMI++ -> works
  • Windows + 10 FMUs 2.0 + FMPy -> doesn't work, the error message is xyz.

That will help I think

Thierry Nouidui's avatar Thierry Nouidui  ( 2021-08-18 08:09:19 -0500 )edit

Hi, sorry if it was unclear. FMPy on Linux and Windows works with either FMU1.0 or FMU2.0, but I have warning messages when using FMU2.0 (see https://github.com/lbl-srg/EnergyPlus...)

xavfa's avatar xavfa  ( 2021-08-19 09:24:48 -0500 )edit

I have responded on GitHub directly.

Thierry Nouidui's avatar Thierry Nouidui  ( 2021-08-20 00:20:33 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

3 followers

Stats

Asked: 2020-03-23 07:34:29 -0500

Seen: 787 times

Last updated: Aug 18 '21