Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update gui branch #20

Merged
merged 24 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
628df58
refactoring old functions
ahmedosama07 Apr 21, 2023
b9f78af
ABCD parameters
ahmedosama07 Apr 21, 2023
84f077b
lineParameters function
ahmedosama07 Apr 21, 2023
c7757d3
Create shortLine.m
ahmedosama07 Apr 21, 2023
715be60
Update shortLine.m
ahmedosama07 Apr 21, 2023
c8a00b3
Create midiumLine.m
ahmedosama07 Apr 21, 2023
9774e51
Create longLine.m
ahmedosama07 Apr 21, 2023
2c64b0e
Tasks 1 and 2
ahmedosama07 Apr 21, 2023
5be4a94
Merge pull request #9 from ahmedosama07/code-refactor
ahmedosama07 Apr 21, 2023
b6f6f97
case 1 demo
ahmedosama07 Apr 22, 2023
7597dea
case1 working demo
ahmedosama07 Apr 22, 2023
50c351d
s
mazenmohamed214 Apr 22, 2023
5a111a2
fix the duplication of c variable
mazenmohamed214 Apr 22, 2023
286c32d
Merge branch 'main' of https://github.com/skinchizer/Transmission-Lines
mazenmohamed214 Apr 22, 2023
7e990d9
fix C duplication
mazenmohamed214 Apr 22, 2023
708acc7
Merge pull request #17 from skinchizer/main
ahmedosama07 Apr 22, 2023
f1f5b44
fixed some bugs regarding measuring units
ahmedosama07 Apr 22, 2023
afa4ee7
fixed an issue with measuring units
ahmedosama07 Apr 22, 2023
5df54a8
Merge branch 'main' into task-3-demo-trial
ahmedosama07 Apr 22, 2023
d19f435
Update lineParameters.m
ahmedosama07 Apr 22, 2023
23434d1
Delete test.m
ahmedosama07 Apr 22, 2023
a495af9
Merge pull request #18 from ahmedosama07/task-3-demo-trial
ahmedosama07 Apr 22, 2023
6df69f8
case 2
mazenmohamed214 Apr 22, 2023
4a6ffcb
Merge pull request #19 from skinchizer/main
ahmedosama07 Apr 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.asv
27 changes: 27 additions & 0 deletions CASE1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function [efficiency, VR, P_r, pf] = CASE1(A, B, C, D)
%CASE1 Summary of this function goes here
% Detailed explanation goes here
V_r = complex((input('Recieving voltage (in kV): ') / sqrt(3)) * 10^3);
pf = 0.8; % 0.8 lagging power factor
phi = -1 * acos(pf);
P_r = 0:100*10^(3); % recieved active power
P_r = complex(P_r);


I_r = complex((P_r/(3*V_r*pf))*cos(phi), (P_r/(3*V_r*pf))*sin(phi));
% recieved current

V_s = A * V_r + B * I_r; % sending voltage
I_s = C * V_r + D * I_r; % sending current

pfs = cos(angle(V_s) - angle(I_s));

P_s = 3 * (abs(V_s) .* abs(I_s)) .* pfs; % sending active power

efficiency = (P_r ./ P_s) .* 100; % efficiency

V_rnl = V_s / A; % no load voltage

VR = ((abs(V_rnl) - abs(V_r)) / abs(V_r)) * 100; % voltage regulation
end

41 changes: 41 additions & 0 deletions CASE2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function [efficiency, VR, P_r, pf] = CASE2(A ,B ,C ,D)
%UNTITLED2 Summary of this function goes here
% calculate efficiency and voltage reg for case 2
V_r = complex((input('Recieving voltage (in kV): ') / sqrt(3)) * 10^3);
pf = 0.3:0.01:1;
phi_lag = -1 * acos(pf);
phi_lead = acos(pf);

P_r = 100*10^(3);
P_r = complex(P_r);

I_r_lag = complex((P_r./(3*V_r*pf)).*cos(phi_lag), (P_r./(3*V_r*pf)).*sin(phi_lag));
I_r_lead = complex((P_r./(3*V_r*pf)).*cos(phi_lead), (P_r./(3*V_r*pf)).*sin(phi_lead));

V_s_lag = A * V_r + B * I_r_lag; % sending voltage lag
I_s_lag = C * V_r + D * I_r_lag; % sending current lag

V_s_lead = A * V_r + B * I_r_lead; % sending voltage lead
I_s_lead = C * V_r + D * I_r_lead; % sending current lead

pfs_lag = cos(angle(V_s_lag) - angle(I_s_lag));
pfs_lead = cos(angle(V_s_lead) - angle(I_s_lead));


P_s_lag = 3 * (abs(V_s_lag) .* abs(I_s_lag)) .* pfs_lag; % sending active power lag
P_s_lead = 3 * (abs(V_s_lead) .* abs(I_s_lead)) .* pfs_lead; % sending active power lead

efficiency_lag = (P_r ./ P_s_lag) .* 100; % efficiency lag
efficiency_lead = (P_r ./ P_s_lead) .* 100; % efficiency lead

V_rnl_lag = V_s_lag / A; % no load voltage lag
V_rnl_lead = V_s_lead / A; % no load voltage lead

VR_lag = ((abs(V_rnl_lag) - abs(V_r)) / abs(V_r)) * 100; % voltage regulation lag
VR_lead = ((abs(V_rnl_lead) - abs(V_r)) / abs(V_r)) * 100; % voltage regulation lead

efficiency = [efficiency_lag efficiency_lead];
VR = [VR_lag VR_lead];

end

70 changes: 0 additions & 70 deletions TL_param.m

This file was deleted.

12 changes: 0 additions & 12 deletions TL_param_fun.m

This file was deleted.

28 changes: 0 additions & 28 deletions abcd_param.m

This file was deleted.

19 changes: 0 additions & 19 deletions cal_inductance_capactance.m

This file was deleted.

6 changes: 6 additions & 0 deletions capacitance.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function Cap = capacitance(diameter, length, GMD)
%capacitance Summary of this function goes here
% function that calculates the capacitance of the transmission line
radius = (diameter / 2) * 10^(-2); % radius in meters
Cap = (( 2 * pi * 8.85 * 10 ^(-12))/(log(GMD/radius))) * (length* 10^(3));
end
7 changes: 7 additions & 0 deletions inductance.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function L = inductance(diameter, length, GMD)
%inductance Summary of this function goes here
% function that calculates the inductance of the transmission line
radius = (diameter / 2) * 10^(-2); % radius in meters
GMR = radius * exp(-0.25); % gemetric mean radius
L = (2 * 10^(-7) * log(GMD/GMR))*(length* 10^(3)); % conductor inductance
end
19 changes: 19 additions & 0 deletions lineParameters.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function [A, B, C, D] = lineParameters(length, R, Cap, L)
%lineParameters Summary of this function goes here
% function that calculates ABCD parameters of the transmission line

XL = 2 * pi * 50 * L; % inductive reactance
YC = 2 * pi * 50 * Cap; % capacitive admittance
Z = complex(R, XL); % total complex impedance
Y = complex(0, YC); % total complex admittance

if length < 80
[A, B, C, D] = shortLine(Z);
elseif (length >= 80) && (length <= 250)
[A, B, C, D] = midiumLine(Z, Y);
else
[A, B, C, D] = longLine(Z, Y);
end

end

20 changes: 20 additions & 0 deletions linePerformance.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function [efficiency, VR, P_r, pf] = linePerformance(A, B, C, D)
%linePerformance Summary of this function goes here
% Detailed explanation goes here

fprintf('1. CASE I: constant recieving power factor (0.8 lagging)\n');
fprintf('2. CASE II: constant recieving power (100 kW [full load])\n');
type = input('');

switch type
case 1
[efficiency, VR, P_r, pf] = CASE1(A, B, C, D);
cftool(P_r, efficiency);
cftool(P_r, VR);
case 2
[efficiency, VR, P_r, pf] = CASE2(A, B, C, D);
cftool(pf, efficiency(1:length(efficiency)/2));
cftool(pf, VR(1:length(VR)/2));
cftool(pf, efficiency(length(efficiency)/2+1:end));
cftool(pf, VR(length(VR)/2+1:end));
end
14 changes: 14 additions & 0 deletions longLine.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function [A, B, C, D] = longLine(Z, Y)
%longLine Summary of this function goes here
% function that calculates ABCD parameters of long transmission line
% parameters are set to NaN since they cannot be calculated as the other
% two cases
fprintf("Cannot measure ABCD parameters.\n");
fprintf("*The distributed nature of the parameters is considered.\n");
fprintf("*The resistance, inductance, and capacitance of the line are not lumped.\n");

fprintf("Line impedance: %.3f ∠ %.3f° Ω", abs(Z), rad2deg(andle(Z)));
fprintf("Capacitive admitance: %.3f ∠ %.3f° ℧", abs(Y), rad2deg(andle(Y)));

[A, B, C, D] = struct('x', num2cell([NaN, NaN, NaN, NaN])).x;
end
19 changes: 19 additions & 0 deletions main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
clc;
length = input('Transmission line length (in kilo meters): ');
while length <= 0
clc;
fprintf('****Invalid Input****\n');
length = input('Transmission line length (in kilo meters): ');
end
diameter = input('Conductor diameter (in centimeters): ');
while diameter <= 0
clc;
fprintf('****Invalid Input****\n');
diameter = input('Conductor diameter (in centimeters): ');
end

[R, Cap, L] = rcl(length, diameter);

[A, B, C, D] = lineParameters(length, R, Cap, L);

[efficiency, VR, P_r, pf] = linePerformance(A, B, C, D);
12 changes: 12 additions & 0 deletions midiumLine.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function [A, B, C, D] = midiumLine(Z, Y)
%midiumLine Summary of this function goes here
% function that calculates ABCD parameters of midiuam transmission line
model = input('1. Π model\n2. T model');
switch model
case 1
[A, B, C, D] = struct('x', num2cell([1 + (Z*Y)/2, Z, Y * (1 + (Z*Y/4)), 1 + (Z*Y)/2])).x;
case 2
[A, B, C, D] = struct('x', num2cell([1 + (Z*Y)/2, Z * (1 + (Z*Y/4)), Y, 1 + (Z*Y)/2])).x;
end
end

20 changes: 20 additions & 0 deletions rcl.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function [r, c, l] = rcl(length, diameter)
%rcl Summary of this function goes here
% function that calculates the rcl parameters of the transmission line

type = input('Line spacing: \n1-Symetrical system\n2-Unsymetrical system\n');

switch type
case 1
GMD = input('Seperation distance (in meters): ');
case 2
d1 = input('Distance between a and b (in meters): ');
d2 = input('Distance between b and c (in meters): ');
d3 = input('Distance between a and c (in meters): ');
dis = d1 * d2 * d3;
GMD = nthroot(dis, 3);
end
r = resistance(diameter, length); % line resistance
c = capacitance(diameter, length, GMD); % line capacitance
l = inductance(diameter, length, GMD); % line inductance
end
13 changes: 13 additions & 0 deletions resistance.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function R = resistance(diameter, length)
%resistance Summary of this function goes here
% function that calculates the resistance of the transmission line
radius = (diameter / 2) * 10^(-2); % convert radius to meters
resistivity = input('Conductor resistivity (in SI units): ');
while resistivity <= 0
clc;
fprintf('****Invalid Input****\n');
resistivity = input('Conductor resistivity (in SI units): ');
end
area = pi * radius^2 ; % conductor cross-section area
R = resistivity * (length* 10^(3))/area; % conductor resistance
end
6 changes: 6 additions & 0 deletions shortLine.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function [A, B, C, D] = shortLine(Z)
%shortLine Summary of this function goes here
% function that calculates ABCD parameters of short transmission line
[A, B, C, D] = struct('x', num2cell([1, Z, 0, 1])).x;
end

19 changes: 0 additions & 19 deletions start.m

This file was deleted.