Dear all, I would like to calculate the PTDFs of a subset of ~500 nodes for a large network of > 10,000 nodes. Since the whole calculation of the PTDF matrix is very CPU-intensive (as I have already read in https://github.com/MATPOWER/matpower/issues/37 and [email protected]/msg05580.html), I tried to orientate myself on this: https://github.com/MATPOWER/matpower/issues/37#issuecomment-391459159.
Here is my consideration using the example of the test scenario "case30": mpc = loadcase(case30); mpc = ext2int(mpc); %%% Referenz PTDF % distributed_slack_setNodes = [1, 7, 15, 24]; define_constants() mpc = loadcase(case30); exemplary_subSet_slack = randi(30,1,5); weightSlack = zeros(size(mpc.bus,1),1); weightSlack(exemplary_subSet_slack) = 1; slackForPTDF = weightSlack/numel(exemplary_subSet_slack); H_makePTDF = makePTDF(mpc,slackForPTDF);%,slackForPTDF)%,slack); H_makePTDF_rel = H_makePTDF(:,exemplary_subSet_slack); %%% alternative as in https://github.com/MATPOWER/matpower/issues/37#issuecomment-391459159 nb = size(mpc.bus, 1); slack_bus = find(mpc.bus(:, BUS_TYPE) == REF); % Ref. slack slack = slack_bus; noslack = find((1:nb)' ~= slack_bus); [Bbus, Bf, Pbusinj, Pfinj] = makeBdc(mpc); Bbus(slack, :) = []; % remove slack row Bbus(:, slack) = []; % remove slack col for it = 1:numel(exemplary_subSet_slack) dP = zeros(nb, 1); % init dP(slack) = []; % remove slack i = exemplary_subSet_slack(it); tmpDistributed_slack_set = exemplary_subSet_slack; tmpDistributed_slack_set(it) = []; dP(i) = 1; j = tmpDistributed_slack_set; dP(j) = -1 / numel(j); dx = Bbus \ dP; dTheta = zeros(nb, 1); % init dTheta(noslack) = dx; H_altern(:,it) = Bf * dTheta; end %%% slack distribution slack_weights(1:numel(exemplary_subSet_slack)) = 1/numel(tmpDistributed_slack_set) - 1/numel(exemplary_subSet_slack); v = H_altern * slack_weights'; for k = 1:numel(exemplary_subSet_slack) H_altern_2(:, k) = H_altern(:, k) - v; end Unfortunately, the calculation does not lead to the desired result. I suspect my error in the distribution of the slack, but I am not sure. I would be very happy about a help. Thanks a lot! With best regards, Tobias Hoffman
