function mpc = case37

%CASE30    Power flow data for 30 bus, 6 generator + 5 DG case.
%   MATPOWER

%% MATPOWER Case Format : Version 2
mpc.version = '2';

%%-----  Power Flow Data  -----%%
%% system MVA base
mpc.baseMVA = 15;

%% bus data
%	bus_i	type	Pd	Qd	Gs	Bs	area	Vm	Va	baseKV	zone	Vmax	Vmin
mpc.bus = [
	1	3	0	0	0	0	1	1	0	20  1	1.05	0.95;
    2	1	0.630   0.315   0   0   1   1   0   20  1   1.05    0.95;
    3   2   1.617   0.767   0   0   1   1   0   20  1   1.05    0.95;	
	4   2   1.490   0.706   0   0   1   1   0   20  1   1.05    0.95;
    5   1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    6   2   1.405   0.666   0   0   1   1   0   20  1   1.05    0.95;
    7   2   0.865   0.471   0   0   1   1   0   20  1   1.05    0.95;
    8   1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    9   1   0.042   0.040   0   0   1   1   0   20  1   1.05    0.95;
    10  1   0.140   0.070   0   0   1   1   0   20  1   1.05    0.95;
    11  1   0.126   0.061   0   0   1   1   0   20  1   1.05    0.95;
    12  2   0.475   0.225   0   0   1   1   0   20  1   1.05    0.95;
    13  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    14  2   0.433   0.204   0   0   1   1   0   20  1   1.05    0.95;
    15  1   0.093   0.044   0   0   1   1   0   20  1   1.05    0.95;
    16  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    17  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    18  2   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    19  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    20  1   0.042   0.021   0   0   1   1   0   20  1   1.05    0.95;
    21  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    22  1   0.038   0.018   0   0   1   1   0   20  1   1.05    0.95;
    23  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    24  2   0.445   0.155   0   0   1   1   0   20  1   1.05    0.95;
    25  1   0.042   0.021   0   0   1   1   0   20  1   1.05    0.95;
    26  1   0.166   0.080   0   0   1   1   0   20  1   1.05    0.95;
    27  1   0.042   0.021   0   0   1   1   0   20  1   1.05    0.95;
    28  1   0.042   0.021   0   0   1   1   0   20  1   1.05    0.95;
    29  1   0.042   0.021   0   0   1   1   0   20  1   1.05    0.95;
    30  1   0.126   0.063   0   0   1   1   0   20  1   1.05    0.95;
    31  2   0.126   0.061   0   0   1   1   0   20  1   1.05    0.95;
    32  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    33  1   0.042   0.021   0   0   1   1   0   20  1   1.05    0.95;
    34  2   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    35  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    36  1   0.042   0.021   0   0   1   1   0   20  1   1.05    0.95;
    37  1   0.085   0.040   0   0   1   1   0   20  1   1.05    0.95;
    ];

%% generator data
%	bus	Pg	Qg	        Qmax Qmin Vg mBase	status	Pmax	Pmin	Pc1	Pc2	Qc1min	Qc1max	Qc2min	Qc2max	ramp_agc	ramp_10	ramp_30	ramp_q	apf
mpc.gen = [
	1	11.52    0   1.50    -0.20   1   15  1   10  0   0   0	0	0	0	0	0	0	0	0	0;
	
    ];

%% branch data
%	fbus	tbus	r	x	b	rateA	rateB	rateC	ratio	angle	status	angmin	angmax
mpc.branch = [
	1	2	0.9   0.6	0	1.30	1.30	1.30	0	0	1	-360	360;
    2	3	0.09    0.05	0	1.30	1.30	1.30	0	0	1	-360	360;
	3	4	0.12    0.07	0	1.30	1.30	1.30	0	0	1	-360	360;
    4	5	0.08    0.03	0	1.30	1.30	1.30	0	0	1	-360	360;
    5	6	0.13    0.05	0	1.30	1.30	1.30	0	0	1	-360	360;
    6	7	0.13    0.05	0	1.30	1.30	1.30	0	0	1	-360	360;
    7	8	0.14    0.08	0	1.30	1.30	1.30	0	0	1	-360	360;
    8	9	0.16    0.09	0	1.30	1.30	1.30	0	0	1	-360	360;
    9	10	0.10    0.06	0	1.30	1.30	1.30	0	0	1	-360	360;
    10	11	0.10    0.06	0	1.30	1.30	1.30	0	0	1	-360	360;
    11	12	0.10    0.06	0	1.30	1.30	1.30	0	0	1	-360	360;
    12	13	0.10    0.06	0	1.30	1.30	1.30	0	0	1	-360	360;
    13	14	0.08    0.05	0	1.30	1.30	1.30	0	0	1	-360	360;
    14	15	0.10    0.04	0	1.30	1.30	1.30	0	0	1	-360	360;
    15	16	0.09    0.05	0	1.30	1.30	1.30	0	0	1	-360	360;
    16	17	0.13    0.08	0	1.30	1.30	1.30	0	0	1	-360	360;
    17	18	0.13    0.08	0	1.30	1.30	1.30	0	0	1	-360	360;
    18	19	0.2     0.12	0	1.30	1.30	1.30	0	0	1	-360	360;
    2   35  0.05    0.93    0	1.30	1.30	1.30	0	0	1	-360	360;
    35  36  0.51    0.19    0	1.30	1.30	1.30	0	0	1	-360	360;
    36  37  0.08    0.03    0	1.30	1.30	1.30	0	0	1	-360	360;
    3	30	0.13    0.08	0	1.30	1.30	1.30	0	0	1	-360	360;
    30	31	0.08    0.05	0	1.30	1.30	1.30	0	0	1	-360	360;
    31	32	0.13    0.08	0	1.30	1.30	1.30	0	0	1	-360	360;
    32	33	0.21    0.08	0	1.30	1.30	1.30	0	0	1	-360	360;
    6   22  0.21    0.08	0	1.30	1.30	1.30	0	0	1	-360	360;
    22  23  0.37    0.14    0	1.30	1.30	1.30	0	0	1	-360	360;
    23  24  0.30    0.11    0	1.30	1.30	1.30	0	0	1	-360	360;
    24  25  0.05    0.02    0	1.30	1.30	1.30	0	0	1	-360	360;
    25  26  0.10    0.04    0	1.30	1.30	1.30	0	0	1	-360	360;
    26  27  0.07    0.04    0	1.30	1.30	1.30	0	0	1	-360	360;
    27  28  0.07    0.04    0	1.30	1.30	1.30	0	0	1	-360	360;
    28  29  0.08    0.03    0	1.30	1.30	1.30	0	0	1	-360	360;
    8   21  0.03    0.01    0	1.30	1.30	1.30	0	0	1	-360	360;
    9   20  0.11    0.04    0	1.30	1.30	1.30	0	0	1	-360	360;
    11  19  0.15    0.09    0	1.30	1.30	1.30	0	0	1	-360	360;
];

%%-----  OPF Data  -----%%
%% generator cost data
%	1	startup	shutdown	n	x1	y1	...	xn	yn
%	2	startup	shutdown	n	c(n-1)	...	c0
mpc.gencost = [
	2	0	0	3	0.02	2	0;
	
	];
%% convert branch impedances from Ohms to p.u.
[PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
    VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
[F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
    TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
    ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
Vbase = mpc.bus(1, BASE_KV) * 1e3;      %% in Volts
Sbase = mpc.baseMVA * 1e6;              %% in VA
mpc.branch(:, [BR_R BR_X]) = mpc.branch(:, [BR_R BR_X]) / (Vbase^2 / Sbase);
