diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21229f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.asv \ No newline at end of file diff --git a/CASE1.m b/CASE1.m new file mode 100644 index 0000000..51da101 --- /dev/null +++ b/CASE1.m @@ -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 + diff --git a/CASE2.m b/CASE2.m new file mode 100644 index 0000000..41c9383 --- /dev/null +++ b/CASE2.m @@ -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 + diff --git a/TL_param.m b/TL_param.m deleted file mode 100644 index 116cc48..0000000 --- a/TL_param.m +++ /dev/null @@ -1,70 +0,0 @@ -%% Transimission line parameters -resistivity = input('Please enter the conductor resistivity: '); -while resistivity <= 0 - fprintf('****Invalid Input****\n'); - resistivity = input('Please enter the conductor resistivity: '); -end -length = input('Please enter the length in meters: '); -while length <= 0 - fprintf('****Invalid Input****\n'); - length = input('Please enter the length in meters: '); -end -diameter = input('Please enter the diameter in centimeters: '); -while diameter <= 0 - fprintf('****Invalid Input****\n'); - diameter = input('Please enter the diameter in centimeters: '); -end -radius = (diameter / 2) * 10^(-2); -area = pi * radius^2 ; -GMR = radius * exp(-0.25); -R = resistivity * length/area; -fprintf('Please enter the number corresponding to your choice\n1-Symetrical system\n2-Unsymetrical system\n'); -choice = input('Choice: '); -switch choice - case 1 - distance = input('Please enter the seperation distance in meters: '); - L = (2 * 10^(-7) * log(distance/GMR)) * length; - C = (( 2 * pi * 8.85 * 10 ^(-6))/(log(distance/radius))) * length; - case 2 - dis_1 = input('Please enter the distance between a and b in meters: '); - dis_2 = input('Please enter the distance between b and c in meters: '); - dis_3 = input('Please enter the distance between a and c in meters: '); - dis = dis_1 * dis_2 * dis_3; - GMD = nthroot(dis, 3); - L = (2 * 10^(-7) * log(GMD/GMR)) * length; - C = (( 2 * pi * 8.85 * 10 ^(-6))/(log(GMD/radius))) * length; -end -fprintf('The tansmission line per phase resistance R = %f ohm\nThe transmission line per phase inductance L = %f H\nThe transmission line per phase capcitance C = %f uF\n' , R, L, C); -%% ABCD Parameters -X_l = 2 * pi * 50 * L; -Y_c = 2 * pi * 50 * C * 10^(-6); -Z = complex(R, X_l); -Y = complex(0, Y_c); -if length < 80000 - fprintf('Short Line Model\n'); - A = 1; - B = Z; - C = 0; - D = 1; - fprintf('A = %0.1f\nB =%f+j%f\nC=%0.1f\nD=%0.1f\n', A, real(B), imag(B), C, D); -elseif (length >= 80000) && (length <= 250000) - fprintf('Which medium line model would you like to work with?\n1-pi Model\n2-T Model\n'); - choice = input('Choice: '); - switch choice - case 1 - A = 1 + (Z*Y)/2; - B = Z; - C = Y * (1 + (ZY/4)); - D = 1 + (Z*Y)/2; - case 2 - A = 1 + (Z*Y)/2; - C = Z * (1 + (ZY/4)); - C = Y; - D = 1 + (Z*Y)/2; - end - fprintf('A = %f+j%f\nB =%f+j%f\nC=%f+j%f\nD=%f+j%f\n', real(A), imag(A), real(B), imag(B), real(C), imag(C), real(D), imag(D)); -elseif length > 250000 - fprintf('Long Transmission Line has no accurate model\n'); -end -%% - \ No newline at end of file diff --git a/TL_param_fun.m b/TL_param_fun.m deleted file mode 100644 index eda8c69..0000000 --- a/TL_param_fun.m +++ /dev/null @@ -1,12 +0,0 @@ -[resistivity, length, diameter] = start(); %reading the input from the user -radius = (diameter / 2) * 10^(-2); -area = pi * radius^2 ; -R = resistivity * length/area; -[L, C] = cal_inductance_capactance(radius, length); -fprintf('The transmission line per phase resistance R = %f ohm\nThe transmission line per phase inductance L = %f H\nThe transmission line per phase capcitance C = %f uF\n' , R, L, C); -X_l = 2 * pi * 50 * L; -Y_c = 2 * pi * 50 * C * 10^(-6); -Z = complex(R, X_l); -Y = complex(0, Y_c); -[A, B, C, D] = abcd_param(Z, Y, length); -fprintf('A= %f <%f\nB=%f <%f\nC=%f <%f\nD=%f <%f\n', abs(A), angle(A)*180/pi, abs(B), angle(B)*180/pi, abs(C), angle(C)*180/pi, abs(D), angle(D)*180/pi); \ No newline at end of file diff --git a/abcd_param.m b/abcd_param.m deleted file mode 100644 index d29a204..0000000 --- a/abcd_param.m +++ /dev/null @@ -1,28 +0,0 @@ -function [A, B, C, D] = abcd_param(Z, Y, length) - if length < 80000 - fprintf('Short Line Model\n'); - A = 1; - B = Z; - C = 0; - D = 1; - fprintf('A = %0.1f\nB =%f+j%f\nC=%0.1f\nD=%0.1f\n', A, real(B), imag(B), C, D); - elseif (length >= 80000) && (length <= 250000) - fprintf('Which medium line model would you like to work with?\n1-pi Model\n2-T Model\n'); - choice = input('Choice: '); - switch choice - case 1 - A = 1 + (Z*Y)/2; - B = Z; - C = Y * (1 + (Z*Y/4)); - D = 1 + (Z*Y)/2; - case 2 - A = 1 + (Z*Y)/2; - B = Z * (1 + (Z*Y/4)); - C = Y; - D = 1 + (Z*Y)/2; - end - fprintf('A = %f+j%f\nB =%f+j%f\nC=%f+j%f\nD=%f+j%f\n', real(A), imag(A), real(B), imag(B), real(C), imag(C), real(D), imag(D)); - elseif length > 250000 - fprintf('Long Transmission Line has no accurate model\n'); - end -end \ No newline at end of file diff --git a/cal_inductance_capactance.m b/cal_inductance_capactance.m deleted file mode 100644 index d0b9c3f..0000000 --- a/cal_inductance_capactance.m +++ /dev/null @@ -1,19 +0,0 @@ -function [L, C] = cal_inductance_capactance(radius, length) - fprintf('Please enter the number corresponding to your choice\n1-Symetrical system\n2-Unsymetrical system\n'); - choice = input('Choice: '); - GMR = radius * exp(-0.25); - switch choice - case 1 - distance = input('Please enter the seperation distance in meters: '); - L = (2 * 10^(-7) * log(distance/GMR)) * length; - C = (( 2 * pi * 8.85 * 10 ^(-6))/(log(distance/radius))) * length; - case 2 - dis_1 = input('Please enter the distance between a and b in meters: '); - dis_2 = input('Please enter the distance between b and c in meters: '); - dis_3 = input('Please enter the distance between a and c in meters: '); - dis = dis_1 * dis_2 * dis_3; - GMD = nthroot(dis, 3); - L = (2 * 10^(-7) * log(GMD/GMR)) * length; - C = (( 2 * pi * 8.85 * 10 ^(-6))/(log(GMD/radius))) * length; - end -end \ No newline at end of file diff --git a/capacitance.m b/capacitance.m new file mode 100644 index 0000000..081d6ae --- /dev/null +++ b/capacitance.m @@ -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 \ No newline at end of file diff --git a/inductance.m b/inductance.m new file mode 100644 index 0000000..9a96c3f --- /dev/null +++ b/inductance.m @@ -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 \ No newline at end of file diff --git a/lineParameters.m b/lineParameters.m new file mode 100644 index 0000000..5761820 --- /dev/null +++ b/lineParameters.m @@ -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 + diff --git a/linePerformance.m b/linePerformance.m new file mode 100644 index 0000000..eea4acd --- /dev/null +++ b/linePerformance.m @@ -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 \ No newline at end of file diff --git a/longLine.m b/longLine.m new file mode 100644 index 0000000..0f0e137 --- /dev/null +++ b/longLine.m @@ -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 \ No newline at end of file diff --git a/main.m b/main.m new file mode 100644 index 0000000..773a669 --- /dev/null +++ b/main.m @@ -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); diff --git a/midiumLine.m b/midiumLine.m new file mode 100644 index 0000000..078a7e0 --- /dev/null +++ b/midiumLine.m @@ -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 + diff --git a/rcl.m b/rcl.m new file mode 100644 index 0000000..0429029 --- /dev/null +++ b/rcl.m @@ -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 \ No newline at end of file diff --git a/resistance.m b/resistance.m new file mode 100644 index 0000000..701daac --- /dev/null +++ b/resistance.m @@ -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 \ No newline at end of file diff --git a/shortLine.m b/shortLine.m new file mode 100644 index 0000000..590b495 --- /dev/null +++ b/shortLine.m @@ -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 + diff --git a/start.m b/start.m deleted file mode 100644 index 267e7e4..0000000 --- a/start.m +++ /dev/null @@ -1,19 +0,0 @@ -function [resistivity, length, diameter] = start() - clc; - - resistivity = input('Please enter the conductor resistivity: '); - while resistivity <= 0 - fprintf('****Invalid Input****\n'); - resistivity = input('Please enter the conductor resistivity: '); - end - length = input('Please enter the length in meters: '); - while length <= 0 - fprintf('****Invalid Input****\n'); - length = input('Please enter the length in meters: '); - end - diameter = input('Please enter the diameter in centimeters: '); - while diameter <= 0 - fprintf('****Invalid Input****\n'); - diameter = input('Please enter the diameter in centimeters: '); - end -end \ No newline at end of file