Home > matpower7.0 > extras > syngrid > lib > sg_gen_cost.m

sg_gen_cost

PURPOSE ^

SG_GEN_COST main function to run generation cost assignment

SYNOPSIS ^

function [gencost, genfuel, gentype] = sg_gen_cost(PgMax, cost_model, Tab_2D_gcost)

DESCRIPTION ^

SG_GEN_COST main function to run generation cost assignment
   [GENCOST, GENFUEL, GENTYPE] = SG_GEN_COST(PGMAX, COST_MODEL, TAB_2D_GCOST)

   Input:
       PgMax - matrix (Ng by 2) indicating the generation bus number and
           its maximum capacity
       cost_model - Indicating the approach for generation cost (1/2)
                   coefficients (1 = linear, based on heat rate and
                   2 = quadratic, based on dispatch coefficients)
       Tab_2D_gcost - PMF map table to assign generation types based on
           generation capacities

   Output:
       gencost - MATPOWER generator cost matrix (see CASEFORMAT, IDX_COST)
       genfuel - MATPOWER generator fuel type cell array (see GENFUELS)
       gentype - MATPOWER generator type cell array (see GENTYPES)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [gencost, genfuel, gentype] = sg_gen_cost(PgMax, cost_model, Tab_2D_gcost)
0002 %SG_GEN_COST main function to run generation cost assignment
0003 %   [GENCOST, GENFUEL, GENTYPE] = SG_GEN_COST(PGMAX, COST_MODEL, TAB_2D_GCOST)
0004 %
0005 %   Input:
0006 %       PgMax - matrix (Ng by 2) indicating the generation bus number and
0007 %           its maximum capacity
0008 %       cost_model - Indicating the approach for generation cost (1/2)
0009 %                   coefficients (1 = linear, based on heat rate and
0010 %                   2 = quadratic, based on dispatch coefficients)
0011 %       Tab_2D_gcost - PMF map table to assign generation types based on
0012 %           generation capacities
0013 %
0014 %   Output:
0015 %       gencost - MATPOWER generator cost matrix (see CASEFORMAT, IDX_COST)
0016 %       genfuel - MATPOWER generator fuel type cell array (see GENFUELS)
0017 %       gentype - MATPOWER generator type cell array (see GENTYPES)
0018 
0019 %   SynGrid
0020 %   Copyright (c) 2018, Electric Power and Energy Systems (EPES) Research Lab
0021 %   by Hamidreza Sadeghian and Zhifang Wang, Virginia Commonwealth University
0022 %
0023 %   This file is part of SynGrid.
0024 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0025 
0026 Ng=length(PgMax);
0027 % normalized PgMax
0028 PgMax_norm = PgMax;
0029 MAX_PgMax = max(PgMax(:,2));
0030 PgMax_norm (:,2) = PgMax_norm (:,2)./MAX_PgMax;
0031 % Assignment of generation types based on their generation capacity and 2D table
0032 [Corr_type,Type_setting]=Assignment(PgMax_norm,Tab_2D_gcost);
0033 % Output: calculate actual values for generation capacities
0034 Type_setting(:,2)= Type_setting(:,2).*MAX_PgMax;
0035 gentype = cell(Ng,1);
0036 genfuel = cell(Ng,1);
0037 gencost = zeros(Ng,4);
0038 if cost_model == 2  %% Approach 2 (quadratic, based on dispatch cost coeffcients)
0039     gencost(:,1) = 2;
0040     gencost(:,4) = 3;
0041     for it = 1:Ng
0042         if Type_setting(it,3) == 1
0043             gentype{it}  = 'HY';
0044             genfuel{it}  = 'hydro';
0045             gencost (it,5:7) = 0;
0046         elseif Type_setting(it,3) == 2
0047             gentype{it}  = 'W2';
0048             genfuel{it}  = 'wind';
0049             gencost (it,5:7) = 0;
0050         elseif Type_setting(it,3) == 3
0051             gentype{it}  = 'GT';
0052             genfuel{it}  = 'ng';
0053             if Type_setting(it,2) <=400
0054                 gencost (it,7) = 0 + 600*rand; %  reference "Aplication of Large-Scale Synthetic Power System Models ....." a0 -> (0 - 600)
0055             else
0056                 gencost (it,7) = 600 + 3259*rand; % a0 -> (600 - 3859) [$/hr]
0057             end
0058             gencost (it,6) = 23.13 + 33.9*rand; %   a1 -> (23.13-57.03)  [$/MWh]
0059             gencost (it,5) = 0.002 + 0.006*rand; % a2 -> (0.002 - 0.008)  [$/MWh^2]
0060         elseif Type_setting(it,3) == 4
0061             gentype{it}  = 'ST';
0062             genfuel{it}  = 'coal';
0063             if Type_setting(it,2) <=75
0064                 gencost (it,7) = 0 + 238*rand; % a0  -> (0-238)
0065             elseif Type_setting(it,2) > 75 && Type_setting(it,2) <=150
0066                 gencost (it,7) = 238 + 507*rand; % a0 -> (238 - 745)
0067             elseif Type_setting(it,2) > 150 && Type_setting(it,2) <=350
0068                 gencost (it,7) = 745 + 468*rand; % a0 -> (745 - 1213)
0069             else
0070                 gencost (it,7) = 1213 + 1830*rand; % a0 -> (1213 - 3043)
0071             end
0072             gencost (it,6) = 19; %   a1 -> (19)
0073             gencost (it,5) = 0.001; % a2 -> (0.001)
0074         elseif Type_setting(it,3) == 5
0075             gentype{it}  = 'NB';
0076             genfuel{it}  = 'nuclear';
0077             gencost (it,7) = 1000 + 500*rand; % a0 -> (1000 - 1500)
0078             gencost (it,6) = 5 + 6*rand; % a1 -> (5 - 11)
0079             gencost (it,5) = 0.00015 + 0.00008*rand; % a2 -> (0.00015 - 0.00023)
0080 %             gencost (it,5) = 0.000015 + 0.000008*rand; % a2 -> (0.00015 - 0.00023)
0081         end
0082     end
0083 elseif cost_model == 1  %% Approach 1 (linear, based on heat rate)
0084     gencost(:,1) = 2;
0085     gencost(:,4) = 2;
0086     for it = 1:Ng
0087         if Type_setting(it,3) == 1
0088             gentype{it}  = 'HY';
0089             genfuel{it}  = 'hydro';
0090             gencost (it,5:6) = 0;
0091         elseif Type_setting(it,3) == 2
0092             gentype{it}  = 'W2';
0093             genfuel{it}  = 'wind';
0094             gencost (it,5:6) = 0;
0095         elseif Type_setting(it,3) == 3
0096             gentype{it}  = 'GT';
0097             genfuel{it}  = 'ng';
0098             if Type_setting(it,2) <=400
0099                 gencost (it,6) = 0 + 600*rand; %  reference "Aplication of Large-Scale Synthetic Power System Models ....." a0 -> (0 - 600)
0100             else
0101                 gencost (it,6) = 600 + 3259*rand; % a0 -> (600 - 3859)
0102             end
0103             gencost (it,5) = 2.59.*(6.5 + rand*11); % a1 = cf*b1 -> cf = 2.59   & b1 = (6.5 - 17.5)
0104         elseif Type_setting(it,3) == 4
0105             gentype{it}  = 'ST';
0106             genfuel{it}  = 'coal';
0107             if Type_setting(it,2) <=75
0108                 gencost (it,6) = 0 + 238*rand; % a0  -> (0-238)
0109             elseif Type_setting(it,2) > 75 && Type_setting(it,2) <=150
0110                 gencost (it,6) = 238 + 507*rand; % a0 -> (238 - 745)
0111             elseif Type_setting(it,2) > 150 && Type_setting(it,2) <=350
0112                 gencost (it,6) = 745 + 468*rand; % a0 -> (745 - 1213)
0113             else
0114                 gencost (it,6) = 1213 + 1830*rand; % a0 -> (1213 - 3043)
0115             end
0116             gencost (it,5) = 2.16.*(9.43 + rand*9.1); % a1 = cf*b1 -> cf = 2.16   & b1 = (9.43 - 18.53)
0117         elseif Type_setting(it,3) == 5
0118             gentype{it}  = 'NB';
0119             genfuel{it}  = 'nuclear';
0120             gencost (it,6) = 1000 + 500*rand; % a0 -> (1000 - 1500)
0121             gencost (it,5) = 0.85.*10.46; % a1 = cf*b1 -> cf = 0.85   & b1 = 10.46
0122         end
0123     end
0124 end
0125 
0126 %%
0127     function [Corr_co,Type_setting]=Assignment(PgMax_norm,Tab_2D)
0128         % This is a function to assign the generation types to the generation buses based
0129         % on PgMAX
0130         %
0131         % input:
0132         %       Normalized_Generation_capacity- matrix (2 by Ng) indicating
0133         %       the normalized value of generation capacity
0134         %       Tab_2D - matrix (5 by 14) indicating the assignment pattern
0135         % output:
0136         %       Type_setting- matrix (Ng by 3) indicating the type setting at each generation bus
0137         
0138         Ng=length(PgMax_norm);
0139         % calculate actual nnumber of each cell in 2D table nased on the total
0140         % number of generation capacities
0141         Tab_2D_Ng=round(Tab_2D.*Ng);
0142         % check the mismatch comes from "round". Add or subtract from maximum
0143         % number in the matrix
0144         if sum(sum(Tab_2D_Ng))<Ng
0145             [Max_tab,ind_max_tab]=max(Tab_2D_Ng(:));
0146             [I_row, I_col] = ind2sub(size(Tab_2D_Ng),ind_max_tab);
0147             Tab_2D_Ng(I_row,I_col)=Tab_2D_Ng(I_row,I_col)+(Ng-sum(sum(Tab_2D_Ng)));
0148         elseif sum(sum(Tab_2D_Ng))>Ng
0149             [Max_tab,ind_max_tab]=max(Tab_2D_Ng(:));
0150             [I_row, I_col] = ind2sub(size(Tab_2D_Ng),ind_max_tab);
0151             Tab_2D_Ng(I_row,I_col)=Tab_2D_Ng(I_row,I_col)-(sum(sum(Tab_2D_Ng))-Ng);
0152         end
0153         %% calculate target number of buses based on node degree and 2D table
0154         N_PgM= zeros(1,14); % matrix for total number of buses in each node degree category
0155         N_PgM = sum(Tab_2D_Ng,1);
0156         
0157         %% sort node degrees
0158         Sort_PgMax=sortrows(PgMax_norm,2);
0159         %% assign buses to the node degree categories
0160         PgM1=Sort_PgMax(1:N_PgM(1,1),:);
0161         Sort_PgMax(1:N_PgM(1,1),:)=[];
0162         
0163         PgM2=Sort_PgMax(1:N_PgM(1,2),:);
0164         Sort_PgMax(1:N_PgM(1,2),:)=[];
0165         
0166         PgM3=Sort_PgMax(1:N_PgM(1,3),:);
0167         Sort_PgMax(1:N_PgM(1,3),:)=[];
0168         
0169         PgM4=Sort_PgMax(1:N_PgM(1,4),:);
0170         Sort_PgMax(1:N_PgM(1,4),:)=[];
0171         
0172         PgM5=Sort_PgMax(1:N_PgM(1,5),:);
0173         Sort_PgMax(1:N_PgM(1,5),:)=[];
0174         
0175         PgM6=Sort_PgMax(1:N_PgM(1,6),:);
0176         Sort_PgMax(1:N_PgM(1,6),:)=[];
0177         
0178         PgM7=Sort_PgMax(1:N_PgM(1,7),:);
0179         Sort_PgMax(1:N_PgM(1,7),:)=[];
0180         
0181         PgM8=Sort_PgMax(1:N_PgM(1,8),:);
0182         Sort_PgMax(1:N_PgM(1,8),:)=[];
0183         
0184         PgM9=Sort_PgMax(1:N_PgM(1,9),:);
0185         Sort_PgMax(1:N_PgM(1,9),:)=[];
0186         
0187         PgM10=Sort_PgMax(1:N_PgM(1,10),:);
0188         Sort_PgMax(1:N_PgM(1,10),:)=[];
0189         
0190         PgM11=Sort_PgMax(1:N_PgM(1,11),:);
0191         Sort_PgMax(1:N_PgM(1,11),:)=[];
0192         
0193         PgM12=Sort_PgMax(1:N_PgM(1,12),:);
0194         Sort_PgMax(1:N_PgM(1,12),:)=[];
0195         
0196         PgM13=Sort_PgMax(1:N_PgM(1,13),:);
0197         Sort_PgMax(1:N_PgM(1,13),:)=[];
0198         
0199         PgM14=Sort_PgMax(1:N_PgM(1,14),:);
0200         Sort_PgMax(1:N_PgM(1,14),:)=[];
0201         
0202         %% calculate target number of generations in normalized generation capacity categories
0203         N_T=zeros(1,5); % matrix for total number of buses in each node degree category
0204         N_T = sum(Tab_2D_Ng,2)';
0205         %% assign grouped generation capacities to the 2D table cells
0206         % 1) Save generation buses and their related node degrees in cell arreys of
0207         % K_cell
0208         % 2) Save generation capacities in cell arreys of G_cell
0209         % 3) Assigne generation capacities to the node degrees based  : For each
0210         % cell arrey of K_cell (category of node degrees) starting from first array of G_cell based on the number of
0211         % each cell in Tab_2D_Ng assigne generation capacities and then remove
0212         % asigned generation capacities from G_cell.
0213         K_cell=cell(1,14);
0214         K_cell{1}=PgM1; K_cell{2}=PgM2; K_cell{3}=PgM3; K_cell{4}=PgM4; K_cell{5}=PgM5; K_cell{6}=PgM6; K_cell{7}=PgM7;
0215         K_cell{8}=PgM8; K_cell{9}=PgM9; K_cell{10}=PgM10; K_cell{11}=PgM11; K_cell{12}=PgM12; K_cell{13}=PgM13; K_cell{14}=PgM14;
0216         
0217         Type_gen =[];
0218         for pgm=1:14
0219             for tt=1:1:5
0220                 if Tab_2D_Ng(tt,pgm)>0
0221                     [samp_G,ind_G]=sg_datasample(K_cell{pgm},Tab_2D_Ng(tt,pgm),'replace',false);
0222                     K_cell{pgm}(ind_G,3)=tt;
0223                     Type_gen = [Type_gen;K_cell{pgm}(ind_G,:)];
0224                     K_cell{pgm}(ind_G,:)=[];
0225                 end
0226             end
0227         end
0228         Type_setting=sortrows(Type_gen,1);
0229         Corr_co=corr(Type_setting(:,2),Type_setting(:,3));
0230     end
0231 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005