0% found this document useful (0 votes)
21 views

Experiment-2 MATLAB Codes +plots

The document describes using MATLAB code to plot the convex input-output and incremental heat rate characteristics of thermal units. It defines parameters and functions for three examples and plots the corresponding curves on figures.

Uploaded by

WAQAR BHATTI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Experiment-2 MATLAB Codes +plots

The document describes using MATLAB code to plot the convex input-output and incremental heat rate characteristics of thermal units. It defines parameters and functions for three examples and plots the corresponding curves on figures.

Uploaded by

WAQAR BHATTI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

title('Convex Incremental Heat Rate Characteristics');

Experiment-2
xlabel('Output (MW)');

TO STUDY THE CONVEX AND NON- ylabel('Incremental Heat Rate (Btu/kWh)');

CONVEX CHARACTERISTICS OF grid on;

THERMAL UNITS USING MATLAB % Manually set limits and ticks for x and y axes for Figure-2

xlim([0, 110]); % Set x-axis limits from 0 to 110


MATLAB Code Convex Characteristics (Procedure) Function-1:

ylim([0, 2000]); % Set y-axis limits from 0 to 2000


% Define Parameters for Function

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10
a = 550;

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100
b = 8.1;

% Define Parameters for Function


c = 0.028;

a = 550;
% Define Range for Power Output

b = 8.1;
p = 10:10:100;

c = 2.8;
% Calculate Function

% Calculate
P = a + b * p + c * (p).^2;

F_P = a./p + b + c * p;
% Plot Function in Figure-1

% Plot Function in Figure-3


figure;

figure;
plot(p, P);

plot(p, dP_P);
title('Convex Input-Output Characteristics');

title('Convex Net Heat Rate Characteristics');


xlabel('Output (MW)');

xlabel('Output (MW)');
ylabel('MBTU/hr or Rs./hr');

ylabel('Unit Heat Rate Curve (Btu/kWh)');


grid on;

grid on;
% Manually set limits and ticks for x and y axes for Figure-1

% Manually set limits and ticks for x and y axes for Figure-2
xlim([0, 110]); % Set x-axis limits from 0 to 110

xlim([0, 110]); % Set x-axis limits from 0 to 110


ylim([0, 2000]); % Set y-axis limits from 0 to 2000

ylim([0, 2000]); % Set y-axis limits from 0 to 2000


set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10
set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100
% Define Parameters for Function

a = 550; Convex Input-Output Characteristics Plot Function-1


(Procedure):
b = 8.1;

c = 2.8;

% Calculate Derivative of Function

dF_dP = b + 2 * c * p;

% Plot Function in Figure-2

figure;

plot(p, dF_dP);
Convex Incremental Heat Rate Characteristics Plot xlim([0, 110]); % Set x-axis limits from 0 to 110

Function-1 (Procedure):
ylim([0, 2000]); % Set y-axis limits from 0 to 2000

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

% Define Parameters for Function

a = 309;

b = 8.1;

c = 5.6;

% Calculate Derivative of Function

Convex Net Heat Rate Characteristics Plot Function-1 dF_dP = b + 2 * c * p;


(Procedure):
% Plot Function in Figure-2

figure;

plot(p, dF_dP);

title('Convex Incremental Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Incremental Heat Rate (Btu/kWh)');

grid on;

% Manually set limits and ticks for x and y axes for Figure-2

MATLAB Code Convex Characteristics xlim([0, 110]); % Set x-axis limits from 0 to 110

(Procedure) Function-2: ylim([0, 2000]); % Set y-axis limits from 0 to 2000

% Define Parameters for Function set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

a = 309; set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

b = 8.1; % Define Parameters for Function

c = 0.056; a = 309;

% Define Range for Power Output b = 8.1;

p = 10:10:100; c = 5.6;

% Calculate Function % Calculate

P = a + b * p + c * (p).^2; F_P = a./p + b + c * p;

% Plot Function in Figure-1 % Plot Function in Figure-3

figure; figure;

plot(p, P); plot(p, dP_P);

title('Convex Input-Output Characteristics'); title('Convex Net Heat Rate Characteristics');

xlabel('Output (MW)'); xlabel('Output (MW)');

ylabel('MBTU/hr or Rs./hr'); ylabel('Unit Heat Rate Curve (Btu/kWh)');

grid on; grid on;

% Manually set limits and ticks for x and y axes for Figure-1 % Manually set limits and ticks for x and y axes for Figure-2
xlim([0, 110]); % Set x-axis limits from 0 to 110
MATLAB Code Convex Characteristics
ylim([0, 2000]); % Set y-axis limits from 0 to 2000 (Procedure) Function-3:

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10 % Define Parameters for Function

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100 a = 307;

b = 8.1;
Convex Input-Output Characteristics Plot Function-2
(Procedure): c = 0.056;

% Define Range for Power Output

p = 10:10:100;

% Calculate Function

P = a + b * p + c * (p).^2;

% Plot Function in Figure-1

figure;

plot(p, P);

title('Convex Input-Output Characteristics');

xlabel('Output (MW)');

ylabel('MBTU/hr or Rs./hr');

grid on;

Convex Incremental Heat Rate Characteristics Plot


% Manually set limits and ticks for x and y axes for Figure-1
Function-2 (Procedure):
xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

% Define Parameters for Function

a = 307;

b = 8.1;

c = 5.6;

% Calculate Derivative of Function

dF_dP = b + 2 * c * p;

Convex Net Heat Rate Characteristics Plot Function-2 % Plot Function in Figure-2

(Procedure):
figure;

plot(p, dF_dP);

title('Convex Incremental Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Incremental Heat Rate (Btu/kWh)');

grid on;

% Manually set limits and ticks for x and y axes for Figure-2

xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10
set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100
Convex Net Heat Rate Characteristics Plot Function-3
% Define Parameters for Function (Procedure):

a = 307;

b = 8.1;

c = 5.6;

% Calculate

F_P = a./p + b + c * p;

% Plot Function in Figure-3

figure;

plot(p, dP_P);

title('Convex Net Heat Rate Characteristics');

xlabel('Output (MW)');
MATLAB Code Non-Convex Characteristics
ylabel('Unit Heat Rate Curve (Btu/kWh)');
(Procedure) Function-1:
grid on;
% Define the Parameters
% Manually set limits and ticks for x and y axes for Figure-2
a = 550;
xlim([0, 110]); % Set x-axis limits from 0 to 110
b = 8.1;
ylim([0, 2000]); % Set y-axis limits from 0 to 2000
c = 0.00028;
set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10
e = 300;
set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100
f = 0.035;

Convex Input-Output Characteristics Plot Function-3 (Procedure):


% Define the Output Power Range

p = 10:10:100;

% Calculate the Non-Convex Input-Output Characteristics

P = a + b * p + c * (p).^2 + abs(e * sin(f * (10 - p)));

% Plot Non-Convex Input-Output Characteristics

figure;

plot(p, P);

title('Non-Convex Input-Output Characteristics');

xlabel('Output (MW)');

ylabel('MBTU/hr or Rs./hr');
Convex Incremental Heat Rate Characteristics Plot Function-3 (Procedure):

xlim([0, 110]);

ylim([0, 2000]);

xticks([0:10:110]);

yticks([0:100:2000]);

grid on;

% Define the Parameters

a = 550;

b = 8.1;

c = 0.028;

e = 300;
f = 0.035; Non-Convex Input-Output Characteristics Plot Function-1 (Procedure):

% Calculate the Non-Convex Incremental Heat Rate Characteristics

dF_dP = b + 2 * c * (p).^2 + abs(e * cos(f * (10 - p)) - f);

% Plot Non-Convex Incremental Heat Rate Characteristics

figure;

plot(p, dF_dP);

title('Non-Convex Incremental Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Incremental Heat Rate (Btu/kWh)');

xlim([0, 110]); Non-Convex Incremental Heat Rate Characteristics Plot


Function-1 (Procedure):
ylim([0, 2000]);

xticks([0:10:110]);

yticks([0:100:2000]);

grid on;

% Define the Parameters

a = 550;

b = 8.1;

c = 2.8;

e = 300;

f = 0.035;
Non-Convex Net Heat Rate Characteristics Plot

% Calculate the Non-Convex Net Heat Rate Characteristics


Function-1 (Procedure):

F_P = a./p + b + c * p + abs(e * sin(f * (10 - p)))./p;

% Plot Non-Convex Net Heat Rate Characteristics

figure;

plot(p, F_P);

title('Non-Convex Net Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Unit Heat Rate Curve (Btu/kWh)');

xlim([0, 110]);

ylim([0, 2000]);

xticks([0:10:110]);

yticks([0:100:2000]); MATLAB Code Non-Convex Characteristics (Procedure) Function-2:

grid on; % Define the Parameters

a = 309;

b = 8.1;

c = 0.00056;

e = 200;

f = 0.042;
% Define the Output Power Range f = 0.042;

p = 10:10:100; % Calculate the Non-Convex Net Heat Rate Characteristics

% Calculate the Non-Convex Input-Output Characteristics F_P = a./p + b + c * p + abs(e * sin(f * (10 - p)))./p;

P = a + b * p + c * (p).^2 + abs(e * sin(f * (10 - p))); % Plot Non-Convex Net Heat Rate Characteristics

% Plot Non-Convex Input-Output Characteristics figure;

figure; plot(p, F_P);

plot(p, P); title('Non-Convex Net Heat Rate Characteristics');

title('Non-Convex Input-Output Characteristics'); xlabel('Output (MW)');

xlabel('Output (MW)'); ylabel('Unit Heat Rate Curve (Btu/kWh)');

ylabel('MBTU/hr or Rs./hr'); xlim([0, 110]);

xlim([0, 110]); ylim([0, 2000]);

ylim([0, 2000]); xticks([0:10:110]);

xticks([0:10:110]); yticks([0:100:2000]);

yticks([0:100:2000]); grid on;

grid on; Non-Convex Input-Output Characteristics Plot Function-2 (Procedure):

% Define the Parameters

a = 309;

b = 8.1;

c = 0.056;

e = 200;

f = 0.042;

% Calculate the Non-Convex Incremental Heat Rate Characteristics

dF_dP = b + 2 * c * (p).^2 + abs(e * cos(f * (10 - p)) - f);

% Plot Non-Convex Incremental Heat Rate Characteristics

Non-Convex Incremental Heat Rate Characteristics Plot


figure;
Function-2 (Procedure):
plot(p, dF_dP);

title('Non-Convex Incremental Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Incremental Heat Rate (Btu/kWh)');

xlim([0, 110]);

ylim([0, 2000]);

xticks([0:10:110]);

yticks([0:100:2000]);

grid on;

% Define the Parameters

a = 309;

b = 8.1;

c = 5.6;

e = 200;
dF_dP = b + 2 * c * (p).^2 + abs(e * cos(f * (10 - p)) - f);

Non-Convex Net Heat Rate Characteristics Plot Function-2 (Procedure): % Plot Non-Convex Incremental Heat Rate Characteristics

figure;

plot(p, dF_dP);

title('Non-Convex Incremental Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Incremental Heat Rate (Btu/kWh)');

xlim([0, 110]);

ylim([0, 2000]);

xticks([0:10:110]);

MATLAB Code Non-Convex Characteristics (Procedure) Function-3: yticks([0:100:2000]);

% Define the Parameters grid on;

a = 307; % Define the Parameters

b = 8.1; a = 307;

c = 0.00056; b = 8.1;

e = 150; c = 5.6;

f = 0.042; e = 150;

% Define the Output Power Range f = 0.042;

p = 10:10:100; % Calculate the Non-Convex Net Heat Rate Characteristics

% Calculate the Non-Convex Input-Output Characteristics F_P = a./p + b + c * p + abs(e * sin(f * (10 - p)))./p;

P = a + b * p + c * (p).^2 + abs(e * sin(f * (10 - p))); % Plot Non-Convex Net Heat Rate Characteristics

% Plot Non-Convex Input-Output Characteristics figure;

figure; plot(p, F_P);

plot(p, P); title('Non-Convex Net Heat Rate Characteristics');

title('Non-Convex Input-Output Characteristics'); xlabel('Output (MW)');

xlabel('Output (MW)'); ylabel('Unit Heat Rate Curve (Btu/kWh)');

ylabel('MBTU/hr or Rs./hr'); xlim([0, 110]);

xlim([0, 110]); ylim([0, 2000]);

ylim([0, 2000]); xticks([0:10:110]);

xticks([0:10:110]); yticks([0:100:2000]);

yticks([0:100:2000]); grid on

grid on;

% Define the Parameters

a = 307;

b = 8.1;

c = 0.056;

e = 150;

f = 0.042;

% Calculate the Non-Convex Incremental Heat Rate Characteristics ;


Non-Convex Input-Output Characteristics Plot Function-3 (Procedure): P = a + b * p + c * (p).^2;

% Plot Function in Figure-1

figure;

plot(p, P);

title('Convex Input-Output Characteristics');

xlabel('Output (MW)');

ylabel('MBTU/hr or Rs./hr');

grid on;

% Manually set limits and ticks for x and y axes for Figure-1

xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000


Non-Convex Incremental Heat Rate Characteristics Plot Function-3
(Procedure): set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

% Define Parameters for Function

a = 500;

b = 5.3;

c = 4;

% Calculate Derivative of Function

dF_dP = b + 2 * c * p;

% Plot Function in Figure-2

Non-Convex Net Heat Rate Characteristics Plot Function-3 figure;


(Procedure):
plot(p, dF_dP);

title('Convex Incremental Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Incremental Heat Rate (Btu/kWh)');

grid on;

% Manually set limits and ticks for x and y axes for Figure-2

xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

MATLAB Code Convex Characteristics Function-1 (Exercise):


% Define Parameters for Function

% Define Parameters for Function


a = 500;

a = 500;
b = 5.3;

b = 5.3;
c = 4;

c = 0.04;
% Calculate

% Define Range for Power Output


F_P = a./p + b + c * p;

p = 10:10:100;
% Plot Function in Figure-3

% Calculate Function
figure;
plot(p, dP_P); Convex Net Heat Rate Characteristics Plot Function-1 (Exercise):

title('Convex Net Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Unit Heat Rate Curve (Btu/kWh)');

grid on;

% Manually set limits and ticks for x and y axes for Figure-2

xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

Convex Input-Output Characteristics Plot Function-1 (Exercise):

MATLAB Code Convex Characteristics (Exercise) Function-2:

% Define Parameters for Function

a = 400;

b = 5.5;

c = 0.06;

% Define Range for Power Output

p = 10:10:100;

% Calculate Function

P = a + b * p + c * (p).^2;

% Plot Function in Figure-1

figure;
Convex Incremental Heat Rate Characteristics Plot Function-1 (Exercise):

plot(p, P);

title('Convex Input-Output Characteristics');

xlabel('Output (MW)');

ylabel('MBTU/hr or Rs./hr');

grid on;

% Manually set limits and ticks for x and y axes for Figure-1

xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

% Define Parameters for Function

a = 400;

b = 5.5;

c = 6;

% Calculate Derivative of Function

dF_dP = b + 2 * c * p;
% Plot Function in Figure-2 Convex Input-Output Characteristics Plot Function-2 (Exercise):

figure;

plot(p, dF_dP);

title('Convex Incremental Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Incremental Heat Rate (Btu/kWh)');

grid on;

% Manually set limits and ticks for x and y axes for Figure-2

xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

% Define Parameters for Function

Convex Incremental Heat Rate Characteristics Plot Function-2 (Exercise):


a = 400;

b = 5.5;

c = 6;

% Calculate

F_P = a./p + b + c * p;

% Plot Function in Figure-3

figure;

plot(p, dP_P);

title('Convex Net Heat Rate Characteristics');

xlabel('Output (MW)');
Convex Net Heat Rate Characteristics Plot Function-2 (Exercise):

ylabel('Unit Heat Rate Curve (Btu/kWh)');

grid on;

% Manually set limits and ticks for x and y axes for Figure-2

xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

MATLAB Code Convex Characteristics (Exercise) Function-3:

% Define Parameters for Function

a = 200;

b = 5.8;

c = 0.09;

% Define Range for Power Output

p = 10:10:100;
% Calculate Function figure;

P = a + b * p + c * (p).^2; plot(p, dP_P);

% Plot Function in Figure-1 title('Convex Net Heat Rate Characteristics');

figure; xlabel('Output (MW)');

plot(p, P); ylabel('Unit Heat Rate Curve (Btu/kWh)');

title('Convex Input-Output Characteristics'); grid on;

xlabel('Output (MW)'); % Manually set limits and ticks for x and y axes for Figure-2

ylabel('MBTU/hr or Rs./hr'); xlim([0, 110]); % Set x-axis limits from 0 to 110

grid on; ylim([0, 2000]); % Set y-axis limits from 0 to 2000

% Maually set limits and ticks for x and y axes for Figure-1 set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

xlim([0, 110]); % Set x-axis limits from 0 to 110 set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

ylim([0, 2000]); % Set y-axis limits from 0 to 2000 Convex Input-Output Characteristics Plot Function-3 (Exercise):

set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

% Define Parameters for Function

a = 200;

b = 5.8;

c = 9;

% Calculate Derivative of Function

dF_dP = b + 2 * c * p;

% Plot Function in Figure-2 Convex Incremental Heat Rate Characteristics Plot Function-3 (Exercise):

figure;

plot(p, dF_dP);

title('Convex Incremental Heat Rate Characteristics');

xlabel('Output (MW)');

ylabel('Incremental Heat Rate (Btu/kWh)');

grid on;

% Manually set limits and ticks for x and y axes for Figure-2

xlim([0, 110]); % Set x-axis limits from 0 to 110

ylim([0, 2000]); % Set y-axis limits from 0 to 2000

Convex Net Heat Rate Characteristics Plot Function-2 (Exercise):


set(gca, 'XTick', 0:10:110); % Set x-axis ticks from 0 to 110 with step of 10

set(gca, 'YTick', 0:100:2000); % Set y-axis ticks from 0 to 2000 with step of 100

% Define Parameters for Function

a = 200;

b = 5.8;

c = 9;

% Calculate

F_P = a./p + b + c * p;

% Plot Function in Figure-3

You might also like