0001 function Sd = makeSdzip(baseMVA, bus, mpopt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0022 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0023
0024 if nargin < 3
0025 mpopt = [];
0026 end
0027 if ~isempty(mpopt) && ~isempty(mpopt.exp.sys_wide_zip_loads.pw)
0028 if any(size(mpopt.exp.sys_wide_zip_loads.pw) ~= [1 3])
0029 error('makeSdzip: ''exp.sys_wide_zip_loads.pw'' must be a 1 x 3 vector');
0030 end
0031 if abs(sum(mpopt.exp.sys_wide_zip_loads.pw) - 1) > eps
0032 error('makeSdzip: elements of ''exp.sys_wide_zip_loads.pw'' must sum to 1');
0033 end
0034 pw = mpopt.exp.sys_wide_zip_loads.pw;
0035 else
0036 pw = [1 0 0];
0037 end
0038 if ~isempty(mpopt) && ~isempty(mpopt.exp.sys_wide_zip_loads.qw)
0039 if any(size(mpopt.exp.sys_wide_zip_loads.qw) ~= [1 3])
0040 error('makeSdzip: ''exp.sys_wide_zip_loads.qw'' must be a 1 x 3 vector');
0041 end
0042 if abs(sum(mpopt.exp.sys_wide_zip_loads.qw) - 1) > eps
0043 error('makeSdzip: elements of ''exp.sys_wide_zip_loads.qw'' must sum to 1');
0044 end
0045 qw = mpopt.exp.sys_wide_zip_loads.qw;
0046 else
0047 qw = pw;
0048 end
0049
0050 Sd.z = (bus(:, PD) * pw(3) + 1j * bus(:, QD) * qw(3)) / baseMVA;
0051 Sd.i = (bus(:, PD) * pw(2) + 1j * bus(:, QD) * qw(2)) / baseMVA;
0052 Sd.p = (bus(:, PD) * pw(1) + 1j * bus(:, QD) * qw(1)) / baseMVA;