Professional Documents
Culture Documents
Micro-Grids Documentation: Release 1.0.0
Micro-Grids Documentation: Release 1.0.0
Release 1.0.0
1 Contents 3
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Model Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 API Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 License 17
3.1 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
i
ii
Micro-Grids Documentation, Release 1.0.0
Contents 1
Micro-Grids Documentation, Release 1.0.0
2 Contents
CHAPTER 1
Contents
1.1 Overview
The main objective of the Micro-grid library is to determine the combination of install capacities of PV, Lion-Ion
Batteries and diesel generators that makes the lowest Net Present Cost for the life time of the project and accomplish
the constraints of the system. For this objective the problem is express as a linear programming problem.
3
Micro-Grids Documentation, Release 1.0.0
After the optimization process finish and the results are found, a post-processing tool is used in order to present the
results and the most important parameters in an excel sheet, finally a Figure with the energy flow from the choose days
is created.
1.1.1 Reference
[1] Agarwal N., Kumar A., Varun., Optimization of grid independent hybrid PV-diesel-battery system for power
generation in remote villages of uttar Pradesh, india. Energy for Sustainable Development 2013; 17:210-219
1.2.1 Sets
1.2.2 Parameters
4 Chapter 1. Contents
Micro-Grids Documentation, Release 1.0.0
PV parameters
Project parameters
1.2.3 Variables
PV variables
Battery variables
6 Chapter 1. Contents
Micro-Grids Documentation, Release 1.0.0
Project variables
The objective function will minimize the sum of the multiplication of the net present cost of each scenario and their
probability of occurrence.
∑︁
𝑂𝑏𝑗𝑒𝑐𝑡𝑖𝑣𝑒𝐹 𝑢𝑛𝑡𝑖𝑜𝑛 = ScenarioNetPresentCost 𝑠 · ProbalityOccurrence 𝑠
𝑠
The net present cost of each scenario is computed with the following equation:
The total cost incurred in the lifetime of the project for the financial cost is calculated with equation:
∑︁ 𝐹 𝑖𝑛𝑎𝑛𝑐𝑖𝑎𝑙𝐶𝑜𝑠𝑡
𝐹 𝑖𝑛𝑎𝑛𝑐𝑖𝑎𝑙𝐶𝑜𝑠𝑡𝑇 𝑜𝑡𝑎𝑙 =
𝑛
(1 + 𝐷𝑖𝑠𝑐𝑜𝑢𝑛𝑡𝑅𝑎𝑡𝑒)𝑛
Finally the cost for the unmment load is calculated with the following equation:
∑︁ ∑︀ LostLoad 𝑠,𝑡 · 𝑉 𝑎𝑙𝑢𝑒𝑂𝑓 𝐿𝑜𝑠𝑡𝐿𝑜𝑎𝑑
𝑡
LostLoadCostTotal 𝑠 =
𝑛
(1 + 𝐷𝑖𝑠𝑐𝑜𝑢𝑛𝑡𝑅𝑎𝑡𝑒)𝑛
PV model
The equation that model the PV array energy yield is given by:
Diesel generator
In order to ensure that the generator will not exceed his capacity the fallowing constraint is added to the model:
Battery bank
In this equations is important to highlight that in the period 1 the stated of charge of the batterie is equal to the total
capacity of the battery.
In order to ensure the durability of the battery a minimum depth of discharge (%) and maximum charge are establish
as a constraint:
8 Chapter 1. Contents
Micro-Grids Documentation, Release 1.0.0
Energy constraints
In order to ensure a perfect match between generation and demand, an energy balance is created as a constraint.
EnergyDemand 𝑠,𝑡 = TotalEnergyPV 𝑠,𝑡 + DieselConsumed 𝑠,𝑡 + EnergyBatteryCharge 𝑠,𝑡
+EnergyBatteryDischarge 𝑠,𝑡 + EnergyCurtailment 𝑠,𝑡 + LostLoad 𝑠,𝑡
This constraint is used to ensure that a percentage of the demand will always be supply and is express as follow:
∑︀
LostLoad 𝑠,𝑡
𝐿𝑜𝑠𝑡𝐿𝑜𝑎𝑑𝑃 𝑟𝑜𝑏𝑎𝑏𝑖𝑙𝑖𝑡𝑦 = ∑︀ 𝑡
𝑡 EnergyDemand 𝑠,𝑡
1.3.4 Constraints
1.3.6 Results
1.4 Tutorial
This section is a walkthrough of how to use the Micro-Grids library in order to obtain the optimal nominal capacity
for an isolated micro-grid with a given demand and PV production.
1.4.1 Requirements
The MicroGrid library can be use in Linux or windows and needs different programs and phyton libraries in order to
work.
Python
First of all Micro-Grids needs Python 3 install in the computer. The easiest way to obtain it, is download anaconda in
order to have all the tools needed to run python scripts.
Python libraries
Solver
Any of the fallowing solvers can be used during the optimization process in the Micro-Grids library:
• cplex
For the moment the Micro-Grids library is in form of python scripts, in order to download them please follow this link:
https://github.com/squoilin/MicroGrids
Once they have been download, create a folder and put the scripts in there. Also create two folders with the names of
‘Results’ and Inputs as show in the following Figure:
1.4.3 Inputs
The Micro-grids library needs the input files are stored in the folder ‘Inputs’, these are the needed files:
Name of the file type of file Description
Data.dat Txt file In this file the value of the parameters are set
Demand.xls Excel file The demand of energy of the system for each period is set in this file
PV_Energy.xls Excel file The energy yield in each period from one PV is set in this file
Data.dat file
This file has to contain all the parameters for the Micro-Grids library to be able to perform an optimization of the
nominal capacity of the PV, battery bank and diesel generator. This file has to be write in AMPL data format. A table
of all the parameters with an example of value and how they have to be written in the txt can be seen in the next table.
10 Chapter 1. Contents
Micro-Grids Documentation, Release 1.0.0
This file must be save inside the folder “Inputs”. An example can be downloaded in the fallowing link:
https://github.com/squoilin/MicroGrids/tree/master/MicroGrids/Example
Demand.xls file
The Demand.xls file has to have the energy demand of the system in each period of analysis. The excel file must have
a column with the periods and another with the demand in W as shown in the following figure.
1.4. Tutorial 11
Micro-Grids Documentation, Release 1.0.0
This file must be save inside the folder “Inputs”. An example can be downloaded in the fallowing link:
https://github.com/squoilin/MicroGrids/tree/master/MicroGrids/Example
PV_Energy.xls
The PV_Energy.xls file has to have the energy yield for one PV in each period of analysis. The excel file must have a
column with the periods and the number of columns equal to the number of scenarios energy yield in W as shown in
the following figure.
12 Chapter 1. Contents
Micro-Grids Documentation, Release 1.0.0
This file must be save inside the folder “Inputs”. An example can be downloaded in the fallowing link:
https://github.com/squoilin/MicroGrids/tree/master/MicroGrids/Example
Once all the above steps are performed, the easiest way to run the Micro-grids library is opening the Micro-Grids.py
file in an development environment like spider and run the script inside it. Another way is to open a terminal in the
folder where all the scripts are and use the following command:
python Micro-Grids.py
1.4. Tutorial 13
Micro-Grids Documentation, Release 1.0.0
1.4.5 Outputs
After the optimization is finish a message will appear with the Levelized cost of energy and the net present value of
the system. Also 3 files will be created in the ‘Results’ folder, this files are specified in the following table.
Name of the file type of Description
file
Size.xls Txt file Contains the nominal capacities of the PV, Battery, Diesel generator and other
information
Time_series.xls Excel Contains the the energy flow in each period for all the energy variables and
file the diesel consume
Sce- Excel Contains some information of the scenarios
nario_Information.xls file
Energy_flow.png Excel Contains the Figure of the energy flow from the ‘PlotDay’ during for
file ‘PlotTime’ days
14 Chapter 1. Contents
CHAPTER 2
• genindex
• modindex
• search
15
Micro-Grids Documentation, Release 1.0.0
License
3.1 References
17