fsolve message "Equation solved, inaccuracy possible"
Mostrar comentarios más antiguos
Hi
I want to solve a system of nonlinear equations using fsolve. But I get "Equation solved, inaccuracy possible." and all x are incorrect. By changing initial guess, nothing improves!
I appreciate your help
Regards,
Fun = @xisolver1;
x0 = [1e-4 1e-4 1e-4 1e-4 1e-4 1e-2 1e-2];
% options = optimoptions('fsolve','OptimalityTolerance',1e-20, 'FunctionTolerance', 1e-20);
options = optimoptions('fsolve','Display','iter','TolFun',1e-40,'TolX',1e-40);
xr = fsolve(Fun, x0, options);
function y = xisolver1(x)
T = 31.65 + 275.15;
lnK1 = 132.899 + (-13445.9/T) + -22.4773*(log10(T)/log10(exp(1)));
lnK2 = 216.05 + (-12431.7/T) + -35.4819*(log10(T)/log10(exp(1)));
lnK3 = 231.465 + (-12092.1/T) + -36.7816*(log10(T)/log10(exp(1)));
K1 = power(exp(1),lnK1);
K2 = power(exp(1),lnK2);
K3 = power(exp(1),lnK3);
KS1 = 1/K1;
KS2 = 1/K2;
KS3 = 1/K3;
% mole
n_CO2 = 6.3746;
n_K2CO3 = 9.7119;
n_H2O = 358.8905;
n_T = n_CO2 + n_K2CO3 + n_H2O;
% mass - gr/s
m_T = 8088.2946;
% molecular weight
MW_CO2 = 44.0095;
MW_CO3 = 60.0089;
MW_HCO3 = 61.0168;
MW_OH = 17.0073;
MW_H3O = 19.0232;
MW_H2O = 18.01528;
MW_K = 39.098;
MW_K2CO3 = 138.2055;
MW_KHCO3 = 100.1151;
% mole fraction
X_CO2T = (n_CO2 + n_K2CO3)/n_T;
X_K__ = 2*(n_K2CO3/n_T);
% mole number
N_CO2T = (n_CO2 + n_K2CO3);
y(1) = K1*(x(6)^2) - 1*x(4)*x(5);
y(2) = K2*x(3)*x(6) - 1*x(5)*x(2);
y(3) = K3*x(1)*(x(6)^2) - 1*x(5)*x(3);
y(4) = x(7) + x(5) - (2*x(2) + x(3) + x(4));
y(5) = x(1) + x(2) + x(3) - ...
N_CO2T/(m_T/(x(1)*MW_CO2 + x(2)*MW_CO3 + x(3)*MW_HCO3 + x(4)*MW_OH + ...
x(5)*MW_H3O + x(6)*MW_H2O + x(7)*MW_K));
y(6) = x(1) + x(2) + x(3) + x(4) + x(5) + x(6) + x(7) - 1;
y(7) = x(7) - (2*n_K2CO3)/(m_T/(x(1)*MW_CO2 + x(2)*MW_CO3 + x(3)*MW_HCO3 + x(4)*MW_OH + ...
x(5)*MW_H3O + x(6)*MW_H2O + x(7)*MW_K));
2 comentarios
John D'Errico
el 26 de Abr. de 2019
Editada: John D'Errico
el 26 de Abr. de 2019
You should understand that
log10(T)/log10(exp(1))
is equivalent to the simple
log(T)
That is, log(T) is the NATURAL LOG of T?\
As well, why would you do this?
K1 = power(exp(1),lnK1);
You seem to understand that exp(1) yields the number e. So just use
K1 = exp(lnK1);
sina
el 26 de Abr. de 2019
Respuesta aceptada
Más respuestas (1)
Alex Sha
el 22 de Abr. de 2019
0 votos
Multi-solutions:
1:
x1: 1.00788811123075E-6
x2: 0.0083586258586415
x3: 0.0330975342164431
x4: 0.000243072462467804
x5: 4.25824266670525E-13
x6: 0.908241901178143
x7: 0.0500578583957681
2:
x1: 0.0398069369652828
x2: 4.09226387610729E-13
x3: -6.59445321197498E-9
x4: -7.80181990889573E-15
x5: -0.0480652696493024
x6: 0.960193076222411
x7: 0.0480652630556597
3:
x1: -0.00867531212733977
x2: 3.28114366134408E-10
x3: 0.0504921742289807
x4: -1.14968645806141E-9
x5: -1.22255237713138E-9
x6: 0.907690964984408
x7: 0.0504921749580755
Categorías
Más información sobre Systems of Nonlinear Equations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!