How to make a Forward/Backward sweep method transient, over a year

8 visualizzazioni (ultimi 30 giorni)
I want to make this code, below, to work for a transient case. The second and third row in "BD" I want to consist for a timeseries over a year, so for example position 2,2 in "BD" will de a seris of 8760 values and 3,2 will be another 8760 values. Then I want the resulting "voltage" to be ploted for each of the timeseries in a series. Is it possible to make this happen and if so, how?
Thanks in advanced!
Here is the code:
clc
clear all
close all
%%% Base value for p.u.
Sbase=100e6;
Ubase=11e3;
Zbase=(Ubase^2)/Sbase;
%%% data for all the busses
% Here we ar going to import data regarding P and Q for all busses
BD = [1 0 0
2 P1 Q1
3 P2 Q2
4 P3 Q3
5 P4 Q4];
%%% data for all the transmission lines
% here we are going to import data regarding R and X for all lines.
TLD =[1 1 2 R1 X1
2 2 3 R2 X2
3 3 4 R3 X3
4 3 5 R4 X4];
%%% normalisation of bus and transmission line data
TLD(:,4:5)=TLD(:,4:5)/Zbase;
BD(:,2:3)=BD(:,2:3)/Sbase;
S_load=complex(BD(:,2), BD(:,3));
Z=complex(TLD(:,4), TLD(:,5));
N=max(max(TLD(:,2:3)));
U=ones(size(BD(:,1), 1));
I_transmissionlines = zeros(size(TLD(:,1), 1));
iterations = 1000;
%%% Calculations
% this is the step where this tool is using FBS.
% Backward sweep
for i=1:iterations
I_load=conj(S_load./U);
for j=size(TLD, 1):-1:1
f = [];
h = [];
[f h]=find(TLD(:,2:3)==TLD(j,3));
if size(f, 1)==1
I_transmissionlines(TLD(j, 1)) = I_load(TLD(j, 3));
else
I_transmissionlines(TLD(j, 1)) = I_load(TLD(j, 3)) + sum(I_transmissionlines(TLD(f, 1)))-I_transmissionlines(TLD(j, 1));
end
end
% Forward sweep
for j=size(TLD, 1)
U(TLD(j, 3)) = U(TLD(j, 2)) - I_transmissionlines(TLD(j, 1))*Z(j);
end
end
voltage=abs (U);

Risposte (1)

Sufiyan
Sufiyan il 19 Feb 2024
You can try something like this by looping through the series
% ......
% ...... same code as yours untill here
TLD(:,4:5)=TLD(:,4:5)/Zbase;
num_time_steps = 8760; % Number of time steps
voltage_time_series = zeros(num_time_steps, size(BD, 1));
for t = 1:num_time_steps
% Update P and Q values for the current time step
BD(2, 2:3) = [P1(t) Q1(t)] / Sbase;
BD(3, 2:3) = [P2(t) Q2(t)] / Sbase;
S_load=complex(BD(:,2), BD(:,3));
Z=complex(TLD(:,4), TLD(:,5));
N=max(max(TLD(:,2:3)));
U=ones(size(BD(:,1), 1));
I_transmissionlines = zeros(size(TLD(:,1), 1));
iterations = 1000;
% Backward sweep
for i=1:iterations
% .........
% .........
% mention the same code as yours in this loop
% Forward sweep
for j=size(TLD, 1)
U(TLD(j, 3)) = U(TLD(j, 2)) - I_transmissionlines(TLD(j, 1))*Z(j);
end
end
voltage_time_series(t, :) = abs(U); % Store the voltage for this time step
end
% Plot the voltage time series for each bus
time = 1:num_time_steps;
for i = 2:size(BD, 1)
figure;
plot(time, voltage_time_series(:, i));
title(['Voltage at Bus ' num2str(BD(i, 1)) ' Over Time']);
xlabel('Time (hours)');
ylabel('Voltage (p.u.)');
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by