Skip to content

Economic Dispatch Hydrogen

This example demonstrates the workflow for the optimization of the economic dispatch of a microgrid that integrates photovoltaic electricity production as well as hydrogen production, storage and utilization.

By integrating hydrogen production into the economic dispatch framework, it becomes possible to leverage renewable energy sources and optimize the utilization of electricity considering operation cost, storage capacities, load, and insolation profiles. Hydrogen energy storage systems are an excellent addition to the microgrid as it introduces the degree of freedom to produce hydrogen rather than enforcing photovoltaic curtailment in situations of power excess in the microgrid.


Scope of the Example🔗

The experiment demonstrates energy management within a microgrid system integrated with a hydrogen-based energy storage system along with other energy sources and storage technologies. Depending on factors such as grid price, insolation profiles, condition of charges, availability of renewable energy sources, etc., the ideal combination of various energy sources is selected to fit the customer's load demand. The photovoltaic system in the microgrid system generates energy based on the timeseries insolation data, whereas the electric grid acts as a variably priced energy source as well as a sink, balancing the energy flows of the whole system. The hydrogen energy-based storage system represents the storage component of the microgrid. These, along with the fuel cell system, form the controllable assets in the microgrid system, whose input/output power flows are optimized aiming at minimizing the operational expenses (OPEX).

Component models in the microgrid system:🔗

  • Photovoltaics : This component describes a basic model of a photovoltaic system. The output power of the PV modules depends on their base power rating and solar irradiation
  • Electric Grid : It is an ideal grid model (voltage source) that accepts power flow in both directions and thus balances the energy flow in the system. This component takes a time-varying electric pricing input, which is then accounted for in the calculation of operating expenditure.
  • Fuel Cell System : Availeble hydrogen in the tank can be used by the fuel cell system to produce electric power for the microgrid. The production costs are assumed constant.
  • Hydrogen Energy Storage System (HESS) : HESS is composed of an electrolyser model that produces hydrogen based on the control current command from the microgrid controller. The hydrogen thus produced is then compressed and stored in a tank via compressor.

Workflow applied🔗

The workflow applied in this model is based on ThermalPower's built-in optimization function. To activate it, choose "optimize_microgrid" instead of "dynamic" in Modelon Impact (either by hovering over the play bottom or through the experiment setup panel). Underneath, the following steps are executed

Initial Guess Calculation Through Dynamic Simulation of the Model🔗

In order to enable an efficient and robust dynamic optimization of the problem a valid initial guess is needed for the optimizer to start. To calculate this initial guess, a dynamic simulation of the model is performed. In this context, the aim of the microgrid controller is to distribute the energy flows through the components and meet the electric load and hydrogen demands.


One of the striking features of the microgrid package is its capability to be used for gradient-based dynamic optimisation which is the second step in the workflow. Dynamic optimisation is a Modelon Impact tool feature and may not run in other tools due to a variety of reasons. The block instance "optimizer" allows to define the objective function of the problem to be optimized. Setting up the constraints and free sizing of the components are enabled within the selections available in the components' coptimization tabs. See MicroGrid model requirements for general advice on creating microgrid experiments.

Optimization Problem Description🔗

There are various design and operational problems to be solved for micro-grids presenting different use cases, both for design and operational problems illustrating the flexibility of the approach and one such is economic dispatch. The optimization for economic dispatch is carried out on a given time horizon by providing historical data for the boundary conditions of electricity price, insolation, and load demand that varies with respect to time. Using the optimizer component at the top-level of the simulation, formulate the objective function to minimize the operating expenditure per second, this makes sure the optimal control of the hydrogen energy storage system and fuel cell takes place in a cost-effective way. By doing so optimisation ensures tracking of the electricity prices with respect to time and then sell electricity back to grid when the price is high (use hydrogen in the tank through a fuel cell) and consume electricity from the grid when the price is low (produce and store hydrogen in the tank through an electrolyser).

Objective function🔗


  • Image is the optimal control input (degree of freedom) that controls the current drawn for the operation of electrolyzer for hydrogen production.
  • Image is the optimal control input (degree of freedom) to control the output current fed to the grid by the fuel cell system.
  • Image is the net cost of electricity from the grid, including what has been purchased and sold in case of surplus.
  • Mathematically it is Image, where Image is power supplied and Image is price per energy unit.

  • Image is the time horizon of optimisation

subject to main constraints

Main Constraints🔗

Image (SoC limits of hydrogen tank)

Timeseries data of electricity load demand and hydrogen demand forms the boundary conditions for this problem. ThermalPower.MicroGrid.Optimization.BoundaryCondition offers a simple way to transfer these boundary conditions to the optimization problem. Also, ThermalPower.MicroGrid.Optimization.OptimalControl is used to connect the optimal control inputs to controllable assets in the system model.


Optimal working of electrolyzer and fuel cell with the variation in electricity grid price:


Above figure shows the optimal use of fuel cell and electrolyzer systems as one can observe that fuel cells become operational when the cost of electricity is higher wheras hydrogen production comes into picture only when the grid prices are lower than the mean electricity purchase price.

Comparison of Initial Guess Trajectory and Optimal Trajectory


There are two modes of simulation for this experiment, namely dynamic and optimisation. In the first mode, the microgrid assets are controlled using a controller that is part of the system model, whereas in optimisation, the gradient-based dynamic optimisation workflow is used for asset management. In addition to the economic dispatch, we can see how optimisation limits the consumption of the electric grid during peak demand by effectively managing other dispatchable energy sources in the microgrid.

Further Reading🔗


Another scenario the user can work with is to find the optimum size of the tank that minimizes the overal cost of operation of the microgrid. The tank component consist of parameter values where minimum and maximum values of the tank capacity can be mentioned. For sizing problem the capacity of the tank has to be defined as a degree of freedom and can be assigned through a boolean parameter v_free in the tank model.


Other scenarios🔗

Similar examples of sizing, economic dispatch, peak shaving can be also simulated in case if the campus or microgrid include battery systems, photovoltaics, diesel generators and their combinations.

  • Sizing of photovoltaic deals with a design problem aiming to identify the size of the PV plant that minimizes the overall cost.
  • Demand charge reduction minimize the power peak from the grid through complete battery utilisation.
  • Sizing of generator aims to find the ideal size of the generator that minimized overall operation cost,