I was trying to solve a system of 9 non-linear equations using fsolve. However, I ran into a problem that quite unexpected.
After running the code, on the command screen it wrote:
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 9.000000e+02.
Therefore, I added the optimaloptions command trying to increase the MaxFunctionEvaluations :
options = optimoptions(@fsolve,'MaxFunctionEvaluations',10000);
x= fsolve(f,[0.01,0.01,0.01,0.01,0.9,0.1,0.1,0.1,10000]);
However, the calculation results didn't change at all, on the command screen it wrote again:
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 9.000000e+02.
I also could't change functiontolerance, optimalitytolerance, steptolerance, etc.
Is there an issue in my code? Or is it other issue?
Thanks for helping.
The full code is below (I trimmed out the parameters input to save space).
%%%%%%%%%%%%%% Solving the systems of equations for IAST model %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate initial C for all
PCE_ini= PCE_sim +(ma)./(Vw+Vg.*H_PCE./R./T).*KF_PCE_TOG.*PCE_sim.^N_PCE_TOG;
TCE_ini= TCE_sim +(ma)./(Vw+Vg.*H_TCE./R./T).*KF_TCE_TOG.*TCE_sim.^N_TCE_TOG;
cDCE_ini= cDCE_sim +(ma)./(Vw+Vg.*H_cDCE./R./T).*KF_DCE_TOG.*cDCE_sim.^N_DCE_TOG;
tDCE_ini= tDCE_sim +(ma)./(Vw+Vg.*H_tDCE./R./T).*KF_DCE_TOG.*tDCE_sim.^N_DCE_TOG;
f=@(x)[
x(1)-(x(9).*N_PCE_TOG./KF_PCE_TOG).^(1./N_PCE_TOG).*x(5);
x(2)-(x(9).*N_TCE_TOG./KF_TCE_TOG).^(1./N_TCE_TOG).*x(6);
x(3)-(x(9).*N_DCE_TOG./KF_DCE_TOG).^(1./N_DCE_TOG).*x(7);
x(4)-(x(9).*N_DCE_TOG./KF_DCE_TOG).^(1./N_DCE_TOG).*x(8);
(Vw+Vg.*H_PCE./R./T)./ma.*(PCE_ini-x(1))-x(5).*( (x(5)./(KF_PCE_TOG.*x(1).^N_PCE_TOG))+(x(6)./(KF_TCE_TOG.*x(2).^N_TCE_TOG))+(x(7)./(KF_DCE_TOG.*x(3).^N_DCE_TOG))+(x(8)./(KF_DCE_TOG.*x(4).^N_DCE_TOG))).^(-1);
(Vw+Vg.*H_TCE./R./T)./ma.*(TCE_ini-x(2))-x(6).*( (x(5)./(KF_PCE_TOG.*x(1).^N_PCE_TOG))+(x(6)./(KF_TCE_TOG.*x(2).^N_TCE_TOG))+(x(7)./(KF_DCE_TOG.*x(3).^N_DCE_TOG))+(x(8)./(KF_DCE_TOG.*x(4).^N_DCE_TOG))).^(-1);
(Vw+Vg.*H_cDCE./R./T)./ma.*(cDCE_ini-x(3))-x(7).*( (x(5)./(KF_PCE_TOG.*x(1).^N_PCE_TOG))+(x(6)./(KF_TCE_TOG.*x(2).^N_TCE_TOG))+(x(7)./(KF_DCE_TOG.*x(3).^N_DCE_TOG))+(x(8)./(KF_DCE_TOG.*x(4).^N_DCE_TOG))).^(-1);
(Vw+Vg.*H_tDCE./R./T)./ma.*(tDCE_ini-x(4))-x(8).*( (x(5)./(KF_PCE_TOG.*x(1).^N_PCE_TOG))+(x(6)./(KF_TCE_TOG.*x(2).^N_TCE_TOG))+(x(7)./(KF_DCE_TOG.*x(3).^N_DCE_TOG))+(x(8)./(KF_DCE_TOG.*x(4).^N_DCE_TOG))).^(-1);
x(5)+x(6)+x(7)+x(8)-1]
options = optimoptions(@fsolve,'MaxFunctionEvaluations',10000);
x= fsolve(f,[0.01,0.01,0.01,0.01,0.9,0.1,0.1,0.1,10000]);
PCE_eq=x(1);
TCE_eq=x(2);
cDCE_eq=x(3);
tDCE_eq=x(4);
Z_PCE=x(5);
Z_TCE=x(6);
Z_cDCE=x(7);
Z_tDCE=x(8);
Phi=x(9);
fprintf('PCE_eq = %d\n',PCE_eq)
fprintf('TCE_eq = %d\n',TCE_eq)
fprintf('cDCE_eq = %d\n',cDCE_eq)
fprintf('tDCE_eq = %d\n',tDCE_eq)
fprintf('Z_PCE = %d\n',Z_PCE)
fprintf('Z_TCE = %d\n',Z_TCE)
fprintf('Z_cDCE = %d\n',Z_cDCE)
fprintf('Z_tDCE = %d\n',Z_tDCE)
fprintf('Phi = %d\n',Phi)

 채택된 답변

Torsten
Torsten 2024년 3월 26일
편집: Torsten 2024년 3월 26일

0 개 추천

You didn't include the "options" setting in the call to "fsolve":
x= fsolve(f,[0.01,0.01,0.01,0.01,0.9,0.1,0.1,0.1,10000],options);
instead of
x= fsolve(f,[0.01,0.01,0.01,0.01,0.9,0.1,0.1,0.1,10000]);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

릴리스

R2023b

질문:

2024년 3월 26일

댓글:

2024년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by