% This program displays the plot for the PV curve given the PV equation of % V2^2 = (V1^2/2 - B*PD*X) + sqrt(V1^4/4 - PD*X*(PD*X + B*V1^2)) % % This program assumes certain initial values for this equation: % V1 = 1 (p.u.) % PD ranges from 0 to 1 (p.u.) % X = 0.8 and 1.2 (p.u.) % % This program then asks from the user a B value and solves for V2. % V2 is then plotted against PD in a graph for both a two transmission % line and a plot given a lost transmission line. % Set initial for parameters. x1 = 0.8; x2 = 1.2; x = (x1 * x2)/(x1 + x2); v = 1.0; p = linspace(0, 1, 100); % Welcome user and describe program. fprintf('\nThis program computes PV plots based on your input for B in the following \n'); fprintf('PV equation for a two transmission line system. \n\n'); fprintf('V2^2 = (V1^2/2 - B*PD*X) + sqrt(V1^4/4 - PD*X*(PD*X + B*V1^2))\n\n'); fprintf('This program also assumes the following initial values: \n'); fprintf('The reactance of the two lines are X = 0.8 and 1.2 p.u. \n'); fprintf('The voltage at the generator bus V1 = 1.0 p.u. \n'); fprintf('The value for the power delivered PD to the load ranges from 0.0 to 1.0 p.u. \n'); % Request from the user a value for B and verify that it is an integer % between -1 and 1. fprintf('\nPlease enter an enter a value for B. \n'); fprintf('This must be an integer between -1.0 and 1.0 \n'); fprintf('\nFor example you may begin by first setting B to zero to get a PV plot based solely \n'); fprintf('on the initial values. \n\n'); b = input(' '); while (b < -1) | (b > 1) fprintf('\nThis number should be an integer between -1.0 and 1.0 \n'); fprintf('Please re-enter an enter a value for B. \n\n'); b = input(' '); end % Calculate and plot transmission line figures given intial parameters. a1 = (v^2/2 - b.*p.*x) + sqrt(v^4/4 - p.*x.*(p*x + b*v^2)); a2 = (v^2/2 - b.*p.*x) - sqrt(v^4/4 - p.*x.*(p*x + b*v^2)); a3 = sqrt(a1); a4 = sqrt(a2); b1 = (v^2/2 - b.*p.*x1) + sqrt(v^4/4 - p.*x1.*(p*x1 + b*v^2)); b2 = (v^2/2 - b.*p.*x1) - sqrt(v^4/4 - p.*x1.*(p*x1 + b*v^2)); b3 = sqrt(b1); b4 = sqrt(b2); c1 = (v^2/2 - b.*p.*x2) + sqrt(v^4/4 - p.*x2.*(p*x2 + b*v^2)); c2 = (v^2/2 - b.*p.*x2) - sqrt(v^4/4 - p.*x2.*(p*x2 + b*v^2)); c3 = sqrt(c1); c4 = sqrt(c2); subplot(2, 1, 1), plot(p, a3, 'b-', p, a4, 'b-', p, b3, 'g:', p, b4, 'g:'); xlabel('PD (p.u.) with X = 0.8 p.u.'); ylabel('|V2| (p.u.)'); axis([0, 1, 0, 1.2]); subplot(2, 1, 2), plot(p, a3, 'b-', p, a4, 'b-', p, c3, 'r:', p, c4, 'r:'); xlabel('PD (p.u.) with X = 1.2 p.u.'); ylabel('|V2| (p.u.)'); axis([0, 1, 0, 1.2]); % Explain graph characteristics. fprintf('\nThe first plot in the blue solid line shows the PV plot given the assumed initial values.\n'); fprintf('The second plot in the dashed green line shows the PV plot with X = 0.8 p.u. \n'); fprintf('The third plot in the dashed red line shows the PV plot with X = 1.2 p.u. \n\n'); fprintf('The second and third plots are the equivalent of transmission line failures. \n'); % Request from user if another plot is desired. % Request from the user a new value for B and verify that it is an integer % between -1 and 1. fprintf('\nWould you like to see another PV plot with B adjusted to compensate for the \n'); fprintf('loss of the transmission line? \n'); fprintf('Please answer yes or no. \n\n'); z = input(' ', 's'); z1 = 'yes'; while strncmp(z, z1, 1) == 1 fprintf('\nPlease enter an enter a value for B. \n'); fprintf('This can be any integer between -1.0 and 1.0 \n\n'); r = input(' '); while (r < -1) | (r > 1) fprintf('\nThis number should be an integer between -1.0 and 1.0 \n'); fprintf('Please re-enter an enter a value for B. \n\n'); r = input(' '); end % Calculate and plot new transmission line figures given new B. d1 = (v^2/2 - r.*p.*x1) + sqrt(v^4/4 - p.*x1.*(p*x1 + r*v^2)); d2 = (v^2/2 - r.*p.*x1) - sqrt(v^4/4 - p.*x1.*(p*x1 + r*v^2)); d3 = sqrt(d1); d4 = sqrt(d2); e1 = (v^2/2 - r.*p.*x2) + sqrt(v^4/4 - p.*x2.*(p*x2 + r*v^2)); e2 = (v^2/2 - r.*p.*x2) - sqrt(v^4/4 - p.*x2.*(p*x2 + r*v^2)); e3 = sqrt(e1); e4 = sqrt(e2); subplot(2, 1, 1), plot(p, a3, 'b-', p, a4, 'b-', p, b3, 'g:', p, b4, 'g:', p, d3, 'r-.', p, d4, 'r-.'); xlabel('PD (p.u.) with X = 0.8 p.u.'); ylabel('|V2| (p.u.)'); axis([0, 1, 0, 1.2]); subplot(2, 1, 2), plot(p, a3, 'b-', p, a4, 'b-', p, c3, 'g:', p, c4, 'g:', p, e3, 'r-.', p, e4, 'r-.'); xlabel('PD (p.u.) with X = 1.2 p.u.'); ylabel('|V2| (p.u.)'); axis([0, 1, 0, 1.2]); % Explain graph characteristics. fprintf('\nThe first plot in the blue solid line shows the PV plot given the assumed initial \n'); fprintf('values. \n'); fprintf('The second plot in the dashed green line shows the PV plot with X = 0.8 and 1.2 p.u. \n'); fprintf('The third plot in the red dashes shows the adjusted PV plot based on your \n'); fprintf('inputted value for B against its respected transmission line. \n\n'); fprintf('Would you like to try another value for B? \n'); fprintf('Please answer yes or no. \n\n'); z = input(' ', 's'); end end % Request from user if another plot is desired using user inputted values. fprintf('\nWould you like to see another example for a loss of a transmission line \n'); fprintf('and its associated PV plot based on your own inputted parameters \n'); fprintf('Please answer yes or no. \n\n'); w = input(' ', 's'); w1 = 'yes'; while strncmp(w, w1, 1) == 1 % Request from user values for PV equation parameters. fprintf('\nPlease enter an enter a value for B. \n'); fprintf('This must be an integer between -1.0 and 1.0 \n\n'); b = input(' '); while (b < -1) | (b > 1) fprintf('\nThis number should be an integer between -1.0 and 1.0 \n'); fprintf('Please re-enter an enter a value for B. \n\n'); b = input(' '); end fprintf('\nThe values for PD will remain from 0.0 to 1.0 p.u. \n\n'); p = linspace(0, 1, 100); fprintf('\nPlease enter an enter a value for V1 in p.u. \n\n'); v = input(' '); fprintf('\nPlease enter an enter a value for reactance for one of the two transmission lines. \n\n'); x1 = input(' '); fprintf('\nPlease enter an enter a value for reactance for the second of the two transmission lines. \n\n'); x2 = input(' '); x = (x1 * x2)/(x1 + x2); % Calculate and plot transmission line figures given user inputted parameters. a1 = (v^2/2 - b.*p.*x) + sqrt(v^4/4 - p.*x.*(p*x + b*v^2)); a2 = (v^2/2 - b.*p.*x) - sqrt(v^4/4 - p.*x.*(p*x + b*v^2)); a3 = sqrt(a1); a4 = sqrt(a2); b1 = (v^2/2 - b.*p.*x1) + sqrt(v^4/4 - p.*x1.*(p*x1 + b*v^2)); b2 = (v^2/2 - b.*p.*x1) - sqrt(v^4/4 - p.*x1.*(p*x1 + b*v^2)); b3 = sqrt(b1); b4 = sqrt(b2); c1 = (v^2/2 - b.*p.*x2) + sqrt(v^4/4 - p.*x2.*(p*x2 + b*v^2)); c2 = (v^2/2 - b.*p.*x2) - sqrt(v^4/4 - p.*x2.*(p*x2 + b*v^2)); c3 = sqrt(c1); c4 = sqrt(c2); subplot(2, 1, 1), plot(p, a3, 'b-', p, a4, 'b-', p, b3, 'g:', p, b4, 'g:'); xlabel('PD (p.u.) with X1'); ylabel('|V2| (p.u.)'); axis([0, 1, 0, 1.2]); subplot(2, 1, 2), plot(p, a3, 'b-', p, a4, 'b-', p, c3, 'r:', p, c4, 'r:'); xlabel('PD (p.u.) with X2'); ylabel('|V2| (p.u.)'); axis([0, 1, 0, 1.2]); fprintf('\nThe first plot in the blue solid line shows the PV plot given your inputted values.\n'); fprintf('The second and third plots in green and red are the equivalent of transmission line \n'); fprintf('failures with x1 = %1.2f p.u. and x2 = %1.2f p.u. from your inputted reactance values. \n', x1, x2); % Request from user if another plot is desired using user inputted values. fprintf('\nWould you like to see another example for a loss of a transmission line \n'); fprintf('and its associated PV plot based on your own inputted parameters \n'); fprintf('Please answer yes or no. \n\n'); w = input(' ', 's'); end fprintf(' \n');