SkillAgentSearch skills...

Microgrid

Optimization of Microgrid (Multi-Objective Optimization)

Install / Use

/learn @lukecyb8687/Microgrid
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Outline

  • I. Introduction
  • II. Quickstart
    • II.A. Packages
    • II.B. Code execution
  • III. Architecture
  • IV. Simulator
    • IV.A. Dispatching
    • IV.B. Costs
      • IV.B.1. Battery
      • IV.B.2. Diesel generator
      • IV.B.3. Photovoltaic pannels
      • IV.B.4. Wind turbines
      • IV.B.a) Dollar cost
      • IV.B.b) Carbon cost
  • V. Optimizer
    • V.A. Cost functions
    • V.B. Bounds and parameters
  • VI. Limits and extensions
    • VI.A. Efficiency
    • VI.B. Solver
    • VI.C. User interface
  • VII. Acknowledgements
  • VIII. License
  • IX. Contributors

I. Introduction

In most places (in developped countries at least), people get their energy from the national grid. The energy comes from different power plants such as nuclear power plants or hydro power plants. But in many other isolated places, like islands (for instance the Ouessant Island in France), it is more relevant to implemant a new smaller grid to meet the power needs of the island's inhabitants. It is more cost-efficient to build a new grid than to connect the island to the national grid with submarine cables.

The power needs of a small island are obviously not that of a whole region, so nuclear power plants can be discarded from the beginning, water dams as well. It usually boils down to a few renewable energy production sites and a diesel generator to ensure steady energy production (when the sun sets, and the wind stops to blow, mainly).

However, before picking your hammer and your screw driver, you must precisely know the dimensions of your micro grid : What is the power demand on the grid?, How much sun and wind ressources can we reckon with?, How many PVs and windmills should we build?, How big should our batteries be?, etc. All these questions are subject to optimization : there are multile costs to optimize but mainly the regular cost 💸 and the environmental cost ⛽ captured inside the carbon dioxyde emissions.

Unfailingly, this leads to a multi-objective optimization problem where variables are merely the sizes of each installation (how much power supplied by each of the energy production sites).

Therefore, the aim of the project is to give an end-to-end program that optimizes the grid specifications for its needs. The inputs should be the load (during a year, what is the power demand hour after hour), and a few constraints (no more than 3 windmills, no more than one acre of PVs, you name it). The outputs of this program are mainly the values of the multiple cost-functions that have been optimized and most importantly, the size of each power plant facility.

II. Quickstart

Start by git cloning the repository on your machine and then download the following packages if they are or not already in your environment.

II.A. Packages

  • numpy 👉 the basic scientific library of Python with built-in math functions and easy array handling
  • time 👉 for the sole purpose of printing the computational times
  • platypus 👉 the multi-objective optimization library with It's library
  • matplotlib.pyplot 👉 for graph plotting
  • pandas 👉 to manipulate dataframes, a Python object that comes in handy when we manipulate large datasets

II.B. Code execution

Too make sure everything works all right, open main.py in your favorite compiler (Pyzo, Spyder, ...) and execute the file. You should see plots popping. They display the results of the optimization process.

Then, if you want to go further and run the optimizer with your own data, you are more than encouraged to modify the parameters inside the optimizerTest() function. You should look for these variables in the code, and modify them accordingly :

fixedParameters =
{
  "gridComponents": {
    .
    .
    .
  "strategy" : "LF"
}

constraints =
{
  "diesel": {
    "upperBound": 2000,
    .
    .
    .                                                       "lowerBound": 0
}

III. Architecture

Below is the architecture of our project. it is subdivided in multiple packages and modules that all lead one main function, the one that will help the end user in his task of properly designing the micro-grid.

  • 📑 README.md
  • 📑 .gitignore
  • 📑 main.py
  • 📁 optimizer
    • 📑 optimizer.py
    • 📑 optimizerV2.py
    • 📁 simulator
      • 📁 dispatching
        • 📑 dispatchingLoop.py
        • 📑 dispatchingStrategy.py
      • 📁 costs
        • 📁 dollars
          • 📑 dollarCost.py
          • 📁 battery
            • 📑 auxilliaryCostFunctions.py
            • 📑 batteryCost.py
          • 📁 pv
            • 📑 auxilliaryCostFunctions.py
            • 📑 pvCostAlt.py
            • 📑 pvCost.py
          • 📁 diesel
            • 📑 auxilliaryCostFunctions.py
            • 📑 dgCostAlt.py
            • 📑 dgCost.py
          • 📁 windmill
            • 📑 windCost.py
        • 📁 carbon
          • 📑 carbonCost.py

IV. Simulator

The simulator is a simplified package that yields the various costs of the micro-grid, given the sizes of each component of the grid. For instance :

The lifespan of the project is 25 years. I know the load profile of the place over a whole year. How much would it cost (💸 and ⛽) if I had a 5 kWh battery, 2 wind turbines of 2kW each, 3kW worth of PVs and a diesel generator (dg) of 3kW ?

dollarCost.py and carbonCost.py are the two Python files in which functions compute the global cost and the global carbon dioxyde emissions during the whole project. Those are the cost functions that the optimizer will aim at minimizing.

IV.A. Dispatching

Over a year, depending on the sun irradiation, or the windspeed, you might alternatively switch on and off the diesel generator, or even store energy in the battery to meet future demand. For instance, during summer, there is a much higher sun irradiation, more than needed to meet the power demand during the day. So thanks to the PVs and the battery, one part of the energy can be directly consumed, and the extra amount of energy can be stored in the battery. The battery will discharge at night, after the sun set.

With regard to the dispatch, we can adopt two different dispatching strategies : cycle charging and load following.

| Load following | Cycle charging | | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | When renewable energies don't suffice to provide enough energy to the grid, we might want to turn on the dg. If we follow a load following strategy, we first check if there's enough energy in the battery to complete the energy supply. If not, we turn on the dg at a pace such that it precisely meets the load. | The case-study is exactly the same as the previous one, but this time, instead of turning on the dg at a lower pace, we turn it on at rate such that it both meets the load and the power needed to fully charge the battery. |

Whether we chose one strategy or the other, the dispatching algorithm will compute the amount of energy stored in the battery at each time step as well as the functioning power of the dg at each time step. It directly impacts the amount of fuel consumed as well as the lifetime of the battery for instance.

IV.B. Costs

IV.B.1. Battery

The cost of the battery is calculated with the following formula :

total cost = investment cost + (replacement cost - salvage cost) + operating cost

where :

  • The investment cost is basically the price of your batteries
  • The replacement cost is the price of the batteries multiplied by the number of times you should replace them over the whole project's lifespan where :
  • The salvage cost is the price at which you could expect to sell your batteries at the end of the project, considering their remaining lifetime
  • The operating cost is the price you pay for your workforce to operate and maintain the batteries

The battery cost relies on the dispatch described above. Indeed, the dispatch heavily impacts the battery throughput (how much energy flows through the battery) and therefore its lifetime and consequently the number of replacements and therefore : the cost.

IV.B.2. Diesel generator

The cost of the Diesel generator is calculated with the following formula :

total cost = capital cost + (replacement cost - salvage cost) + operation & maintenance cost + fuel cost

where :

  • The capital cost is the inital purchase price of the diesel generator
  • The replacement cost is the cost of replacing the generator at the end of its lifetime
  • The operational and maintenance cost is the annual cost of operating and maintaining the generator
  • The salvage cost is the price at which you could expect to sell your diesel generator at the end of the project, considering their remaining

Related Skills

View on GitHub
GitHub Stars86
CategoryDevelopment
Updated4d ago
Forks10

Languages

Python

Security Score

80/100

Audited on Mar 26, 2026

No findings