Create FMUs for co-simulation directly from Python

330 views
Skip to first unread message

Esther Borkowski

unread,
May 14, 2020, 2:57:35 AM5/14/20
to energyplus-fmu
Hi there,

I would like to export EnergyPlus files as FMUs for co-simulation through EnergyPlusToFMU directly from Python. Is anyone aware of a workable solution?

I know how to create FMUs from the command-line, and at the moment, I am using a small batch file that is calling EnergyPlusToFMU to create the FMUs. I am currently calling this batch file from Python but I think the code would be much cleaner if I would be able to create FMUs directly from Python and not through the detour with the batch file. So I was wondering if anyone out there has come across the same question and already got an answer?

Many thanks and best regards,
Esther

Thierry Nouidui

unread,
May 14, 2020, 3:03:28 AM5/14/20
to energyplus-fmu
I don't understand the question. EnergyplusToFMU is written in Python.  
What do you mean by directly creating the FMU from Python? Could you describe the workflow you anticipate and why it doesn't work with EnergyPlusToFMU?

Esther Borkowski

unread,
May 14, 2020, 3:15:41 AM5/14/20
to energyplus-fmu
Hi Thierry, many thanks for getting back to me so quickly.

I'm currently running some Monte Carlo simulations. So I created an automated script in Python, which changes variables in the EnergyPlus file, creates an FMU from the EnergyPlus file, links this to the controller model in Dymola and runs the co-simulation. The script then returns the results and repeats the process until all the Monte Carlo simulations are done.
I'm currently using subprocess in Python to call a batch file that calls EnergyPlusToFMU but I just wonder if there is a more straightforward way to export all the EnergyPlus files as FMUs for the co-simulation?

Thierry Nouidui

unread,
May 19, 2020, 7:12:05 AM5/19/20
to Esther Borkowski, energyplus-fmu
You wrote, " I'm currently using subprocess in Python to call a batch file that calls EnergyPlusToFMU "
Why can't subprocess not call EnergyPlusToFMU directly? Why do you need the intermediate step?

--
You received this message because you are subscribed to the Google Groups "energyplus-fmu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to energyplus-fm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/energyplus-fmu/d78ef26d-e257-4eca-8732-94e3294ad4f2%40googlegroups.com.


--
Prof. Thierry Nouidui
Nouidui Consulting Group
https://nouidui.com/index.php/consulting/

Esther Borkowski

unread,
May 19, 2020, 7:38:08 AM5/19/20
to energyplus-fmu
That's a good point. I will give it a try and post the solution here.


Am Dienstag, 19. Mai 2020 13:12:05 UTC+2 schrieb Thierry Nouidui:
You wrote, " I'm currently using subprocess in Python to call a batch file that calls EnergyPlusToFMU "
Why can't subprocess not call EnergyPlusToFMU directly? Why do you need the intermediate step?

On Thu, May 14, 2020 at 10:15 AM 'Esther Borkowski' via energyplus-fmu <energyp...@googlegroups.com> wrote:
Hi Thierry, many thanks for getting back to me so quickly.

I'm currently running some Monte Carlo simulations. So I created an automated script in Python, which changes variables in the EnergyPlus file, creates an FMU from the EnergyPlus file, links this to the controller model in Dymola and runs the co-simulation. The script then returns the results and repeats the process until all the Monte Carlo simulations are done.
I'm currently using subprocess in Python to call a batch file that calls EnergyPlusToFMU but I just wonder if there is a more straightforward way to export all the EnergyPlus files as FMUs for the co-simulation?



Am Donnerstag, 14. Mai 2020 09:03:28 UTC+2 schrieb Thierry Nouidui:
I don't understand the question. EnergyplusToFMU is written in Python.  
What do you mean by directly creating the FMU from Python? Could you describe the workflow you anticipate and why it doesn't work with EnergyPlusToFMU?

On Thursday, May 14, 2020 at 9:57:35 AM UTC+3, Esther Borkowski wrote:
Hi there,

I would like to export EnergyPlus files as FMUs for co-simulation through EnergyPlusToFMU directly from Python. Is anyone aware of a workable solution?

I know how to create FMUs from the command-line, and at the moment, I am using a small batch file that is calling EnergyPlusToFMU to create the FMUs. I am currently calling this batch file from Python but I think the code would be much cleaner if I would be able to create FMUs directly from Python and not through the detour with the batch file. So I was wondering if anyone out there has come across the same question and already got an answer?

Many thanks and best regards,
Esther

--
You received this message because you are subscribed to the Google Groups "energyplus-fmu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to energyp...@googlegroups.com.

Esther Borkowski

unread,
Jun 5, 2020, 10:03:18 AM6/5/20
to energyplus-fmu
Hi there,

I just tried to call EnergyPlusToFMU directly. However, I forgot to mention in my last post that I am working with Python 3 so I am getting the same error as someone else here.

Just in case someone is running into a similar problem, here is my solution with the batch file:

This is the batch file to call EnergyPlusToFMU and create the FMU:

@echo off
set arg1=%1
set arg2=%2
cd C:\Python27
python C:\EnergyPlusToFMU-v2.1.0\Scripts\EnergyPlusToFMU.py -d -i C:\EnergyPlusV8-9-0\Energy+.idd -w %arg1% %arg2%

From Python 3, I am calling the batch file through subprocess:

subprocess.call([path_to_bat_file, path_to_epw_file, path_to_idf_file], shell=False)

Esther Borkowski

unread,
Jun 19, 2020, 9:23:40 AM6/19/20
to energyplus-fmu
Here is a hint for a solution to call EnergyPlusToFMU directly through subprocess: https://stackoverflow.com/a/62413173/10758323
Reply all
Reply to author
Forward
0 new messages