Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.654055e-18.
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello
I am working with matpower and doing power flow analysis however when i run my code it doesnt converge. Please let me know what i might be doing wrong.
function mpc = model
%CASE33BW Power flow data for 33 bus distribution system from Baran & Wu
% Please see CASEFORMAT for details on the case file format.
%
% Data from ...
% M. E. Baran and F. F. Wu, "Network reconfiguration in distribution
% systems for loss reduction and load balancing," in IEEE Transactions
% on Power Delivery, vol. 4, no. 2, pp. 1401-1407, Apr 1989.
% doi: 10.1109/61.25627
% URL: http://doi.org/10.1109/61.25627
%% MATPOWER Case Format : Version 2
mpc.version = '2';
%%----- Power Flow Data -----%%
%% system MVA base
mpc.baseMVA = 8995;
%% bus data
% bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
mpc.bus = [ %% (Pd and Qd are specified in kW & kVAr here, converted to MW & MVAr below)
%bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
1 3 15.528 6.67704 0 0 1 1 0 0.23 1 1.1 0.9;
2 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
3 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
4 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
5 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
6 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
7 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
8 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
9 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
10 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
11 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
12 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
13 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
14 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
15 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
16 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
17 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
18 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
19 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
20 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
21 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
22 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
23 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
24 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
25 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
26 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
27 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
28 1 -0.944 -0.40592 0 0 1 1 0 0.23 1 1.1 0.9;
29 1 -0.624 -0.26832 0 0 1 1 0 0.23 1 1.1 0.9;
30 1 -0.764 -0.32852 0 0 1 1 0 0.23 1 1.1 0.9;
31 1 -0.86 -0.3698 0 0 1 1 0 0.23 1 1.1 0.9;
32 1 -0.884 -0.38012 0 0 1 1 0 0.23 1 1.1 0.9;
33 1 -0.12 -0.0516 0 0 1 1 0 0.23 1 1.1 0.9;
34 1 -1.264 -0.54352 0 0 1 1 0 0.23 1 1.1 0.9;
35 1 -2.056 -0.88408 0 0 1 1 0 0.23 1 1.1 0.9;
36 1 -1.904 -0.81872 0 0 1 1 0 0.23 1 1.1 0.9;
37 1 -0.224 -0.09632 0 0 1 1 0 0.23 1 1.1 0.9;
38 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
39 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
40 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
41 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
42 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
43 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
44 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
45 1 0 0 0 0 1 1 0 0.23 1 1.1 0.9;
46 1 -1.448 -0.62264 0 0 1 1 0 0.23 1 1.1 0.9;
47 1 -1.132 -0.48676 0 0 1 1 0 0.23 1 1.1 0.9;
48 1 -1.572 -0.67596 0 0 1 1 0 0.23 1 1.1 0.9;
49 1 -2.192 -0.94256 0 0 1 1 0 0.23 1 1.1 0.9;
50 1 -0.932 -0.40076 0 0 1 1 0 0.23 1 1.1 0.9;
51 1 1.392 0.59856 0 0 1 1 0 0.23 1 1.1 0.9;
];
%% 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 0 0 10 -10 1 100 1 0.02 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 = [ %% (r and x specified in ohms here, converted to p.u. below)
1 2 0.000428 0.000272 1.130832 0.0805 0.0805 0.0805 0 0 1 -360 360
2 3 0.001712 0.001088 4.523328 0.0805 0.0805 0.0805 0 0 1 -360 360
17 4 0.001177 0.000748 3.109788 0.0805 0.0805 0.0805 0 0 1 -360 360
3 5 0.001284 0.000816 3.392496 0.0805 0.0805 0.0805 0 0 1 -360 360
5 6 0.000749 0.000476 1.978956 0.0805 0.0805 0.0805 0 0 1 -360 360
6 7 0.000321 0.000204 0.848124 0.0805 0.0805 0.0805 0 0 1 -360 360
7 8 0.000428 0.000272 1.130832 0.0805 0.0805 0.0805 0 0 1 -360 360
4 9 0.001605 0.00102 4.24062 0.0805 0.0805 0.0805 0 0 1 -360 360
8 10 0.001375 0.000748 2.59149 0.06555 0.06555 0.06555 0 0 1 -360 360
10 11 0.0015 0.000816 2.82708 0.06555 0.06555 0.06555 0 0 1 -360 360
11 12 0.000625 0.00034 1.17795 0.06555 0.06555 0.06555 0 0 1 -360 360
9 13 0.000875 0.000476 1.64913 0.06555 0.06555 0.06555 0 0 1 -360 360
12 14 0.00175 0.000952 3.29826 0.06555 0.06555 0.06555 0 0 1 -360 360
13 15 0.000625 0.00034 1.17795 0.06555 0.06555 0.06555 0 0 1 -360 360
15 16 0.001 0.000544 1.88472 0.06555 0.06555 0.06555 0 0 1 -360 360
14 17 0.00075 0.000408 1.41354 0.06555 0.06555 0.06555 0 0 1 -360 360
17 18 0.001 0.000544 1.88472 0.06555 0.06555 0.06555 0 0 1 -360 360
18 19 0.001125 0.000612 2.12031 0.06555 0.06555 0.06555 0 0 1 -360 360
16 20 0.00175 0.000952 3.29826 0.06555 0.06555 0.06555 0 0 1 -360 360
19 21 0.001 0.000544 1.88472 0.06555 0.06555 0.06555 0 0 1 -360 360
20 22 0.00075 0.000408 1.41354 0.06555 0.06555 0.06555 0 0 1 -360 360
21 23 0.001875 0.00102 3.53385 0.06555 0.06555 0.06555 0 0 1 -360 360
23 24 0.000375 0.000204 0.70677 0.06555 0.06555 0.06555 0 0 1 -360 360
24 25 0.00075 0.000408 1.41354 0.06555 0.06555 0.06555 0 0 1 -360 360
22 26 0.000375 0.000204 0.70677 0.06555 0.06555 0.06555 0 0 1 -360 360
26 27 0.000875 0.000476 1.64913 0.06555 0.06555 0.06555 0 0 1 -360 360
3 28 0.01064 0.00148 3.392496 0.0368 0.0368 0.0368 0 0 1 -360 360
5 29 0.00798 0.00111 2.544372 0.0368 0.0368 0.0368 0 0 1 -360 360
6 30 0.007448 0.001036 2.3747472 0.0368 0.0368 0.0368 0 0 1 -360 360
7 31 0.005852 0.000814 1.8658728 0.0368 0.0368 0.0368 0 0 1 -360 360
8 32 0.013832 0.001924 4.4102448 0.0368 0.0368 0.0368 0 0 1 -360 360
9 33 0.017024 0.002368 5.4279936 0.0368 0.0368 0.0368 0 0 1 -360 360
10 34 0.019684 0.002738 6.2761176 0.0368 0.0368 0.0368 0 0 1 -360 360
11 35 0.018088 0.002516 5.7672432 0.0368 0.0368 0.0368 0 0 1 -360 360
12 36 0.017024 0.002368 5.4279936 0.0368 0.0368 0.0368 0 0 1 -360 360
13 37 0.009044 0.001258 2.8836216 0.0368 0.0368 0.0368 0 0 1 -360 360
14 38 0.0133 0.00185 4.24062 0.0368 0.0368 0.0368 0 0 1 -360 360
15 39 0.015428 0.002146 4.9191192 0.0368 0.0368 0.0368 0 0 1 -360 360
16 40 0.009044 0.001258 2.8836216 0.0368 0.0368 0.0368 0 0 1 -360 360
17 41 0.001064 0.000148 0.3392496 0.0368 0.0368 0.0368 0 0 1 -360 360
18 42 0.011172 0.001554 3.5621208 0.0368 0.0368 0.0368 0 0 1 -360 360
19 43 0.004256 0.000592 1.3569984 0.0368 0.0368 0.0368 0 0 1 -360 360
20 44 0.001596 0.000222 0.5088744 0.0368 0.0368 0.0368 0 0 1 -360 360
21 45 0.019152 0.002664 6.1064928 0.0368 0.0368 0.0368 0 0 1 -360 360
22 46 0.017024 0.002368 5.4279936 0.0368 0.0368 0.0368 0 0 1 -360 360
23 47 0.017024 0.002368 5.4279936 0.0368 0.0368 0.0368 0 0 1 -360 360
24 48 0.009576 0.001332 3.0532464 0.0368 0.0368 0.0368 0 0 1 -360 360
25 49 0.019152 0.002664 6.1064928 0.0368 0.0368 0.0368 0 0 1 -360 360
26 50 0.012236 0.001702 3.9013704 0.0368 0.0368 0.0368 0 0 1 -360 360
27 51 0.005852 0.000814 1.8658728 0.0368 0.0368 0.0368 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 20 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);
%% convert loads from kW to MW
mpc.bus(:, [PD, QD]) = mpc.bus(:, [PD, QD]) / 1e3;
0 comentarios
Respuestas (1)
Shiva Kalyan Diwakaruni
el 28 de Mayo de 2021
Hi,
The error "Matrix is close to singular or badly sclaed.Results may be inaccurate" are generally a result of using double-precision arithmetic;
The best way to increase precision of numeric calculations is to use the "vpa" function from the Symbolic Math Toolbox. The "vpa" function uses variable-precision floating-point arithmetic (VPA) to evaluate each element of the symbolic input to this function to a specified number of significant digits. Please refer to the below links
Hope it helps
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!