Name: Hafiz Waqar Ahmad Bhatti
Reg. No: L1F20BSEE0053
Section: EA (Power)
Complex Engineeing problem (PSOC)
(b) Part 2: (WP2,WP3, WP4, EP2) - 10 marks • Design a lambda iteration program that can
solve the Lagrange function you have formulated in Q3 to find the incremental cost and the
power generated by each plant.
MATLAB Code (EDP Without Losses):
% Given data
Pd = 200; % Total load demand
% Cost characteristics [a, b, c] for each unit
A = [105 2.450 0.005;
44.1 3.510 0.005;
40.6 3.890 0.005];
% Maximum and minimum generation values for each unit
Pmin = [10; 20; 20];
Pmax = [160; 80; 50];
% Lambda Iteration Method
epsilon = 1e-5; % Convergence tolerance
maxIter = 1000; % Maximum number of iterations
% Initialize Lambda
lambda_min = min(A(:, 2)); % Minimum b value
lambda_max = max(A(:, 2)); % Maximum b value
lambda = (lambda_min + lambda_max) / 2;
iter = 0;
while iter < maxIter
% Calculate power generation for each unit
P = max(Pmin, min(Pmax, (lambda - A(:, 2)) ./ (2 * A(:, 3))));
% Calculate total generation and mismatch
Ptotal = sum(P);
deltaP = Pd - Ptotal;
% Check for convergence
if abs(deltaP) < epsilon
break;
end
% Update Lambda
if deltaP > 0
lambda_min = lambda;
else
lambda_max = lambda;
end
lambda = (lambda_min + lambda_max) / 2;
iter = iter + 1;
end
% Display results
if iter == maxIter
disp('Lambda Iteration did not converge.');
else
fprintf('Lambda Iteration converged in %d iterations.\n', iter);
fprintf('Lambda = %.6f\n', lambda);
fprintf('Power generation for each unit (MW):\n');
for i = 1:length(P)
fprintf('P%d = %.4f\n', i, P(i));
end
end
The Output:
(c) Part 3: (WP2, WP3, WP4, WP5) - 20 marks • Compute the Transmission Line Loss
Coefficients, reformulate the Economic Load Dispatch problem along with the Lagrange
function and use lambda iterative method to find the new set of generated powers.
MATLAB Code (EDP With Losses):
% Given cost characteristics (A matrix)
A = [105 2.450 0.005; % Cost coefficients for generator 1
44.1 3.510 0.005; % Cost coefficients for generator 2
40.6 3.890 0.005]; % Cost coefficients for generator 3
% Power demand
Pd = 200;
% Maximum and minimum generation values
Pmax = [160; 80; 50];
Pmin = [10; 20; 20];
% Calculated B-coefficients matrix for transmission losses
B = [0.0002 0.0001 0.00015;
0.0001 0.0003 0.0002;
0.00015 0.0002 0.00025];
% Lambda iteration parameters
epsilon = 1e-5;
max_iterations = 1000;
% Initial guess for lambda
lambda = 10;
d_lambda = 0.01;
% Function to calculate power output based on lambda
calculate_P = @(lambda) max(min((lambda - A(:,2)) ./ (2 * A(:,3)), Pmax), Pmin);
% Lambda iteration method
for iter = 1:max_iterations
P = calculate_P(lambda);
P_total = sum(P);
P_loss = P' * B * P;
% Check if total generation equals demand plus losses
if abs(P_total - Pd - P_loss) < epsilon
break;
end
% Adjust lambda
if P_total > Pd + P_loss
lambda = lambda - d_lambda;
else
lambda = lambda + d_lambda;
end
end
% Display results
fprintf('Lambda: %.5f\n', lambda);
fprintf('Iterations: %d\n', iter);
fprintf('Generator Outputs (MW):\n');
fprintf('P1: %.2f\n', P(1));
fprintf('P2: %.2f\n', P(2));
fprintf('P3: %.2f\n', P(3));
fprintf('Total Generation: %.2f MW\n', P_total);
fprintf('Transmission Losses: %.2f MW\n', P_loss);
fprintf('Total Demand + Losses: %.2f MW\n', Pd + P_loss);
The Output: