0
votes

we want to publish an Open-Source for integrating Reinforcement Learning to Smartgrid optimization. We use OpenModelica as GUI, PyFMI for the import to Python and Gym.

Nearly everything is running, but a possibility to connect or disconnect additional loads during the simulation is missing. Everything we can do for now is a variation of the parameters of existing loads, which gives some flexibility, but way less then the possibility to switch loads on and off.

Using the implemented switches in OpenModelica is not really an option. They just place a resistor at this spot, giving it either a very low or very high resistance. First, its not really decoupled, and second, high resistances make the ODE-system stiff, which makes it really hard (and costly) to solve it. In tests our LSODA solver (in stiff cases basically a BDF) ran often in numerical errors, regardless of how the jacobian was calculated (analytically by directional derivatives or with finite differences).

Has anyone an idea how we can implement a real "switching effect"?

Best regards,

Henrik

1
You should add a minimal working example to show what you have now and what you want to achieve.AnHeuermann

1 Answers

0
votes

Ideal connection and disconnection of components during simulation requires structure variability, which is not fully supported by Modelica (yet). See also this answer https://stackoverflow.com/a/30487641/8725275

One solution for this problem is to translate all possible model structures in advance and switch the simulation model if certain conditions are met. As there is some overhead involved, this approach only makes sense, when the model is not switched very often.

There is a python framework, which was built to support this process: DySMo. The tool was written by Alexandra Mehlhase, who made a lot of interesting publications regarding structure variability, e.g. An example of beneficial use of variable-structure modeling to enhance an existing rocket model.

The paper Simulating a Variable-structure Model of an Electric Vehicle for Battery Life Estimation Using Modelica/Dymola and Python of Moritz Stueber is also worth a look. It contains a nice introduction about variable structure systems and available solutions.