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

Revision history [back]

Call Python code from EnergyPlus simulation

We're developing a PCM technology for which we have a physical model implemented in Matlab. Currently, the model can run standalone in Matlab, or along with a building simulation using the MLE+ toolbox.

We want to develop an implementation of the model (language to be defined, could be Python) we could distribute to allow integrating the PCM product into building simulations.

Is there such thing as generic Python bindings that would call custom Python code at each simulation step? I naively imagined so, but I can't find anything like this. This could allow anyone with light development experience (scientific, researcher) to easily plug his model into E+.

I did a bit of searching and identified two different approaches:

E+ Module

We might provide our model as an E+ Module. Does this mean the module would have to be integrated into E+ (with validation from the team, etc.), or is there a way to add own/custom modules to an E+ installation, maybe even in user space (not system-wide)? I suppose it could be a C++ module calling Python code if we find it more practical to develop the model with Python.

We may even collaborate on an E+ Module that would act as a generic Python proxy. Not sure how much more work this would represent and who would be interested in doing this. Has this been planned by anyone already?

Functional Mock-up Interface

This post (both question an answer) indicates FMI would be the way.

If looking for E+ (and only E+) compliance, wouldn't it be easier to skip the FMI layer and plug the Python code into an E+ module? What in FMI makes it easier to achieve what we want?

I feel like I'm missing the obvious. Any hint appreciated.

Call Python code from EnergyPlus simulation

We're developing a PCM technology for which we have a physical model implemented in Matlab. Currently, the model can run standalone in Matlab, or along with a building simulation using the MLE+ toolbox.

We want to develop an implementation of the model (language to be defined, could be Python) we could distribute to allow integrating the PCM product into building simulations.

Is there such thing as generic Python bindings that would call custom Python code at each simulation step? I naively imagined so, but I can't find anything like this. This could allow anyone with light development experience (scientific, researcher) to easily plug his model into E+.

I did a bit of searching and identified two different approaches:

E+ Module

We might provide our model as an E+ Module. Does this mean the module would have to be integrated into E+ (with validation from the team, etc.), or is there a way to add own/custom modules to an E+ installation, maybe even in user space (not system-wide)? I suppose it could be a C++ module calling Python code if we find it more practical to develop the model with Python.

We may even collaborate on an E+ Module that would act as a generic Python proxy. Not sure how much more work this would represent and who would be interested in doing this. Has this been planned by anyone already?

Functional Mock-up Interface

This post (both question an answer) indicates FMI would be the way.

If looking for E+ (and only E+) compliance, wouldn't it be easier to skip the FMI layer and plug the Python code into an E+ module? What in FMI makes it easier to achieve what we want?

I feel like I'm missing the obvious. Any hint appreciated.

Call Python code from EnergyPlus simulation

We're developing a PCM technology for which we have a physical model implemented in Matlab. Currently, the model can run standalone in Matlab, or along with a building simulation using the MLE+ toolbox.

We want to develop an implementation of the model (language to be defined, could be Python) we could distribute to allow integrating the PCM product into building simulations.

Is there such thing as generic Python bindings that would call custom Python code at each simulation step? I naively imagined so, but I can't find anything like this. This could allow anyone with light development experience (scientific, researcher) to easily plug his model into E+.

I did a bit of searching and identified two different approaches:

E+ Module

We might provide our model as an E+ Module. Does this mean the module would have to be integrated into E+ (with validation from the team, etc.), or is there a way to add own/custom modules to an E+ installation, maybe even in user space (not system-wide)? I suppose it could be a C++ module calling Python code if we find it more practical to develop the model with Python.

We may even collaborate on an E+ Module that would act as a generic Python proxy. Not sure how much more work this would represent and who would be interested in doing this. Has this been planned by anyone already?

Functional Mock-up Interface

This post (both question an answer) indicates FMI would be the way.

If looking for E+ (and only E+) compliance, wouldn't it be easier to skip the FMI layer and plug the Python code into an E+ module? What in FMI makes it easier to achieve what we want?

I feel like I'm missing the obvious. Any hint appreciated.

Related question: FMU Export of Python Code or Python Interface with FMI Standard for Use in EnergyPlus Co-Simulation