Professional Documents
Culture Documents
Exp 5
Exp 5
Lab Report
Task 1,2,3:
Code:
% Clear workspace, close figures, and clear command window
clearvars;
close all;
clc;
% Given parameters
H_val = 5; % Inertia constant in seconds
P_mech = 0.8; % Mechanical power in per unit
delta_initial_deg = 25.15; % Initial swing angle in degrees
P_e_before = P_mech / sind(delta_initial_deg);
P_e_fault = 0.575; % Electrical power during fault in per unit
P_e_after = 1.294; % Electrical power after fault in per unit
f_nominal = 60; % Nominal frequency in Hz
r1_ratio = P_e_fault / P_e_before;
r2_ratio = P_e_after / P_e_before;
delta_max_deg = 180 - rad2deg(asin(P_mech / P_e_after));
% Time parameters
t_fault_occurrence = 0; % Time of fault occurrence in seconds
cycles_per_clearance = [4.5 15 30]; % Cycles per fault clearance
t_clearance = cycles_per_clearance / f_nominal; % Convert cycles to seconds
t_res = 0.05; % Time resolution in seconds
t_simulation_end = 12; % End time for simulation in seconds
% Initialize arrays
time_steps = 0:t_res:t_simulation_end;
angle_degrees = zeros(size(time_steps));
angle_degrees(1) = delta_initial_deg;
time_idx = time_idx + 1;
end
clearance_idx = clearance_idx + 1;
end
Task 4:
Code:
clc;
close all;
clear all;
% Given parameters
H = 5; % Inertia constant in seconds
Pm = [3.5 1.85]; % Mechanical power in per unit
delta0 = 16.19; % Initial swing angle in degrees
Pe_prefault=Pm/sind(delta0);
Pe_duringfault = [0 0.1545]; % Electrical power during fault in per unit
Pe_afterfault = [0.6056 0.1804]; % Electrical power after fault in per unit
f_nominal = 60; % Nominal frequency in Hz
% Time parameters
t_fault = 0; % Time of fault occurrence in seconds
cpc = 12; % Cycles per fault clearance
t_clrnce = cpc / f_nominal; % Convert cycles to seconds
t_rsltion = 0.005; % Time resolution in seconds
t_end = 1; % End time for simulation in seconds
% % Convert initial angle to radians
% delta0_rad = deg2rad(delta0);
% % Initial conditions
omega = 2 * pi * f_nominal; % Convert frequency to rad/s
% Initialize arrays
time = 0:t_rsltion:t_end;
angle_deg = zeros(size(time));
dif_delta=zeros(size(time));
dif_delta(1)=0;
angle_deg(1)=delta0;
% Numerical solution using Step-by-step method
j = 1;
while j <= 2
i = 1;
while i <= length(time) - 1
t = time(i);
i = i + 1;
end
angle_mech{j} = angle_deg;
j = j + 1;
end
figure(1)
plot(time, angle_mech{1}); hold on
plot(time, angle_mech{2});
xlabel('Time (s)');
ylabel('Rotor Angle (degrees)');
title('Synchronous Generator Swing Curve');
ylim([0 50]);
legend('Machine 1','Machine 2');
grid on;
% Display the time at which the fault is cleared
fprintf('Fault cleared at t = %.5f seconds\n', t_fault + t_clrnce);
Output: