How to find an unknown in an integral equation

2 visualizzazioni (ultimi 30 giorni)
Hi, I am experiencing errors in calculating the following. Kindly help me solve these equations.
a = 0.0859;
b = -0.1650;
c = 0.0344;
lambda = 2.8e-9;
alphaA = 0.52;
T = 303;
F = 96487;
R = 8.314;
Ioref = 0.0013;
K = 7.5e-4;
Icell = 0.02;
A = 1000;
Cmeoh = (a .* (z.^2)) + (b.*z) + c;
fun = @(z,nA) Cmeoh./(Cmeoh + (lambda.*exp((alphaA.*nA.*F)./(R.*T))));
eqn = Icell == A.*Ioref.*K.*exp((2.*alphaA.*nA.*F)./(R.*T)).*(integral(fun,0.015,0.0173));
"nA" is the unknown and it has to be found from the above equation.
Thank you for your time and help.

Risposta accettata

Alan Stevens
Alan Stevens il 14 Gen 2021
Here's one way:
nA0 = 1; % Initial guess
nA = fzero(@fn, nA0);
disp(nA)
function Z = fn(nA)
alphaA = 0.52;
T = 303;
F = 96487;
R = 8.314;
Ioref = 0.0013;
K = 7.5e-4;
Icell = 0.02;
A = 1000;
a = 0.0859;
b = -0.1650;
c = 0.0344;
lambda = 2.8e-9;
Cmeoh = @(z) a*z.^2 + b*z + c;
fun = @(z) Cmeoh(z)./(Cmeoh(z) + (lambda.*exp((alphaA.*nA.*F)./(R.*T))));
I = integral(fun,0.015,0.0173);
Z = A.*Ioref.*K.*exp((2.*alphaA.*nA.*F)./(R.*T)).*I - Icell;
end
  2 Commenti
Narasimha Varma Hemadri
Narasimha Varma Hemadri il 14 Gen 2021
Thanks a lot. It worked !
Now I want to do the same calcualtion for different values of T, Icell, Cb. Kindly help me out.
T has 5 values, Icell has 10 values and Cb has 5. So, you will see I have used 3 nested for loops.
I have to find "nA" for all these different inputs. I am attaching the text file which contains the code.
Thank you for your time !
Alan Stevens
Alan Stevens il 15 Gen 2021
More like this, with the loops around the fzero function:
nA = zeros(5,10,5);
nA0 = 1; % Initial guess
for t = 1:1:5
for i = 1:1:10
for j = 1:1:5
nA(t,i,j) = fzero(@(nA)fn(nA,t,i,j), nA0);
end
end
end
disp(nA)
function Z = fn(nA,t,i,j)
alphaA = 0.52;
T = [303,313,323,333,343]; % Kelvin
Cb = [0.05,0.1,0.2,0.3,0.5]; %Concentration of Methanol
delA = 0.0023; % cm
delB = 0.015;
n = 6;
F = 96487;
R = 8.314;
K = 7.5e-4;
A = 1000;
Dm = 4.9e-6.*exp(-2436.*((1/333)-(1./T)));
K2 = 0.8;
K1 = 0.8;
Db = 8.7e-6; % cm^2/s
delM = 0.018; % cm
Da = 2.8e-5.*exp(-2436.*((1/353)-(1./T)));
xmeoh = Cb./(Cb+55.55);
Emeoh = 2.5.*xmeoh;
Icell = linspace(0.02,2,10); %0.02:0.02:0.2; *******Only 10 values for i
Ioref = 9.425e-3.*exp((35570/R).*((1/353)-(1./T)));
lambda = 2.8e-9; % mol/cm^3
C1A = (delA.*Dm(t).*K2.*((Db.*Cb(j))-(Icell(i).*delB)./(12*F)) + delM.*Da(t).*((Db.*Cb(j))-(1+6.*Emeoh(j)).*(Icell(i).*delB)./(6*F)))...
./((Db.*K1.*(delA.*Dm(t).*K2+delM.*Da(t)))+(delB.*Da(t).*Dm(t).*K2));
C2A = (delM.*((Da(t).*Db.*Cb(j)) - (delA.*Db.*K1.*(1+12.*Emeoh(j)).*(Icell(i))./(2*n*F)) - (delB.*Da(t).*(1+6.*Emeoh(j)).*(Icell(i))./(6*F))))...
./((Db.*K1.*(delA.*Dm(t).*K2+delM.*Da(t)))+(delB.*Da(t).*Dm(t).*K2));
a = Icell(i)./(12.*F.*delA.*Da(t));
b = (((C2A - C1A)./delA) - ((Icell(i)./(12.*F.*delA.*Da(t))).*((2.*delB)+delA)));
c = C1A - (((C2A-C1A)./delA).*delB) + (Icell(i)./(12.*F.*delA.*Da(t)).*delB.*(delB+delA));
Cmeoh = @(z) a.*(z.^2) + b.*z + c;
f1 = @(z) Cmeoh(z)./(Cmeoh(z) + (lambda.*exp((alphaA.*nA.*F)./(R.*T(t)))));
I = integral(f1,0.015,0.0173);
Z = A.*Ioref(t).*K.*exp((2.*alphaA.*nA.*F)./(R.*T(t))).*I - Icell(i);
end

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by