Skip to content



The main aim of this application is to show a workflow for building and choosing an optimal microgrid design (topology and components selection) based on consumer types and the selected area. The second aim is to come up with a suitable control strategy, allowing us to minimize the investment price.

The application mainly solves two problems:

  • Optimal operation of microgrids

  • Optimal design of microgrids

These two objectives can also be combined into a single problem, i.e. solving for the optimal operation of a microgrid with optimal design.

What is the Microgrid good for?🔗

Most of the time, we rely on the traditional power grid as our main energy source. But when massive blackouts occur, organizations, and communities need to rely on power systems that are secure and flexible.

Moreover, renewable energy sources like wind, photovoltaic power-plants and others do not provide constant power output and they are dependent on the weather, causing power fluctuation to the power grids.

Microgrids — which operate as part of the traditional grid or independently — are an ingenious solution that can lead to fewer blackouts, greater cost savings, and less dependence on fossil fuels.

What are we creating in this application?

In this application, we will show how to open and run a defined set of microgrid configurations with several specific control strategies equipped by a dynamic optimization. It consists of Modelica models, Jupyter notebooks and web-application.


This application requires Modelon Impact 2022.1 desktop installation.

You will learn how to:

  • Install all application parts
  • Run optimization models
  • Run Jupyter notebooks
  • Run web-app


It is necessary to download and install all the Microgrid components to a desktop computer from Modelon Thermal Power library.

Custom function🔗

  1. Add Optimize Microgrid custom function by copying C:/ModelonImpact_X.X/modelica-dist/ThermalPower X.XX/Resources/custom_functions/Microgrid/ to C:/Users/<User_name>/impact/custom_functions.


The .py files need to be on the top level. If the .py files are in a folder (impact/custom_function/custom_functions) then Modelon Impact won’t find them.


For web-application, please contact us directly on


  1. Microgrid optimization notebook can be found in C:/ModelonImpact_X.X/modelica-dist/ThermalPower X.XX/Resources/Python/Microgrid

  2. Copy C:/ModelonImpact_X.X/modelica-dist/ThermalPower X.XX/Resources/Python/Microgrid to e.g. C:/Jupyter/.


You can install Jupyter Notebook on your computer and use it for running the notebooks. This is described in Installation chapter of Jupyter notebook getting started guide.

  1. Run Jupyter Notebooks (e.g. run C:/Jupyter/Microgrid_notebooks/LaunchNotebook.bat)


Check that the *.bat file includes correct Modelon Impact installation path (e.g. set JMDIR=C:\ModelonImpact-X.XX\oct-dist).

  1. This opens a browser with Jupyter notebook.

  2. OpenMicrogrid-Optimization.ipynb which starts the notebook landing page.

Optimization models🔗

Microgrid library includes several example models placed within ThermalPower.MicroGrid.Examples. The whole package includes a detailed documentation and description explaining the background, purpose and results of the specific examples.

Click here to find out, how to access the library documentation.

The optimization models can be run using below approach:

  1. Copy C:\ModelonImpact-1.2b2\modelica-dist\ThermalPower 1.22\Resources\custom_functions\Microgrid folder content into C:/Users/<user_name>/impact/custom_functions to make the Optimize Microgrid avaliable in Modelon Impact.

  2. Restart the Modelon Impact server.

  3. Create a new workspace "Microgrid".

  4. Duplicate ThermalPower.MicroGrid.Examples.Optimization.EconomicDispatch model into your workspace.

  5. Go to Experimentation mode and select custom function Optimize Microgrid.

  6. Paste ThermalPower.MicroGrid.Examples.Simulation.EconomicDispatch as the "sim_model" within the custom function settings.

  7. Run the simulation.

Optimization notebooks🔗

The Microgrid landing page offers a basic description and links to specific notebooks. Click on the links to access the desired notebook.

Each notebook is divided into different chapters:

  • System overview
  • Models
  • Problem formulation
  • Parameterization & General setup
  • Simulation
  • Optimization with post-processing


Do not forget to set up a correct path to the Microgrid notebook at the beggining of the notebook:

microgrid_package_path = "c:\ModelonImpact-X.XX\modelica-dist\ThermalPower X.XX"

my_libs=[microgrid_package_path, "c:\ModelonImpact-X.XX\modelica-dist\Modelon X.XX"]

Optimization web-app🔗

The Microgrid web-app is self-explanatory.

  1. The user selects a position on a map, where the microgrid should be placed and select a battery capacity with or without a diesel generator.

  2. A user can run the basic simulation or choose from predefined optimization options.