Sie sind auf Seite 1von 24

Energy system modelling & Technical Optimisation

The open-source MicroGridsPy model (CESP 4)


Prof. Emanuela Colombo,
Eng. Francesco Lombardi,
Eng. Nicolò Stevanato
Department of Energy
SESAM group
1. Energy System Modelling

2. Village-scale energy systems modelling

3. The MicroGridsPy model

4. Research developments

5. Working with the teaching version

6. Tutorial
5. Working with the Teaching version
Overview
The student version of the model (MicroGridsPy-Teaching) is a simplified version of the
core multi year model.

In this version only LP formulation is allowed: all code lines related to other formulations
have been removed for simplicity and for having a lighter source-code.

To use MicroGridsPy-Teaching, a working Python 3.6 environment must be installed, with


the libraries:
• Pyomo 5.5.0: optimisation object library, interface to LP solver
• pandas 0.23.0: for inputs and results data handling
• matplotlib: for plotting dispatch strategy
5. Working with the Teaching version
Basic Python instruments
Python is an open-source, community-based, non-profit, interpreted high-level
programming language. It is the most widespread language in scientific research. It hosts
thousands of thematic libraries for specific purposes (e.g. matplotlib, numpy, pyomo)

Latest release is v.3.7, but most applications currently run on v.3.6 and may have minor
compatibility issues.

Anaconda “is a free and open source distribution of the Python and R programming
languages for data science and machine learning related applications […] that aims to
simplify package management and deployment” (Wikipedia)

[https://repo.continuum.io/archive/] - Anaconda3-5.2.0-Windows-x86_64.exe
5. Working with the Teaching version
Basic Python instruments
Optimisation problems in Python are commonly implemented within the Pyomo library.

Pyomo is used to formulate the optimisation problem within a Python environment, but
the actual problem resolution relies on external solvers. Pyomo-compatible solvers
include:
― Gurobi (commercial)
― CBC (free)
― GLPK (free)

The first is an-order-of-magnitude faster than the two freeware alternatives, and it can be
downloaded and installed with a Polimi license.

Gurobi is the solver that is by default selected within MicroGridsPy-Teaching code and
that is recommended.
5. Working with the Teaching version
Basic Python instruments
ACTIVATING YOUR GUROBI ACADEMIC LICENSE
5. Working with the Teaching version
Basic Python instruments
INSTALLING PYTHON PACKAGES

• Open Anaconda Prompt

• Type the following commands:

 pip install msgpack


 pip install pyomo==5.5.0
 pip install pandas==0.23.0
 pip install matplotlib
 pip install xlrd
 pip install openpyxl
5. Working with the Teaching version
Download and installation
MicroGridsPy-Student can be downloaded from the SESAM Polimi GitHub repository:

https://github.com/SESAM-Polimi/MicroGridsPy-Teaching
5. Working with the Teaching version
Download and installation
Decompress the downloaded archive and get the following:

Scripts composing Main script to be


the source-code launched in Spyder
5. Working with the Teaching version
Running
Main script opened in Spyder:
5. Working with the Teaching version
Example basic output
The basic output provided by the Python console in real-time:
1. Energy System Modelling

2. Village-scale energy systems modelling

3. The MicroGridsPy model

4. Research developments

5. Working with the teaching version

6. Tutorial
6. Tutorial
MicroGridsPy-Teaching example exercise
Defining the inputs: data_MY.dat file

Project parameters:

param: Periods := 8760;

param: Years := 5;

param: StartDate := '01/01/2019 00:00:00';

param: Delta_Time := 1.0;

...

param: Discount_Rate := 0.037;

...

Param: Lost_Load_Probability := 0

param: Value_Of_Lost_Load := 0; [USD/Wh]


6. Tutorial
MicroGridsPy-Teaching example exercise
Defining the inputs: data_MY.dat file

Technological and economic parameters: VRES


param: Renewable_Source := 2;

param: Renewable_Nominal_Capacity :=
1 1000 [W]
2 1000; [W]

param: Renewable_Inverter_Efficiency :=
1 0.96
2 1;

param: Renewable_Investment_Cost :=
1 2 [USD/W]
2 3.3; [USD/W]

param: Renewable_Operation_Maintenance_Cost :=
1 0.02 [% of investment]
2 0.02; [% of investment]
6. Tutorial
MicroGridsPy-Teaching example exercise
Defining the inputs: data_MY.dat file

Technological and economic parameters: Generators


param: Generator_Type := 1;
param: Generator_Invesment_Cost :=
1 0.45; [USD/W]
param: Generator_Operation_Maintenance_Cost :=
1 0.15; [% of investment]
param: Fuel_Cost :=
1 1.1; [USD/L]
param: Generator_Efficiency :=
1 0.25;
param: Lower_Heating_Value :=
1 9840; [Wh/lt]
6. Tutorial
MicroGridsPy-Teaching example exercise
Defining the inputs: data_MY.dat file

Technological and economic parameters: Battery

param: Battery_Investment_Cost := 0.4;

param: Battery_Electronic_Investment_Cost := 0.09;

param: Discharge_Battery_Efficiency := 0.96;

param: Charge_Battery_Efficiency := 0.96;

param: Depth_of_Discharge := 0.2;

param: Maximum_Battery_Discharge_Time := 4;

param: Maximum_Battery_Charge_Time := 4;

param: Battery_Cycles := 5500;


6. Tutorial
MicroGridsPy-Teaching example exercise
Defining the inputs: timeseries
VRES timeseries: can be extrapolated from renewables.ninja in the form of hourly
timeseries for a reference year, for a typical PV panel and for multiple wind turbine
models, for any location on the planet.
6. Tutorial
MicroGridsPy-Teaching example exercise
Defining the inputs: timeseries
VRES timeseries: can be extrapolated from renewables.ninja
Pay attention to use the local time and perform the required adjustments if not matching
UTC
Renewable energy timeseries extracted from csv file must be inserted in the
“Renewable_Energy.xls” file (Inputs folder) PV WT
6. Tutorial
MicroGridsPy-Teaching example exercise
Defining the inputs: timeseries

VRES timeseries: the hourly power output obtainable from different power sources must
be independently assessed, if needed.

Load demand: to be assessed by means of the methodologies discussed during the


course; in this case, an example input based on real data is given.
6. Tutorial
MicroGridsPy-Teaching example exercise
Running the model

Optimization Goal: you can choose to optimize either NPC or Operation-Costs

Renewable penetration and Battery independency are two parameters that the user can
play with:
 If 0, the model does not take them into account
 If other than 0, they become additional constraints for the model resolution
6. Tutorial
MicroGridsPy-Teaching example exercise
Analysing the results – Default case
6. Tutorial
MicroGridsPy-Teaching example exercise
Analysing the results – High VRES penetration case
6. Tutorial
MicroGridsPy-Teaching example exercise
Analysing the results – Increased Battery Independence case
6. Tutorial
MicroGridsPy-Teaching example exercise
Plotting results
Default: Timeseries

Alternative: Average
(e.g. weekly, monthly)

Das könnte Ihnen auch gefallen