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

Call Python code from EnergyPlus simulation

asked 2015-07-28 06:14:30 -0600

Jérôme's avatar

updated 2015-11-16 07:33:29 -0600

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

edit retag flag offensive close merge delete

Comments

Jerome,

Wrapping your PCM module around an FMI layer and exporting it as an FMU will make your product reusable in any tool which can import FMUs. There are a growing number of tools which are adopting this technology (see https://www.fmi-standard.org/). I would recommend to consider that path rather than having a solution which is tight to a tool.

Thanks!

Thierry

Thierry Nouidui's avatar Thierry Nouidui  ( 2015-07-28 16:02:32 -0600 )edit

1 Answer

Sort by » oldest newest most voted
7

answered 2015-07-28 13:38:04 -0600

@Jerome, You're not missing the obvious. You're simply missing the EnergyPlus development process. EnergyPlus is an open-source project. Here's the code (https://github.com/NREL/EnergyPlusRel...). You are free to clone your own repository and make your own modified version, keeping it synchronized with future updates if you need to.

If what you want instead is to add a feature that will be incorporated into the main EnergyPlus release and that will be maintained by the EnergyPlus team, there is a process for this (https://energyplus.net/contributing). And there is no guarantee that your feature will be accepted. In fact, people have submitted PCM features in the past that were not accepted because they were not well supported by experiment.

The statically compiled/linked module vs. FMU decision will be partly influenced by the decision above. If you cannot get your feature into the main distribution, you are probably better off packaging it as an FMU so that you don't have to maintain an entire private EnergyPlus distribution.

edit flag offensive delete link more

Comments

Thank you for your answer. Although new to E+, I know about FOSS. I don't think our model qualifies as an E+ feature. It is specific to a product, which currently is only a prototype. And it may take a while before it reaches E+ quality, if it ever does. I'm not aiming as high as integration. I've been digging into FMU today. Not straightforward, but I'll try to dig further. Anyway, thanks for narrowing down my search, particularly for telling me that there is no way to provide a dynamically linked E+ module, apart from going the FMU way.

Jérôme's avatar Jérôme  ( 2015-07-28 14:09:38 -0600 )edit

The second part of my E+ paragraph was about creating (and integrating into E+) a generic module that would be some sort of socket for Python extensions. Basically, it would call a user-defined Python module with a user-defined list of arguments (variables from the simulation step) and inject the return values back into the simulation. With this, Python extensions would be easy to plug in. This could be done for other languages, too. I realize that I know very little about E+ and that this may well be total heresy.

Jérôme's avatar Jérôme  ( 2015-07-28 14:19:50 -0600 )edit

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

3 followers

Stats

Asked: 2015-07-28 06:14:30 -0600

Seen: 1,118 times

Last updated: Nov 16 '15