i have to get combine correct figure

3 次查看(过去 30 天)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXAMPLE 3-3: Calculating the Voltage Losses for a Polarization Curve
% UnitSystem SI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inputs
R = 8.314; % Ideal gas constant (J/molK)
F = 96487; % Faraday’s constant (Coulombs)
Tc = 80; % Temperature in degrees C
P_H2 = 3; % Hydrogen pressure in atm
P_air = 3; % Air pressure in atm
A_cell=100; % Area of cell
N_cells=90; % Number of Cells
r = 0.19; % Internal Resistance (Ohm-cm^2)
Alpha = 0.5; % Transfer coeffi cient
Alpha1 = 0.085; % Amplifi cation constant
io = 10^-6.912; % Exchange Current Density (A/cm^2)
il = 1.4; % Limiting current density (A/cm2)
Gf_liq = -228170; % Gibbs function in liquid form (J/mol)
k = 1.1; % Constant k used in mass transport
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Convert degrees C to K
Tk = Tc + 273.15;
% Create loop for current
loop = 1;
i = 0;
for N = 0:150;
i = i + 0.01;
% Calculation of Partial Pressures
% Calculation of saturation pressure of water
x = -2.1794 + 0.02953 .* Tc-9.1837 .* (10.^-5) .* (Tc.^2) + 1.4454 .* (10.^-7) .* (Tc.^3);
P_H2O = (10.^x);
% Calculation of partial pressure of hydrogen
pp_H2 = 0.5 .* ((P_H2)./(exp(1.653 .* i./(Tk.^1.334)))-P_H2O);
% Calculation of partial pressure of oxygen
pp_O2 = (P_air./exp(4.192 .* i/(Tk.^1.334)))-P_H2O;
% Activation Losses
b = R .* Tk./(2 .* Alpha .* F);
V_act = -b .* log10(i./io); % Tafel equation
% Ohmic Losses
V_ohmic = -(i .* r);
% Mass Transport Losses
term = (1-(i./il));
if term > 0;
V_conc = Alpha1 .* (i.^k) .* log(1-(i./il));
else
V_conc = 0;
end
% Calculation of Nernst voltage
E_nernst = -Gf_liq./(2 .* F) - ((R .* Tk) .* log(P_H2O./(pp_H2 .* (pp_O2.^0.5))))./(2 .* F);
% Calculation of output voltage
V_out = E_nernst - V_ohmic - V_act - V_conc;
if term < 0;
V_conc = 0;
break
end
if V_out < 0;
V_out = 0;
break
end
figure(1)
title('Fuel cell polarization curve')
xlabel('Current density (A/cm^2)');
ylabel('Output voltage (Volts)');
plot(i,V_out,'b-o')
grid on
hold on
disp(V_out)
end
Here i got grapgoc for v_out and when i changed it with v_ohmic and v_act i got correct output. But the problem is that I need to display 3 graphs in 1 graph.So i also did try it but didnt work well. I'm uploading the hand drawing of the figure it should be.

回答(2 个)

Sulaymon Eshkabilov
编辑:Sulaymon Eshkabilov 2021-11-3
Here is how you can attain all three plots in one fig.:
...
plot(i,V_out,'b-o', i, V_act, 'r-d', i, V_ohmic, 'g--s')
disp(V_out), hold on
end
grid on
legend('V_{out}', 'V_{act}', 'V_{ohmic}')
  1 个评论
sevgul demir
sevgul demir 2021-11-3
Thank you for reply me :) also i did try it and got the same result but the figure is not what we want ...
i have to show those 3 graph as like hand write figure :( but i dont know how...

请先登录,再进行评论。


Sulaymon Eshkabilov
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXAMPLE 3-3: Calculating the Voltage Losses for a Polarization Curve
% UnitSystem SI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inputs
R = 8.314; % Ideal gas constant (J/molK)
F = 96487; % Faraday’s constant (Coulombs)
Tc = 80; % Temperature in degrees C
P_H2 = 3; % Hydrogen pressure in atm
P_air = 3; % Air pressure in atm
A_cell=100; % Area of cell
N_cells=90; % Number of Cells
r = 0.19; % Internal Resistance (Ohm-cm^2)
Alpha = 0.5; % Transfer coeffi cient
Alpha1 = 0.085; % Amplifi cation constant
io = 10^-6.912; % Exchange Current Density (A/cm^2)
il = 1.4; % Limiting current density (A/cm2)
Gf_liq = -228170; % Gibbs function in liquid form (J/mol)
k = 1.1; % Constant k used in mass transport
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Convert degrees C to K
Tk = Tc + 273.15;
% Create loop for current
loop = 1;
i = 0;
for N = 0:150
i = i + 0.01;
% Calculation of Partial Pressures
% Calculation of saturation pressure of water
x = -2.1794 + 0.02953 .* Tc-9.1837 .* (10.^-5) .* (Tc.^2) + 1.4454 .* (10.^-7) .* (Tc.^3);
P_H2O = (10.^x);
% Calculation of partial pressure of hydrogen
pp_H2 = 0.5 .* ((P_H2)./(exp(1.653 .* i./(Tk.^1.334)))-P_H2O);
% Calculation of partial pressure of oxygen
pp_O2 = (P_air./exp(4.192 .* i/(Tk.^1.334)))-P_H2O;
% Activation Losses
b = R .* Tk./(2 .* Alpha .* F);
V_act = -b .* log10(i./io); % Tafel equation
% Ohmic Losses
V_ohmic = -(i .* r);
% Mass Transport Losses
term = (1-(i./il));
if term > 0
V_conc = Alpha1 .* (i.^k) .* log(1-(i./il));
else
V_conc = 0;
end
% Calculation of Nernst voltage
E_nernst = -Gf_liq./(2 .* F) - ((R .* Tk) .* log(P_H2O./(pp_H2 .* (pp_O2.^0.5))))./(2 .* F);
% Calculation of output voltage
V_out = E_nernst - V_ohmic - V_act - V_conc;
if term < 0
V_conc = 0;
break
end
if V_out < 0
V_out = 0;
break
end
figure(1)
title('Fuel cell polarization curve')
xlabel('Current density (A/cm^2)');
ylabel('Output voltage (Volts)');
plot(i,V_out,'b-o', i, V_act, 'r-d', i, V_ohmic, 'g--s', i, E_nernst, 'k--x', 'markerfacecolor', 'y')
disp(V_out), hold all
end
grid on
hold on
legend('V_{out}', 'V_{act}', 'V_{ohmic}', 'E_{nernst}', 'location', 'best')
gtext('V_{out}'),gtext( 'V_{act}'), gtext('V_{ohmic}'), gtext('E_{nernst}')
Click where you want to display the line name, e.g. V_out, V_act, V_ohm, E_nernst
  1 个评论
sevgul demir
sevgul demir 2021-11-3
Thank you very much for your effort, but I have to say with regret that this result is very different from the graphic I was trying to make. :(
It looks like I need to add a new code or formula, but I don't know exactly. My attempts do not give the correct result.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by