Hi, I’m working on a research project where I’d like to use OpenEMS to optimize the management of a microgrid. Specifically, I want to implement custom optimization algorithms to make the EMS choose the Distributed Energy Resources (DERs) from which to draw energy, based on economic or environmental criteria. However, before attempting to implement such algorithms, I need to connect an actual microgrid to OpenEMS. Since I currently don’t have access to one, I would like to use a software simulator, preferably one that’s compatible with the Modbus protocol. This would allow me to model a microgrid in the simulator and connect it to OpenEMS Edge.
As I’m completely new to the energy management domain, could you please tell me if this approach is feasible? Additionally, if you’re aware of any, could you suggest some ready-to-use, free simulators? Thank you.
Hi Fabio,
I can’t recommend a ready-to-use simulator, but I probably had a similar task in my MA. I set up a test stand for exactly the same application, but it consisted of real components and virtually simulated ones. I wrote a Python application for simulated consumers and generators, which provided me with a Modbus server and wrote values to it cyclically from a CSV. I used an already implemented meter as a register. The default values of the CSV were standard load profiles and also real recorded measured values. For the battery storage, I programmed a new component in OpenEMS that functions as an interface for an external storage. In principle, this is just a simple Modbus protocol with the data relevant to me. I also simulated this externally using a Python script. This worked well and can be extended as required.
Thank you for your answer. Could you give me some guidance on how to make such a simulator (i.e. what are the needed components and how they should be linked to each other, if they should)? Another thing I would like to understand is how to implement a two-way communication between the simulator and OpenEMS. As for my understanding, the simulator should produce some values about energy production from its DERs, and send them to OpenEMS via the Modbus server. Then, OpenEMS should use those values, in conjunction with the load information from the consumers (it could be a CSV), to compute setpoints for each DER using some optimization algorithm, and send those setpoints back to the simulator which, eventually, should apply them so that we can see the results. Is this approach correct, and did you do anything similar?
For only ‘measured’ generators or consumers, for which you simply evaluate a meter in the real case, I do it in exactly the same way. To do this, I set up a modbus server with different ports for each meter on my PC using a Python script. I then configured an OpenEMS Modbus bridge
on these and connected this in turn to an implemented Modbus meter e.g. I use the Siemens PAC1600.
To describe the server, I wrote a simple script that has exactly the registers of the real meter. This means that you have integrated the individual meters but not yet a network connection point. You define this by building the point by adding the components virtual substract and virtual add meter.
If you send me your email by personal message, I can also send you a simple example of the virtual meter script in Python.
Another thing I would like to understand is how to implement a two-way communication between the simulator and OpenEMS. As for my understanding, the simulator should produce some values about energy production from its DERs, and send them to OpenEMS via the Modbus server. Then, OpenEMS should use those values, in conjunction with the load information from the consumers (it could be a CSV), to compute setpoints for each DER using some optimization algorithm, and send those setpoints back to the simulator which, eventually, should apply them so that we can see the results. Is this approach correct, and did you do anything similar?
I have done it in a very similar way, as I have integrated a BESS whose behaviour should be controlled by an OpenEMS algorithm. Here I also had a Modbus server, which was described by OpenEMS and an external script. The EMS always wrote my power specification to it and the Python script determined the current power from my model and the specification. In principle, every BESS that is integrated in OpenEMS does this. By simulating the storage system, however, you also have to subtract this power from your grid connection point so that it is correct.
My OpenEMS Component to connect the simulated BESS to OpenEMS is on a public repository, but I haven’t the time to switch it to the official Repo.
Thank you for your help and detailed answers. I have some questions though: supposing you wanted to emulate a microgrid made up by multiple DERs (let’s say a PV panel, a wind turbine, an ESS and a diesel generator), would you need to implement a device in OpenEMS for each of them, or would it be enough to simply implement a meter which collects all the values from all of them, allowing two-way communication with each simulator via Modbus?
Secondly, in your example, if I understood correctly, you created a simulator for a BESS, and you also implemented a corresponding device within OpenEMS, right? What is the role of the meter which you talked earlier about? As for my understanding, you created another simulator for a meter, then connected it to OpenEMS Modbus Bridge which, in turn, was connected to a device implemented within OpenEMS. Is this correct or did I get it wrong?
I have some questions though: supposing you wanted to emulate a microgrid made up by multiple DERs (let’s say a PV panel, a wind turbine, an ESS and a diesel generator), would you need to implement a device in OpenEMS for each of them, or would it be enough to simply implement a meter which collects all the values from all of them, allowing two-way communication with each simulator via Modbus?
If you need only the sum of all Components, you can put it in one component. But if you need all DERs at there own, you have to make it for each component.
Secondly, in your example, if I understood correctly, you created a simulator for a BESS, and you also implemented a corresponding device within OpenEMS, right? What is the role of the meter which you talked earlier about? As for my understanding, you created another simulator for a meter, then connected it to OpenEMS Modbus Bridge which, in turn, was connected to a device implemented within OpenEMS. Is this correct or did I get it wrong?
I think you understand it correct. If you implement a external simulated device, OpenEMS only see what the state of the component is, but this have no impact to the grid meter, because there is no real energy flow. If you use than e.g. a controller to balance the grid point it can’t work correctly. To fix this problem I builded in a production and consumtion meter, that have the same powerflow as the BESS. This one I substract from the grid meter and use the new one as simulated grid meter.
Do both approaches allow for a two-way communication between the simulator and OpenEMS, so that the latter can send parameters to the former, after running some controllers?
This is trickier for me to understand: for “external simulated device” do you mean a device implemented in OpenEMS or within the external simulator? If it is the former, are you saying that, other than the device implemented in OpenEMS, we also need to implement a meter? And for “production and consumption meter” do you mean the same meter or two different ones?
A meter is only a one way component from which OpenEMS read the actuall state. If you have a real meter e.g. your energy meter in your home to measure the energy consumption this can only measure and give you the value but this can’t controll something. If you need a two way communication you have to use a system like the BESS systems they are implemented.
With external simulated device I mean in this context a device that is a simulated device which is simulated external but can communicate with OpenEMS what it actually did and what it has to do. So this has a two-way communication.
This is a nature of the meter.
Have you done the Getting Started Guide before? I think this will help you to understand a little bit more how OpenEMS work and what I mean.
Yes, I followed both the Getting Started and the device implementation guide. My doubts are due to my lack of knowledge on how a microgrid could be emulated and how to connect it to OpenEMS. Anyway, thank you again for your help.
Thank you Stefan. I knew there are some simulated devices (I’ve followed the tutorial), but I wanted to emulate the interaction with an external microgrid in the most realistic way.
Anyway, what are the included optimization algorithms to balance the micrigrid? I 've taken a look at the list of controllers, but couldn’t understand the differences between the various algorithms. Could you please explain it in a simple way?