File Exchange

image thumbnail

EnergyPlus Co-simulation Toolbox

version 1.2.3.1 (70.8 MB) by Jiri Dostal
Co-simulation of EnergyPlus models in Matlab/Simulink.

43 Downloads

Updated 20 Feb 2020

From GitHub

View Version History

View license on GitHub

Description
---------------
The toolbox facilitates simultaneous simulation of EnergyPlus and Matlab (co-simulation). The main component is the mlep class containing all the necessary tools to configure and run EnergyPlus co-simulation within the Matlab environment.

System Requirements
-----------------------------
* Windows. The toolbox has only been tested for Windows, but considerable preparations for other OS has already been done.
* EnergyPlus installed. You can obtain the software here https://energyplus.net/. If you install the EnergyPlus to the default location ('C:\EnergyPlusVx-x-x') then it might be detected automatically by the toolbox.

Installation
--------
Obtain a copy of the toolbox from
* Matlab Add-on Manager
* or Mathworks File Exchange https://uk.mathworks.com/matlabcentral/fileexchange/69074-energyplus-co-simulation-toolbox
* or a GitHub repository https://github.com/dostaji4/EnergyPlus-co-simulation-toolbox/releases
and install.

Features
-----------
The toolbox contains:

* Parsing of the IDF file to determine co-simulation inputs/outputs.
* Automatic socket communication configuration (on localhost).
* Background start of the EnergyPlus process with an output to the Matlab command line.
* System Object implementation usable in Matlab & Simulink.
* Bus input/output integration for easy Simulink model setup.

Examples
-------------
See the GettingStarted.mlx guide delivered with the Matlab toolbox or the documentation residing under Help -> Supplemental Software -> EnergyPlus co-simulation toolbox

Troubleshooting
---------------------
* Always be sure that EnergyPlus itself is working. To check run "EP-Launch.exe" from the EnergyPlus installation folder and try running one of its examples (located at <EP folder>/ExampleFiles/).
* If you have issues with "EnergyPlus not found." run "setupMlep.m".
* If you have an issue with a "Vector to Bus" block not having its bus types correctly specified, run the model again. Bus objects should now be in the workspace and it should work.

Copyright (C) 2019, Jiri Dostal (jiri.dostal@cvut.cz)
All rights reserved.

This software builds on the free software by Truong Nghiem(truong@seas.upenn.edu), Willy Bernal (Willy.BernalHeredia@nrel.gov) and several other third-party open-source tools.

Cite As

Dostal, Jiri, and Tomas Baumelt. “Model Predictive Control for Buildings with Active One-Pipe Hydronic Heating.” E3S Web of Conferences, edited by S.I Tanabe et al., vol. 111, EDP Sciences, 2019, p. 04050, doi:10.1051/e3sconf/201911104050.

View more styles

Comments and Ratings (23)

islam abu awadh

@ Jiri Dostal I’m trying to run an example from the toolbox but it gave me this error:
The server closed the socket while the client was reading...I appreciate any help..

ross flynn

im trying to run the simulink example, i need to get the toolbox working in simulink for a project i have. when i go to run the simulation in simulink i get the following error
Warning: Sample time of 'EP_schedule__CoolingSetpointTemperature'
in bus object 'epInbus' must be inherited (-1). To specify a
non-inherited sample time ('600') for a bus element, use the
SampleTime parameter of the block that produces the signal
corresponding to this element.
> In Simulink.Bus.cellToObject (line 131)
In mlepSO/createBusObjects (line 339)
In mlepSO/saveToUserData (line 408)
In mlepSO/validatePropertiesImpl (line 128)

as far as i can see the sampling time for all is set to -1

any ideas?

Thanks
Ross

Jiri Dostal

Dear 梅子 段, it is most certainly not. I'm sorry. Jiri

梅子 段

Dear Jiri, is this toolbox available on a Macbook currently?

Dongxue Zhan

Hi Sravros,
Did you fix this problem? I faced the same problem rencently.
EnergyPlusCosim: EnergyPlus process sent flag"-20".
Thanks a lot at advance!

Dongxue Zhan

Jiri Dostal

Dear Stavros,
you could have contacted me by email, since comments on Mathworks site are not forwarded to email (at least for me). Now to your problem at hand: It seems that EnergyPlus has a problem with an initialization. If EnergyPlus cannot initialize, there is nothing to co-simulate with - so to speak. Are the example files working for you?
Jiri

Stavros Stavrinidis

Does anybody know how to use it ?

Stavros Stavrinidis

I'm a new user of the energyplus co-simulation toolbox.
I create a new .idf file (an office) using SketchUp.
When i run the example everything is fine but when i try my building a get this error:

An error occurred while running the simulation and the simulation was terminated
Caused by:
MATLAB System block 'mlepSimulink_example/EnergyPlus Simulation/mlep System Object' error occurred when invoking 'outputImpl' method of 'mlep'. The error was thrown from '
'C:\Users\Stavros\Documents\MATLAB\Add-Ons\Collections\EnergyPlus Co-simulation Toolbox\code\dostaji4-EnergyPlus-co-simulation-toolbox-137c614\@mlep\mlep.m' at line 334
'C:\Users\Stavros\Documents\MATLAB\Add-Ons\Collections\EnergyPlus Co-simulation Toolbox\code\dostaji4-EnergyPlus-co-simulation-toolbox-137c614\library\mlepSO.m' at line 189'.
EnergyPlusCosim: EnergyPlus process sent flag "-10" (Simulation terminated due to an error during initialization).Check the office5mx10m.err file for further information.

Reza Mokhtari

Thanks so much, it so very useful.
I'm really grateful for implementing this simple bridge between EnergyPlus and MATLAB in order to create vast oportunities to work on.

Zahra Rahimpour

Lu Yiqing

Chenjie

Timotius Kelvin

Sun Ho Kim

DemandQModeling

Hi, I have not been able to run the MATLAB example file, mlepMatlab_example.m, without having Simulink installed.

When I installed a free trial of Simulink on 2019b, the MATLAB example file worked fine. However, my 2018b license that does not have Simulink will not run mlepMatlab_example.m.

It looks like the toolbox makes several function calls that require Simulink to be installed. Examples that I have seen are get_param and bdroot.

Is it possible to use this toolbox without Simulink installed? How might I get it working on my 2018b license?

Thank you

ZHENG Zhuang

By the way, I am still confused with communication part, especially the usage of Socket.cfg... I would be grateful if you explain it a bit for me. Thanks!

ZHENG Zhuang

Rui Guo

Chirath Pathiravasam

Jiri Dostal

@PaulaVanDenBrom I haven't found myself in such a need so far. Do you need to co-simulate multiple buildings simultaneously? With my only limited knowledge of parallelization, I don't find an extension for parfor trivial. What about having multiple buildings side-by-side in Simulink? I haven't tested this yet, to be honest, but that is one feature I'd like to work! So, be sure to let me know. EnergyPlus simulation is running in a separate OS process. Simulation of several buildings would result in several EnergyPlus processes. And the OS is responsible for loading multiple computation cores (how it does that? I don't have the slightest idea).

Paula van den Brom

Is it possible to convert this code into a parfor loop?

Paula van den Brom

Jiri Rehor

MATLAB Release Compatibility
Created with R2019b
Compatible with R2017a and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

examples/legacy_example

library